Skip to content

Commit 54cde8a

Browse files
Jakub Horkýhorkykuba
authored andcommitted
lib/tty/key.c: Add Kitty Keyboard Protocol support
The protocol is described here: https://sw.kovidgoyal.net/kitty/keyboard-protocol/ The old functionality that "eats" all characters following an unknown escape sequence has been removed, as it causes severe side effects (such as not responding to any keys following an unknown sequence for some time). This is superseded by parsing CSI and SS3 sequences, which are the de facto standard for sending any function keys. Signed-off-by: Jakub Horký <jakub.git@horky.net>
1 parent cd66057 commit 54cde8a

20 files changed

Lines changed: 491 additions & 120 deletions

File tree

doc/man/es/mc.1.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,6 +3965,13 @@ For example:
39653965
.nf
39663966
autodetect_codeset=russian
39673967
.fi
3968+
.TP
3969+
.I kitty_keyboard_protocol
3970+
De forma predeterminada, Midnight Commander envía una secuencia de escape que habilita el
3971+
protocolo de teclado de Kitty, lo que permite un manejo preciso del teclado (incluyendo
3972+
combinaciones de teclas como C\-Enter o C\-S\-Enter) cuando se conecta desde terminales
3973+
que admiten este protocolo. Si se establece en falso, Midnight Commander no intentará
3974+
habilitar este protocolo.
39683975
.\"NODE "Parameters for external editor or viewer"
39693976
.SH "Parámetros para editor o visor externo"
39703977
Midnight Commander permite especificar opciones para editores y visores

doc/man/hu/mc.1.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,6 +3014,14 @@ utolsó fájl a panelben.
30143014
.IP
30153015
Ha ez a változó be van állítva (alapértelmezésben) meg foja jelölni azt
30163016
a fájl parancsot, amelyhez a
3017+
.PP
3018+
.I kitty_keyboard_protocol
3019+
Alapértelmezés szerint a Midnight Commander egy olyan escape szekvenciát
3020+
küld, amely engedélyezi a Kitty billentyűzetprotokollt. Ez lehetővé teszi
3021+
a billentyűzet pontos kezelését (beleértve az olyan billentyűkombinációkat
3022+
is, mint a C\-Enter vagy a C\-S\-Enter), amikor olyan terminálról
3023+
csatlakoznak, amely támogatja ezt a protokollt. Ha az érték hamisra van
3024+
állítva, a Midnight Commander nem próbálja meg engedélyezni ezt a protokollt.
30173025
.\"LINK2"
30183026
Társításokban
30193027
.\"Edit Extension File"

doc/man/it/mc.1.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,6 +3014,14 @@ pannello.
30143014
.I use_file_to_guess_type
30153015
Se questa variabile è abilitata (valore predefinito) userà il comando
30163016
file per trovare delle corrispondenze sui tipi di file elencati nel
3017+
.TP
3018+
.I kitty_keyboard_protocol
3019+
Per impostazione predefinita, Midnight Commander invia una sequenza di
3020+
escape che abilita il Kitty Keyboard Protocol, il quale consente una
3021+
gestione precisa della tastiera (incluse combinazioni di tasti come
3022+
C\-Enter o C\-S\-Enter) quando ci si connette da terminali che supportano
3023+
questo protocollo. Se impostato su false, Midnight Commander non tenterà
3024+
di abilitare questo protocollo.
30173025
.\"LINK2"
30183026
file mc.ext.ini\&.
30193027
.\"Edit Extension File"

doc/man/mc.1.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,13 @@ For example:
41904190
.nf
41914191
autodetect_codeset=russian
41924192
.fi
4193+
.TP
4194+
.I kitty_keyboard_protocol
4195+
By default, Midnight Commander sends an escape sequence that enables the Kitty
4196+
Keyboard Protocol, which allows precise keyboard handling (including key
4197+
combinations such as C\-Enter or C\-S\-Enter) when connected from terminals that
4198+
support this protocol. If set to false, Midnight Commander will not attempt to
4199+
enable this protocol.
41934200
.\"NODE "Parameters for external editor or viewer"
41944201
.SH "Parameters for external editor or viewer"
41954202
Midnight Commander provides a way for specify an options for external editors

