feat(messages)!: graduate the 'msgsep' feature

The old behaviour (e.g. via `set display-=msgsep`) will not be available.
Assuming that messages always are being drawn on msg_grid
(or not drawn at all, and forwarded to `ext_messages` enabled UI)
will allows some simplifcations and enhancements moving forward.
This commit is contained in:
bfredl
2022-09-27 16:19:15 +02:00
parent cce0840cbf
commit 6ae144a921
18 changed files with 77 additions and 418 deletions

View File

@@ -153,8 +153,7 @@ void msg_grid_set_pos(int row, bool scrolled)
bool msg_use_grid(void)
{
return default_grid.chars && msg_use_msgsep()
&& !ui_has(kUIMessages);
return default_grid.chars && !ui_has(kUIMessages);
}
void msg_grid_validate(void)
@@ -172,19 +171,17 @@ void msg_grid_validate(void)
xfree(msg_grid.dirty_col);
msg_grid.dirty_col = xcalloc((size_t)Rows, sizeof(*msg_grid.dirty_col));
// Tricky: allow resize while pager is active
int pos = msg_scrolled ? msg_grid_pos : max_rows;
// Tricky: allow resize while pager or ex mode is active
int pos = MAX(max_rows - msg_scrolled, 0);
msg_grid.throttled = false; // don't throttle in 'cmdheight' area
msg_grid_set_pos(pos, msg_scrolled);
ui_comp_put_grid(&msg_grid, pos, 0, msg_grid.rows, msg_grid.cols,
false, true);
ui_call_grid_resize(msg_grid.handle, msg_grid.cols, msg_grid.rows);
msg_grid.throttled = false; // don't throttle in 'cmdheight' area
msg_scrolled_at_flush = msg_scrolled;
msg_grid.focusable = false;
msg_grid_adj.target = &msg_grid;
if (!msg_scrolled) {
msg_grid_set_pos(max_rows, false);
}
} else if (!should_alloc && msg_grid.chars) {
ui_comp_remove_grid(&msg_grid);
grid_free(&msg_grid);
@@ -2336,13 +2333,6 @@ int msg_scrollsize(void)
return msg_scrolled + (int)p_ch + ((p_ch > 0 || msg_scrolled > 1) ? 1 : 0);
}
bool msg_use_msgsep(void)
{
// the full-screen scroll behavior doesn't really make sense with
// 'ext_multigrid'
return (dy_flags & DY_MSGSEP) || p_ch == 0 || ui_has(kUIMultigrid);
}
bool msg_do_throttle(void)
{
return msg_use_grid() && !(rdb_flags & RDB_NOTHROTTLE);
@@ -2355,23 +2345,19 @@ void msg_scroll_up(bool may_throttle, bool zerocmd)
msg_grid.throttled = true;
}
msg_did_scroll = true;
if (msg_use_msgsep()) {
if (msg_grid_pos > 0) {
msg_grid_set_pos(msg_grid_pos - 1, !zerocmd);
if (msg_grid_pos > 0) {
msg_grid_set_pos(msg_grid_pos - 1, !zerocmd);
// When displaying the first line with cmdheight=0, we need to draw over
// the existing last line of the screen.
if (zerocmd && msg_grid.chars) {
grid_clear_line(&msg_grid, msg_grid.line_offset[0], msg_grid.cols, false);
}
} else {
grid_del_lines(&msg_grid, 0, 1, msg_grid.rows, 0, msg_grid.cols);
memmove(msg_grid.dirty_col, msg_grid.dirty_col + 1,
(size_t)(msg_grid.rows - 1) * sizeof(*msg_grid.dirty_col));
msg_grid.dirty_col[msg_grid.rows - 1] = 0;
// When displaying the first line with cmdheight=0, we need to draw over
// the existing last line of the screen.
if (zerocmd && msg_grid.chars) {
grid_clear_line(&msg_grid, msg_grid.line_offset[0], msg_grid.cols, false);
}
} else {
grid_del_lines(&msg_grid_adj, 0, 1, Rows, 0, Columns);
grid_del_lines(&msg_grid, 0, 1, msg_grid.rows, 0, msg_grid.cols);
memmove(msg_grid.dirty_col, msg_grid.dirty_col + 1,
(size_t)(msg_grid.rows - 1) * sizeof(*msg_grid.dirty_col));
msg_grid.dirty_col[msg_grid.rows - 1] = 0;
}
grid_fill(&msg_grid_adj, Rows - 1, Rows, 0, Columns, ' ', ' ', HL_ATTR(HLF_MSG));
@@ -2436,21 +2422,17 @@ void msg_reset_scroll(void)
}
// TODO(bfredl): some duplicate logic with update_screen(). Later on
// we should properly disentangle message clear with full screen redraw.
if (msg_use_grid()) {
msg_grid.throttled = false;
// TODO(bfredl): risk for extra flicker i e with
// "nvim -o has_swap also_has_swap"
msg_grid_set_pos(Rows - (int)p_ch, false);
clear_cmdline = true;
if (msg_grid.chars) {
// non-displayed part of msg_grid is considered invalid.
for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.rows); i++) {
grid_clear_line(&msg_grid, msg_grid.line_offset[i],
msg_grid.cols, false);
}
msg_grid.throttled = false;
// TODO(bfredl): risk for extra flicker i e with
// "nvim -o has_swap also_has_swap"
msg_grid_set_pos(Rows - (int)p_ch, false);
clear_cmdline = true;
if (msg_grid.chars) {
// non-displayed part of msg_grid is considered invalid.
for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.rows); i++) {
grid_clear_line(&msg_grid, msg_grid.line_offset[i],
msg_grid.cols, false);
}
} else {
redraw_all_later(UPD_NOT_VALID);
}
msg_scrolled = 0;
msg_scrolled_at_flush = 0;