-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
Break down the generalized ENTER command #1497
Conversation
The intention behind the refactoring is clear. The code looks good to me. |
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.
Looks good to me. I think it achieves the goal of preparing for better contextual help.
A downside of restructuring it like this, is that the code now could accidentally get stale as no one is stopped from using for example ACTIVATE_BUTTON
when actually in a context where EXECUTE_SEARCH
would be the "correct Enter" variant. A follow-up change could be to not have a single KEY_BINDINGS
, but one per category/context. But that's not meant as a request, just a thought that came up. Or add the category in the keys_for_command
calls.
Regarding your outstanding items:
Need to consider the placement of the new commands within their categories in the Help Menu.
How would you imagine the placement? Is it related to any of the other open PRs?
Ctrl+M can work as Enter too. This has not yet been addressed.
How did you mean to address this? The fact that ^M works "as Enter" (or rather CR) has to do with ASCII control characters. My understanding is that it's determined on a system or maybe terminal emulator level. My opinion is that, as an application, we should not worry about this. It might even be impossible to tell the difference at this level. As for documenting this, I wouldn't do that either for similar reasons (it's nothing people usually need, and if people know about this, it's rather more widely applicable than just zulip-terminal)
Thank you for addressing the outstanding items @zormit
It's something that Neil suggested in the feedback of #1494. That we could re-order these help entries in the help menu, based on their significance / frequency of use, which is fairly subjective.
I didn't get till there. Just mentioning that it exists, for the sake of completeness.
Great then.
Ah, great point, thank you for the suggestions! |
80ea619
to
f84e1ca
Compare
Linting and tests are passing on my fork here. |
f84e1ca
to
64f5c89
Compare
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.
@Niloth-p It'll be useful to have these split 👍
I left a few points inline. From a code perspective this is fairly straightforward, though the ordering/category looks a bit strange.
@zormit, you wrote:
A downside of restructuring it like this, is that the code now could accidentally get stale as no one is stopped from using for example ACTIVATE_BUTTON when actually in a context where EXECUTE_SEARCH would be the "correct Enter" variant. A follow-up change could be to not have a single KEY_BINDINGS, but one per category/context. But that's not meant as a request, just a thought that came up. Or add the category in the keys_for_command calls.
I'm not sure I follow this; do you mean where enter
ends up being present for multiple actions, it could be unclear what should occur if two are present on the same UI object by mistake, or something like that?
zulipterminal/config/keys.py
Outdated
'ACTIVATE_BUTTON': { | ||
'keys': ['enter'], | ||
'help_text': 'Trigger the selected entry', | ||
'key_category': 'general', | ||
}, |
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.
Priority: In the online help and the generated document, this is now at the top of the General section, and help overall, which seems a bit more dominant than I would expect!
Category: This is a very 'general' key, but perhaps really belongs in the same kind of category as the top part of those in 'Navigation', ie. moving around in the UI? That supports splitting that existing section, which I think was discussed already, so we could have eg. 'UI Navigation', or something simpler.
Keys: There's a small section at the end of keys.py
which syncs our keys back to urwid (check the git blame/PR). It would be useful to follow up on this commit with a commit/PR which emphasizes that other keys can also activate an item/button/..., which has come up in discussions in the channel previously. For example, space
works on buttons, at least as it stands, and possibly others.
=> Maybe:
- Split out 'UI Navigation' category first? (or move this addition into Navigation?)
- Apply this
- Investigate correcting our help to match the urwid defaults, or adjust the urwid keys themselves
In the longer term it would be useful to make this even more specific, since 'trigger' or 'activate' is very general, and it's not obvious just reading this one entry that it is overridden by the other uses of enter
, ie. those we're splitting out here, as well as for replying to a message :)
Another aspect of that is my note in the discussion that we don't document the behavior of enter
in the user list to reply/compose to a user. That's distinct from this split, and likely depends on a user-list/panel category.
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.
Re. UI Navigation category,
I can't particularly recall discussing "UI Navigation".
Do you mean moving the narrowing commands in #1516?
We haven't used the term "UI Navigation" there yet, just extracting the narrowing commands from it. I'll update the category name.
I think we could do them independently, and in any order? As it would make sense to have ACTIVATE_BUTTON in navigation category even before it's split.
Please let me know if you have more in mind, as I don't think we've discussed this before.
space works on buttons
I totally missed that one.
Thank you for that clear guidance. That really helped.
I've added the space key, updated the display function.
I have tied it to the Urwid mapping even though we do not add any new hotkeys at the moment, for consistency and safety.
document the behavior of enter in the user list to reply/compose to a user. That's distinct from this split, and likely depends on a user-list/panel category.
Yes, I've added that as part of this commit in #1515.
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.
I'm not sure 'UI Navigation' is the best term, but essentially referring to the simple UI movement/trigger commands that are left behind after indeed #1516.
So the main aspect until #1516 is really where we place ACTIVATE_BUTTON
for now, which you addressed in the commit to be squashed.
My last point was upon rereading some discussion text, so good to see it in another PR.
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.
@neiljp Thank you for the detailed review and the great explanations!
I hope I've addressed all your suggestions with this update.
I'm not sure I follow this; do you mean where enter ends up being present for multiple actions, it could be unclear what should occur if two are present on the same UI object by mistake, or something like that?
This is my understanding of what @zormit meant,
If we add a new button, and support keypress for it, then the code there can use is_command_key("EXECUTE_SEARCH")
instead of is_command_key("ACTIVATE_BUTTON")
, and achieve the same functionality.
As in the developer could add a mismatched command that may still work because both of them map to Enter. But, this error would create wrong contextual hints.
@@ -1968,6 +1968,7 @@ def test_footlinks_limit(self, maximum_footlinks, expected_instance): | |||
def test_mouse_event_left_click( | |||
self, mocker, msg_box, key, widget_size, compose_box_is_open | |||
): | |||
expected_keypress = primary_key_for_command("ACTIVATE_BUTTON") |
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.
zulipterminal/config/keys.py
Outdated
'ACTIVATE_BUTTON': { | ||
'keys': ['enter'], | ||
'help_text': 'Trigger the selected entry', | ||
'key_category': 'general', | ||
}, |
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.
Re. UI Navigation category,
I can't particularly recall discussing "UI Navigation".
Do you mean moving the narrowing commands in #1516?
We haven't used the term "UI Navigation" there yet, just extracting the narrowing commands from it. I'll update the category name.
I think we could do them independently, and in any order? As it would make sense to have ACTIVATE_BUTTON in navigation category even before it's split.
Please let me know if you have more in mind, as I don't think we've discussed this before.
space works on buttons
I totally missed that one.
Thank you for that clear guidance. That really helped.
I've added the space key, updated the display function.
I have tied it to the Urwid mapping even though we do not add any new hotkeys at the moment, for consistency and safety.
document the behavior of enter in the user list to reply/compose to a user. That's distinct from this split, and likely depends on a user-list/panel category.
Yes, I've added that as part of this commit in #1515.
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.
@Niloth-p It looks like most of my points were accounted for already, while you were updating :)
Re the point about potentially incorrect use of Commands that are essentially equivalent in terms of keys, I agree this is a possible challenge. However, the aim is to maintain semantic naming, a little like we do with theme styles which may have the same content but are still named differently. We can examine this again when the contextual part becomes finalized.
zulipterminal/config/keys.py
Outdated
'ACTIVATE_BUTTON': { | ||
'keys': ['enter'], | ||
'help_text': 'Trigger the selected entry', | ||
'key_category': 'general', | ||
}, |
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.
I'm not sure 'UI Navigation' is the best term, but essentially referring to the simple UI movement/trigger commands that are left behind after indeed #1516.
So the main aspect until #1516 is really where we place ACTIVATE_BUTTON
for now, which you addressed in the commit to be squashed.
My last point was upon rereading some discussion text, so good to see it in another PR.
@@ -442,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 comment
The 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.
00da8d4
to
f441bac
Compare
Squashed the commits. |
docs/hotkeys.md
Outdated
@@ -24,7 +24,7 @@ | |||
|Scroll up|<kbd>PgUp</kbd> / <kbd>K</kbd>| | |||
|Scroll down|<kbd>PgDn</kbd> / <kbd>J</kbd>| | |||
|Go to bottom / Last message|<kbd>End</kbd> / <kbd>G</kbd>| | |||
|Trigger the selected entry|<kbd>Enter</kbd>| | |||
|Trigger the selected entry|<kbd>Enter</kbd> / | |
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.
It looks like we need a special case to handle the documented keys here?
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.
Oops with the squashing. Guess I didn't check the diff, my apologies.
zulipterminal/config/keys.py
Outdated
@@ -244,16 +249,16 @@ class KeyBinding(TypedDict): | |||
'excluded_from_random_tips': True, | |||
'key_category': 'searching', | |||
}, | |||
'EXECUTE_SEARCH': { | |||
'keys': ['enter'], | |||
'help_text': 'Execute the search and go to search results', |
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.
Nit: We can address this on merging, but 'execute' is likely not the best user-facing language.
Perhaps "Submit search and browse results"?
I don't have the web app to compare to right now (as we discussed in the call).
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.
I checked the list here. They don't seem to use an equivalent for the search op. But, I did find an equivalent for ACTIVATE_BUTTON - "Use Enter to engage with elements".
I have updated the EXECUTE_SEARCH description to match your suggestion, and left the ACTIVATE_BUTTON as-is.
@Niloth-p To clarify, this looks good to go except for space-handling in the hotkeys doc translation, so that looks like it'll need to be addressed if we're going to include that in this PR. |
Breaks down the ENTER command into more specific commands. - ACTIVATE_BUTTON - EXECUTE_SEARCH - NEW_LINE Tests and docs updated.
For consistency with Urwid's ACTIVATE command. Urwid's command map is updated to link Urwid's ACTIVATE with our ACTIVATE_BUTTON command. Although they currently use the same keys, they are synced to ensure future compatibility. Hotkeys document regenerated. Tests updated.
f441bac
to
f423e94
Compare
@Niloth-p Thanks for the adjustment - good to know it was the simple change you had previously that already fixed this and was just dropped by mistake 👍 Merging now 🎉 |
What does this PR do, and why?
Breaks down the broader ENTER command into more specific commands.
This would enable using more specific help texts, categories and context.
And clarifies the purposes of the key better.
Updated the usage of each command in the UI tools.
Tests and docs updated.
The NEW_LINE command would also allow us to create a new user setting, where
ENTER
key andMeta
+Enter
can be switched between entering new lines and sending messages.Outstanding aspect(s)
Ctrl
+M
can work asEnter
too. This has not yet been addressed.External discussion & connections
re-categorize
How did you test this?
Self-review checklist for each commit