diff options
| author | robot-piglet <[email protected]> | 2025-09-11 19:12:15 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2025-09-11 19:43:09 +0300 |
| commit | 91708f49a58e3c0a1a3cf0a60c268c2d5b474a3e (patch) | |
| tree | 9dbcd5cd1811b171ca7636600287d72327ef98ec /contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py | |
| parent | f4413504c29db8e1e7cce3a2103e89ecb4073271 (diff) | |
Intermediate changes
commit_hash:87ab6d7772f084decaa30c0cb439a3e0c000406e
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py')
| -rw-r--r-- | contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py index 1ff3234a398..616df8e78d0 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py @@ -104,8 +104,8 @@ class Win32Input(_Win32InputBase): def read_keys(self) -> list[KeyPress]: return list(self.console_input_reader.read()) - def flush(self) -> None: - pass + def flush_keys(self) -> list[KeyPress]: + return self.console_input_reader.flush_keys() @property def closed(self) -> bool: @@ -295,6 +295,10 @@ class ConsoleInputReader: else: yield from all_keys + def flush_keys(self) -> list[KeyPress]: + # Method only needed for structural compatibility with `Vt100ConsoleInputReader`. + return [] + def _insert_key_data(self, key_press: KeyPress) -> KeyPress: """ Insert KeyPress data, for vt100 compatibility. @@ -640,6 +644,20 @@ class Vt100ConsoleInputReader: self._buffer = [] return result + def flush_keys(self) -> list[KeyPress]: + """ + Flush pending keys and return them. + (Used for flushing the 'escape' key.) + """ + # Flush all pending keys. (This is most important to flush the vt100 + # 'Escape' key early when nothing else follows.) + self._vt100_parser.flush() + + # Return result. + result = self._buffer + self._buffer = [] + return result + def _get_keys( self, read: DWORD, input_records: Array[INPUT_RECORD] ) -> Iterator[str]: |
