Skip to content

Commit 28d5f6a

Browse files
Niloth-pneiljp
authored andcommitted
keys: Add space key as an additional trigger of ACTIVATE_BUTTON command.
For consistency with Urwid's ACTIVATE command. Urwid's command map is updated to link Urwid's ACTIVATE with our ACTIVATE_BUTTON command. Although they currently use the same keys, they are synced to ensure future compatibility. Hotkeys document regenerated. Tests updated.
1 parent 589c789 commit 28d5f6a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

docs/hotkeys.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
|Scroll up|<kbd>PgUp</kbd> / <kbd>K</kbd>|
2626
|Scroll down|<kbd>PgDn</kbd> / <kbd>J</kbd>|
2727
|Go to bottom / Last message|<kbd>End</kbd> / <kbd>G</kbd>|
28-
|Trigger the selected entry|<kbd>Enter</kbd>|
28+
|Trigger the selected entry|<kbd>Enter</kbd> / <kbd>Space</kbd>|
2929
|Narrow to all messages|<kbd>a</kbd> / <kbd>Esc</kbd>|
3030
|Narrow to all direct messages|<kbd>P</kbd>|
3131
|Narrow to all starred messages|<kbd>f</kbd>|

tests/ui_tools/test_messages.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pytest import param as case
88
from urwid import Columns, Divider, Padding, Text
99

10-
from zulipterminal.config.keys import keys_for_command
10+
from zulipterminal.config.keys import keys_for_command, primary_key_for_command
1111
from zulipterminal.config.symbols import (
1212
ALL_MESSAGES_MARKER,
1313
DIRECT_MESSAGE_MARKER,
@@ -1968,6 +1968,7 @@ def test_footlinks_limit(self, maximum_footlinks, expected_instance):
19681968
def test_mouse_event_left_click(
19691969
self, mocker, msg_box, key, widget_size, compose_box_is_open
19701970
):
1971+
expected_keypress = primary_key_for_command("ACTIVATE_BUTTON")
19711972
size = widget_size(msg_box)
19721973
col = 1
19731974
row = 1
@@ -1981,4 +1982,4 @@ def test_mouse_event_left_click(
19811982
if compose_box_is_open:
19821983
msg_box.keypress.assert_not_called()
19831984
else:
1984-
msg_box.keypress.assert_called_once_with(size, key)
1985+
msg_box.keypress.assert_called_once_with(size, expected_keypress)

zulipterminal/config/keys.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from typing_extensions import NotRequired, TypedDict
88
from urwid.command_map import (
9+
ACTIVATE,
910
CURSOR_DOWN,
1011
CURSOR_LEFT,
1112
CURSOR_MAX_RIGHT,
@@ -97,7 +98,7 @@ class KeyBinding(TypedDict):
9798
'key_category': 'navigation',
9899
},
99100
'ACTIVATE_BUTTON': {
100-
'keys': ['enter'],
101+
'keys': ['enter', ' '],
101102
'help_text': 'Trigger the selected entry',
102103
'key_category': 'navigation',
103104
},
@@ -450,6 +451,7 @@ class KeyBinding(TypedDict):
450451
"SCROLL_UP": CURSOR_PAGE_UP,
451452
"SCROLL_DOWN": CURSOR_PAGE_DOWN,
452453
"GO_TO_BOTTOM": CURSOR_MAX_RIGHT,
454+
"ACTIVATE_BUTTON": ACTIVATE,
453455
}
454456

455457

@@ -495,6 +497,9 @@ def display_key_for_urwid_key(urwid_key: str) -> str:
495497
"""
496498
Returns a displayable user-centric format of the urwid key.
497499
"""
500+
if urwid_key == " ":
501+
return "Space"
502+
498503
for urwid_map_key, display_map_key in URWID_KEY_TO_DISPLAY_KEY_MAPPING.items():
499504
if urwid_map_key in urwid_key:
500505
urwid_key = urwid_key.replace(urwid_map_key, display_map_key)

0 commit comments

Comments
 (0)