diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-07-22 22:32:56 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-07-22 22:32:56 +0200 |
commit | b13501f7dada4154fc7633d79989d1dab98ae99d (patch) | |
tree | 097de64eb33e7c336cd83b15491316256181950e /src/os_unix.c | |
parent | d7d3cbedb3dc5c843724430539ad52ddafcefc93 (diff) | |
download | vim-git-b13501f7dada4154fc7633d79989d1dab98ae99d.tar.gz |
patch 8.0.0753: no size reports to a job running in a terminalv8.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.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 4caf38bb4..f2ab7b15e 100644 --- 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 |