Are the escape sequences for F1, F2 and F4 (documented) wrong? #7650
Replies: 5 comments 4 replies
-
On Sat, Jul 20, 2024 at 04:08:11AM -0700, plotski wrote:
Are the escape sequences for F1, F2 and F4 (documented) wrong?
According to https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional pressing the keys F1, F2 and F4 should produce the escape sequences `CSI 1 P` (or `CSI 11 ~`), `CSI 1 Q` (or `CSI 12 ~`) and `CSI 1 S` (or `CSI 14 ~`), respectively.
But when I run `kitten show-key -m kitty`, I'm getting `CSI P`, `CSI Q` and `CSI S`.
1 is the default value, so the two are identical.
You should not be matching bytes directly, but instead parsing the escape code
properly. It takes only about 20 lines of code to write a correct parser
for these sequences.
Same thing for the cursor keys (`CSI 1 A/B/C/D`) and Home/End.
Am I misunderstanding something or are documentation and implementation in disagreement?
And why are there two sequences for some keys? Under which circumstances will the terminal send each one? Is this predictable?
Any given terminal should send just one, but depending on what its legacy
encoding for those keys was it might be one or the other.
In a client library you should recognize both.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
plotski
-
On Sat, Jul 20, 2024 at 04:23:36AM -0700, plotski wrote:
> 1 is the default value, so the two are identical.
The default value for what, exactly?
Quoting the spec:
The second form is used for a few functional keys, such as the Home, End, Arrow keys and F1 … F4, they are enumerated in the Functional key definitions table below. Note that if no modifiers are present the parameters are omitted entirely giving an escape code of the form CSI [ABCDEFHPQS].
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Grep for decode_key_event()
|
Beta Was this translation helpful? Give feedback.
2 replies
-
BTW: Line 326 in ff2baf9 The I believe the |
Beta Was this translation helpful? Give feedback.
0 replies
-
On Sat, Jul 20, 2024 at 06:40:29AM -0700, plotski wrote:
BTW:
https://github.com/kovidgoyal/kitty/blob/ff2baf91225180d335603bd53100aca14f64cfd4/kitty/key_encoding.py#L326
The `R` is not in the documented string: `ABCDEFHPQS`
I believe the `R` was removed due to the cursor position response conflict?
Yes, it was, but kittens dont use the cursor position report and so I
left it in there, in case the kitten is ever run on an old version of
kitty that did generate R. Modern code should not use it, of course.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Are the escape sequences for F1, F2 and F4 (documented) wrong?
According to https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional pressing the keys F1, F2 and F4 should produce the escape sequences
CSI 1 P
(orCSI 11 ~
),CSI 1 Q
(orCSI 12 ~
) andCSI 1 S
(orCSI 14 ~
), respectively.But when I run
kitten show-key -m kitty
, I'm gettingCSI P
,CSI Q
andCSI S
.Same thing for the cursor keys (
CSI 1 A/B/C/D
) and Home/End.Am I misunderstanding something or are documentation and implementation in disagreement?
And why are there two sequences for some keys? Under which circumstances will the terminal send each one? Is this predictable?
Beta Was this translation helpful? Give feedback.
All reactions