-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Flexible keymap (hotkeys / shortcut) #872
Comments
i want to discuss this approach before i will start implementation, so any feedback is welcomed: ideas, questions, concerns, problems, etc |
@leo @codetheory @ekmartin @rauchg what do you think? |
I'm not sure if it's a good idea to bind keybindings to rpc directly. Far from all combinations have an rpc event connected to them at the moment, so not sure if that's a good direction to go. Why not have a separate keymap file that maps a string key to a combination? I.e. Example would be: |
maybe its not a good idea, but rpc as a central piece of code for key bindings — is the best point i could think of. To be honest, in the end it can be not a rpc, but any central broadcast communication api. It just happens, that rpc is what we have now.
We can add them later, once proposed changes will be in place, it should be easy.
main reason against two files over one, is simplicity: harder to show/sync your settings with two configuration files You may think that configuration file with a whole keymap will be too hard to read, though to cure this problem we need to think careful about sane default keymap.
Exactly! I'm all for that as i mentioned in proposal. Need to note, that
Yep!
Kinda, as far as pairs are revered you have to do smth like this: Object.keys(this.config.keymap).map(accelerator => {
const event = this.config.keys[key];
keys.bind(
mousetrapify(accelerator),
() => { rpc.emit(event); } // kinda
);
}) |
tldr:
|
I'll argue for an approach to keybindings that guarantees sensible rebinding and/or unbinding. A concrete example: When using iTerm2, I rebind the ⌘1 through ⌘9 keys globally (across all profiles). Instead of their normal function of switching the first nine iTerm2 tabs, they instead are bound to emit Another frustration of some keybinding systems (vim, I'm lookin' at you) is that not all bindings are first-class and/or introspectable. I.e. there's no command or API that can ask such questions as:
These operations aid both config debugging and discoverability. |
@jwhitley After and if proposed change will land in master. All keybindings will be declared in one |
bad news everyone, Hyper has two rpc, one for Electron and one for Renderer processes, and you cant share them. problem here is that key bindings in |
on the other note, there is another way |
This PR #925 is another approach, i was talking about |
@iamstarkov I switched the label |
Plz add request inside issue: ppot#11 |
Referring to the label "In progress", is this issue actively being worked on? All i could find was @iamstarkov closed PR. |
and yes it is in progress |
here #1509 |
close in #1876 |
the important key to achieve it in flexible and reliable way is to have two things:
rpc.emit
11 Note:
rpc
bus should be the only way to broadcast key events).Initial array of events can be collected from
lib/index.js#L38-L129
: likesplit request vertical
orsplit request horizontal
, etc.Then in config we can do smth like this:
where keys are electron accelerators and values are those events for rpc to emit/receive.
After that, we need to modify
attachKeyListeners()
lib/containers/hyper.js#L38-L76 to not bind hardcoded keys, but instead to pick up keys and events from keymap:Also, Hyper needs to verify that this.config is merged object similar to
Object.assign({}, defaultConfig, ...[pluginsAndThemesConfigs], userConfig)
Thats it.
One interesting benefit of proposed approach is that you can update menu accelerators very easy and smooth. just needs to write a function which will lookup desired accelerator by key event relevant to that menu item. 2, 3
Result
what do you think?
The text was updated successfully, but these errors were encountered: