-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Add title-to-title scroll feature to Help Menu #1527
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1261,6 +1261,33 @@ def __init__(self, controller: Any, title: str) -> None: | |
|
||
super().__init__(controller, widgets, "HELP", popup_width, title) | ||
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. It's mainly independent of this PR, but it seems a bit strange to me to have a It seems that the general pattern is to have the super init at the end. But now that the setup code for Nevertheless I'd be curious if that's also something we can prevent, maybe by putting the responsibility for the category positions to the parent or something. |
||
|
||
self.category_start_positions = [ | ||
index | ||
for index, widget in enumerate(self.log) | ||
if isinstance(widget, urwid.Text) | ||
and widget.get_text()[1] | ||
and widget.get_text()[1][0][0] == "popup_category" | ||
] | ||
|
||
def keypress(self, size: urwid_Size, key: str) -> str: | ||
if is_command_key("GO_TO_NEXT_TITLE", key): | ||
focus_position = self.log.get_focus()[1] | ||
last_visible_position = focus_position + size[1] - 1 # type: ignore[misc] | ||
last_help_entry = len(self.log) - 1 | ||
if last_help_entry > last_visible_position: | ||
for category_start_position in self.category_start_positions: | ||
if category_start_position > focus_position: | ||
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. My LSP (I think) shows me a type error here. I think this file is not typed, so the CI passes on github. The error is:
Which might be caused by the previous 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. For reference, I think this was caused by using a later version of Urwid here. |
||
self.log.set_focus(category_start_position) | ||
break | ||
|
||
elif is_command_key("GO_TO_PREVIOUS_TITLE", key): | ||
focus_position = self.log.get_focus()[1] | ||
for category_start_position in reversed(self.category_start_positions): | ||
if category_start_position < focus_position: | ||
self.log.set_focus(category_start_position) | ||
break | ||
return super().keypress(size, key) | ||
|
||
|
||
class MarkdownHelpView(PopUpView): | ||
def __init__(self, controller: Any, title: str) -> None: | ||
|
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 whether
navigation
is a good category for this, but I don't see a better one either. The problem I see is that the two new commands are very specific to the "Help" popup while the other ones seem to be more generic. In that sense the new commands seem to be a bit similar to "Show/hide user information (from user list)": It could also be "Go to previous category (in Help Menu)" or something like that.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 am also wondering whether it's useful to put hints towards those keys in the headline of the popup. It probably will get a bit crowded there.
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.
For future reference, see the linked topic for some discussion. The keys aren't critical here, but my thoughts would be to use ones that
n
&p
; so don't need to remember context)Some options I raised were perhaps
tab/shift-tab
(depending on usage of that elsewhere), and various matching parentheses such as(
/)
, or]
, or}
.