-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Come up with good story for custom (non-xterm) keybindings support #487
Comments
This could be a How does that sound? |
Something like that is what I was thinking, however it gets tricky in the case like |
This is also the reason we can't use an |
I've been thinking a lot about this recently, here is my idea (considering the many issues open on hyper related on this topic): The main problem is, that accelerators of the app (e.g. hyper) collide with accelerators that the app running in the terminal wants to consume. To get around this problem, most apps introduce a meta key that helps to escape from the terminal. While this works in most cases, it is uncomfortable to use, because you need three fingers. So why don't we... Use a keyboard gesture to escape the terminal Example: There are some edge cases that we have to consider: In addition, for the very commonly used Pasting can be done with |
@mofux for VS Code I introduced a My personal thinking is this is more about having xterm.js handle the common keybindings that are not standard but generally desirable, but allowing consumers to opt out and/or handle it themselves. |
Oh i see, having a map of actions (e.g. 'JUMP_WORD_LEFT') and a default but customisable keybinding for it would certainly make sense. Might be worth to have a mapping that looks like this: {
"COPY": { "mac": "cmd+c", "win": "ctrl+c", "default": "ctrl+c" },
"JUMP_WORD_LEFT": { "default": "alt+left" }
}
Hyper uses a lib called |
Yeah something like that, I think this is the sort of information we need to encode:
Pressing alt+delete will send |
Which is similar to the format of an |
So, should we settle in an option named Would the following format also work? {
"all": {
"ctrl+space": "\x00"
},
"mac": {
"alt+delete": "\x17"
},
"win": {
"ctrl-v": null
}
} |
Looks good, shall we construct the default {
"all": {
"alt+left": "\x1b[1;5D",
"alt+right": "\x1b[1;5C",
"alt+up": "\x1b[1;5A",
"alt+down": "\x1b[1;5B",
"ctrl+backspace": "\x17"
},
"mac": {
"alt+left": "\x1bb", // Mac use different escape sequences to Linux for jumping word
"alt+right": "\x1bf",
"alt+delete": "\x17"
}
} Writing this up there is the ctrl/shift+insert case which skips the terminal, should consumers now handle that if they want it via |
OK, I created this Git as my take on https://gist.github.com/parisk/f2d7eb8bd5584d9969c2449eee9d052c The two questions I have in mind right now are:
|
We could have a KeyMap.ts/Options.ts which exported the default one so it's nicely separated. I think sending strings is the best option. Apps built on top could be clever if they want to add aliases but including it here may be overkill for this project and cause bloat that not many use? |
From @LeviticusMB in microsoft/vscode#11314 (comment)
|
@Tyriar does Gnome3 have any particular bindings worth sharing, besides the ones listed in the comment above? |
Not that I'm aware of |
From @peabnuts123 in microsoft/vscode#11314 (comment)
|
The more I've thought about this the more I think it should be handled at a higher level than xterm.js. Most embedders have some keybinding system that is far more featureful than what xterm.js would be able to offer (Hyper and VS Code for example), especially if we were trying to minimize bloat. As such I suggest we close this off and instruct embedders to handle this themselves, perhaps setting up a FAQ on the website too? |
Hi @Tyriar -- could you please advice what changes are necessary for Mac OSX users to be able to just Here is the corresponding bug on Hyper: vercel/hyper#2578. Any recommendations or hints on what config to change would be much appreciated. |
@saamalik the "alt as meta feature" on macOS needs support added to xterm.js, then Hyper would get it when they upgrade. It will involve hooking up a new option here: Line 66 in d33c340
Line 130 in d33c340
And then using the option where the escape sequences are built from keystrokes: Line 1404 in d33c340
|
@Tyriar added. Let me know if you'd like me to make any changes! Also not sure if we're supposed to checkin package-lock? |
@Tyriar ok removed package-lock.json. |
Closing this as out of scope. Embedders will generally have their own keybindings system which would be better that the small one we would want to do for this, it would be better to leave this up to them rather than include another one that just adds bloat. |
Also is there a simple way to update the key mappings? Like we generally do in Xdefaults, a single json file which can take in configs and override them with default will be good. |
@krishnautpala we decided on letting you the user of xterm.js come up with your own system for handling keybindings since most terminals/ides would have their own system anyway. If you need to override the F keys, use this API to handle the keys manually and cancel them before they get to xterm.js by returning false in the handler: Lines 726 to 735 in 3504e2e
|
We currently support things like alt+arrow to jump words which is done by overriding what escape sequence we send to the pty. We should look at making this configurable with safe defaults so that consumer(s) can turn it off/configure if they desire.
The text was updated successfully, but these errors were encountered: