Patch 9.0.1126
Problem:    Bracketed paste can be enabled when pasted text is not recognized.
Solution:   Output t_BE only when t_PS and t_PE are set.
Files:      runtime/doc/term.txt, src/term.c, src/proto/term.pro,
            src/edit.c, src/normal.c


*** ../vim-9.0.1125/runtime/doc/term.txt        2022-12-19 18:56:44.169594372 
+0000
--- runtime/doc/term.txt        2023-01-01 17:43:07.302080114 +0000
***************
*** 117,122 ****
--- 118,127 ----
  If this is done while Vim is running the 't_BD' will be sent to the terminal
  to disable bracketed paste.
  
+ If |t_PS| or |t_PE| is not set, then |t_BE| will not be used.  This is to make
+ sure that bracketed paste is not enabled when the escape codes surrounding
+ pasted text cannot be recognized.
+ 
  If your terminal supports bracketed paste, but the options are not set
  automatically, you can try using something like this: >
  
***************
*** 126,132 ****
          exec "set t_PS=\e[200~"
          exec "set t_PE=\e[201~"
        endif
! <
                                                        *tmux-integration*
  If you experience issues when running Vim inside tmux, here are a few hints.
  You can comment-out parts if something doesn't work (it may depend on the
--- 131,141 ----
          exec "set t_PS=\e[200~"
          exec "set t_PE=\e[201~"
        endif
! 
! The terminfo entries "BE", "BD", "PS" and "PE" were added in ncurses version
! 6.4, early 2023, for some terminals.  If you have this version then you may
! not have to manually configure your terminal.
! 
                                                        *tmux-integration*
  If you experience issues when running Vim inside tmux, here are a few hints.
  You can comment-out parts if something doesn't work (it may depend on the
***************
*** 294,306 ****
  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
--- 303,334 ----
  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-terminfo-entries*
+ For some time the terminfo entries were insufficient to describe all the
+ features tht Vim can use.  The builtin xterm termcap entries did have these,
+ with the result that several terminals that were similar enough to xterm took
+ advantage of these by prefixing "xterm-" to the terminal name in $TERM.
+ 
+ This leads to problems, because quite often these terminals are not 100%
+ compatible with xterm.  At the start of 2023 several entries have been added
+ to the terminfo database to make it possible to use these features without
+ using the "xterm" workaround.  These are the relevant entries (so far):
+ 
+       name    xterm value     description ~
+       RV      "\033[>c"       Request version |t_RV|
+ 
+       BE      "\033[?2004h"   enable bracketed paste mode |t_BE|
+       BD      "\033[?2004l"   disable bracketed paste mode |t_BD|
+       PS      "\033[200~"     pasted text start |t_PS|
+       PE      "\033[201~"     pasted text end |t_PE|
+ 
                                                *xterm-kitty* *kitty-terminal*
! The Kitty terminal is a special case.  Mainly because it works differently
! 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
***************
*** 563,571 ****
        t_KK    <k8>            keypad 8                 *<k8>* *t_KK* *'t_KK'*
        t_KL    <k9>            keypad 9                 *<k9>* *t_KL* *'t_KL'*
                <Mouse>         leader of mouse code            *<Mouse>*
!                                                               *t_PS* *'t_PS'*
!       t_PS    start of bracketed paste |xterm-bracketed-paste|
!       t_PE    end of bracketed paste |xterm-bracketed-paste|  *t_PE* *'t_PE'*
  
  Note about t_so and t_mr: When the termcap entry "so" is not present the
  entry for "mr" is used.  And vice versa.  The same is done for "se" and "me".
--- 592,604 ----
        t_KK    <k8>            keypad 8                 *<k8>* *t_KK* *'t_KK'*
        t_KL    <k9>            keypad 9                 *<k9>* *t_KL* *'t_KL'*
                <Mouse>         leader of mouse code            *<Mouse>*
! 
!       t_PS    <PasteStart>    start of bracketed paste        *t_PS* *'t_PS'*
!                               |xterm-bracketed-paste|
!       t_PE    <PasteEnd>      end of bracketed paste          *t_PE* *'t_PE'*
!                               |xterm-bracketed-paste|
!               <FocusGained>   Vim window got focus (internal only)
!               <FocusLost>     Vim window lost focus (internal only)
  
  Note about t_so and t_mr: When the termcap entry "so" is not present the
  entry for "mr" is used.  And vice versa.  The same is done for "se" and "me".