doc/man/pl/mc.1.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,13 @@ Jeśli ta opcja jest włączona (standardowo tak nie jest) kiedy przeglądasz pl
27082708
w panelu drzewa, będzie on automatycznie przeładowywał drugi panel na
27092709
zawartość wybranego katalogu.
27102710
.PP
2711+
.I kitty_keyboard_protocol
2712+
Domyślnie Midnight Commander wysyła sekwencję escape, która włącza protokół
2713+
klawiatury Kitty. Umożliwia on precyzyjną obsługę klawiatury (w tym kombinacje
2714+
klawiszy takie jak C\-Enter czy C\-S\-Enter) podczas połączenia z terminalami
2715+
obsługującymi ten protokół. Jeśli ustawione na false, Midnight Commander
2716+
nie będzie próbował włączyć tego protokołu.
2717+
.PP
27112718
.\"NODE "Terminal databases"
27122719
.SH Baza danych terminali (Terminal databases)
27132720
Midnight Commander pozwala ci na naprawienie bazy danych terminali bez

doc/man/ru/mc.1.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4660,6 +4660,13 @@ clipboard_paste=xclip \-o
46604660
.nf
46614661
autodetect_codeset=russian
46624662
.fi
4663+
.PP
4664+
.I kitty_keyboard_protocol
4665+
По умолчанию Midnight Commander отправляет управляющую последовательность, которая
4666+
включает протокол клавиатуры Kitty. Этот протокол обеспечивает точную обработку
4667+
клавиатуры (включая такие комбинации клавиш, как C\-Enter или C\-S\-Enter) при
4668+
подключении из терминалов, поддерживающих данный протокол. Если установить значение
4669+
в false, Midnight Commander не будет пытаться включить этот протокол.
46634670
.\"NODE "Parameters for external editor or viewer"
46644671
.SH "Параметры для внешних редакторов и программ просмотра"
46654672
Midnight Commander позволяет задать некоторые параметрыы для внешних редакторов

doc/man/sr/mc.1.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,6 +3006,14 @@ base_color=normal=white,default:marked=magenta,default
30063006
Уколико је ова променљива укључена (подразумевано је искључена),
30073007
приликом разгледања система датотека у окну које је у режиму Стабла,
30083008
друго окно ће се аутоматски поново учитати у изабраном директоријуму.
3009+
.TP
3010+
.I kitty_keyboard_protocol
3011+
Подразумевано, Midnight Commander шаље escape секвенцу која омогућава
3012+
Kitty протокол тастатуре, што омогућава прецизно руковање тастатуром
3013+
(укључујући комбинације тастера као што су C\-Enter или C\-S\-Enter)
3014+
када се повезује са терминала који подржавају овај протокол. Ако је
3015+
постављено на false, Midnight Commander неће покушати да омогући овај
3016+
протокол.
30093017
.\"NODE "Terminal databases"
30103018
.SH "Базе терминала"
30113019
Поноћни наредник обезбеђује начин да поправи вашу системску базу

lib/global.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ mc_global_t mc_global =
103103
.disable_colors = FALSE,
104104
.ugly_line_drawing = FALSE,
105105
.old_mouse = FALSE,
106-
.alternate_plus_minus = FALSE
106+
.alternate_plus_minus = FALSE,
107+
.kitty_keyboard_protocol = TRUE
107108
},
108109

109110
.vfs =

lib/global.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ typedef struct
206206
/* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
207207
and M-- and keypad + / - */
208208
gboolean alternate_plus_minus;
209+
210+
// If true, send Kitty Keyboard Protocol initialization string to the terminal
211+
// Defaults to true, because terminals that don't support it simply do nothing
212+
gboolean kitty_keyboard_protocol;
209213
} tty;
210214

211215
struct

lib/terminal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ parse_csi (csi_command_t *out, const char **sptr, const char *end)
156156
{
157157
out->private_mode = private_mode;
158158
out->param_count = param_count;
159+
out->final_byte = c;
159160
}
160161

161162
invalid_sequence:

0 commit comments

Comments
 (0)