Patch 9.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.
Files:      runtime/doc/term.txt, src/term.c


*** ../vim-9.0.1072/runtime/doc/term.txt        2022-12-01 12:03:42.259227523 
+0000
--- runtime/doc/term.txt        2022-12-18 17:04:40.328414318 +0000
***************
*** 294,299 ****
--- 295,320 ----
  starts with CSI, it assumes that the terminal is in 8-bit mode and will
  convert all key sequences to their 8-bit variants.
  
+                                               *xterm-kitty* *kitty-terminal*
+ The Kitty terminal is a special case.  Mainly because it works different from
+ most other terminals, but also because, instead of trying the fit in and make
+ it behave like other terminals by default, it dictates how applications need
+ to work when using Kitty.  This makes it very difficult for Vim to work in a
+ Kitty terminal.  Some exceptions have been hard coded, but it is not at all
+ nice to have to make exceptions for one specific terminal.
+ 
+ One of the problems is that the value for $TERM is set to "xterm-kitty".  For
+ Vim this is an indication that the terminal is xterm-compatible and the
+ builtin xterm termcap entries should be used.  Many other terminals depend on
+ this.  However, Kitty is not fully xterm compatible.  The author suggested to
+ ignore the "xterm-" prefix and use the terminfo entry anyway, but that
+ conflicts with what is needed for other terminals.  Therefore Vim removes the
+ "xterm-" prefix from "xterm-kitty" when it comes from $TERM.
+ 
+ Note that using the kitty keyboard protocol is a separate feature, see
+ |kitty-keyboard-protocol|.
+ 
+ 
  ==============================================================================
  2. Terminal options           *terminal-options* *termcap-options* *E436*
  
*** ../vim-9.0.1072/src/term.c  2022-12-17 15:35:37.778657492 +0000
--- src/term.c  2022-12-18 17:26:20.064007686 +0000
***************
*** 2071,2076 ****
--- 2071,2082 ----
      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,2613 ****
      void
  termcapinit(char_u *name)
  {
!     char_u    *term;
  
!     if (name != NULL && *name == NUL)
!       name = NULL;        // empty name is equal to no name
!     term = name;
  
  #ifndef MSWIN
      if (term == NULL)
        term = mch_getenv((char_u *)"TERM");
  #endif
      if (term == NULL || *term == NUL)
        term = DEFAULT_TERM;
--- 2605,2638 ----
      void
  termcapinit(char_u *name)
  {
!     char_u    *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,2626 ****
      set_string_default("term", term);
      set_string_default("ttytype", term);
  
!     /*
!      * Avoid using "term" here, because the next mch_getenv() may overwrite 
it.
!      */
      set_termname(T_NAME != NULL ? T_NAME : term);
  }
  
  /*
--- 2642,2653 ----
      set_string_default("term", term);
      set_string_default("ttytype", term);
  
!     // 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,5004 ****
--- 5026,5034 ----
        {
            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.
*** ../vim-9.0.1072/src/version.c       2022-12-18 12:28:54.334332509 +0000
--- src/version.c       2022-12-18 13:35:52.811860107 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1073,
  /**/

-- 
MORTICIAN:    What?
CUSTOMER:     Nothing -- here's your nine pence.
DEAD PERSON:  I'm not dead!
MORTICIAN:    Here -- he says he's not dead!
CUSTOMER:     Yes, he is.
DEAD PERSON:  I'm not!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221218174748.3D1E51C0C91%40moolenaar.net.

Raspunde prin e-mail lui