Skip to content
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

take advantage of kitty keyboard protocol #2131

Closed
8 tasks done
dankamongmen opened this issue Aug 31, 2021 · 28 comments · Fixed by #2139
Closed
8 tasks done

take advantage of kitty keyboard protocol #2131

dankamongmen opened this issue Aug 31, 2021 · 28 comments · Fixed by #2139
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request input readin' dem bytes
Milestone

Comments

@dankamongmen
Copy link
Owner

dankamongmen commented Aug 31, 2021

I thought i had a bug on this, but i guess not? https://sw.kovidgoyal.net/kitty/keyboard-protocol/ seems a reasonable thing to support. it would have a few parts:

  • move to the alternate screen before doing queries
  • lex the kitty protocol elements
  • query for support with CSI ? u
  • watch for support response of form CSI ? flags u
  • request stepup with CSI = flags ; 1 u
  • push the current keyboard handling state at startup with CSI > u
  • pop the keyboard handling state at exit with CSI < u
  • synthesize SIGINT and SIGQUIT

so throw the query into our initial query string. initialize keyflags to 0. if we get a CSI ? flags u response, write flags to keyflags, and emit stepup CSI = flags ; 1 u and push CSI > u.

decode the inputs regardless of what flags said.

at exit, if we pushed, pop with CSI < u.

@dankamongmen dankamongmen added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 31, 2021
@dankamongmen dankamongmen added this to the 3.0.0 milestone Aug 31, 2021
@dankamongmen dankamongmen self-assigned this Aug 31, 2021
@dankamongmen
Copy link
Owner Author

looks like the kitty keyboard protocol disables the standard line discipline:

With this flag turned on, all key events that do not generate text are represented in one of the following two forms:
CSI number; modifier u
CSI 1; modifier [~ABCDEFHPQRS]
This makes it very easy to parse key events in an application. In particular, ctrl+c will no longer generate the SIGINT signal, but instead be delivered as a CSI u escape code.

@dankamongmen
Copy link
Owner Author

i've started the dankamongmen/kitty-keyboard branch for this.

@dankamongmen
Copy link
Owner Author

looks like we also need to make the switch to the alternate screen (if we intend to do it) before sending any of this, as the keyboard context is per-screen. added another item.

@dankamongmen
Copy link
Owner Author

looks like there's some limited support for this using XTMODKEYS, of which i was unaware.

@dankamongmen
Copy link
Owner Author

yeah we definitely need to move our push and set after smcup; this is why we remain in markedup mode following exit from notcurses-input currently.

dankamongmen added a commit that referenced this issue Aug 31, 2021
@dankamongmen
Copy link
Owner Author

shit, this means we can't do setupterm() after sending the query string. unless we hardcoded smcup and always fired it off....gross, but that would work.

@dankamongmen
Copy link
Owner Author

we need to leave the alternate screen in most interrogate_terminfo() failures now...

@dankamongmen
Copy link
Owner Author

alright, i've completed the handling of level 1, except we need to turn ctrl+{c, q, } into SIGINT and friends.

@dankamongmen
Copy link
Owner Author

hrmmm, arrow keys are having unexpected results.

@dankamongmen
Copy link
Owner Author

I think we're good to go for a merge here. I think there's a few more definitions I've not yet added, which we'll want to. Synthesis of signals is critical, but can't really be done properly until #2136 is complete, which I don't intend to do in 2.4.0.

@dankamongmen dankamongmen added the input readin' dem bytes label Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request input readin' dem bytes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants