Skip to content

Commit 37ae850

Browse files
committed
lint-hotkeys: Use keyboard representation in hotkeys doc.
Applies - Capitalization of all keys. - Add Shift for uppercase keys. - Fix "<kbd>page</kbd> + <kbd>up</kbd>" to "<kbd>PgUp</kbd>".
1 parent a2e616e commit 37ae850

File tree

2 files changed

+84
-69
lines changed

2 files changed

+84
-69
lines changed

docs/hotkeys.md

+65-65
Original file line numberDiff line numberDiff line change
@@ -6,96 +6,96 @@
66
|Command|Key Combination|
77
| :--- | :---: |
88
|Show/hide help menu|<kbd>?</kbd>|
9-
|Show/hide markdown help menu|<kbd>meta</kbd> + <kbd>m</kbd>|
10-
|Show/hide about menu|<kbd>meta</kbd> + <kbd>?</kbd>|
11-
|Go Back|<kbd>esc</kbd>|
12-
|Open draft message saved in this session|<kbd>d</kbd>|
13-
|Redraw screen|<kbd>ctrl</kbd> + <kbd>l</kbd>|
14-
|Quit|<kbd>ctrl</kbd> + <kbd>c</kbd>|
15-
|View user information (From Users list)|<kbd>i</kbd>|
9+
|Show/hide markdown help menu|<kbd>Meta</kbd> + <kbd>M</kbd>|
10+
|Show/hide about menu|<kbd>Meta</kbd> + <kbd>?</kbd>|
11+
|Go Back|<kbd>Esc</kbd>|
12+
|Open draft message saved in this session|<kbd>D</kbd>|
13+
|Redraw screen|<kbd>Ctrl</kbd> + <kbd>L</kbd>|
14+
|Quit|<kbd>Ctrl</kbd> + <kbd>C</kbd>|
15+
|View user information (From Users list)|<kbd>I</kbd>|
1616

1717
## Navigation
1818
|Command|Key Combination|
1919
| :--- | :---: |
20-
|Go up / Previous message|<kbd>up</kbd> / <kbd>k</kbd>|
21-
|Go down / Next message|<kbd>down</kbd> / <kbd>j</kbd>|
22-
|Go left|<kbd>left</kbd> / <kbd>h</kbd>|
23-
|Go right|<kbd>right</kbd> / <kbd>l</kbd>|
24-
|Scroll up|<kbd>page</kbd> + <kbd>up</kbd> / <kbd>K</kbd>|
25-
|Scroll down|<kbd>page</kbd> + <kbd>down</kbd> / <kbd>J</kbd>|
26-
|Go to bottom / Last message|<kbd>end</kbd> / <kbd>G</kbd>|
27-
|Narrow to all messages|<kbd>a</kbd> / <kbd>esc</kbd>|
28-
|Narrow to all direct messages|<kbd>P</kbd>|
29-
|Narrow to all starred messages|<kbd>f</kbd>|
20+
|Go up / Previous message|<kbd>Up</kbd> / <kbd>K</kbd>|
21+
|Go down / Next message|<kbd>Down</kbd> / <kbd>J</kbd>|
22+
|Go left|<kbd>Left</kbd> / <kbd>H</kbd>|
23+
|Go right|<kbd>Right</kbd> / <kbd>L</kbd>|
24+
|Scroll up|<kbd>PgUp</kbd> / <kbd>Shift</kbd> + <kbd>K</kbd>|
25+
|Scroll down|<kbd>PgDn</kbd> / <kbd>Shift</kbd> + <kbd>J</kbd>|
26+
|Go to bottom / Last message|<kbd>End</kbd> / <kbd>Shift</kbd> + <kbd>G</kbd>|
27+
|Narrow to all messages|<kbd>A</kbd> / <kbd>Esc</kbd>|
28+
|Narrow to all direct messages|<kbd>Shift</kbd> + <kbd>P</kbd>|
29+
|Narrow to all starred messages|<kbd>F</kbd>|
3030
|Narrow to messages in which you're mentioned|<kbd>#</kbd>|
31-
|Next unread topic|<kbd>n</kbd>|
32-
|Next unread direct message|<kbd>p</kbd>|
33-
|Perform current action|<kbd>enter</kbd>|
31+
|Next unread topic|<kbd>N</kbd>|
32+
|Next unread direct message|<kbd>P</kbd>|
33+
|Perform current action|<kbd>Enter</kbd>|
3434

3535
## Searching
3636
|Command|Key Combination|
3737
| :--- | :---: |
38-
|Search Users|<kbd>w</kbd>|
38+
|Search Users|<kbd>W</kbd>|
3939
|Search Messages|<kbd>/</kbd>|
40-
|Search Streams|<kbd>q</kbd>|
41-
|Search topics in a stream|<kbd>q</kbd>|
42-
|Search emojis from Emoji-picker popup|<kbd>p</kbd>|
40+
|Search Streams|<kbd>Q</kbd>|
41+
|Search topics in a stream|<kbd>Q</kbd>|
42+
|Search emojis from Emoji-picker popup|<kbd>P</kbd>|
4343

4444
## Message actions
4545
|Command|Key Combination|
4646
| :--- | :---: |
47-
|Reply to the current message|<kbd>r</kbd> / <kbd>enter</kbd>|
47+
|Reply to the current message|<kbd>R</kbd> / <kbd>Enter</kbd>|
4848
|Reply mentioning the sender of the current message|<kbd>@</kbd>|
4949
|Reply quoting the current message text|<kbd>></kbd>|
50-
|Reply directly to the sender of the current message|<kbd>R</kbd>|
51-
|Edit message's content or topic|<kbd>e</kbd>|
52-
|New message to a stream|<kbd>c</kbd>|
53-
|New message to a person or group of people|<kbd>x</kbd>|
50+
|Reply directly to the sender of the current message|<kbd>Shift</kbd> + <kbd>R</kbd>|
51+
|Edit message's content or topic|<kbd>E</kbd>|
52+
|New message to a stream|<kbd>C</kbd>|
53+
|New message to a person or group of people|<kbd>X</kbd>|
5454
|Show/hide Emoji picker popup for current message|<kbd>:</kbd>|
55-
|Narrow to the stream of the current message|<kbd>s</kbd>|
56-
|Narrow to the topic of the current message|<kbd>S</kbd>|
57-
|Narrow to a topic/direct-chat, or stream/all-direct-messages|<kbd>z</kbd>|
55+
|Narrow to the stream of the current message|<kbd>S</kbd>|
56+
|Narrow to the topic of the current message|<kbd>Shift</kbd> + <kbd>S</kbd>|
57+
|Narrow to a topic/direct-chat, or stream/all-direct-messages|<kbd>Z</kbd>|
5858
|Toggle first emoji reaction on selected message|<kbd>=</kbd>|
5959
|Add/remove thumbs-up reaction to the current message|<kbd>+</kbd>|
60-
|Add/remove star status of the current message|<kbd>ctrl</kbd> + <kbd>s</kbd> / <kbd>*</kbd>|
61-
|Show/hide message information|<kbd>i</kbd>|
62-
|Show/hide message sender information|<kbd>u</kbd>|
63-
|Show/hide edit history (from message information)|<kbd>e</kbd>|
64-
|View current message in browser (from message information)|<kbd>v</kbd>|
65-
|Show/hide full rendered message (from message information)|<kbd>f</kbd>|
66-
|Show/hide full raw message (from message information)|<kbd>r</kbd>|
60+
|Add/remove star status of the current message|<kbd>Ctrl</kbd> + <kbd>S</kbd> / <kbd>*</kbd>|
61+
|Show/hide message information|<kbd>I</kbd>|
62+
|Show/hide message sender information|<kbd>U</kbd>|
63+
|Show/hide edit history (from message information)|<kbd>E</kbd>|
64+
|View current message in browser (from message information)|<kbd>V</kbd>|
65+
|Show/hide full rendered message (from message information)|<kbd>F</kbd>|
66+
|Show/hide full raw message (from message information)|<kbd>R</kbd>|
6767

