-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Can't bind Ctrl-Tab to anything #2868
Comments
|
Thanks, is Ctrl-Tab not passed through by the terminal? I noticed that it just does the "Tab" action, so does the program only see the Tab key? Also I noticed another issue, when using "IndetnLine", it only works if the cursor is at the start of a line. Is this intended? Normally indent line would just add a tab at the start of the line, regardless of where the cursor is, but if the cursor is in the middle of the line it just inserts a tab there (correction, OutdentLine works, IndentLine does not, see edit below) Edit: Just looked at the code in Edit2: Previously I was mapping IndentLine to Edit3: If I change this:
in bindings.go to this:
Then pressing ctrl-j will work, so it seems like the issue is that ctrl-i is not actually getting sent to the program. Pressing Ctrl-I after this change still does the inserting-a-tab thing, and I noticed in my terminal if I press ctrl-i it autocompletes, just like tab does. Is Ctrl-I just a reserved shortcut maybe? I've testing this in Xfce4-Terminal, Alacritty, Suckless Terminal (st) and Kitty, all show the same behaviour. I don't think it has anything to do with IndentLine, as if I map Ctrl-i to DeleteLine, it also doesn't work, and still inserts a tab at the cursor. I think micro uses tcell v2 for handling keyboard inputs, and using this tcell demo program: https://github.com/gdamore/tcell/blob/main/_demos/mouse.go And pressing various Ctrl+Key combinations, they all show up correctly except 4:
I'm not sure if there is a way to change this in tcell. Sorry for all the edits, I can create a separate bug report for this if you like? |
It is passed by the terminal as Tab, i.e. both Tab and Ctrl-Tab are passed as the same character, so micro is not able to distinguish between them. Please read the sections Summarizing, to make Ctrl-Tab work, you'd need to:
This is described in Also, as mentioned in the last paragraph of
This is because
Hah, that's because Tab by default is bound to
It is getting sent, but it is getting sent, again, as the same character as Tab, for historical reasons. This is another reason why we love Unix terminals. If you're interested why exactly Ctrl-I and Tab are sent the same way: Tab is an ASCII character with code 9 (see For the same reason Ctrl-M and Enter work the same way (Enter aka Return character is an ASCII character 13). Excited?
This can be only fixed in the terminal. Tcell, like micro, is on the receiving side, not on the sending side. If the terminal presents two different keys as the same character, micro or tcell can do nothing about that. Fixing it in the terminal means overriding the standard (annoying) terminal binding for Ctrl-I, Ctrl-M etc with a non-standard one (remember, in micro you also need to correspondingly bind the same non-standard character sequence to the action), and breaking backward compatibility, which is why no one does that by default (or hardly does at all). |
FYI, nowadays lots of editors support the kitty keyboard protocol, vim, neovim, dte, emacs, kakoune, helix to name some. it fixes all these issues and many more, out of the box. https://sw.kovidgoyal.net/kitty/keyboard-protocol/ |
@kovidgoyal Looks interesting, thanks. (I recall I might have seen this specification a few years ago, when it probably had far fewer implementations than it does now...) The thread discussing adding support for this protocol to tcell (thus potentially to micro): gdamore/tcell#500 The remaining fundamental issue is how many terminals do support it. Looks like only 3 so far, but let's see how well it proliferates in the future. |
I was trying to bind Ctrl-Tab to NextTab, but it wasn't working, I tested it a it more and I can't seem to bind Ctrl-Tab to anything. Is this a reserved shortcut? I didn't find anything in the docs about it. I tried
Ctrl-Tab
CtrlTab
andCtrl-tab
and none worked.Specifications
Commit hash: ceaa143
OS: Manjaro
Terminal: Xfce Terminal
The text was updated successfully, but these errors were encountered: