Patch 8.0.0753
Problem:    A job running in a terminal does not get notified of changes in
            the terminal size.
Solution:   Use ioctl() and SIGWINCH to report the terminal size.
Files:      src/terminal.c, src/os_unix.c, src/proto/os_unix.pro


*** ../vim-8.0.0752/src/terminal.c      2017-07-22 19:03:28.184044163 +0200
--- src/terminal.c      2017-07-22 22:31:23.014380356 +0200
***************
*** 12,21 ****
   *
   * There are three parts:
   * 1. Generic code for all systems.
   * 2. The MS-Windows implementation.
!  *    Uses a hidden console for the terminal emulator.
   * 3. The Unix-like implementation.
!  *    Uses libvterm for the terminal emulator directly.
   *
   * For each terminal one VTerm is constructed.  This uses libvterm.  A copy of
   * that library is in the libvterm directory.
--- 12,22 ----
   *
   * There are three parts:
   * 1. Generic code for all systems.
+  *    Uses libvterm for the terminal emulator.
   * 2. The MS-Windows implementation.
!  *    Uses winpty.
   * 3. The Unix-like implementation.
!  *    Uses pseudo-tty's (pty's).
   *
   * For each terminal one VTerm is constructed.  This uses libvterm.  A copy of
   * that library is in the libvterm directory.
***************
*** 32,39 ****
   * while, if the terminal window is visible, the screen contents is drawn.
   *
   * TODO:
-  * - When 'termsize' is set and dragging the separator the terminal gets 
messed
-  *   up.
   * - set buffer options to be scratch, hidden, nomodifiable, etc.
   * - set buffer name to command, add (1) to avoid duplicates.
   * - Add a scrollback buffer (contains lines to scroll off the top).
--- 33,38 ----
***************
*** 605,613 ****
       */
      if ((!term->tl_rows_fixed && term->tl_rows != wp->w_height)
            || (!term->tl_cols_fixed && term->tl_cols != wp->w_width))
!       vterm_set_size(vterm,
!               term->tl_rows_fixed ? term->tl_rows : wp->w_height,
!               term->tl_cols_fixed ? term->tl_cols : wp->w_width);
  
      /* The cursor may have been moved when resizing. */
      vterm_state_get_cursorpos(state, &pos);
--- 604,635 ----
       */
      if ((!term->tl_rows_fixed && term->tl_rows != wp->w_height)
            || (!term->tl_cols_fixed && term->tl_cols != wp->w_width))
!     {
!       int rows = term->tl_rows_fixed ? term->tl_rows : wp->w_height;
!       int cols = term->tl_cols_fixed ? term->tl_cols : wp->w_width;
! 
!       vterm_set_size(vterm, rows, cols);
!       ch_logn(term->tl_job->jv_channel, "Resizing terminal to %d lines",
!                                                                        rows);
! 
! #if defined(UNIX)
!       /* Use an ioctl() to report the new window size to the job. */
!       if (term->tl_job != NULL && term->tl_job->jv_channel != NULL)
!       {
!           int fd = -1;
!           int part;
! 
!           for (part = PART_OUT; part < PART_COUNT; ++part)
!           {
!               fd = term->tl_job->jv_channel->ch_part[part].ch_fd;
!               if (isatty(fd))
!                   break;
!           }
!           if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK)
!               mch_stop_job(term->tl_job, (char_u *)"winch");
!       }
! #endif
!     }
  
      /* The cursor may have been moved when resizing. */
      vterm_state_get_cursorpos(state, &pos);
*** ../vim-8.0.0752/src/os_unix.c       2017-07-22 20:33:01.353391250 +0200
--- src/os_unix.c       2017-07-22 22:25:40.444847016 +0200
***************
*** 3918,3923 ****
--- 3918,3961 ----
      return OK;
  }
  
+ #if defined(FEAT_TERMINAL) || defined(PROTO)
+ /*
+  * Report the windows size "rows" and "cols" to tty "fd".
+  */
+     int
+ mch_report_winsize(int fd, int rows, int cols)
+ {
+ # ifdef TIOCSWINSZ
+     struct winsize    ws;
+ 
+     ws.ws_col = cols;
+     ws.ws_row = rows;
+     ws.ws_xpixel = cols * 5;
+     ws.ws_ypixel = rows * 10;
+     if (ioctl(fd, TIOCSWINSZ, &ws) == 0)
+     {
+       ch_log(NULL, "ioctl(TIOCSWINSZ) success");
+       return OK;
+     }
+     ch_log(NULL, "ioctl(TIOCSWINSZ) failed");
+ # else
+ #  ifdef TIOCSSIZE
+     struct ttysize    ts;
+ 
+     ts.ts_cols = cols;
+     ts.ts_lines = rows;
+     if (ioctl(fd, TIOCSSIZE, &ws) == 0)
+     {
+       ch_log(NULL, "ioctl(TIOCSSIZE) success");
+       return OK;
+     }
+     ch_log(NULL, "ioctl(TIOCSSIZE) failed");
+ #  endif
+ # endif
+     return FAIL;
+ }
+ #endif
+ 
  /*
   * Try to set the window size to Rows and Columns.
   */
***************
*** 5473,5478 ****
--- 5511,5520 ----
        sig = SIGINT;
      else if (STRCMP(how, "kill") == 0)
        sig = SIGKILL;
+ #ifdef SIGWINCH
+     else if (STRCMP(how, "winch") == 0)
+       sig = SIGWINCH;
+ #endif
      else if (isdigit(*how))
        sig = atoi((char *)how);
      else
*** ../vim-8.0.0752/src/proto/os_unix.pro       2017-07-22 18:04:04.309865751 
+0200
--- src/proto/os_unix.pro       2017-07-22 22:20:00.483312289 +0200
***************
*** 53,58 ****
--- 53,59 ----
  void check_mouse_termcode(void);
  int mch_screenmode(char_u *arg);
  int mch_get_shellsize(void);
+ int mch_report_winsize(int fd, int rows, int cols);
  void mch_set_shellsize(void);
  void mch_new_shellsize(void);
  int mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc);
*** ../vim-8.0.0752/src/version.c       2017-07-22 21:15:36.975052622 +0200
--- src/version.c       2017-07-22 21:51:18.323737339 +0200
***************
*** 771,772 ****
--- 771,774 ----
  {   /* Add new patch number below this line */
+ /**/
+     753,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
213. Your kids start referring to you as "that guy in front of the monitor."

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui