mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
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.
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user