-
Notifications
You must be signed in to change notification settings - Fork 93
Always set standard(really?) CSI keybindings #567
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
Conversation
|
@tompng Thanks for adding this PR. I like it a lot if we are set on not wanting to enter application mode. I'll see if I can help find some answers to your questions. |
Agreed. Based on my research these are for output not input, and have to do with moving the cursor. Also, some manual testing confirm it, e.g., telling it to move the cursor down 3:
I thought this was weird as well when I first encountered it. But I think the answer is not that "\E[B" is standard, but rather that terminfo can only return one escape sequence for a given capability, or in other words, For better or worse, based on what I have read and seen so far, when the escape sequence for a given capability is different in normal mode vs application mode, terminfo always returns the application mode escape sequence. I suppose this is because it was primarily designed to be used by applications.
I don't think it's that these "standard" ones are left out of terminfo. In fact, several of them are present in my terminfo for xterm: Keep in mind that, as I believe you alluded to below, most or all of the sequences listed here on wikipedia are for output (e.g., move cursor), not for input (keys). So we shouldn't be referencing this list when setting up key bindings, although what you've entered in the code are indeed the correct sequences for the arrow keys and Home and End keys, at least for xterm (and probably many other terminals).
I believe so, but perhaps only for the output sequences, not input sequences. For example, in the ECMA-48 standard we can find this: The only thing I don't understand is why it shows the representation as "CSI Pn 04/02" instead of "CSI Pn B", but I think it's referencing the ascii value 0x42, perhaps by indicating row 4 column 2 in an ASCII table.
I found the CSI escapes for cursor keys and Home and End keys for xterm here: I found the CSI escapes for cursor keys for vt220 here: I don't think these escape sequences are standard across all terminals, but probably are for VT-based terminals. |
|
I do see the cursor keys at least in Table 3-6 of the vt100 manual:
So I think the cursor keys are pretty standard across all ANSI-based terminals. However, the Home and End keys are not as standard. For example, with the "linux" console terminal they are "\E[1~" and "\E[4~" (I believe in both normal and application mode), and in rxvt-based terminals they are "\E[7~" and "\E[8~". Note that these are all covered by the comprehensive list.
|
|
After more investigation, I've opened an improved version of similar approach #569 that considers modifier keys. |
This is work in progress / in survey.
In ansi.rb,
cuu', 'cud', 'cuf', 'cub'are registered to keybinding with replacing hack.cud=\E[%p1%dBis replaced tocud=\E[B.I think this is doing wrong. Other escape sequence for keyboard input have prefix
k. Maybe these non-k-prefix sequences are only for printing, not for keyboard input.However, there is no
"\E[B"in output ofinfocmpcommand. This is weird. Maybe it is not written in terminfo because "\E[B" is standard, no need to write because every terminal emulator have it. (really?)I found the following sentence in wikipedia https://en.wikipedia.org/wiki/ANSI_escape_code#CSIsection.
If only "private" is written in terminfo, Reline should always set "standard" CSI keybindings.
TODO