aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/terminal.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-27 14:15:08 +0100
committerGitHub <noreply@github.com>2019-01-27 14:15:08 +0100
commit8171e96b9640c54eb67a8e5d1082f1fd6e794f23 (patch)
tree7ef2ee67b4328b7e5478a74bfccc6d5ec6eb8d38 /src/nvim/terminal.c
parentf2398a766e094d74ab19f3037872abbc97c16728 (diff)
parentde16c0bf6445f92f2b6e92ba3253d581e5562178 (diff)
downloadrneovim-8171e96b9640c54eb67a8e5d1082f1fd6e794f23.tar.gz
rneovim-8171e96b9640c54eb67a8e5d1082f1fd6e794f23.tar.bz2
rneovim-8171e96b9640c54eb67a8e5d1082f1fd6e794f23.zip
Merge pull request #9551 from bfredl/multiterm
Fix :terminal resizing, and some multigrid size cleanup
Diffstat (limited to 'src/nvim/terminal.c')
-rw-r--r--src/nvim/terminal.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index eae0f7ca13..6516f46b2f 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -334,41 +334,32 @@ void terminal_close(Terminal *term, char *msg)
}
}
-void terminal_resize(Terminal *term, uint16_t width, uint16_t height)
+void terminal_check_size(Terminal *term)
{
if (term->closed) {
- // If two windows display the same terminal and one is closed by keypress.
return;
}
- bool force = width == UINT16_MAX || height == UINT16_MAX;
+
int curwidth, curheight;
vterm_get_size(term->vt, &curheight, &curwidth);
+ uint16_t width = 0, height = 0;
- if (force || !width) {
- width = (uint16_t)curwidth;
- }
-
- if (force || !height) {
- height = (uint16_t)curheight;
- }
-
- if (!force && curheight == height && curwidth == width) {
- return;
- }
-
- if (height == 0 || width == 0) {
- return;
- }
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (wp->w_buffer && wp->w_buffer->terminal == term) {
const uint16_t win_width =
- (uint16_t)(MAX(0, wp->w_width - win_col_off(wp)));
+ (uint16_t)(MAX(0, wp->w_width_inner - win_col_off(wp)));
width = MAX(width, win_width);
- height = (uint16_t)MAX(height, wp->w_height);
+ height = (uint16_t)MAX(height, wp->w_height_inner);
}
}
+ // if no window displays the terminal, or such all windows are zero-height,
+ // don't resize the terminal.
+ if ((curheight == height && curwidth == width) || height == 0 || width == 0) {
+ return;
+ }
+
vterm_set_size(term->vt, height, width);
vterm_screen_flush_damage(term->vts);
term->pending_resize = true;
@@ -383,8 +374,10 @@ void terminal_enter(void)
memset(s, 0, sizeof(TerminalState));
s->term = buf->terminal;
- // Ensure the terminal is properly sized.
- terminal_resize(s->term, 0, 0);
+ // Ensure the terminal is properly sized. Ideally window size management
+ // code should always have resized the terminal already, but check here to
+ // be sure.
+ terminal_check_size(s->term);
int save_state = State;
s->save_rd = RedrawingDisabled;