Skip to content

Commit

Permalink
keys/ui: Add hotkey and command to generate new random footer hint.
Browse files Browse the repository at this point in the history
Added tests.
Hotkeys document regenerated.
  • Loading branch information
Niloth-p authored and neiljp committed Jul 4, 2024
1 parent d46b6d8 commit 967d762
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/hotkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
|Redraw screen|<kbd>Ctrl</kbd> + <kbd>l</kbd>|
|Quit|<kbd>Ctrl</kbd> + <kbd>c</kbd>|
|Show/hide user information (from users list)|<kbd>i</kbd>|
|New footer hotkey hint|<kbd>Tab</kbd>|

## Navigation
|Command|Key Combination|
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,23 @@ def test_keypress_STREAM_MESSAGE(
assert returned_key == key
assert view.body.focus_col == 1

@pytest.mark.parametrize("key", keys_for_command("NEW_HINT"))
def test_keypress_NEW_HINT(
self,
view: View,
mocker: MockerFixture,
key: str,
widget_size: Callable[[Widget], urwid_Box],
) -> None:
size = widget_size(view)
set_footer_text = mocker.patch(VIEW + ".set_footer_text")
mocker.patch(CONTROLLER + ".is_in_editor_mode", return_value=False)

returned_key = view.keypress(size, key)

set_footer_text.assert_called_once_with()
assert returned_key == key

@pytest.mark.parametrize("key", keys_for_command("SEARCH_PEOPLE"))
@pytest.mark.parametrize("autohide", [True, False], ids=["autohide", "no_autohide"])
def test_keypress_autohide_users(
Expand Down
5 changes: 5 additions & 0 deletions zulipterminal/config/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ class KeyBinding(TypedDict):
'help_text': 'Show/hide full raw message (from message information)',
'key_category': 'msg_actions',
},
'NEW_HINT': {
'keys': ['tab'],
'help_text': 'New footer hotkey hint',
'key_category': 'general',
},
}
# fmt: on

Expand Down
3 changes: 3 additions & 0 deletions zulipterminal/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
elif is_command_key("MARKDOWN_HELP", key):
self.controller.show_markdown_help()
return key
elif is_command_key("NEW_HINT", key):
self.set_footer_text()
return key
return super().keypress(size, key)

def mouse_event(
Expand Down

0 comments on commit 967d762

Please sign in to comment.