Skip to content
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

Help menu #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Help menu #82

wants to merge 1 commit into from

Conversation

blargg
Copy link

@blargg blargg commented Mar 5, 2020

Initial commit, for review and comment. This adds a new key binding ('H' by default) for a help menu.
Pressing the key generates a list of the program's current key bindings and pipes it into the pager program ($PAGER or defaults to "less").

I think we can also add information like the current program version and a description of the program to this menu, but wanted feedback on the implementation and direction first.

@blargg blargg mentioned this pull request Mar 5, 2020
@rabite0
Copy link
Owner

rabite0 commented May 21, 2020

Sorry for the late reply, I quite like it and this has been a long requested feature. Using $PAGER for makes a lot of sense since the text widget is so bare bones... It's a good idea actually.

If you're still interested in working on this it would be great if you could add the default binding to the keys config file stored in config.tar.gz, too. It's easy to miss, but the default bindings in keybind.rs are completely ignored when hunter finds a ~/.config/hunter/keys instead of being merged with them. Not sure what I was thinking to be honest, but oh well.

I think we can also add information like the current program version and a description of the program to this menu

Maybe a link to the github repo and to the irc channel, too. Other than that I'd be happy to merge your changes as is.

EDIT: I'm currently improving the text widget (or rather just hooking up the key bindings), so maybe you could use that instead of relying on $PAGER? it still lacks a search feature, but on the other hand it would allow for some fomatting/coloring by just feeding it a string with the right ANSI escape codes. I think less handles this correctly with the right flags, but not all pagers do and I'm not sure how portable it is.

To get it to work you'd need to:

  1. Create a TextView. You can take the WidgetCore from FileBrowser to get the correct dimensions.
  2. Feed it the text with .set_text() or .set_lines().
  3. Call .popup() to make it run in the foreground.

For the actual color codes you can just use the stuff in term.rs. I'm not sure it's actually worth it, I'm just fond of colors personally ;).

@blargg
Copy link
Author

blargg commented May 22, 2020

I should be able to at least add the help text and the keys to keybinding updates.

Time permitting, I'll look into using the actual text widget. Otherwise, I might leave that as a future improvement.

@rabite0
Copy link
Owner

rabite0 commented May 24, 2020

No worries. Thanks for your work!

@blargg
Copy link
Author

blargg commented May 31, 2020

I updated the help text and add the keys to the config.
It still uses pager. Is there a way to go from the file manager widget to the text view widget and then go back? I couldn't find a clean way to do this.

@rabite0
Copy link
Owner

rabite0 commented Jun 1, 2020

Ohh... right, totally forgot about that. No, there isn't, at least not directly. The kind of bindings and such are completely static at the moment, so there's no way to make one particular widget instance behave differently from any other, or have more types of actions it can handle, other than creating a whole new type.

So to actually do that you'd have to create a "HelpView" that contains the TextView and just passes on all the calls refresh(), get_drawlist() and some other methods from the Widget trait. Then this HelpView would watch for the binding that closes it (conventionally the same key that opened it). That requires implementing the Acting trait which defines the actions and where to look for the bindings. A good example would be the at the end in file_browser.rs. It just calls the appropriate methods on self.columns one way or another and in on_key() it tries to handle the key or passes it on until it's handled by a child widget (or not).

I can understand if you don't feel like doing it, I'd be happy to merge your changes as is, too.

@blargg
Copy link
Author

blargg commented Jun 7, 2020

Let's merge the changes as they currently are. It's mostly lack of time right now.

Thank you for your help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants