aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/popupmnu.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-20 21:23:17 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-02-07 16:43:51 +0100
commit37f8df882463431888dbaf205ce3ea6488cf4702 (patch)
tree4ebb1634d1d0e16ae3d16d56c22e63602ef0efe4 /src/nvim/popupmnu.c
parented0e96cd28f870c4a580c9e8ab74340fecc90fcb (diff)
downloadrneovim-37f8df882463431888dbaf205ce3ea6488cf4702.tar.gz
rneovim-37f8df882463431888dbaf205ce3ea6488cf4702.tar.bz2
rneovim-37f8df882463431888dbaf205ce3ea6488cf4702.zip
UI: implement 'pumblend' option for semi-transparent popupmenu
Why? - Because we can. - Because the TUI is just another GUI™ - Because it looks kinda nice, and provides useful context like 1 out of 100 times Complies with "don't pay for what you don't use". Some crashes for resizing were unfolded, add tests for those.
Diffstat (limited to 'src/nvim/popupmnu.c')
-rw-r--r--src/nvim/popupmnu.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 9b09006b5f..3c10b7ae0f 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -44,6 +44,7 @@ static int pum_col; // left column of pum
static bool pum_is_visible = false;
static bool pum_is_drawn = false;
static bool pum_external = false;
+static bool pum_invalid = false; // the screen was just cleared
static ScreenGrid pum_grid = SCREEN_GRID_INIT;
@@ -360,12 +361,14 @@ void pum_redraw(void)
grid_assign_handle(&pum_grid);
bool moved = ui_comp_put_grid(&pum_grid, pum_row, pum_col-col_off,
pum_height, grid_width);
+ bool invalid_grid = moved || pum_invalid;
+ pum_invalid = false;
if (!pum_grid.chars
|| pum_grid.Rows != pum_height || pum_grid.Columns != grid_width) {
- grid_alloc(&pum_grid, pum_height, grid_width, !moved, false);
+ grid_alloc(&pum_grid, pum_height, grid_width, !invalid_grid, false);
ui_call_grid_resize(pum_grid.handle, pum_grid.Columns, pum_grid.Rows);
- } else if (moved) {
+ } else if (invalid_grid) {
grid_invalidate(&pum_grid);
}
@@ -806,6 +809,17 @@ bool pum_drawn(void)
return pum_visible() && !pum_external;
}
+/// Screen was cleared, need to redraw next time
+void pum_invalidate(void)
+{
+ pum_invalid = true;
+}
+
+void pum_recompose(void)
+{
+ ui_comp_compose_grid(&pum_grid);
+}
+
/// Gets the height of the menu.
///
/// @return the height of the popup menu, the number of entries visible.