-
Notifications
You must be signed in to change notification settings - Fork 6
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
Helpbar improvements (configurable hints and key sorting) #56
Comments
I like that! It's like a customizable cheat-sheet for pter, but inside pter. |
Speaking of cheat sheets, perhaps it'd be helpful to add a CLI param to dump the Help screen to stdout (only without the section titles). Something like what With tmux, I feed its output to A possible format (fields separated by tabs, spaces are just for readability here):
|
Works great, except we need to strip the trailing In terms of columns/sections/etc, I think the output format is perfect for now. Let me play with it for a while and get back to you if I have any improvement ideas! |
With a bit of scripting, I now have a rofi-based cheat sheet for pter, awesome! https://i.imgur.com/cW1wG0b.png |
Have a look at this commit; does this solve the problem with the trailing newline? |
Tested, problem solved, thank you! |
@vonshednob The external cheat sheet works well, but I think it would still be useful to implement 1) and 2) from the original comment. Or at least implement 1) (configurable Helpbar). It's still faster to quickly glance at your Helpbar as opposed to switching contexts to an external cheat sheet. I think these features complement rather than replace each other. What do you say? P.S. It's by no means a blocker, so I'm all for removing the 3.16 milestone tag but keeping this issue open for the future. |
Dang, no you’re right! I missed that these two had been part of this issue! I want these to be in 3.16. |
Showing user-defined keybindings first was easier than expected. |
The new code grabs the first custom keybinding from user config, perfect! But can pter filter out default keybindings ONLY if they are not set in the user config? That way, if a user needs a hint for a default keybinding, they can set it explicitly before other user-defined ones in the configuration file. |
Hm, I’d rather not have all keybindings vanish just because a user has modified one keybinding. Most users will not do any changes in the configuration except the one thing that really bugs them. Maybe a configuration option to only show custom keybindings in the help bar? 🤔 |
So if I set something like (A) + (B) would be ideal, but even (A) alone would be great. My use case is probably not the commonest one, so I don't mind defining all the keybindings explicitly if needed. (I'm assuming the Helpbar would still use the first user-defined keybinding, as in the current git HEAD.) |
Let’s pin examples to this, because it becomes a bit tricky 😅 Let’s take the two actions Right now if a user sets a new keybinding, e.g. If The real tricky problem (and I do not see how I could solve that easily) is what happens if the user writes in their configuration file |
Examples are helpful. yes! So let me back up and explain one of my use cases properly. I don't think I've done that well. I write todos and notes in several languages, e.g. in English and German. Here's a sample German keyboard layout: Note for example the Here comes the important part: For productivity, it's critical to be able to use a single-key binding and not think of the keyboard layout! Pter has amazing keyboard support, so it lets me create multiple sets of keybindings:
So far so good. I can hit the same physical key and call the right action regardless of layout. Now, which key hint should be shown in the Helpbar? To my mind, pter should always prefer a custom keybinding over the default one. If a user sets a keybinding, they must prefer it! In addition (and this is the tricky part you referred to earlier), the user-set keybinding should be shown even if it matches the default one. In my example above, German is a secondary language and I don't always remember where So to summarize, the behavior I would call ideal is this:
Currently, pter mostly works as expected, but because of item number 3 I'm getting
I think I may have misunderstood this idea originally. Right now I don't see the need for this option, but if a separate config option would help get the "arguably ideal behavior" above, I'm all for it! |
For the record, I'm attaching the quick and dirty patch I'm using that seems to get the job done. It only deals with task list keybindings for now, though. |
I could have sworn On topic though I’m afraid to keep track of which user-defined key binding is the first (and for that matter whether a keybinding is user-defined, even if it is the same as the default) is not easily fixable without breaking corner cases (mainly because the keybindings are a dictionary, so bindings are there or they are not…). Or, well, like you did, with lots of duplication of information. I’m not sure how to solve this cleanly yet. 🤔 Gotta give it a bit more time to mull it over. If I can’t come up with a good solution until tomorrow, I’ll just take your fix 🤷 |
Yeah, I thought about changing the data structure for the bindings, but the change seemed too invasive and frankly I don't know the codebase well enough not to introduce new bugs... Also perhaps pter needs a unit test for the keybindings feature as it's become more complex. |
I had the same idea about the changed data structure for keybindings, but it feels a bit like confusing the purposes too much. The unit tests for the keybindings is a good idea; just really tricky with them being so tightly integrated into the user interface. Some refactoring would do the code a lot of good, but who has the time? |
In terms of refactoring, do you prefer any kind of code style? Maybe introducing the black linter would be a baby step in the right direction that wouldn't take a lot of time. With black, all code from all PRs/contributions would always be formatted the same. I don't have a meaningful Python IDE configured right now (working on it) but I remember using black in the past and it helped refactoring and collaboration. |
Yeah, I totally use an IDE and not just two terminals in a trenchcoat 😅 No idea what black is, but I mostly just try to follow the usual PIP style and try to keep the lines shorter than 120 character 🤷 . |
Black is opinionated, but I did like it: https://github.com/psf/black
Good for you, I'm using |
|
First off, I think the initial Helpbar is great and it shows the right kind of information to help newcomers learn the most important actions/commands/keybindings.
But as you keep working with pter and start using other features and/or adjusting keybindings to fit your workflow, you want a different set of hints to be visible. For me, this is for two reasons:
?
is help andq
is for quitting, but I need a reminder thatF12
is for opening todo.txt in external editor)Here's what I'm proposing:
Include
directive).F4
to act ase
-- to edit a task. And I want both the bindings to work. Currently, the Helpbar will only show me thee
-binding (which is the default and which I already know), as it seems to sort in alphabetical order. It would be great if, say, config file order was preserved. Or maybe the Helpbar could always show the custom keybindings first.The text was updated successfully, but these errors were encountered: