Closed Leandros closed 4 years ago
Unfortunately, not right now, no.
Currently it just bubbles the key event up the widget stack until either a widget matches/handles it, or it ends up with a message that the key is not bound. It's completely static and can't be changed without editing the source. In that sense it's like dwm, I guess.
I'm going to change this, but I'm not yet sure of the best way. I'm thinking about giving widgets hash tables with closures, or an enum, or a struct, or something like that.
Not sure how exactly, but key bindings will become configurable in the future.
Alright, cool. I'll keep an eye on this.
Not sure how exactly, but key bindings will become configurable in the future.
:+1: That would be great because I'm used to search with a /
( as a vim user) and in hunter I'm confused again and again with the keybinding :-\
Yeah this is very clunky right now... As a workaround you could create your own branch with the bindings you like and merge master into that when it changes. That's what I do with the vi-style bindings right now.
Actually, you don't even need a branch, just check out the hunter repo, do your changes, run git commit and merge in new updates with git pull.
I have changed the default movement key bindings to vi-style, and put the emacs-style bindings into the holy branch. This should be an improvement for most people, especially when they install it using cargo.
Making keys configurable is a bit more work, but it's coming.
I learning rust at the moment. Couldn't you just read the keybindings from a yaml config file at startup?
Yeah, but the real question is how to connect a character read from the keyboard to executing the right function. I recently got the idea to store all bindings in a hash table that maps keys to an enum variant (like Binding::MoveDown, or something) with all possible bindings. Then it's just a matter of changing all the hard coded match clauses from raw keys to use that enum.
It's not done yet, because it's not really high on my TODO list, since for me at least all bindings are custom anyway and I think the other stuff is more important. I'm running out of things to do though, so it's going to happen eventually.
thank you for your reply. As I mentioned, I am learning rust. I was planning to write a terminal file browser once I finished the podcatcher I am working on now. I plan to read through your code when I have time. if you have any low level stuff you need done, I am glad to help.
Latest commit adds custom key bindings. It's pretty flexible in that it supports "dynamic" key binds, where you can map GotoTab(n) to any F key, so that it automatically switches to the right tab when you press F. I also added some more bindings by default and changed some like "S" -> Ctrl(s).
Forgot to add this to the README, but it can also parse A-
If there are bugs or missing stuff let me know.
Is it possible to change the keybindings? Or would I have to change the source for that?