Skip to content

Commit 84f5014

Browse files
committed
keys: Add a common suffix for all urwid_readline hotkeys.
Tests updated to not use urwid_readline hotkeys, to avoid reliance on external libraries for hotkey commands.
1 parent e5e9010 commit 84f5014

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

tests/config/test_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_display_key_for_urwid_key(urwid_key: str, display_key: str) -> None:
142142

143143

144144
COMMAND_TO_DISPLAY_KEYS = [
145-
("NEXT_LINE", ["Down", "Ctrl n"]),
145+
("SEND_MESSAGE", ["Ctrl d", "Meta Enter"]),
146146
("TOGGLE_STAR_STATUS", ["Ctrl s", "*"]),
147147
("ALL_PM", ["P"]),
148148
]

zulipterminal/config/keys.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
)
1818

1919

20+
READLINE_SUFFIX = "_READLINE"
21+
22+
2023
class KeyBinding(TypedDict):
2124
keys: List[str]
2225
help_text: str
@@ -320,82 +323,82 @@ class KeyBinding(TypedDict):
320323
'help_text': 'Show/hide user information (from users list)',
321324
'key_category': 'general',
322325
},
323-
'BEGINNING_OF_LINE': {
326+
'BEGINNING_OF_LINE' + READLINE_SUFFIX: {
324327
'keys': ['ctrl a', 'home'],
325328
'help_text': 'Start of line',
326329
'key_category': 'editor_navigation',
327330
},
328-
'END_OF_LINE': {
331+
'END_OF_LINE' + READLINE_SUFFIX: {
329332
'keys': ['ctrl e', 'end'],
330333
'help_text': 'End of line',
331334
'key_category': 'editor_navigation',
332335
},
333-
'ONE_WORD_BACKWARD': {
336+
'ONE_WORD_BACKWARD' + READLINE_SUFFIX: {
334337
'keys': ['meta b', 'shift left'],
335338
'help_text': 'Start of current or previous word',
336339
'key_category': 'editor_navigation',
337340
},
338-
'ONE_WORD_FORWARD': {
341+
'ONE_WORD_FORWARD' + READLINE_SUFFIX: {
339342
'keys': ['meta f', 'shift right'],
340343
'help_text': 'Start of next word',
341344
'key_category': 'editor_navigation',
342345
},
343-
'PREV_LINE': {
346+
'PREV_LINE' + READLINE_SUFFIX: {
344347
'keys': ['up', 'ctrl p'],
345348
'help_text': 'Previous line',
346349
'key_category': 'editor_navigation',
347350
},
348-
'NEXT_LINE': {
351+
'NEXT_LINE' + READLINE_SUFFIX: {
349352
'keys': ['down', 'ctrl n'],
350353
'help_text': 'Next line',
351354
'key_category': 'editor_navigation',
352355
},
353-
'UNDO_LAST_ACTION': {
356+
'UNDO_LAST_ACTION' + READLINE_SUFFIX: {
354357
'keys': ['ctrl _'],
355358
'help_text': 'Undo last action',
356359
'key_category': 'editor_text_manipulation',
357360
},
358-
'CLEAR_MESSAGE': {
361+
'CLEAR_MESSAGE' + READLINE_SUFFIX: {
359362
'keys': ['ctrl l'],
360363
'help_text': 'Clear text box',
361364
'key_category': 'editor_text_manipulation',
362365
},
363-
'CUT_TO_END_OF_LINE': {
366+
'CUT_TO_END_OF_LINE' + READLINE_SUFFIX: {
364367
'keys': ['ctrl k'],
365368
'help_text': 'Cut forwards to the end of the line',
366369
'key_category': 'editor_text_manipulation',
367370
},
368-
'CUT_TO_START_OF_LINE': {
371+
'CUT_TO_START_OF_LINE' + READLINE_SUFFIX: {
369372
'keys': ['ctrl u'],
370373
'help_text': 'Cut backwards to the start of the line',
371374
'key_category': 'editor_text_manipulation',
372375
},
373-
'CUT_TO_END_OF_WORD': {
376+
'CUT_TO_END_OF_WORD' + READLINE_SUFFIX: {
374377
'keys': ['meta d'],
375378
'help_text': 'Cut forwards to the end of the current word',
376379
'key_category': 'editor_text_manipulation',
377380
},
378-
'CUT_TO_START_OF_WORD': {
381+
'CUT_TO_START_OF_WORD' + READLINE_SUFFIX: {
379382
'keys': ['ctrl w', 'meta backspace'],
380383
'help_text': 'Cut backwards to the start of the current word',
381384
'key_category': 'editor_text_manipulation',
382385
},
383-
'CUT_WHOLE_LINE': {
386+
'CUT_WHOLE_LINE' + READLINE_SUFFIX: {
384387
'keys': ['meta x'],
385388
'help_text': 'Cut the current line',
386389
'key_category': 'editor_text_manipulation',
387390
},
388-
'PASTE_LAST_CUT': {
391+
'PASTE_LAST_CUT' + READLINE_SUFFIX: {
389392
'keys': ['ctrl y'],
390393
'help_text': 'Paste last cut section',
391394
'key_category': 'editor_text_manipulation',
392395
},
393-
'DELETE_LAST_CHARACTER': {
396+
'DELETE_LAST_CHARACTER' + READLINE_SUFFIX: {
394397
'keys': ['ctrl h'],
395398
'help_text': 'Delete previous character',
396399
'key_category': 'editor_text_manipulation',
397400
},
398-
'TRANSPOSE_CHARACTERS': {
401+
'TRANSPOSE_CHARACTERS' + READLINE_SUFFIX: {
399402
'keys': ['ctrl t'],
400403
'help_text': 'Swap with previous character',
401404
'key_category': 'editor_text_manipulation',

0 commit comments

Comments
 (0)