Skip to content

Commit 58b1a96

Browse files
committed
core/ui/views/keys: Add a Contextual Help Menu.
Assigned an arbitrary hotkey. Will be overloaded onto the HELP command. Help Menus do not currently work from within editors or popups. Hotkeys document regenerated.
1 parent f75a309 commit 58b1a96

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

docs/hotkeys.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
|Command|Key Combination|
77
| :--- | :---: |
88
|Show/hide Help Menu|<kbd>?</kbd>|
9+
|Show/hide Contextual Help Menu|<kbd>Meta</kbd> + <kbd>c</kbd>|
910
|Show/hide Markdown Help Menu|<kbd>Meta</kbd> + <kbd>m</kbd>|
1011
|Show/hide About Menu|<kbd>Meta</kbd> + <kbd>?</kbd>|
1112
|Copy information from About Menu to clipboard|<kbd>c</kbd>|

zulipterminal/config/keys.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class KeyBinding(TypedDict):
3838
'key_category': 'general',
3939
'key_contexts': ['general'],
4040
},
41+
'CONTEXTUAL_HELP': {
42+
'keys': ['meta c'],
43+
'help_text': 'Show/hide Contextual Help Menu',
44+
'excluded_from_random_tips': True,
45+
'key_category': 'general',
46+
'key_contexts': ['general'],
47+
},
4148
'MARKDOWN_HELP': {
4249
'keys': ['meta m'],
4350
'help_text': 'Show/hide Markdown Help Menu',

zulipterminal/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ def is_any_popup_open(self) -> bool:
252252
def exit_popup(self) -> None:
253253
self.loop.widget = self.view
254254

255-
def show_help(self) -> None:
256-
help_view = HelpView(self, f"Help Menu {SCROLL_PROMPT}")
255+
def show_help(self, context: Optional[str] = None) -> None:
256+
help_view = HelpView(self, f"Help Menu {SCROLL_PROMPT}", context)
257257
self.show_pop_up(help_view, "area:help")
258258

259259
def show_markdown_help(self) -> None:

zulipterminal/ui.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
350350
# Show help menu
351351
self.controller.show_help()
352352
return key
353+
elif is_command_key("CONTEXTUAL_HELP", key):
354+
self.controller.show_help(self.context)
355+
return key
353356
elif is_command_key("MARKDOWN_HELP", key):
354357
self.controller.show_markdown_help()
355358
return key

zulipterminal/ui_tools/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,13 +1238,16 @@ def _fetch_user_data(
12381238

12391239

12401240
class HelpView(PopUpView):
1241-
def __init__(self, controller: Any, title: str) -> None:
1241+
def __init__(
1242+
self, controller: Any, title: str, context: Optional[str] = None
1243+
) -> None:
12421244
help_menu_content = []
12431245
for category in HELP_CATEGORIES:
12441246
keys_in_category = (
12451247
binding
12461248
for binding in KEY_BINDINGS.values()
12471249
if binding["key_category"] == category
1250+
and (not context or context in binding["key_contexts"])
12481251
)
12491252
key_bindings = [
12501253
(
@@ -1254,6 +1257,8 @@ def __init__(self, controller: Any, title: str) -> None:
12541257
for binding in keys_in_category
12551258
]
12561259

1260+
if not key_bindings:
1261+
continue
12571262
help_menu_content.append((HELP_CATEGORIES[category], key_bindings))
12581263

12591264
popup_width, column_widths = self.calculate_table_widths(

0 commit comments

Comments
 (0)