6868
## Stream list actions
6969
|Command|Key Combination|
7070
| :--- | :---: |
71-
|Toggle topics in a stream|<kbd>t</kbd>|
72-
|Mute/unmute Streams|<kbd>m</kbd>|
73-
|Show/hide stream information & modify settings|<kbd>i</kbd>|
74-
|Show/hide stream members (from stream information)|<kbd>m</kbd>|
75-
|Copy stream email to clipboard (from stream information)|<kbd>c</kbd>|
71+
|Toggle topics in a stream|<kbd>T</kbd>|
72+
|Mute/unmute Streams|<kbd>M</kbd>|
73+
|Show/hide stream information & modify settings|<kbd>I</kbd>|
74+
|Show/hide stream members (from stream information)|<kbd>M</kbd>|
75+
|Copy stream email to clipboard (from stream information)|<kbd>C</kbd>|
7676

7777
## Composing a Message
7878
|Command|Key Combination|
7979
| :--- | :---: |
80-
|Cycle through recipient and content boxes|<kbd>tab</kbd>|
81-
|Send a message|<kbd>ctrl</kbd> + <kbd>d</kbd> / <kbd>meta</kbd> + <kbd>enter</kbd>|
82-
|Save current message as a draft|<kbd>meta</kbd> + <kbd>s</kbd>|
83-
|Autocomplete @mentions, #stream_names, :emoji: and topics|<kbd>ctrl</kbd> + <kbd>f</kbd>|
84-
|Cycle through autocomplete suggestions in reverse|<kbd>ctrl</kbd> + <kbd>r</kbd>|
85-
|Narrow to compose box message recipient|<kbd>meta</kbd> + <kbd>.</kbd>|
86-
|Jump to the beginning of line|<kbd>ctrl</kbd> + <kbd>a</kbd>|
87-
|Jump to the end of line|<kbd>ctrl</kbd> + <kbd>e</kbd>|
88-
|Jump backward one word|<kbd>meta</kbd> + <kbd>b</kbd>|
89-
|Jump forward one word|<kbd>meta</kbd> + <kbd>f</kbd>|
90-
|Delete previous character (to left)|<kbd>ctrl</kbd> + <kbd>h</kbd>|
91-
|Transpose characters|<kbd>ctrl</kbd> + <kbd>t</kbd>|
92-
|Cut forwards to the end of the line|<kbd>ctrl</kbd> + <kbd>k</kbd>|
93-
|Cut backwards to the start of the line|<kbd>ctrl</kbd> + <kbd>u</kbd>|
94-
|Cut forwards to the end of the current word|<kbd>meta</kbd> + <kbd>d</kbd>|
95-
|Cut backwards to the start of the current word|<kbd>ctrl</kbd> + <kbd>w</kbd>|
96-
|Paste last cut section|<kbd>ctrl</kbd> + <kbd>y</kbd>|
97-
|Undo last action|<kbd>ctrl</kbd> + <kbd>_</kbd>|
98-
|Jump to the previous line|<kbd>up</kbd> / <kbd>ctrl</kbd> + <kbd>p</kbd>|
99-
|Jump to the next line|<kbd>down</kbd> / <kbd>ctrl</kbd> + <kbd>n</kbd>|
100-
|Clear compose box|<kbd>ctrl</kbd> + <kbd>l</kbd>|
80+
|Cycle through recipient and content boxes|<kbd>Tab</kbd>|
81+
|Send a message|<kbd>Ctrl</kbd> + <kbd>D</kbd> / <kbd>Meta</kbd> + <kbd>Enter</kbd>|
82+
|Save current message as a draft|<kbd>Meta</kbd> + <kbd>S</kbd>|
83+
|Autocomplete @mentions, #stream_names, :emoji: and topics|<kbd>Ctrl</kbd> + <kbd>F</kbd>|
84+
|Cycle through autocomplete suggestions in reverse|<kbd>Ctrl</kbd> + <kbd>R</kbd>|
85+
|Narrow to compose box message recipient|<kbd>Meta</kbd> + <kbd>.</kbd>|
86+
|Jump to the beginning of line|<kbd>Ctrl</kbd> + <kbd>A</kbd>|
87+
|Jump to the end of line|<kbd>Ctrl</kbd> + <kbd>E</kbd>|
88+
|Jump backward one word|<kbd>Meta</kbd> + <kbd>B</kbd>|
89+
|Jump forward one word|<kbd>Meta</kbd> + <kbd>F</kbd>|
90+
|Delete previous character (to left)|<kbd>Ctrl</kbd> + <kbd>H</kbd>|
91+
|Transpose characters|<kbd>Ctrl</kbd> + <kbd>T</kbd>|
92+
|Cut forwards to the end of the line|<kbd>Ctrl</kbd> + <kbd>K</kbd>|
93+
|Cut backwards to the start of the line|<kbd>Ctrl</kbd> + <kbd>U</kbd>|
94+
|Cut forwards to the end of the current word|<kbd>Meta</kbd> + <kbd>D</kbd>|
95+
|Cut backwards to the start of the current word|<kbd>Ctrl</kbd> + <kbd>W</kbd>|
96+
|Paste last cut section|<kbd>Ctrl</kbd> + <kbd>Y</kbd>|
97+
|Undo last action|<kbd>Ctrl</kbd> + <kbd>_</kbd>|
98+
|Jump to the previous line|<kbd>Up</kbd> / <kbd>Ctrl</kbd> + <kbd>P</kbd>|
99+
|Jump to the next line|<kbd>Down</kbd> / <kbd>Ctrl</kbd> + <kbd>N</kbd>|
100+
|Clear compose box|<kbd>Ctrl</kbd> + <kbd>L</kbd>|
101101

