aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-26 12:37:38 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-01-27 12:07:06 +0100
commit30bd1c1e85d2fcffa24a87803bec3070e52c7c7e (patch)
tree4a959f9ee8a6050bc7755cc169be5079724c574b /src
parent2ab70cb55c80b17fb4100dd7f2d056131c02b08b (diff)
downloadrneovim-30bd1c1e85d2fcffa24a87803bec3070e52c7c7e.tar.gz
rneovim-30bd1c1e85d2fcffa24a87803bec3070e52c7c7e.tar.bz2
rneovim-30bd1c1e85d2fcffa24a87803bec3070e52c7c7e.zip
terminal: handle size when switching buffers in window
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/buffer_defs.h3
-rw-r--r--src/nvim/ex_cmds.c4
-rw-r--r--src/nvim/move.c3
-rw-r--r--src/nvim/terminal.c7
-rw-r--r--src/nvim/ui.c4
-rw-r--r--src/nvim/window.c2
7 files changed, 19 insertions, 8 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index c15a6f1330..18706f0cbb 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1472,6 +1472,10 @@ void set_curbuf(buf_T *buf, int action)
if (old_tw != curbuf->b_p_tw)
check_colorcolumn(curwin);
}
+
+ if (bufref_valid(&prevbufref) && prevbuf->terminal != NULL) {
+ terminal_check_size(prevbuf->terminal);
+ }
}
/*
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 85043a2a35..076d1dfdc4 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -1034,10 +1034,13 @@ struct window_S {
int w_width; /* Width of window, excluding separation. */
int w_vsep_width; /* Number of separator columns (0 or 1). */
+ // inner size of window, which can be overriden by external UI
int w_height_inner;
int w_width_inner;
+ // external UI request. If non-zero, the inner size will use this.
int w_height_request;
int w_width_request;
+
/*
* === start of cached values ====
*/
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index fe17314b8d..abdf411fc3 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2678,6 +2678,10 @@ int do_ecmd(
theend:
+ if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->terminal != NULL) {
+ terminal_check_size(old_curbuf.br_buf->terminal);
+ }
+
if (did_inc_redrawing_disabled) {
RedrawingDisabled--;
}
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 44ca10d11b..610fd04ebc 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1452,7 +1452,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
curwin->w_topline = loff.lnum) {
loff.lnum = curwin->w_topline;
topline_back(&loff);
- if (loff.height == MAXCOL || used + loff.height > curwin->w_height_inner) {
+ if (loff.height == MAXCOL
+ || used + loff.height > curwin->w_height_inner) {
break;
}
used += loff.height;
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index e2e3bc5f30..6516f46b2f 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -337,19 +337,16 @@ void terminal_close(Terminal *term, char *msg)
void terminal_check_size(Terminal *term)
{
if (term->closed) {
- // TODO: WTF does this mean:
- // If two windows display the same terminal and one is closed by keypress.
return;
}
+
int curwidth, curheight;
vterm_get_size(term->vt, &curheight, &curwidth);
uint16_t width = 0, height = 0;
- bool window_seen = false;
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (wp->w_buffer && wp->w_buffer->terminal == term) {
- window_seen = true;
const uint16_t win_width =
(uint16_t)(MAX(0, wp->w_width_inner - win_col_off(wp)));
width = MAX(width, win_width);
@@ -357,6 +354,8 @@ void terminal_check_size(Terminal *term)
}
}
+ // 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;
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index ec0cfb6caa..b65f3be746 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -453,7 +453,7 @@ void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error)
}
// non-positive indicates no request
- wp->w_height_request = (int)MAX(height,0);
- wp->w_width_request = (int)MAX(width,0);
+ wp->w_height_request = (int)MAX(height, 0);
+ wp->w_width_request = (int)MAX(width, 0);
win_set_inner_size(wp);
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 36d780a661..0edb04f028 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4126,7 +4126,7 @@ void win_alloc_lines(win_T *wp)
{
wp->w_lines_valid = 0;
assert(wp->w_height_inner >= 0);
- // TODO(bfredl) :this should work, add call to win_set_inner_size?
+ // TODO(bfredl): this should work, add call to win_set_inner_size?
// wp->w_lines = xcalloc(wp->w_height_inner+1, sizeof(wline_T));
wp->w_lines = xcalloc(MAX(wp->w_height_inner + 1, Rows), sizeof(wline_T));
}