Skip to content

Commit

Permalink
Add a debug hook for getting sent unknown sequences from the XTerm pa…
Browse files Browse the repository at this point in the history
…rser

This is here only for serving the keyboard checker/recorder tool.
  • Loading branch information
davep committed Oct 9, 2023
1 parent c88c031 commit 46ddf9a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/textual/_xterm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def parse_mouse_code(self, code: str) -> events.Event | None:
return event
return None

_reissued_sequence_debug_book: Callable[[str], None] | None = None
"""INTERNAL USE ONLY!
If this property is set to a callable, it will be called *instead* of
the reissued sequence being emitted as key events.
"""

def parse(self, on_token: TokenCallback) -> Generator[Awaitable, str, None]:
ESC = "\x1b"
read1 = self.read1
Expand All @@ -94,6 +101,9 @@ def parse(self, on_token: TokenCallback) -> Generator[Awaitable, str, None]:
use_prior_escape = False

def reissue_sequence_as_keys(reissue_sequence: str) -> None:
if self._reissued_sequence_debug_book is not None:
self._reissued_sequence_debug_book(reissue_sequence)
return
for character in reissue_sequence:
key_events = sequence_to_key_events(character)
for event in key_events:
Expand Down

0 comments on commit 46ddf9a

Please sign in to comment.