-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix kitty keyboard protocol parsing of ctrl-o #4663
Fix kitty keyboard protocol parsing of ctrl-o #4663
Conversation
7f9b805
to
00eb67a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for a quality contribution featuring... a test!!!11 I'm not sure if you're the first ever, but you get a gold star anyway ⭐ 🌟 ⭐
I'm really unfamiliar with the code and have little idea about the subject, hopefully @aborodin can say something. I only left formal comments that can be easily addressed. Also, please fix the build on Solaris.
Making check in lib
make terminal
CC terminal.o
terminal.c: In function ‘test_strip_ctrl_codes’:
terminal.c:56:1: error: ‘main’ is normally a non-static function [-Werror=main]
56 | main (void)
| ^~~~
terminal.c:70:1: error: expected declaration or statement at end of input
70 | }
| ^
At top level:
terminal.c:56:1: error: ‘main’ defined but not used [-Werror=unused-function]
56 | main (void)
| ^~~~
I guess you missed the END_TEST
macro.
@asl could you please report whether this helps?
Note that capslock still disables ctrl-o. We could change that easily
(and for consistency also allow ctrl-O).
I'm not sure if we generally recognize shifted stuff, and if we do, how it works. I'm afraid to open this can of worms. There is some information in #2150 ... @ossilator and @egmontkob know more about this.
P.S. How amazing was it to enjoy the privilege of using GitHub for issues and a pull-request submission interface?
I know I probably can't impress people with this, but you're the one who experienced our venerable Trac... oh man, that was a hell of a lot of work. I need some encouragement 😅
[ the 3rd commit message (and the PR description) say "add teach". from a cursory look, the kitty kbd proto implements everything i "asked for" in #2150, so: yay. capslock/shiftlock should definitely not suppress control sequences.
|
00eb67a
to
79c6a19
Compare
there's a lot of boilerplate to adding tests I guess.
it's mainly about implementing section 5.4 (Control sequences) from
I think this problem was only seen by @Crashdummyy. Note I've added another commit that will cause fish to not enable kitty
This patch does add some parsing code that could be used in future to
I've been watching that from afar, seems pretty nice. GitHub API docs
Yeah, I think github wants to keep people on their website, so they
ok I made it so c-o still works when capslock is on.
Konsole also hijacks alt-f, that would be very annoying to use for me. Extracted the test to separate commit. range-diff
|
79c6a19
to
5dc7aef
Compare
No, unfortunately I don't. I'm not familiar with Kitty's keyboard protocol at all. So I'll sit out this discussion. |
Well, you didn't just add a test, you added a whole new test suite. I don't see much difference between our current Foot seems to put their tests directly into the source files instead of having a separate tree of suites and tests. I can see how this makes it easier to add tests. It's not that it's an uncontroversial decision, though. I think the biggest problem is that we have so few tests that it's basically not about finding a suite and adding your little new test to it, it's about writing a whole new suite from scratch. But that is a chicken and egg problem. If we don't add more suites and tests, there will never be enough of them to make it easy to add a new test to an existing suite. However, my impression so far has been that most contributors either object on principle, calling it useless bureaucracy, or expect maintainers to write tests for them. That's why I'm so glad you don't seem to exhibit either of those behaviors.
Living in Germany, I've seen a lot worse. They do have their own quirks that you have to learn by doing though... It seems that the REST API has taken a back seat and all new stuff goes into GraphQL, but this is somehow not really made explicit anywhere, so you basically start doing something with REST and bump into missing things, which eventually leads to throwing the whole thing out and starting from scratch with GraphQL. On top of that, their import API has never left "unofficial" status and remains REST. While it's (thankfully) not completely broken yet, it means you don't get a decent client for it (had to code my own) and it also doesn't support new features like resolutions, issue types, etc. But yeah, I am very happy with the results so far :)
I think it's more of a (self-reinforcing) cultural lack of demand these days than a conspiracy against commit messages... They are doing things that enterprise customers are screaming about. Most of the recent improvements to Issues and Projects are well done, in my opinion.
But (unlike for commit messages) they have the tools for those who care to make it work. As you can see (well, probably not, since you don't have the commit bit), I have made it so that the PRs cannot be merged unless they are up-to-date on So I hope we can keep our working style of committing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few fixes. Otherwise I'm happy with the code as it is (but see below).
ok I made it so c-o still works when capslock is on.
I think I can agree with that...
c-s-o works too because from a user perspective that's
exactly the same thing as c-o with capslock on.
Would need a good reason to treat them differently.
... but this definitely sounds wrong to me. In the GUI programs I use, the shortcuts with Shift definitely have a different meaning. That is, Ctrl-O and Ctrl-Shift-O are definitely different, and both work regardless of whether CapsLock is on or not.
Could you please change this back? I don't want to break anything, so I won't do it myself.
range-diff
How did you do that? This could be useful to learn.
@@ -465,7 +465,7 @@ init_subshell_child (const char *pty_name) | |||
|
|||
case SHELL_FISH: | |||
execl (mc_global.shell->path, mc_global.shell->path, "--init-command", | |||
"set --global __mc_csi_u 1", (char *) NULL); | |||
"set --global __mc_kitty_keyboard 1", (char *) NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you care about commit messages, in 5dc7aef:
I guess we could avoid that but I don't think this
is not a big loss, especially because since fish 4.0.1 will enable it again.
The double negation is wrong.
absolutely not.
well, to me this sounds just backwards, like typical workaround thinking for bad tooling. squashing the fixups is a potentially error-prone process (the necessary reordering may cause conflicts), so it shouldn't be delayed. and of course gerrit has an answer to that: diffs between patchsets (versions of a change, or in practice, actual commits), also called inter-diffs, are a rather central element of the workflow. seriously, just import mc to gerrithub (i would do that myself, but you'd need to give me full workflow permissions for the GH project) and import the pending PRs (after squashing the fixups), and see how it looks in practice. i've yet to see a developer with high standards who has looked back. |
c1f130a
to
ae48bf3
Compare
Ok that makes sense, done.
It's a "diff of patches" (or "diff of diffs"), useful after force
I think it takes some time to get accustomed to it, |
Note that CI tests should typically run on a merge commit implicitly created After that suceeds, a
I have no horse in this race but I'm strongly in favor of cleaning I don't think it's right to optimize for the hypothetical reviewer
I think that can be fine momentarily / depending on people but I don't think We should optimize for the reader -- which includes the author; when I send Solving the tooling problem with I like how the Git project does it (see https://public-inbox.org/git/) So it's definitely possible to have both a simple diff to the previous
In parts it's also Git itself; I think Jujutsu does a great job at
I'm not really involved in mc but I'd love to try such a system that I think it's absolutely the right choice to offer github (for 95% |
I think it depends on how much development you do, how big the reviews are, how many comments of what kind you get, etc. In my previous endaviours, it was either a few "big" issues with the PR, or a reasonable number of small things to fix before the merge. For big issues, force-pushing was fine, because I could take a fresh look at the whole new patch, and minor comments could be left until the end. For small issues, the fixup was very convenient. You leave 5 comments, get 5 fixups of a few lines each, tick them off, start an automatic rebase process that is almost guaranteed to end without conflict (unless a wrong commit was fixed or something), and that's it. Polishing series of patches for large projects like the kernel or Qt is a completely different story. Of course, fixups are an inadequate tool for this. But these projects have more than 1-2 people reviewing them, the reviewers have time, the contributors have time and motivation to do anything at all, learning non-trivial tools is definitely worth the benefits, etc. I can't see how that applies to mc in its current form, with its current team and contributors. Maybe if I were working on the kernel, git or Qt I'd feel differently, because that's what I do anyway, but I'm not, not even close. So PRs with fixups seem to me to be the sweet spot right now in terms of being better than nothing, but very light. And of course even that seems to be too much for all the previous submitters I know of.
Can't you just fork mc to your account, set it up and make a demo if you're willing to put the work in? Why do you have to do it with the main organisation? |
That's exactly how I set it up. Moreover, if something else has been merged in the meantime, the merge will be aborted.
Well, I think if you have a 1.5 reviewer and close to zero contributors, it's absolutely right to optimize for what the reviewers find convenient. I tried to explain this above, but in the end I don't think it really matters. I'm not against other workflows, and I'm open to learning and changing mine, but otherwise I prefer what I think is optimal for me under the current circumstances.
Yeah, that's exactly the opposite of what we have here :)
I will take a look at
Looks a lot like the kernel workflow... somewhat unsurprising ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'm happy when CI and Andrew are happy!
common.c: In function 'peek_subshell_switch_key':
common.c:814:20: error: unused variable 'shifted_key' [-Werror=unused-variable]
814 | const uint32_t shifted_key = csi.params[0][1];
| ^~~~~~~~~~~
For small issues, the fixup was very convenient. You leave 5 comments, get 5 fixups of a few lines each, tick them off
I think range-diff allows the same workflow, and it also
1. guarantees that fixups are ordered
2. shows the fixups in their original context (so can tell if the surrounding code is new or not)
3. shows changes to commit messages
But these projects have more than 1-2 people reviewing them, the
reviewers have time, the contributors have time and motivation to
do anything at all, learning non-trivial tools is definitely worth
the benefits, etc.
I'm happy to follow any workflow that helps.
But to give a concrete example for why I prefer squashing early even
if I don't expect anyone else to read my code.
For my most recent push, I wanted to do another pass over my changes.
Specifically I wanted to read all changes except for the boring/noisy
code-movement commit, and also excluding anything that was merged in
from master on this branch.
I think that's a reasonable want (also post-merge, in case we found
a problem with these changes) -- so I'd strongly prefer to not squash
the code-movement commit with logic changes.
But the Git command to do so gets a bit complicated, mainly
because it needs to get rid of the interleaved merge commit
by creating a a fake merge:
code_movement_commit=20e6d84f9dde2949d4840dfcf4e180f433c9a465
git diff $(git merge-tree $(git log -1 --merges --format=%H)^2 $code_movement_commit)
and of course a single "diff" invocation doesn't work well if there are multiple nontrivial patches
|
7979345
to
f228be4
Compare
honestly, you're overthinking it. project and contribution size don't matter at all. once you get into the gerrit workflow, you just want to use it for everything, because it's so natural and efficient. for contributors it's a bit of a hurdle, because they need to get into history polishing in the first place. but my perspective is that this is actually a useful people filter.
i can, but it seems counter-productive to me. if you actually take a look at my "clone" and then want to use it, then you'd have to replicate my steps and your experiments (which should be an actual live review to be realistic), which is a total waste. conversely, if you do the experiment yourself and find it to be garbage, then nothing is lost by doing it in the main org, as it can be just deleted afterwards. |
I found a project that seems to use Gerrithub and read up on their process: https://github.com/cue-lang/cue/blob/master/CONTRIBUTING.md Now I understand better what you are saying. I'm afraid the people filter aspect has filtered me out at the moment. I kind of see the appeal, but the amount of overhead seems too crazy at the moment. Maybe I'll come back to it one day when I've solved more of what I think are pressing problems... |
Following commits want to add more logic (and tests) for decoding terminal escape sequences, and implement a subset of the kitty keyboard protocol. It's probably not right to keep all of this in lib/util.c, so extract a new module. I called it "terminal" because it helps mc act as terminal. We also have lib/tty/tty.h though that's for talking to the actual terminal that mc is running inside. Signed-off-by: Johannes Altmanninger <aclopte@gmail.com> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Take from my fish shell prompt. Signed-off-by: Johannes Altmanninger <aclopte@gmail.com> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Johannes Altmanninger <aclopte@gmail.com> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Commit 6e4510b (subshell: recognize CSI u encoding for ctrl-o, 2024-10-09) made us parse sequences like \e[111;5u (meaning ctrl-o). As reported in fish-shell/fish-shell#10640 (comment), the kitty keyboard protocol specifies various other sequences that also mean ctrl-o. Specifically, when numlock is active. Instead of matching raw byte values, let's teach our ECMA-48 CSI parser to decode parameter bytes and interpret them according to the kitty keyboard protocol. Tested with fish version 4 on kitty: 1. Turn on numlock (or capslock) 2. SHELL=/bin/fish src/mc 3. ctrl-o 4. Enter 5. ctrl-o -- confirmed that this one is recognized now Signed-off-by: Johannes Altmanninger <aclopte@gmail.com> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
…col now __mc_csi_u was added so that fish shell knows when it's safe to enable the kitty keyboard protocol. As seen in the parent commit, it wasn't quite safe; so the upcoming patch release of fish will disable this protocol again -- until fish finds this commit, so add a new version marker. While at it, use a less misleading name. Dropping the old name will mean that fish < 4.0.1 will no longer enable the kitty keyboard protocol (and be safe from the hang on numlock). I guess we could avoid that but I don't think this is a big loss, especially because since fish 4.0.1 will enable it again. Signed-off-by: Johannes Altmanninger <aclopte@gmail.com> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
24cf31e
to
87a6a14
Compare
@krobelus Thanks for your contribution, it was a wild ride! |
The third commit wants to add more logic and a unit test related to decoding
terminal escape sequences and the kitty keyboard protocol. It's probably
not right to keep all of this in lib/util.c, so extract a new module.
I called it "terminal" as first approximation - the name could be workshopped,
especially since we have a lot of terminal-specific code all around. We also
have lib/tty/tty.h though that's slightly different.
Commit 6e4510b (subshell: recognize CSI u encoding for ctrl-o, 2024-10-09)
made us parse sequences like \e[111;5u (meaning ctrl-o). As reported in
https://github.com/fish-shell/fish-shell/issues/10640#issuecomment-2698350151,
the kitty keyboard protocol specifies various other sequences that also
mean ctrl-o. Specifically, when numlock is active.
Instead of matching raw byte values, let's add teach our ECMA-48 CSI parser to
decode parameter bytes and interpret them according to the kitty keyboard protocol.
Tested with fish version 4:
Note that capslock still disables ctrl-o. We could change that easily
(and for consistency also allow ctrl-O).
While at it, add some unit tests (using a fish prompt as input data).