Patch 8.0.1277
Problem:    Terminal window CR-NL conversions may cause problems.
Solution:   Avoid most conversions, only fetch the current backspace key value
            from the tty. (mostly by Ozaki Kiichi, closes #2278)
Files:      src/terminal.c


*** ../vim-8.0.1276/src/terminal.c      2017-11-09 13:21:53.332924026 +0100
--- src/terminal.c      2017-11-09 17:20:21.448794603 +0100
***************
*** 181,191 ****
  static void term_report_winsize(term_T *term, int rows, int cols);
  static void term_free_vterm(term_T *term);
  
! /* The characters that we know (or assume) that the terminal expects for the
!  * backspace and enter keys. */
  static int term_backspace_char = BS;
- static int term_enter_char = CAR;
- static int term_nl_does_cr = FALSE;
  
  
  /**************************************
--- 181,189 ----
  static void term_report_winsize(term_T *term, int rows, int cols);
  static void term_free_vterm(term_T *term);
  
! /* The character that we know (or assume) that the terminal expects for the
!  * backspace key. */
  static int term_backspace_char = BS;
  
  
  /**************************************
***************
*** 651,680 ****
  term_write_job_output(term_T *term, char_u *msg, size_t len)
  {
      VTerm     *vterm = term->tl_vterm;
-     char_u    *p;
-     size_t    done;
-     size_t    len_now;
  
!     if (term_nl_does_cr)
!       vterm_input_write(vterm, (char *)msg, len);
!     else
!       /* need to convert NL to CR-NL */
!       for (done = 0; done < len; done += len_now)
!       {
!           for (p = msg + done; p < msg + len; )
!           {
!               if (*p == NL)
!                   break;
!               p += utf_ptr2len_len(p, (int)(len - (p - msg)));
!           }
!           len_now = p - msg - done;
!           vterm_input_write(vterm, (char *)msg + done, len_now);
!           if (p < msg + len && *p == NL)
!           {
!               vterm_input_write(vterm, "\r\n", 2);
!               ++len_now;
!           }
!       }
  
      /* this invokes the damage callbacks */
      vterm_screen_flush_damage(vterm_obtain_screen(vterm));
--- 649,656 ----
  term_write_job_output(term_T *term, char_u *msg, size_t len)
  {
      VTerm     *vterm = term->tl_vterm;
  
!     vterm_input_write(vterm, (char *)msg, len);
  
      /* this invokes the damage callbacks */
      vterm_screen_flush_damage(vterm_obtain_screen(vterm));
***************
*** 760,766 ****
  
      switch (c)
      {
!       case CAR:               c = term_enter_char; break;
                                /* don't use VTERM_KEY_BACKSPACE, it always
                                 * becomes 0x7f DEL */
        case K_BS:              c = term_backspace_char; break;
--- 736,743 ----
  
      switch (c)
      {
!       /* don't use VTERM_KEY_ENTER, it may do an unwanted conversion */
! 
                                /* don't use VTERM_KEY_BACKSPACE, it always
                                 * becomes 0x7f DEL */
        case K_BS:              c = term_backspace_char; break;
***************
*** 1534,1540 ****
      int               termkey = 0;
      int               ret;
  #ifdef UNIX
!     int               tty_fd = 
curbuf->b_term->tl_job->jv_channel->ch_part[get_tty_part(curbuf->b_term)].ch_fd;
  #endif
  
      /* Remember the terminal we are sending keys to.  However, the terminal
--- 1511,1518 ----
      int               termkey = 0;
      int               ret;
  #ifdef UNIX
!     int               tty_fd = curbuf->b_term->tl_job->jv_channel
!                                ->ch_part[get_tty_part(curbuf->b_term)].ch_fd;
  #endif
  
      /* Remember the terminal we are sending keys to.  However, the terminal
***************
*** 1557,1593 ****
                break;
        update_cursor(curbuf->b_term, FALSE);
  
  #ifdef UNIX
        /*
         * The shell or another program may change the tty settings.  Getting
         * them for every typed character is a bit of overhead, but it's needed
!        * for the first CR typed, e.g. when Vim starts in a shell.
         */
        if (isatty(tty_fd))
        {
            ttyinfo_T info;
  
!           /* Get the current backspace and enter characters of the pty. */
            if (get_tty_info(tty_fd, &info) == OK)
-           {
                term_backspace_char = info.backspace;
-               term_enter_char = info.enter;
-               term_nl_does_cr = info.nl_does_cr;
-           }
        }
  #endif
  
-       c = term_vgetc();
-       if (!term_use_loop())
-       {
-           /* job finished while waiting for a character */
-           if (c != K_IGNORE)
-               vungetc(c);
-           break;
-       }
-       if (c == K_IGNORE)
-           continue;
- 
  #ifdef WIN3264
        /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
         * Use CTRL-BREAK to kill the job. */
--- 1535,1568 ----
                break;
        update_cursor(curbuf->b_term, FALSE);
  
+       c = term_vgetc();
+       if (!term_use_loop())
+       {
+           /* Job finished while waiting for a character.  Push back the
+            * received character. */
+           if (c != K_IGNORE)
+               vungetc(c);
+           break;
+       }
+       if (c == K_IGNORE)
+           continue;
+ 
  #ifdef UNIX
        /*
         * The shell or another program may change the tty settings.  Getting
         * them for every typed character is a bit of overhead, but it's needed
!        * for the first character typed, e.g. when Vim starts in a shell.
         */
        if (isatty(tty_fd))
        {
            ttyinfo_T info;
  
!           /* Get the current backspace character of the pty. */
            if (get_tty_info(tty_fd, &info) == OK)
                term_backspace_char = info.backspace;
        }
  #endif
  
  #ifdef WIN3264
        /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
         * Use CTRL-BREAK to kill the job. */
*** ../vim-8.0.1276/src/version.c       2017-11-09 13:21:53.332924026 +0100
--- src/version.c       2017-11-09 17:32:25.037942458 +0100
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1277,
  /**/

-- 
./configure
Checking whether build environment is sane ...
build environment is grinning and holding a spatula.  Guess not.

 /// 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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui