1
0
forked from aniani/vim

patch 8.0.1711: term_setsize() is not implemented yet

Problem:    Term_setsize() is not implemented yet.
Solution:   Implement it.
This commit is contained in:
Bram Moolenaar
2018-04-14 17:05:38 +02:00
parent 2a43230ce3
commit a42d363bac
6 changed files with 70 additions and 8 deletions

View File

@@ -40,7 +40,6 @@
* TODO:
* - Win32: Make terminal used for :!cmd in the GUI work better. Allow for
* redirection. Probably in call to channel_set_pipes().
* - implement term_setsize()
* - add an optional limit for the scrollback size. When reaching it remove
* 10% at the start.
* - Copy text in the vterm to the Vim buffer once in a while, so that
@@ -4602,6 +4601,31 @@ f_term_getsize(typval_T *argvars, typval_T *rettv)
list_append_number(l, buf->b_term->tl_cols);
}
/*
* "term_setsize(buf, rows, cols)" function
*/
void
f_term_setsize(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
buf_T *buf = term_get_buf(argvars, "term_setsize()");
term_T *term;
varnumber_T rows, cols;
if (buf == NULL || buf->b_term->tl_vterm == NULL)
return;
term = buf->b_term;
rows = get_tv_number(&argvars[1]);
rows = rows <= 0 ? term->tl_rows : rows;
cols = get_tv_number(&argvars[2]);
cols = cols <= 0 ? term->tl_cols : cols;
vterm_set_size(term->tl_vterm, rows, cols);
/* handle_resize() will resize the windows */
/* Get and remember the size we ended up with. Update the pty. */
vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols);
term_report_winsize(term, term->tl_rows, term->tl_cols);
}
/*
* "term_getstatus(buf)" function
*/
@@ -5432,7 +5456,7 @@ term_free_vterm(term_T *term)
}
/*
* Request size to terminal.
* Report the size to the terminal.
*/
static void
term_report_winsize(term_T *term, int rows, int cols)
@@ -5514,7 +5538,7 @@ term_free_vterm(term_T *term)
}
/*
* Request size to terminal.
* Report the size to the terminal.
*/
static void
term_report_winsize(term_T *term, int rows, int cols)