0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 9.0.0813: Kitty terminal is not recognized

Problem:    Kitty terminal is not recognized.
Solution:   Recognize Kitty by the termresponse and then do not set
            seenModifyOtherKeys, since Kitty doesn't support that.
            (issue #11413)
This commit is contained in:
Bram Moolenaar
2022-10-21 14:17:24 +01:00
parent 7fa02bcb3b
commit 4bc85f23ed
4 changed files with 64 additions and 12 deletions

View File

@@ -9670,6 +9670,7 @@ terminalprops() *terminalprops()*
cursor_blink_mode whether sending |t_RC| works ** cursor_blink_mode whether sending |t_RC| works **
underline_rgb whether |t_8u| works ** underline_rgb whether |t_8u| works **
mouse mouse type supported mouse mouse type supported
kitty whether Kitty terminal was detected
** value 'u' for unknown, 'y' for yes, 'n' for no ** value 'u' for unknown, 'y' for yes, 'n' for no

View File

@@ -1350,8 +1350,10 @@ typedef struct {
#define TPR_UNDERLINE_RGB 2 #define TPR_UNDERLINE_RGB 2
// mouse support - TPR_MOUSE_XTERM, TPR_MOUSE_XTERM2 or TPR_MOUSE_SGR // mouse support - TPR_MOUSE_XTERM, TPR_MOUSE_XTERM2 or TPR_MOUSE_SGR
#define TPR_MOUSE 3 #define TPR_MOUSE 3
// term response indicates kitty
#define TPR_KITTY 4
// table size // table size
#define TPR_COUNT 4 #define TPR_COUNT 5
static termprop_T term_props[TPR_COUNT]; static termprop_T term_props[TPR_COUNT];
@@ -1373,6 +1375,8 @@ init_term_props(int all)
term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE; term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE;
term_props[TPR_MOUSE].tpr_name = "mouse"; term_props[TPR_MOUSE].tpr_name = "mouse";
term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE;
term_props[TPR_KITTY].tpr_name = "kitty";
term_props[TPR_KITTY].tpr_set_by_termresponse = FALSE;
for (i = 0; i < TPR_COUNT; ++i) for (i = 0; i < TPR_COUNT; ++i)
if (all || term_props[i].tpr_set_by_termresponse) if (all || term_props[i].tpr_set_by_termresponse)
@@ -4715,6 +4719,13 @@ handle_version_response(int first, int *arg, int argc, char_u *tp)
// else if (version == 115 && arg[0] == 0 && arg[2] == 0) // else if (version == 115 && arg[0] == 0 && arg[2] == 0)
// term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; // term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;
// Kitty sends 1;400{version};{secondary-version}
if (arg[0] == 1 && arg[1] >= 4000 && arg[1] <= 4009)
{
term_props[TPR_KITTY].tpr_status = TPR_YES;
term_props[TPR_KITTY].tpr_set_by_termresponse = TRUE;
}
// GNU screen sends 83;30600;0, 83;40500;0, etc. // GNU screen sends 83;30600;0, 83;40500;0, etc.
// 30600/40500 is a version number of GNU screen. DA2 support is added // 30600/40500 is a version number of GNU screen. DA2 support is added
// on 3.6. DCS string has a special meaning to GNU screen, but xterm // on 3.6. DCS string has a special meaning to GNU screen, but xterm
@@ -4848,7 +4859,11 @@ handle_key_with_modifier(
int modifiers; int modifiers;
char_u string[MAX_KEY_CODE_LEN + 1]; char_u string[MAX_KEY_CODE_LEN + 1];
seenModifyOtherKeys = TRUE; // Do not set seenModifyOtherKeys for kitty, it does send some sequences
// like this but does not have the modifyOtherKeys feature.
if (term_props[TPR_KITTY].tpr_status != TPR_YES)
seenModifyOtherKeys = TRUE;
if (trail == 'u') if (trail == 'u')
key = arg[0]; key = arg[0];
else else

View File

@@ -1647,7 +1647,8 @@ func Test_xx01_term_style_response()
\ cursor_style: 'u', \ cursor_style: 'u',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'u', \ underline_rgb: 'u',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
set t_RV= set t_RV=
@@ -1681,7 +1682,8 @@ func Test_xx02_iTerm2_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'u', \ underline_rgb: 'u',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
set t_RV= set t_RV=
@@ -1700,7 +1702,8 @@ func Run_libvterm_konsole_response(code)
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'u', \ underline_rgb: 'u',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
endfunc endfunc
@@ -1742,7 +1745,8 @@ func Test_xx04_Mac_Terminal_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'y', \ underline_rgb: 'y',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
call assert_equal("\<Esc>[58;2;%lu;%lu;%lum", &t_8u) call assert_equal("\<Esc>[58;2;%lu;%lu;%lum", &t_8u)
@@ -1772,7 +1776,8 @@ func Test_xx05_mintty_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'y', \ underline_rgb: 'y',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
set t_RV= set t_RV=
@@ -1807,7 +1812,8 @@ func Test_xx06_screen_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'n', \ cursor_blink_mode: 'n',
\ underline_rgb: 'y', \ underline_rgb: 'y',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
set t_RV= set t_RV=
@@ -1831,7 +1837,8 @@ func Do_check_t_8u_set_reset(set_by_user)
\ cursor_style: 'u', \ cursor_style: 'u',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'u', \ underline_rgb: 'u',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
call assert_equal(a:set_by_user ? default_value : '', &t_8u) call assert_equal(a:set_by_user ? default_value : '', &t_8u)
endfunc endfunc
@@ -1867,7 +1874,8 @@ func Test_xx07_xterm_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'y', \ underline_rgb: 'y',
\ mouse: 'u' \ mouse: 'u',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
" xterm >= 95 < 277 "xterm2" " xterm >= 95 < 277 "xterm2"
@@ -1882,7 +1890,8 @@ func Test_xx07_xterm_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'u', \ underline_rgb: 'u',
\ mouse: '2' \ mouse: '2',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
" xterm >= 277: "sgr" " xterm >= 277: "sgr"
@@ -1897,7 +1906,8 @@ func Test_xx07_xterm_response()
\ cursor_style: 'n', \ cursor_style: 'n',
\ cursor_blink_mode: 'u', \ cursor_blink_mode: 'u',
\ underline_rgb: 'u', \ underline_rgb: 'u',
\ mouse: 's' \ mouse: 's',
\ kitty: 'u',
\ }, terminalprops()) \ }, terminalprops())
" xterm >= 279: "sgr" and cursor_style not reset; also check t_8u reset, " xterm >= 279: "sgr" and cursor_style not reset; also check t_8u reset,
@@ -1909,6 +1919,30 @@ func Test_xx07_xterm_response()
call test_override('term_props', 0) call test_override('term_props', 0)
endfunc endfunc
func Test_xx08_kitty_response()
" Termresponse is only parsed when t_RV is not empty.
set t_RV=x
call test_override('term_props', 1)
set ttymouse=xterm
call test_option_not_set('ttymouse')
let seq = "\<Esc>[>1;4001;12c"
call feedkeys(seq, 'Lx!')
call assert_equal(seq, v:termresponse)
call assert_equal('sgr', &ttymouse)
call assert_equal(#{
\ cursor_style: 'u',
\ cursor_blink_mode: 'u',
\ underline_rgb: 'y',
\ mouse: 's',
\ kitty: 'y',
\ }, terminalprops())
set t_RV=
call test_override('term_props', 0)
endfunc
func Test_focus_events() func Test_focus_events()
let save_term = &term let save_term = &term
let save_ttymouse = &ttymouse let save_ttymouse = &ttymouse

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
813,
/**/ /**/
812, 812,
/**/ /**/