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

Method handle_erase_word

Lib/getpass.py:345–357  ·  view source on GitHub ↗

Erase previous word (Ctrl+W).

(self)

Source from the content-addressed store, hash-verified

343 self.refresh_display(prev_len)
344
345 def handle_erase_word(self):
346 """Erase previous word (Ctrl+W)."""
347 old_cursor = self.cursor_pos
348 # Calculate the starting position of the previous word,
349 # ignoring trailing whitespaces.
350 while self.cursor_pos > 0 and self.password[self.cursor_pos - 1] == ' ':
351 self.cursor_pos -= 1
352 while self.cursor_pos > 0 and self.password[self.cursor_pos - 1] != ' ':
353 self.cursor_pos -= 1
354 # Delete the previous word and refresh the screen.
355 prev_len = len(self.password)
356 del self.password[self.cursor_pos:old_cursor]
357 self.refresh_display(prev_len)
358
359 def handle_literal_next(self):
360 """State transition to indicate that the next character is literal."""

Callers

nothing calls this directly

Calls 1

refresh_displayMethod · 0.95

Tested by

no test coverage detected