summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-12-18 17:47:18 +0000
committerBram Moolenaar <Bram@vim.org>2022-12-18 17:47:18 +0000
commit731d00770d9006e7dab6a66e2ea86603ed5ef212 (patch)
treee18f2f17ad124db6633f0da5fc386a26cd908838 /src
parentba2d19193201277397c25c1f5a134ea042542555 (diff)
patch 9.0.1073: using "xterm-kitty" for 'term' causes problemsv9.0.1073
Problem: Using "xterm-kitty" for 'term' causes problems. Solution: Remove the "xterm-" part when 'term' is set from $TERM. Detect a few kitty-specific properties based on the version response instead of the terminal name.
Diffstat (limited to 'src')
-rw-r--r--src/term.c44
-rw-r--r--src/version.c2
2 files changed, 39 insertions, 7 deletions
diff --git a/src/term.c b/src/term.c
index 7483974ac1..7a70af450c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2071,6 +2071,12 @@ set_termname(char_u *term)
else
T_CCS = empty_option;
+ // Special case: "kitty" does not normally have a "RV" entry in terminfo,
+ // but we need to request the version for several other things to work.
+ if (strstr((char *)term, "kitty") != NULL
+ && (T_CRV == NULL || *T_CRV == NUL))
+ T_CRV = (char_u *)"\033[>c";
+
#ifdef UNIX
/*
* Any "stty" settings override the default for t_kb from the termcap.
@@ -2599,15 +2605,34 @@ tgoto(char *cm, int x, int y)
void
termcapinit(char_u *name)
{
- char_u *term;
+ char_u *term = name;
- if (name != NULL && *name == NUL)
- name = NULL; // empty name is equal to no name
- term = name;
+ if (term != NULL && *term == NUL)
+ term = NULL; // empty name is equal to no name
#ifndef MSWIN
+ char_u *tofree = NULL;
if (term == NULL)
+ {
term = mch_getenv((char_u *)"TERM");
+
+ // "xterm-kitty" is used for Kitty, but it is not actually compatible
+ // with xterm. Remove the "xterm-" part to avoid trouble.
+ if (term != NULL && STRNCMP(term, "xterm-kitty", 11) == 0)
+ {
+#ifdef FEAT_EVAL
+ ch_log(NULL, "Removing xterm- prefix from terminal name %s", term);
+#endif
+ if (p_verbose > 0)
+ {
+ verbose_enter();
+ smsg(_("Removing xterm- prefix from terminal name %s"), term);
+ verbose_leave();
+ }
+ term = vim_strsave(term + 6);
+ tofree = term;
+ }
+ }
#endif
if (term == NULL || *term == NUL)
term = DEFAULT_TERM;
@@ -2617,10 +2642,12 @@ termcapinit(char_u *name)
set_string_default("term", term);
set_string_default("ttytype", term);
- /*
- * Avoid using "term" here, because the next mch_getenv() may overwrite it.
- */
+ // Avoid using "term" here, because the next mch_getenv() may overwrite it.
set_termname(T_NAME != NULL ? T_NAME : term);
+
+#ifndef MSWIN
+ vim_free(tofree);
+#endif
}
/*
@@ -4999,6 +5026,9 @@ handle_version_response(int first, int *arg, int argc, char_u *tp)
{
term_props[TPR_KITTY].tpr_status = TPR_YES;
term_props[TPR_KITTY].tpr_set_by_termresponse = TRUE;
+
+ // Kitty can handle SGR mouse reporting.
+ term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;
}
// GNU screen sends 83;30600;0, 83;40500;0, etc.
diff --git a/src/version.c b/src/version.c
index 91313cb3f3..0fbc65789a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1073,
+/**/
1072,
/**/
1071,