-
-
Notifications
You must be signed in to change notification settings - Fork 275
Break down the generalized ENTER command #1497
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
from typing_extensions import NotRequired, TypedDict | ||
from urwid.command_map import ( | ||
ACTIVATE, | ||
CURSOR_DOWN, | ||
CURSOR_LEFT, | ||
CURSOR_MAX_RIGHT, | ||
|
@@ -91,6 +92,11 @@ class KeyBinding(TypedDict): | |
'help_text': 'Go to bottom / Last message', | ||
'key_category': 'navigation', | ||
}, | ||
'ACTIVATE_BUTTON': { | ||
'keys': ['enter', ' '], | ||
neiljp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'help_text': 'Trigger the selected entry', | ||
'key_category': 'navigation', | ||
}, | ||
'REPLY_MESSAGE': { | ||
'keys': ['r', 'enter'], | ||
'help_text': 'Reply to the current message', | ||
|
@@ -244,16 +250,16 @@ class KeyBinding(TypedDict): | |
'excluded_from_random_tips': True, | ||
'key_category': 'searching', | ||
}, | ||
'EXECUTE_SEARCH': { | ||
'keys': ['enter'], | ||
'help_text': 'Submit search and browse results', | ||
'key_category': 'searching', | ||
}, | ||
'TOGGLE_MUTE_STREAM': { | ||
'keys': ['m'], | ||
'help_text': 'Mute/unmute streams', | ||
'key_category': 'stream_list', | ||
}, | ||
'ENTER': { | ||
'keys': ['enter'], | ||
'help_text': 'Perform current action', | ||
'key_category': 'navigation', | ||
}, | ||
'THUMBS_UP': { | ||
'keys': ['+'], | ||
'help_text': 'Toggle thumbs-up reaction to the current message', | ||
|
@@ -400,6 +406,14 @@ class KeyBinding(TypedDict): | |
'help_text': 'Swap with previous character', | ||
'key_category': 'editor_text_manipulation', | ||
}, | ||
'NEW_LINE': { | ||
# urwid_readline's command | ||
# This obvious hotkey is added to clarify against 'enter' to send | ||
# and to differentiate from other hotkeys using 'enter'. | ||
'keys': ['enter'], | ||
'help_text': 'Insert new line', | ||
'key_category': 'msg_compose', | ||
}, | ||
'FULL_RENDERED_MESSAGE': { | ||
'keys': ['f'], | ||
'help_text': 'Show/hide full rendered message (from message information)', | ||
|
@@ -432,6 +446,7 @@ class KeyBinding(TypedDict): | |
"SCROLL_UP": CURSOR_PAGE_UP, | ||
"SCROLL_DOWN": CURSOR_PAGE_DOWN, | ||
"GO_TO_BOTTOM": CURSOR_MAX_RIGHT, | ||
"ACTIVATE_BUTTON": ACTIVATE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is strictly necessary, since the urwid default map has the values we're setting already, but it's fine to include and a good pointer that we may need to return to it in future. |
||
} | ||
|
||
|
||
|
@@ -477,6 +492,9 @@ def display_key_for_urwid_key(urwid_key: str) -> str: | |
""" | ||
Returns a displayable user-centric format of the urwid key. | ||
""" | ||
if urwid_key == " ": | ||
neiljp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return "Space" | ||
|
||
for urwid_map_key, display_map_key in URWID_KEY_TO_DISPLAY_KEY_MAPPING.items(): | ||
if urwid_map_key in urwid_key: | ||
urwid_key = urwid_key.replace(urwid_map_key, display_map_key) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to edit this test as mouse_event always calls the
primary_key_for_command("ACTIVATE_BUTTON")
and does not use the passed key.