diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-04-14 17:05:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-04-14 17:05:38 +0200 |
commit | a42d363bac8a581afe769c370db70cf833767c41 (patch) | |
tree | 9ba9d168dbd46f4bfdffced3e447f7c728c2ee0c /src | |
parent | 2a43230ce39eea340aab15fb50a083bc527fb8d0 (diff) |
patch 8.0.1711: term_setsize() is not implemented yetv8.0.1711
Problem: Term_setsize() is not implemented yet.
Solution: Implement it.
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 1 | ||||
-rw-r--r-- | src/proto/terminal.pro | 3 | ||||
-rw-r--r-- | src/terminal.c | 30 | ||||
-rw-r--r-- | src/testdir/test_terminal.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 43 insertions, 6 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 4b09951852..599d61ab81 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -876,6 +876,7 @@ static struct fst # endif {"term_setkill", 2, 2, f_term_setkill}, {"term_setrestore", 2, 2, f_term_setrestore}, + {"term_setsize", 3, 3, f_term_setsize}, {"term_start", 1, 2, f_term_start}, {"term_wait", 1, 2, f_term_wait}, #endif diff --git a/src/proto/terminal.pro b/src/proto/terminal.pro index f7cea5a161..78b640f7a5 100644 --- a/src/proto/terminal.pro +++ b/src/proto/terminal.pro @@ -32,19 +32,20 @@ int term_swap_diff(void); void f_term_dumpdiff(typval_T *argvars, typval_T *rettv); void f_term_dumpload(typval_T *argvars, typval_T *rettv); void f_term_getaltscreen(typval_T *argvars, typval_T *rettv); -void f_term_getansicolors(typval_T *argvars, typval_T *rettv); void f_term_getattr(typval_T *argvars, typval_T *rettv); void f_term_getcursor(typval_T *argvars, typval_T *rettv); void f_term_getjob(typval_T *argvars, typval_T *rettv); void f_term_getline(typval_T *argvars, typval_T *rettv); void f_term_getscrolled(typval_T *argvars, typval_T *rettv); void f_term_getsize(typval_T *argvars, typval_T *rettv); +void f_term_setsize(typval_T *argvars, typval_T *rettv); void f_term_getstatus(typval_T *argvars, typval_T *rettv); void f_term_gettitle(typval_T *argvars, typval_T *rettv); void f_term_gettty(typval_T *argvars, typval_T *rettv); void f_term_list(typval_T *argvars, typval_T *rettv); void f_term_scrape(typval_T *argvars, typval_T *rettv); void f_term_sendkeys(typval_T *argvars, typval_T *rettv); +void f_term_getansicolors(typval_T *argvars, typval_T *rettv); void f_term_setansicolors(typval_T *argvars, typval_T *rettv); void f_term_setrestore(typval_T *argvars, typval_T *rettv); void f_term_setkill(typval_T *argvars, typval_T *rettv); diff --git a/src/terminal.c b/src/terminal.c index f980a09929..09d48872da 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -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 @@ -4603,6 +4602,31 @@ f_term_getsize(typval_T *argvars, typval_T *rettv) } /* + * "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 */ void @@ -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) diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index e97ee06910..137de7ddd6 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -286,9 +286,18 @@ func Test_terminal_size() vsplit exe 'terminal ++rows=5 ++cols=33 ' . cmd - let size = term_getsize('') + call assert_equal([5, 33], term_getsize('')) + + call term_setsize('', 6, 0) + call assert_equal([6, 33], term_getsize('')) + + call term_setsize('', 0, 35) + call assert_equal([6, 35], term_getsize('')) + + call term_setsize('', 7, 30) + call assert_equal([7, 30], term_getsize('')) + bwipe! - call assert_equal([5, 33], size) call term_start(cmd, {'term_rows': 6, 'term_cols': 36}) let size = term_getsize('') diff --git a/src/version.c b/src/version.c index b340f11701..255e24bd98 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1711, +/**/ 1710, /**/ 1709, |