Patch 8.1.2174
Problem:    Screen not recognized as supporting "sgr" mouse codes.
Solution:   Recognize screen 4.7. (Jordan Christiansen, closes #5042)
Files:      src/term.c, src/testdir/test_termcodes.vim


*** ../vim-8.1.2173/src/term.c  2019-10-17 22:58:59.070496999 +0200
--- src/term.c  2019-10-18 21:24:11.719982533 +0200
***************
*** 4649,4656 ****
                    if (tp[0] == CSI)
                        switch_to_8bit();
  
-                   // rxvt sends its version number: "20703" is 2.7.3.
                    // Screen sends 40500.
                    // Ignore it for when the user has set 'term' to xterm,
                    // even though it's an rxvt.
                    if (version > 20000)
--- 4649,4656 ----
                    if (tp[0] == CSI)
                        switch_to_8bit();
  
                    // Screen sends 40500.
+                   // rxvt sends its version number: "20703" is 2.7.3.
                    // Ignore it for when the user has set 'term' to xterm,
                    // even though it's an rxvt.
                    if (version > 20000)
***************
*** 4661,4666 ****
--- 4661,4667 ----
                        int need_flush = FALSE;
                        int is_iterm2 = FALSE;
                        int is_mintty = FALSE;
+                       int is_screen = FALSE;
  
                        // mintty 2.9.5 sends 77;20905;0c.
                        // (77 is ASCII 'M' for mintty.)
***************
*** 4706,4719 ****
                                is_not_xterm = TRUE;
                        }
  
                        // Only set 'ttymouse' automatically if it was not set
                        // by the user already.
                        if (!option_was_set((char_u *)"ttym"))
                        {
                            // Xterm version 277 supports SGR.  Also support
!                           // Terminal.app, iTerm2 and mintty.
!                           if (version >= 277 || is_iterm2 || is_mac_terminal
!                                   || is_mintty)
                                set_option_value((char_u *)"ttym", 0L,
                                                          (char_u *)"sgr", 0);
                            // if xterm version >= 95 use mouse dragging
--- 4707,4727 ----
                                is_not_xterm = TRUE;
                        }
  
+                       // screen sends 83;40500;0 83 is 'S' in ASCII.
+                       if (arg[0] == 83)
+                           is_screen = TRUE;
+ 
                        // Only set 'ttymouse' automatically if it was not set
                        // by the user already.
                        if (!option_was_set((char_u *)"ttym"))
                        {
                            // Xterm version 277 supports SGR.  Also support
!                           // Terminal.app, iTerm2, mintty, and screen 4.7+.
!                           if ((!is_screen && version >= 277)
!                                   || is_iterm2
!                                   || is_mac_terminal
!                                   || is_mintty
!                                   || (is_screen && arg[1] >= 40700))
                                set_option_value((char_u *)"ttym", 0L,
                                                          (char_u *)"sgr", 0);
                            // if xterm version >= 95 use mouse dragging
*** ../vim-8.1.2173/src/testdir/test_termcodes.vim      2019-10-17 
21:55:19.739199454 +0200
--- src/testdir/test_termcodes.vim      2019-10-18 21:19:46.320631611 +0200
***************
*** 882,891 ****
    set t_RV=
  endfunc
  
  " This checks the libvterm version response.
  " This must be after other tests, because it has side effects to xterm
  " properties.
! func Test_xx02_libvterm_response()
    " Termresponse is only parsed when t_RV is not empty.
    set t_RV=x
  
--- 882,916 ----
    set t_RV=
  endfunc
  
+ " This checks the iTerm2 version response.
+ " This must be after other tests, because it has side effects to xterm
+ " properties.
+ func Test_xx02_iTerm2_response()
+   " Termresponse is only parsed when t_RV is not empty.
+   set t_RV=x
+ 
+   " Old versions of iTerm2 used a different style term response.
+   set ttymouse=xterm
+   call test_option_not_set('ttymouse')
+   let seq = "\<Esc>[>0;95;c"
+   call feedkeys(seq, 'Lx!')
+   call assert_equal(seq, v:termresponse)
+   call assert_equal('xterm', &ttymouse)
+ 
+   set ttymouse=xterm
+   call test_option_not_set('ttymouse')
+   let seq = "\<Esc>[>0;95;0c"
+   call feedkeys(seq, 'Lx!')
+   call assert_equal(seq, v:termresponse)
+   call assert_equal('sgr', &ttymouse)
+ 
+   set t_RV=
+ endfunc
+ 
  " This checks the libvterm version response.
  " This must be after other tests, because it has side effects to xterm
  " properties.
! func Test_xx03_libvterm_response()
    " Termresponse is only parsed when t_RV is not empty.
    set t_RV=x
  
***************
*** 899,908 ****
    set t_RV=
  endfunc
  
  " This checks the xterm version response.
  " This must be after other tests, because it has side effects to xterm
  " properties.
! func Test_xx03_xterm_response()
    " Termresponse is only parsed when t_RV is not empty.
    set t_RV=x
  
--- 924,996 ----
    set t_RV=
  endfunc
  
+ " This checks the Mac Terminal.app version response.
+ " This must be after other tests, because it has side effects to xterm
+ " properties.
+ func Test_xx04_Mac_Terminal_response()
+   " Termresponse is only parsed when t_RV is not empty.
+   set t_RV=x
+ 
+   set ttymouse=xterm
+   call test_option_not_set('ttymouse')
+   let seq = "\<Esc>[>1;95;0c"
+   call feedkeys(seq, 'Lx!')
+   call assert_equal(seq, v:termresponse)
+   call assert_equal('sgr', &ttymouse)
+ 
+   " Reset is_not_xterm and is_mac_terminal.
+   set t_RV=
+   set term=xterm
+   set t_RV=x
+ endfunc
+ 
+ " This checks the mintty version response.
+ " This must be after other tests, because it has side effects to xterm
+ " properties.
+ func Test_xx05_mintty_response()
+   " Termresponse is only parsed when t_RV is not empty.
+   set t_RV=x
+ 
+   set ttymouse=xterm
+   call test_option_not_set('ttymouse')
+   let seq = "\<Esc>[>77;20905;0c"
+   call feedkeys(seq, 'Lx!')
+   call assert_equal(seq, v:termresponse)
+   call assert_equal('sgr', &ttymouse)
+ 
+   set t_RV=
+ endfunc
+ 
+ " This checks the screen version response.
+ " This must be after other tests, because it has side effects to xterm
+ " properties.
+ func Test_xx06_screen_response()
+   " Termresponse is only parsed when t_RV is not empty.
+   set t_RV=x
+ 
+   " Old versions of screen don't support SGR mouse mode.
+   set ttymouse=xterm
+   call test_option_not_set('ttymouse')
+   let seq = "\<Esc>[>83;40500;0c"
+   call feedkeys(seq, 'Lx!')
+   call assert_equal(seq, v:termresponse)
+   call assert_equal('xterm', &ttymouse)
+ 
+   " screen supports SGR mouse mode starting in version 4.7.
+   set ttymouse=xterm
+   call test_option_not_set('ttymouse')
+   let seq = "\<Esc>[>83;40700;0c"
+   call feedkeys(seq, 'Lx!')
+   call assert_equal(seq, v:termresponse)
+   call assert_equal('sgr', &ttymouse)
+ 
+   set t_RV=
+ endfunc
+ 
  " This checks the xterm version response.
  " This must be after other tests, because it has side effects to xterm
  " properties.
! func Test_xx07_xterm_response()
    " Termresponse is only parsed when t_RV is not empty.
    set t_RV=x
  
***************
*** 944,951 ****
    set t_RV=
  endfunc
  
- " TODO: check other terminals response
- 
  func Test_get_termcode()
    try
      let k1 = &t_k1
--- 1032,1037 ----
*** ../vim-8.1.2173/src/version.c       2019-10-18 20:53:30.697741631 +0200
--- src/version.c       2019-10-18 21:21:07.024410282 +0200
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     2174,
  /**/

-- 
Mushrooms always grow in damp places and so they look like umbrellas.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/201910181926.x9IJQgee029051%40masaka.moolenaar.net.

Raspunde prin e-mail lui