Skip to content

Improve the handling of editor actions as a help category #1494

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

Merged
merged 4 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 20 additions & 11 deletions docs/hotkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,28 @@
|Autocomplete @mentions, #stream_names, :emoji: and topics|<kbd>Ctrl</kbd> + <kbd>f</kbd>|
Copy link
Collaborator

@neiljp neiljp May 17, 2024

Choose a reason for hiding this comment

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

Thanks for finding these!

I understand what this means, but for future readers of the log, it would be useful to clarify in what way these are missing, in the commit text.

For example, where did you find this information?
Also, are there any you've left out, from that resource? (intentionally?)

Copy link

Choose a reason for hiding this comment

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

It seems this is resolved? 0d1babd now explains that they keys are coming from urwid_readline.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, though in general I would consider including a reference to that resource, if there is one, eg. a reference URL to the code or docs. It provides context for the status during review, and even if that becomes unreachable later, it can give some structure to look in eg. an updated git repo elsewhere.

In terms of the extra keys, like backspace/delete/left/right, let's discuss this as a possible adjustment after this PR. This is a fine first step, and other help refinements can be incremental after that, if they are a priority.

We're also currently missing documenting ctrl b for left, and we don't have the equivalent of right in readline since ctrl f is used for autocomplete. I mentioned a few points to @zormit related to this. It depends how far into readline support (via urwid-readline) we want to go.

|Cycle through autocomplete suggestions in reverse|<kbd>Ctrl</kbd> + <kbd>r</kbd>|
|Narrow to compose box message recipient|<kbd>Meta</kbd> + <kbd>.</kbd>|
|Jump to the beginning of line|<kbd>Ctrl</kbd> + <kbd>a</kbd>|
|Jump to the end of line|<kbd>Ctrl</kbd> + <kbd>e</kbd>|
|Jump backward one word|<kbd>Meta</kbd> + <kbd>b</kbd>|
|Jump forward one word|<kbd>Meta</kbd> + <kbd>f</kbd>|
|Delete previous character (to left)|<kbd>Ctrl</kbd> + <kbd>h</kbd>|
|Transpose characters|<kbd>Ctrl</kbd> + <kbd>t</kbd>|

## Editor: Navigation
|Command|Key Combination|
| :--- | :---: |
|Start of line|<kbd>Ctrl</kbd> + <kbd>a</kbd> / <kbd>Home</kbd>|
|End of line|<kbd>Ctrl</kbd> + <kbd>e</kbd> / <kbd>End</kbd>|
|Start of current or previous word|<kbd>Meta</kbd> + <kbd>b</kbd> / <kbd>Shift</kbd> + <kbd>Left</kbd>|
|Start of next word|<kbd>Meta</kbd> + <kbd>f</kbd> / <kbd>Shift</kbd> + <kbd>Right</kbd>|
|Previous line|<kbd>Up</kbd> / <kbd>Ctrl</kbd> + <kbd>p</kbd>|
|Next line|<kbd>Down</kbd> / <kbd>Ctrl</kbd> + <kbd>n</kbd>|

## Editor: Text Manipulation
|Command|Key Combination|
| :--- | :---: |
|Undo last action|<kbd>Ctrl</kbd> + <kbd>_</kbd>|
|Clear text box|<kbd>Ctrl</kbd> + <kbd>l</kbd>|
|Cut forwards to the end of the line|<kbd>Ctrl</kbd> + <kbd>k</kbd>|
|Cut backwards to the start of the line|<kbd>Ctrl</kbd> + <kbd>u</kbd>|
|Cut forwards to the end of the current word|<kbd>Meta</kbd> + <kbd>d</kbd>|
|Cut backwards to the start of the current word|<kbd>Ctrl</kbd> + <kbd>w</kbd>|
|Cut backwards to the start of the current word|<kbd>Ctrl</kbd> + <kbd>w</kbd> / <kbd>Meta</kbd> + <kbd>Backspace</kbd>|
|Cut the current line|<kbd>Meta</kbd> + <kbd>x</kbd>|
|Paste last cut section|<kbd>Ctrl</kbd> + <kbd>y</kbd>|
|Undo last action|<kbd>Ctrl</kbd> + <kbd>_</kbd>|
|Jump to the previous line|<kbd>Up</kbd> / <kbd>Ctrl</kbd> + <kbd>p</kbd>|
|Jump to the next line|<kbd>Down</kbd> / <kbd>Ctrl</kbd> + <kbd>n</kbd>|
|Clear compose box|<kbd>Ctrl</kbd> + <kbd>l</kbd>|
|Delete previous character|<kbd>Ctrl</kbd> + <kbd>h</kbd>|
|Swap with previous character|<kbd>Ctrl</kbd> + <kbd>t</kbd>|

