Redraw the entire password line with *echo_char*. If *prev_len* is not specified, the current password length is used.
(self, prev_len=None)
| 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.""" |
no test coverage detected