|
40 | 40 | * TODO:
|
41 | 41 | * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for
|
42 | 42 | * redirection. Probably in call to channel_set_pipes().
|
43 |
| - * - implement term_setsize() |
44 | 43 | * - add an optional limit for the scrollback size. When reaching it remove
|
45 | 44 | * 10% at the start.
|
46 | 45 | * - 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)
|
4602 | 4601 | list_append_number(l, buf->b_term->tl_cols);
|
4603 | 4602 | }
|
4604 | 4603 |
|
| 4604 | +/* |
| 4605 | + * "term_setsize(buf, rows, cols)" function |
| 4606 | + */ |
| 4607 | + void |
| 4608 | +f_term_setsize(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
| 4609 | +{ |
| 4610 | + buf_T *buf = term_get_buf(argvars, "term_setsize()"); |
| 4611 | + term_T *term; |
| 4612 | + varnumber_T rows, cols; |
| 4613 | + |
| 4614 | + if (buf == NULL || buf->b_term->tl_vterm == NULL) |
| 4615 | + return; |
| 4616 | + term = buf->b_term; |
| 4617 | + rows = get_tv_number(&argvars[1]); |
| 4618 | + rows = rows <= 0 ? term->tl_rows : rows; |
| 4619 | + cols = get_tv_number(&argvars[2]); |
| 4620 | + cols = cols <= 0 ? term->tl_cols : cols; |
| 4621 | + vterm_set_size(term->tl_vterm, rows, cols); |
| 4622 | + /* handle_resize() will resize the windows */ |
| 4623 | + |
| 4624 | + /* Get and remember the size we ended up with. Update the pty. */ |
| 4625 | + vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols); |
| 4626 | + term_report_winsize(term, term->tl_rows, term->tl_cols); |
| 4627 | +} |
| 4628 | + |
4605 | 4629 | /*
|
4606 | 4630 | * "term_getstatus(buf)" function
|
4607 | 4631 | */
|
@@ -5432,7 +5456,7 @@ term_free_vterm(term_T *term)
|
5432 | 5456 | }
|
5433 | 5457 |
|
5434 | 5458 | /*
|
5435 |
| - * Request size to terminal. |
| 5459 | + * Report the size to the terminal. |
5436 | 5460 | */
|
5437 | 5461 | static void
|
5438 | 5462 | term_report_winsize(term_T *term, int rows, int cols)
|
@@ -5514,7 +5538,7 @@ term_free_vterm(term_T *term)
|
5514 | 5538 | }
|
5515 | 5539 |
|
5516 | 5540 | /*
|
5517 |
| - * Request size to terminal. |
| 5541 | + * Report the size to the terminal. |
5518 | 5542 | */
|
5519 | 5543 | static void
|
5520 | 5544 | term_report_winsize(term_T *term, int rows, int cols)
|
|
0 commit comments