0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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.
This commit is contained in:
Bram Moolenaar
2017-07-22 22:32:56 +02:00
parent d7d3cbedb3
commit b13501f7da
4 changed files with 74 additions and 7 deletions

View File

@@ -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