Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce help context #1484

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
de8d7a6
ui: Make the Help hotkey suggestion in the footer more conventional.
Niloth-p Jul 10, 2024
9fccce3
refactor: ui/core/boxes: Separate out function to reset footer text.
Niloth-p Jul 15, 2024
13410a2
refactor: ui/core: Separate footer events from set_footer_text().
Niloth-p Jul 15, 2024
b9b5ee8
ui: Add state variable to track live footer events.
Niloth-p Jul 15, 2024
af00b47
lint-hotkeys: Handle the doc file does not exist exception.
Niloth-p Jul 15, 2024
d2e0c17
refactor: lint-hotkeys: Remove the write_hotkeys_file() function.
Niloth-p Jul 15, 2024
4e8783c
refactor: lint-hotkeys: Make int error flag boolean & use SystemExit.
Niloth-p Jul 15, 2024
e954870
lint-hotkeys: Rewrite function docstrings and comments.
Niloth-p Jul 15, 2024
4ed23c7
refactor: lint-hotkeys: Rename get_hotkeys_file_string().
Niloth-p Jul 15, 2024
9717776
refactor: lint-hotkeys: Rename ambiguous keyword "action" to "batch".
Niloth-p Jul 15, 2024
11a7ead
refactor: lint-hotkeys: Improve variable naming of generated dict.
Niloth-p Jul 17, 2024
3237251
lint-hotkeys: Refactor the flow by creating new ENTRY_BY_CATEGORIES.
Niloth-p Jul 15, 2024
188bd7f
lint-hotkeys: Delay generation of file string when linting.
Niloth-p Jul 17, 2024
0dd8aa4
refactor: lint-hotkeys: Split out the help text linting function.
Niloth-p Jul 17, 2024
5286488
refactor: lint-hotkeys: Split out the function that lints categories.
Niloth-p Jul 17, 2024
4e7a4f2
lint-hotkeys: Restructure the error messages of lint_help_text().
Niloth-p Jul 17, 2024
efc8f82
lint-hotkeys: Lint for typos in key_category values.
Niloth-p Jul 17, 2024
ac8e715
refactor: lint-hotkeys: Use help_group instead of HELP_CATEGORIES.
Niloth-p Jul 17, 2024
58ec337
refactor: lint-hotkeys: Create generic variable entries_by_group.
Niloth-p Jul 17, 2024
3ce52db
refactor: lint-hotkeys: Create generic variables for key_category.
Niloth-p Jul 17, 2024
4911685
refactor: lint-hotkeys: Replace 'category(ies)' with 'group(s)'.
Niloth-p Jul 17, 2024
b35e0ce
refactor: lint-hotkeys: Delete constant OUTPUT_FILE_NAME, compute it.
Niloth-p Jul 17, 2024
001814b
refactor: lint-hotkeys: Replace usage of OUTPUT_FILE.
Niloth-p Jul 17, 2024
e2c7e57
refactor: lint-hotkeys: Generalize the traversal of key group values.
Niloth-p Jul 17, 2024
f908dc6
refactor: lint-hotkeys: Use bundled group values.
Niloth-p Jul 18, 2024
f5d0bc4
keys: Add a contexts field to Key Binding.
Niloth-p Jul 8, 2024
a8dd4de
lint-hotkeys: Add argument to generate a keys file grouped by contexts.
Niloth-p Jul 18, 2024
a76da7f
keys: Use the help contexts in generating random help tips.
Niloth-p Jul 8, 2024
9c48eb7
keys: Include previously excluded random help hints.
Niloth-p Apr 16, 2024
2e1b0f0
ui: Enable footer texts to display contextual help tips.
Niloth-p Jul 16, 2024
1b6ad6b
ui/keys: Display the context of the footer hint.
Niloth-p Jul 10, 2024
f75a309
contexts/core/ui: Track the currently focused widget in the UI.
Niloth-p Jul 11, 2024
58b1a96
core/ui/views/keys: Add a Contextual Help Menu.
Niloth-p Jul 10, 2024
3513d73
keys/views: Add mapping of contexts to broader contexts they belong to.
Niloth-p Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/hotkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
|Command|Key Combination|
| :--- | :---: |
|Show/hide Help Menu|<kbd>?</kbd>|
|Show/hide Contextual Help Menu|<kbd>Meta</kbd> + <kbd>c</kbd>|
|Show/hide Markdown Help Menu|<kbd>Meta</kbd> + <kbd>m</kbd>|
|Show/hide About Menu|<kbd>Meta</kbd> + <kbd>?</kbd>|
|Copy information from About Menu to clipboard|<kbd>c</kbd>|
Expand Down
7 changes: 7 additions & 0 deletions zulipterminal/config/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class KeyBinding(TypedDict):
'key_category': 'general',
'key_contexts': ['general'],
},
'CONTEXTUAL_HELP': {
'keys': ['meta c'],
'help_text': 'Show/hide Contextual Help Menu',
'excluded_from_random_tips': True,
'key_category': 'general',
'key_contexts': ['general'],
},
'MARKDOWN_HELP': {
'keys': ['meta m'],
'help_text': 'Show/hide Markdown Help Menu',
Expand Down
4 changes: 2 additions & 2 deletions zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def is_any_popup_open(self) -> bool:
def exit_popup(self) -> None:
self.loop.widget = self.view

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

def show_markdown_help(self) -> None:
Expand Down
3 changes: 3 additions & 0 deletions zulipterminal/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
# Show help menu
self.controller.show_help()
return key
elif is_command_key("CONTEXTUAL_HELP", key):
self.controller.show_help(self.context)
return key
elif is_command_key("MARKDOWN_HELP", key):
self.controller.show_markdown_help()
return key
Expand Down
7 changes: 6 additions & 1 deletion zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,13 +1238,16 @@ def _fetch_user_data(


class HelpView(PopUpView):
def __init__(self, controller: Any, title: str) -> None:
def __init__(
self, controller: Any, title: str, context: Optional[str] = None
) -> None:
Comment on lines -1241 to +1244
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails to toggle properly with contextual help.

help_menu_content = []
for category in HELP_CATEGORIES:
keys_in_category = (
binding
for binding in KEY_BINDINGS.values()
if binding["key_category"] == category
and (not context or context in binding["key_contexts"])
)
key_bindings = [
(
Expand All @@ -1254,6 +1257,8 @@ def __init__(self, controller: Any, title: str) -> None:
for binding in keys_in_category
]

if not key_bindings:
continue
help_menu_content.append((HELP_CATEGORIES[category], key_bindings))

popup_width, column_widths = self.calculate_table_widths(
Expand Down