95 changes: 51 additions & 44 deletions zulipterminal/config/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,79 +321,84 @@ class KeyBinding(TypedDict):
'key_category': 'general',
},
'BEGINNING_OF_LINE': {
'keys': ['ctrl a'],
'help_text': 'Jump to the beginning of line',
'key_category': 'msg_compose',
'keys': ['ctrl a', 'home'],
'help_text': 'Start of line',
'key_category': 'editor_navigation',
},
'END_OF_LINE': {
'keys': ['ctrl e'],
'help_text': 'Jump to the end of line',
'key_category': 'msg_compose',
'keys': ['ctrl e', 'end'],
'help_text': 'End of line',
'key_category': 'editor_navigation',
},
'ONE_WORD_BACKWARD': {
'keys': ['meta b'],
'help_text': 'Jump backward one word',
'key_category': 'msg_compose',
'keys': ['meta b', 'shift left'],
'help_text': 'Start of current or previous word',
'key_category': 'editor_navigation',
},
'ONE_WORD_FORWARD': {
'keys': ['meta f'],
'help_text': 'Jump forward one word',
'key_category': 'msg_compose',
'keys': ['meta f', 'shift right'],
'help_text': 'Start of next word',
'key_category': 'editor_navigation',
},
'DELETE_LAST_CHARACTER': {
'keys': ['ctrl h'],
'help_text': 'Delete previous character (to left)',
'key_category': 'msg_compose',
'PREV_LINE': {
'keys': ['up', 'ctrl p'],
'help_text': 'Previous line',
'key_category': 'editor_navigation',
},
'TRANSPOSE_CHARACTERS': {
'keys': ['ctrl t'],
'help_text': 'Transpose characters',
'key_category': 'msg_compose',
'NEXT_LINE': {
'keys': ['down', 'ctrl n'],
'help_text': 'Next line',
'key_category': 'editor_navigation',
},
'UNDO_LAST_ACTION': {
'keys': ['ctrl _'],
'help_text': 'Undo last action',
'key_category': 'editor_text_manipulation',
},
'CLEAR_MESSAGE': {
'keys': ['ctrl l'],
'help_text': 'Clear text box',
'key_category': 'editor_text_manipulation',
},
'CUT_TO_END_OF_LINE': {
'keys': ['ctrl k'],
'help_text': 'Cut forwards to the end of the line',
'key_category': 'msg_compose',
'key_category': 'editor_text_manipulation',
},
'CUT_TO_START_OF_LINE': {
'keys': ['ctrl u'],
'help_text': 'Cut backwards to the start of the line',
'key_category': 'msg_compose',
'key_category': 'editor_text_manipulation',
},
'CUT_TO_END_OF_WORD': {
'keys': ['meta d'],
'help_text': 'Cut forwards to the end of the current word',
'key_category': 'msg_compose',
'key_category': 'editor_text_manipulation',
},
'CUT_TO_START_OF_WORD': {
'keys': ['ctrl w'],
'keys': ['ctrl w', 'meta backspace'],
'help_text': 'Cut backwards to the start of the current word',
'key_category': 'msg_compose',
'key_category': 'editor_text_manipulation',
},
'CUT_WHOLE_LINE': {
'keys': ['meta x'],
'help_text': 'Cut the current line',
'key_category': 'editor_text_manipulation',
},
'PASTE_LAST_CUT': {
'keys': ['ctrl y'],
'help_text': 'Paste last cut section',
'key_category': 'msg_compose',
},
'UNDO_LAST_ACTION': {
'keys': ['ctrl _'],
'help_text': 'Undo last action',
'key_category': 'msg_compose',
'key_category': 'editor_text_manipulation',
},
'PREV_LINE': {
'keys': ['up', 'ctrl p'],
'help_text': 'Jump to the previous line',
'key_category': 'msg_compose',
},
'NEXT_LINE': {
'keys': ['down', 'ctrl n'],
'help_text': 'Jump to the next line',
'key_category': 'msg_compose',
'DELETE_LAST_CHARACTER': {
'keys': ['ctrl h'],
'help_text': 'Delete previous character',
'key_category': 'editor_text_manipulation',
},
'CLEAR_MESSAGE': {
'keys': ['ctrl l'],
'help_text': 'Clear compose box',
'key_category': 'msg_compose',
'TRANSPOSE_CHARACTERS': {
'keys': ['ctrl t'],
'help_text': 'Swap with previous character',
'key_category': 'editor_text_manipulation',
},
'FULL_RENDERED_MESSAGE': {
'keys': ['f'],
Expand All @@ -415,6 +420,8 @@ class KeyBinding(TypedDict):
"msg_actions": "Message actions",
"stream_list": "Stream list actions",
"msg_compose": "Composing a Message",
"editor_navigation": "Editor: Navigation",
"editor_text_manipulation": "Editor: Text Manipulation",
}

ZT_TO_URWID_CMD_MAPPING = {
Expand Down
Loading