From d65cbee7406a3413946e78fb7fcff8ddc8875251 Mon Sep 17 00:00:00 2001
From: Niloth-p <20315308+Niloth-p@users.noreply.github.com>
Date: Thu, 4 Apr 2024 18:37:44 +0530
Subject: [PATCH] lint-hotkeys: Refine display of keys in hotkeys doc.
Uses the new display functions from keys.py.
Applies:
- Capitalization of special keys, eg. Esc, Meta, Ctrl, Up
- Fix "page + up" to "PgUp" (& PgDn)
Fixes parts of #945.
---
docs/hotkeys.md | 74 +++++++++++++++++++++++-----------------------
tools/lint-hotkeys | 12 ++++++--
2 files changed, 46 insertions(+), 40 deletions(-)
diff --git a/docs/hotkeys.md b/docs/hotkeys.md
index 38ad92b34d..c05e0886e3 100644
--- a/docs/hotkeys.md
+++ b/docs/hotkeys.md
@@ -6,31 +6,31 @@
|Command|Key Combination|
| :--- | :---: |
|Show/hide help menu|?|
-|Show/hide markdown help menu|meta + m|
-|Show/hide about menu|meta + ?|
-|Go Back|esc|
+|Show/hide markdown help menu|Meta + m|
+|Show/hide about menu|Meta + ?|
+|Go Back|Esc|
|Open draft message saved in this session|d|
-|Redraw screen|ctrl + l|
-|Quit|ctrl + c|
+|Redraw screen|Ctrl + l|
+|Quit|Ctrl + c|
|View user information (From Users list)|i|
## Navigation
|Command|Key Combination|
| :--- | :---: |
-|Go up / Previous message|up / k|
-|Go down / Next message|down / j|
-|Go left|left / h|
-|Go right|right / l|
-|Scroll up|page + up / K|
-|Scroll down|page + down / J|
-|Go to bottom / Last message|end / G|
-|Narrow to all messages|a / esc|
+|Go up / Previous message|Up / k|
+|Go down / Next message|Down / j|
+|Go left|Left / h|
+|Go right|Right / l|
+|Scroll up|PgUp / K|
+|Scroll down|PgDn / J|
+|Go to bottom / Last message|End / G|
+|Narrow to all messages|a / Esc|
|Narrow to all direct messages|P|
|Narrow to all starred messages|f|
|Narrow to messages in which you're mentioned|#|
|Next unread topic|n|
|Next unread direct message|p|
-|Perform current action|enter|
+|Perform current action|Enter|
## Searching
|Command|Key Combination|
@@ -44,7 +44,7 @@
## Message actions
|Command|Key Combination|
| :--- | :---: |
-|Reply to the current message|r / enter|
+|Reply to the current message|r / Enter|
|Reply mentioning the sender of the current message|@|
|Reply quoting the current message text|>|
|Reply directly to the sender of the current message|R|
@@ -57,7 +57,7 @@
|Narrow to a topic/direct-chat, or stream/all-direct-messages|z|
|Toggle first emoji reaction on selected message|=|
|Add/remove thumbs-up reaction to the current message|+|
-|Add/remove star status of the current message|ctrl + s / *|
+|Add/remove star status of the current message|Ctrl + s / *|
|Show/hide message information|i|
|Show/hide message sender information|u|
|Show/hide edit history (from message information)|e|
@@ -77,25 +77,25 @@
## Composing a Message
|Command|Key Combination|
| :--- | :---: |
-|Cycle through recipient and content boxes|tab|
-|Send a message|ctrl + d / meta + enter|
-|Save current message as a draft|meta + s|
-|Autocomplete @mentions, #stream_names, :emoji: and topics|ctrl + f|
-|Cycle through autocomplete suggestions in reverse|ctrl + r|
-|Narrow to compose box message recipient|meta + .|
-|Jump to the beginning of line|ctrl + a|
-|Jump to the end of line|ctrl + e|
-|Jump backward one word|meta + b|
-|Jump forward one word|meta + f|
-|Delete previous character (to left)|ctrl + h|
-|Transpose characters|ctrl + t|
-|Cut forwards to the end of the line|ctrl + k|
-|Cut backwards to the start of the line|ctrl + u|
-|Cut forwards to the end of the current word|meta + d|
-|Cut backwards to the start of the current word|ctrl + w|
-|Paste last cut section|ctrl + y|
-|Undo last action|ctrl + _|
-|Jump to the previous line|up / ctrl + p|
-|Jump to the next line|down / ctrl + n|
-|Clear compose box|ctrl + l|
+|Cycle through recipient and content boxes|Tab|
+|Send a message|Ctrl + d / Meta + Enter|
+|Save current message as a draft|Meta + s|
+|Autocomplete @mentions, #stream_names, :emoji: and topics|Ctrl + f|
+|Cycle through autocomplete suggestions in reverse|Ctrl + r|
+|Narrow to compose box message recipient|Meta + .|
+|Jump to the beginning of line|Ctrl + a|
+|Jump to the end of line|Ctrl + e|
+|Jump backward one word|Meta + b|
+|Jump forward one word|Meta + f|
+|Delete previous character (to left)|Ctrl + h|
+|Transpose characters|Ctrl + t|
+|Cut forwards to the end of the line|Ctrl + k|
+|Cut backwards to the start of the line|Ctrl + u|
+|Cut forwards to the end of the current word|Meta + d|
+|Cut backwards to the start of the current word|Ctrl + w|
+|Paste last cut section|Ctrl + y|
+|Undo last action|Ctrl + _|
+|Jump to the previous line|Up / Ctrl + p|
+|Jump to the next line|Down / Ctrl + n|
+|Clear compose box|Ctrl + l|
diff --git a/tools/lint-hotkeys b/tools/lint-hotkeys
index 68e9f8cdc2..5ae1363923 100755
--- a/tools/lint-hotkeys
+++ b/tools/lint-hotkeys
@@ -6,7 +6,11 @@ from collections import defaultdict
from pathlib import Path, PurePath
from typing import Dict, List, Tuple
-from zulipterminal.config.keys import HELP_CATEGORIES, KEY_BINDINGS
+from zulipterminal.config.keys import (
+ HELP_CATEGORIES,
+ KEY_BINDINGS,
+ display_keys_for_command,
+)
KEYS_FILE = (
@@ -129,8 +133,10 @@ def read_help_categories() -> Dict[str, List[Tuple[str, List[str]]]]:
Get all help categories from KEYS_FILE
"""
categories = defaultdict(list)
- for item in KEY_BINDINGS.values():
- categories[item["key_category"]].append((item["help_text"], item["keys"]))
+ for cmd, item in KEY_BINDINGS.items():
+ categories[item["key_category"]].append(
+ (item["help_text"], display_keys_for_command(cmd))
+ )
return categories