Add secret --key-debug to debug keypresses
This commit is contained in:
@@ -267,7 +267,7 @@ KEYS = [
|
||||
Key('^\\', b'^\\', '\x1c'),
|
||||
Key('!resize', b'KEY_RESIZE', curses.KEY_RESIZE),
|
||||
]
|
||||
KEYS_TMUX = {k.tmux: k.value for k in KEYS}
|
||||
KEYS_TMUX = {k.tmux: k.wch for k in KEYS}
|
||||
KEYS_CURSES = {k.value: k.curses for k in KEYS}
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ class DeferredRunner:
|
||||
print(f'KEY: {keypress_event.wch!r}')
|
||||
return keypress_event.wch
|
||||
|
||||
def await_text(self, text):
|
||||
def await_text(self, text, timeout=1):
|
||||
self._ops.append(AwaitText(text))
|
||||
|
||||
def await_text_missing(self, text):
|
||||
|
||||
22
tests/features/key_debug_test.py
Normal file
22
tests/features/key_debug_test.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import curses
|
||||
|
||||
from babi.screen import VERSION_STR
|
||||
|
||||
|
||||
def test_key_debug(run):
|
||||
with run('--key-debug') as h:
|
||||
h.await_text(VERSION_STR, timeout=2)
|
||||
|
||||
h.await_text('press q to quit')
|
||||
|
||||
h.press('a')
|
||||
h.await_text("'a' 'STRING'")
|
||||
|
||||
h.press('^X')
|
||||
h.await_text(r"'\x18' '^X'")
|
||||
|
||||
with h.resize(width=20, height=20):
|
||||
h.await_text(f"{curses.KEY_RESIZE} 'KEY_RESIZE'")
|
||||
|
||||
h.press('q')
|
||||
h.await_exit()
|
||||
Reference in New Issue
Block a user