Mercurial > vim
diff src/os_unix.c @ 11741:b4d8f956eb18 v8.0.0753
patch 8.0.0753: no size reports to a job running in a terminal
commit https://github.com/vim/vim/commit/b13501f7dada4154fc7633d79989d1dab98ae99d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 22 22:32:56 2017 +0200
patch 8.0.0753: no size reports to a job running in a terminal
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 22 Jul 2017 22:45:04 +0200 |
parents | d06f3576823a |
children | bf8cfdcdbdd8 |
line wrap: on
line diff
--- a/src/os_unix.c +++ b/src/os_unix.c @@ -3918,6 +3918,44 @@ mch_get_shellsize(void) 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,6 +5511,10 @@ mch_stop_job(job_T *job, char_u *how) 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