*** ../vim-9.0.1125/src/term.c  2022-12-30 21:10:20.665095951 +0000
--- src/term.c  2023-01-01 18:00:52.748815983 +0000
***************
*** 3757,3762 ****
--- 3757,3777 ----
  }
  
  /*
+  * Output T_BE, but only when t_PS and t_PE are set.
+  */
+     void
+ out_str_t_BE(void)
+ {
+     char_u *p;
+ 
+     if (T_BE == NULL || *T_BE == NUL
+           || (p = find_termcode((char_u *)"PS")) == NULL || *p == NUL
+           || (p = find_termcode((char_u *)"PE")) == NULL || *p == NUL)
+       return;
+     out_str(T_BE);
+ }
+ 
+ /*
   * If t_TI was recently sent and there is no typeahead or work to do, now send
   * t_RK.  This is postponed to avoid the response arriving in a shell command
   * or after Vim exits.
***************
*** 3834,3840 ****
                }
                else
                {
!                   out_str(T_BE);      // enable bracketed paste mode (should
                                        // be before mch_settmode().
                    out_str_t_TI();     // possibly enables modifyOtherKeys
                }
--- 3849,3855 ----
                }
                else
                {
!                   out_str_t_BE();     // enable bracketed paste mode (should
                                        // be before mch_settmode().
                    out_str_t_TI();     // possibly enables modifyOtherKeys
                }
***************
*** 3862,3868 ****
        out_str(T_TI);                  // start termcap mode
        out_str_t_TI();                 // start "raw" mode
        out_str(T_KS);                  // start "keypad transmit" mode
!       out_str(T_BE);                  // enable bracketed paste mode
  
  #if defined(UNIX) || defined(VMS)
        // Enable xterm's focus reporting mode when 'esckeys' is set.
--- 3877,3883 ----
        out_str(T_TI);                  // start termcap mode
        out_str_t_TI();                 // start "raw" mode
        out_str(T_KS);                  // start "keypad transmit" mode
!       out_str_t_BE();                 // enable bracketed paste mode
  
  #if defined(UNIX) || defined(VMS)
        // Enable xterm's focus reporting mode when 'esckeys' is set.
*** ../vim-9.0.1125/src/proto/term.pro  2022-12-01 12:03:42.259227523 +0000
--- src/proto/term.pro  2023-01-01 17:47:19.713955197 +0000
***************
*** 49,54 ****
--- 49,55 ----
  void set_shellsize(int width, int height, int mustset);
  void out_str_t_TE(void);
  void out_str_t_TI(void);
+ void out_str_t_BE(void);
  void may_send_t_RK(void);
  void settmode(tmode_T tmode);
  void starttermcap(void);
*** ../vim-9.0.1125/src/edit.c  2022-12-27 19:54:48.118194735 +0000
--- src/edit.c  2023-01-01 17:46:44.537972713 +0000
***************
*** 3714,3720 ****
        MAY_WANT_TO_LOG_THIS;
  
        // Re-enable bracketed paste mode.
!       out_str(T_BE);
  
        // Re-enable modifyOtherKeys.
        out_str_t_TI();
--- 3714,3720 ----
        MAY_WANT_TO_LOG_THIS;
  
        // Re-enable bracketed paste mode.
!       out_str_t_BE();
  
        // Re-enable modifyOtherKeys.
        out_str_t_TI();
*** ../vim-9.0.1125/src/normal.c        2022-12-15 13:14:17.411527402 +0000
--- src/normal.c        2023-01-01 17:45:42.734003408 +0000
***************
*** 454,460 ****
            MAY_WANT_TO_LOG_THIS;
  
            // Re-enable bracketed paste mode and modifyOtherKeys
!           out_str(T_BE);
            out_str_t_TI();
        }
  
--- 454,460 ----
            MAY_WANT_TO_LOG_THIS;
  
            // Re-enable bracketed paste mode and modifyOtherKeys
!           out_str_t_BE();
            out_str_t_TI();
        }
  
*** ../vim-9.0.1125/src/version.c       2023-01-01 14:11:23.358483466 +0000
--- src/version.c       2023-01-01 17:44:08.550049981 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1126,
  /**/

-- 
   [The rest of the ARMY stand around looking at a loss.]
INSPECTOR END OF FILM: (picks up megaphone) All right!  Clear off!  Go on!
                 "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/20230101180543.597141C0AA3%40moolenaar.net.

Raspunde prin e-mail lui