-
Notifications
You must be signed in to change notification settings - Fork 248
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
Handle a "modifier+bare key" key combination #151
Comments
Hi, and thanks for the report! The "Enter" key is a special one, and isn't very well supported with modifier keys - terminals just don't send the complete information to the application. Now, there seems to be some problem detecting this modifier. Apparently As a note, you can use the |
Oh, I missed the example, thanks for pointing out. Since ncurses does not support new features of modern terminals I already knew that keyboard handling is messy, but I never thought it's that messy. So I came up with a table:
This shows that there are many cases where one modifier set is recognized as another one, some send an escape sequence, some are not recognized by Cursive and others are trapped entirely, though I don't know what exactly in keyboard OS event chain should be blamed for trapping. Also your observation
contradicts with mine: it's detected as plain |
Another note: the terminal used has a large impact on the events actually delivered to the application. I just pushed a1737ca, which at least fixes most modifier+key input on my computer for the ncurses backend. I tested it locally with gnome-terminal and konsole. Not all key combinations work on both, but I didn't see any If this doesn't work for you, then it means the key codes are different between multiple systems (could be terminfo version, terminal used, ...), which would be a bit of a pain... Notes:
For these reasons, I used to have in the Readme a compatibility table of the events available on various terminals, but it ended up being out-of-date, it depended on the backend used, and was overall too much work to maintain. |
Yeah, I only tested on gnome-terminal. I also have xterm and urxvt installed, so I'll test your commit against them too. |
After realizing that the actual key <=> code mapping was changing between ncurses versions, I understood hard-coding this table wasn't going anywhere. So now it should detect this mapping at runtime. This include the ( |
I'm seeing incorrect mapping with macOS Terminal and the default backend. For example, Alt(Left) appears to be an escape code of Key(Esc) Char('b'). When I get some time, I'll dig into the code to see what can be done. |
What's the future of this task? |
TLDR: Shift+Enter and Ctrl+Enter are probably impossible to differentiate from Enter, because the terminal sends the same code to the application. Input encoding depends on the terminal used, and those can vary a lot. Recognizing the encoding scheme and parsing the input appropriately is a huge task, and ncurses is supposed to do exactly that. As much as possible, I'd like to leave most of the That being said, parsing the output from ncurses itself isn't always trivial; many key codes are correctly parsed, but the returned code isn't documented, and the actual value depends on the ncurses version. This is what can be improved here - for instance, confusing Regarding macOS compatibility, I don't have a machine to test; #206 may be of interest. Regarding variations for the Enter key, most terminals simply send the same code even if Shift or Ctrl is pressed, so cursive cannot tell the difference. As for the termion backend, it doesn't currently check the current terminal, but there's an issue for that (https://github.com/ticki/termion/issues/106). |
Same behaviour on macos terminal. i need the ctrl-enter but it does not work. |
Description
Cannot process a "modifier+bare key" key combination, only a "bare key".
Configuration
Cursive version 0.6.4, the issue is relevant to all backends except BearLibTerminal which I didn't test.
Expected behaviour
Print on the upper-left corner:
ctrl+enter
on Ctrl+Enter;shift+enter
on Shift+Enter;alt+enter
on Alt+Enter.Actual behaviour
Nothing happens.
Code to reproduce
P.S. If the
Event::Key(Key::Enter) => "enter"
part is uncommented, the program will printenter
for all 4 cases.UPD: Add gnome-terminal as the terminal used and its version.
The text was updated successfully, but these errors were encountered: