Patch 9.0.1065 (after 9.0.1063)
Problem:    A shell command switching screens may still have a problem with
            the kitty keyboard protocol.
Solution:   Disable the kitty keyboard protocol both in the current and the
            alternate screen, if there are indications it might be needed.
            (issue #11705)  Also fix naming.
Files:      src/map.c, src/term.c, src/globals.h


*** ../vim-9.0.1064/src/map.c   2022-11-26 19:16:44.186717893 +0000
--- src/map.c   2022-12-16 18:18:36.984328046 +0000
***************
*** 326,332 ****
                case MOKS_OFF: name = _("Off"); break;
                case MOKS_ENABLED: name = _("On"); break;
                case MOKS_DISABLED: name = _("Disabled"); break;
!               case MOKS_AFTER_T_KE: name = _("Cleared"); break;
            }
  
            char buf[200];
--- 326,332 ----
                case MOKS_OFF: name = _("Off"); break;
                case MOKS_ENABLED: name = _("On"); break;
                case MOKS_DISABLED: name = _("Disabled"); break;
!               case MOKS_AFTER_T_TE: name = _("Cleared"); break;
            }
  
            char buf[200];
***************
*** 344,350 ****
                case KKPS_OFF: name = _("Off"); break;
                case KKPS_ENABLED: name = _("On"); break;
                case KKPS_DISABLED: name = _("Disabled"); break;
!               case KKPS_AFTER_T_KE: name = _("Cleared"); break;
            }
  
            char buf[200];
--- 344,350 ----
                case KKPS_OFF: name = _("Off"); break;
                case KKPS_ENABLED: name = _("On"); break;
                case KKPS_DISABLED: name = _("Disabled"); break;
!               case KKPS_AFTER_T_TE: name = _("Cleared"); break;
            }
  
            char buf[200];
*** ../vim-9.0.1064/src/term.c  2022-12-16 13:08:32.742359073 +0000
--- src/term.c  2022-12-16 18:29:05.202525300 +0000
***************
*** 3689,3695 ****
            || modify_otherkeys_state == MOKS_DISABLED)
        modify_otherkeys_state = MOKS_DISABLED;
      else if (modify_otherkeys_state != MOKS_INITIAL)
!       modify_otherkeys_state = MOKS_AFTER_T_KE;
  
      // When the kitty keyboard protocol is enabled we expect t_TE to disable
      // it.  Remembering that it was detected to be enabled is useful in some
--- 3689,3695 ----
            || modify_otherkeys_state == MOKS_DISABLED)
        modify_otherkeys_state = MOKS_DISABLED;
      else if (modify_otherkeys_state != MOKS_INITIAL)
!       modify_otherkeys_state = MOKS_AFTER_T_TE;
  
      // When the kitty keyboard protocol is enabled we expect t_TE to disable
      // it.  Remembering that it was detected to be enabled is useful in some
***************
*** 3700,3706 ****
            || kitty_protocol_state == KKPS_DISABLED)
        kitty_protocol_state = KKPS_DISABLED;
      else
!       kitty_protocol_state = KKPS_AFTER_T_KE;
  }
  
  static int send_t_RK = FALSE;
--- 3700,3706 ----
            || kitty_protocol_state == KKPS_DISABLED)
        kitty_protocol_state = KKPS_DISABLED;
      else
!       kitty_protocol_state = KKPS_AFTER_T_TE;
  }
  
  static int send_t_RK = FALSE;
***************
*** 3892,3899 ****
        out_flush();
        termcap_active = FALSE;
  
!       // Output t_te first, it may switch between main and alternate screen,
!       // and following codes may work on the active screen only.
        out_str(T_TE);                  // stop termcap mode
        cursor_on();                    // just in case it is still off
        out_str_t_TE();                 // stop "raw" mode, modifyOtherKeys and
--- 3892,3909 ----
        out_flush();
        termcap_active = FALSE;
  
!       // Output t_te before t_TE, t_te may switch between main and alternate
!       // screen and following codes may work on the active screen only.
!       //
!       // When using the Kitty keyboard protocol the main and alternate screen
!       // use a separate state.  If we are (or were) using the Kitty keyboard
!       // protocol and t_te is not empty (possibly switching screens) then
!       // output t_TE both before and after outputting t_te.
!       if (*T_TE != NUL && (kitty_protocol_state == KKPS_ENABLED
!                                    || kitty_protocol_state == KKPS_DISABLED))
!           out_str_t_TE();             // probably disables the kitty keyboard
!                                       // protocol
! 
        out_str(T_TE);                  // stop termcap mode
        cursor_on();                    // just in case it is still off
        out_str_t_TE();                 // stop "raw" mode, modifyOtherKeys and
***************
*** 5158,5164 ****
      if (trail != 'u'
            && (kitty_protocol_state == KKPS_INITIAL
                || kitty_protocol_state == KKPS_OFF
!               || kitty_protocol_state == KKPS_AFTER_T_KE)
            && term_props[TPR_KITTY].tpr_status != TPR_YES)
      {
  #ifdef FEAT_EVAL
--- 5168,5174 ----
      if (trail != 'u'
            && (kitty_protocol_state == KKPS_INITIAL
                || kitty_protocol_state == KKPS_OFF
!               || kitty_protocol_state == KKPS_AFTER_T_TE)
            && term_props[TPR_KITTY].tpr_status != TPR_YES)
      {
  #ifdef FEAT_EVAL
*** ../vim-9.0.1064/src/globals.h       2022-12-15 13:14:17.411527402 +0000
--- src/globals.h       2022-12-16 18:19:08.304317558 +0000
***************
*** 1396,1407 ****
      MOKS_OFF,
      // Used when receiving the state and the level is two.
      MOKS_ENABLED,
!     // Used after outputting t_KE when the state was MOKS_ENABLED.  We do not
!     // really know if t_KE actually disabled the protocol, the following t_KI
      // is expected to request the state, but the response may come only later.
      MOKS_DISABLED,
!     // Used after outputting t_KE when the state was not MOKS_ENABLED.
!     MOKS_AFTER_T_KE,
  } mokstate_T;
  
  // Set when a response to XTQMODKEYS was received.  Only works for xterm
--- 1396,1407 ----
      MOKS_OFF,
      // Used when receiving the state and the level is two.
      MOKS_ENABLED,
!     // Used after outputting t_TE when the state was MOKS_ENABLED.  We do not
!     // really know if t_TE actually disabled the protocol, the following t_TI
      // is expected to request the state, but the response may come only later.
      MOKS_DISABLED,
!     // Used after outputting t_TE when the state was not MOKS_ENABLED.
!     MOKS_AFTER_T_TE,
  } mokstate_T;
  
  // Set when a response to XTQMODKEYS was received.  Only works for xterm
***************
*** 1416,1427 ****
      KKPS_OFF,
      // Used when receiving the state and the flags are non-zero.
      KKPS_ENABLED,
!     // Used after outputting t_KE when the state was KKPS_ENABLED.  We do not
!     // really know if t_KE actually disabled the protocol, the following t_KI
      // is expected to request the state, but the response may come only later.
      KKPS_DISABLED,
!     // Used after outputting t_KE when the state was not KKPS_ENABLED.
!     KKPS_AFTER_T_KE,
  } kkpstate_T;
  
  EXTERN kkpstate_T kitty_protocol_state INIT(= KKPS_INITIAL);
--- 1416,1427 ----
      KKPS_OFF,
      // Used when receiving the state and the flags are non-zero.
      KKPS_ENABLED,
!     // Used after outputting t_TE when the state was KKPS_ENABLED.  We do not
!     // really know if t_TE actually disabled the protocol, the following t_TI
      // is expected to request the state, but the response may come only later.
      KKPS_DISABLED,
!     // Used after outputting t_TE when the state was not KKPS_ENABLED.
!     KKPS_AFTER_T_TE,
  } kkpstate_T;
  
  EXTERN kkpstate_T kitty_protocol_state INIT(= KKPS_INITIAL);
*** ../vim-9.0.1064/src/version.c       2022-12-16 16:41:19.208714806 +0000
--- src/version.c       2022-12-16 18:32:29.314053437 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1065,
  /**/

-- 
FIRST GUARD: Ah!  Now ... we're not allowed to ...
   SIR LAUNCELOT runs him through,  grabs his spear and stabs the other
   guard who collapses in a heap.  Hiccoughs quietly.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/20221216183354.BB45E1C0869%40moolenaar.net.

Raspunde prin e-mail lui