tools/lint-hotkeys

+19-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ from collections import defaultdict
66
from pathlib import Path, PurePath
77
from typing import Dict, List, Tuple
88

9-
from zulipterminal.config.keys import HELP_CATEGORIES, KEY_BINDINGS
9+
from zulipterminal.config.keys import (
10+
HELP_CATEGORIES,
11+
KEY_BINDINGS,
12+
display_keys_for_command,
13+
)
1014

1115

1216
KEYS_FILE = (
@@ -104,7 +108,16 @@ def get_hotkeys_file_string() -> str:
104108
for help_text, key_combinations_list in categories[action]:
105109
various_key_combinations = " / ".join(
106110
[
107-
" + ".join([f"<kbd>{key}</kbd>" for key in key_combination.split()])
111+
" + ".join(
112+
[
113+
f"<kbd>Shift</kbd> + <kbd>{key}</kbd>"
114+
if len(key) == 1 and key.isupper()
115+
else f"<kbd>{key.capitalize()}</kbd>"
116+
if len(key) == 1
117+
else f"<kbd>{key}</kbd>"
118+
for key in key_combination.split()
119+
]
120+
)
108121
for key_combination in key_combinations_list
109122
]
110123
)
@@ -129,8 +142,10 @@ def read_help_categories() -> Dict[str, List[Tuple[str, List[str]]]]:
129142
Get all help categories from KEYS_FILE
130143
"""
131144
categories = defaultdict(list)
132-
for item in KEY_BINDINGS.values():
133-
categories[item["key_category"]].append((item["help_text"], item["keys"]))
145+
for cmd, item in KEY_BINDINGS.items():
146+
categories[item["key_category"]].append(
147+
(item["help_text"], display_keys_for_command(cmd))
148+
)
134149
return categories
135150

136151

0 commit comments

Comments
 (0)