-
Notifications
You must be signed in to change notification settings - Fork 46
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
ctrl-j and enter were indistinguishable #149
Conversation
You are correct that we don't distinguish between these two cases. I looked at a couple of other TUI libraries (tcell, notcurses, crossterm) and they handle things differently: Tcell => Ctrl+J is a distinct event I normally would say that @dankamongmen (notcurses) is the end-all, be-all truth. However in this case I do think it makes sense to distinguish. The method you've gone is not the right way though. We don't have any keys that are defined as a |
i agree. i feel this is a bug in notcurses. thanks for bringing it to my attention! |
Thank you for the comments and feedback, appreciate it! I made the changes, and tested |
I made the changes, and tested `ctrl-j` is being successfully detected.
Looks good, thanks!
By the way how do you handle tests for this? I tested it by rebuilding it and
using it with the commit here, and it properly detects it; not sure what the
approach for writing tests is here.
If you look further down in Parser.zig there are some tests where we manually
feed bytes to the parser and check against the resulting events. No need to add
one for this though.
|
Also FYI squashed this one down to a single commit and reworded the commit title and message. Thanks again! |
Hey!
I realized that the library logic currently (from my understanding) was making it indistinguishable to detect if the keypress is Ctrl-j or Enter.
This was for example in terminal applications treating it as Enter. Vim terminal users pretty frequently use
Control-j
as a separate keymap so I made this PR - let me know what you folks think, I just added both checks everywhere there was the existingEnter
checks such as in the examples.https://github.com/natecraddock/zf/blob/f8ba4a46b5ee6261c2c3d92fc0bc7239806d5406/src/tui/ui.zig#L268
The tests were failing for me on Aarch64 MacOS so due to an error for a missing method on the
tty
insrc/tty.zig
- not sure how relevant it is. But the tests and build passed after I just added it to the test struct.Great library!