MCPcopy Index your code
hub / github.com/python/cpython / refresh_display

Method refresh_display

Lib/getpass.py:279–291  ·  view source on GitHub ↗

Redraw the entire password line with *echo_char*. If *prev_len* is not specified, the current password length is used.

(self, prev_len=None)

Source from the content-addressed store, hash-verified

277 }
278
279 def refresh_display(self, prev_len=None):
280 """Redraw the entire password line with *echo_char*.
281
282 If *prev_len* is not specified, the current password length is used.
283 """
284 prompt_len = len(self.prompt)
285 clear_len = prev_len if prev_len is not None else len(self.password)
286 # Clear the entire line (prompt + password) and rewrite.
287 self.stream.write('\r' + ' ' * (prompt_len + clear_len) + '\r')
288 self.stream.write(self.prompt + self.echo_char * len(self.password))
289 if self.cursor_pos < len(self.password):
290 self.stream.write('\b' * (len(self.password) - self.cursor_pos))
291 self.stream.flush()
292
293 def insert_char(self, char):
294 """Insert *char* at cursor position."""

Callers 7

insert_charMethod · 0.95
handle_move_startMethod · 0.95
handle_move_endMethod · 0.95
handle_eraseMethod · 0.95
handle_kill_lineMethod · 0.95
handle_kill_forwardMethod · 0.95
handle_erase_wordMethod · 0.95

Calls 2

writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected