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

@@ -428,74 +428,41 @@ int update_screen(void)
msg_grid.cols, false);
}
}
if (msg_use_msgsep()) {
msg_grid.throttled = false;
bool was_invalidated = false;
msg_grid.throttled = false;
bool was_invalidated = false;
// UPD_CLEAR is already handled
if (type == UPD_NOT_VALID && !ui_has(kUIMultigrid) && msg_scrolled) {
was_invalidated = ui_comp_set_screen_valid(false);
for (int i = valid; i < Rows - p_ch; i++) {
grid_clear_line(&default_grid, default_grid.line_offset[i],
Columns, false);
// UPD_CLEAR is already handled
if (type == UPD_NOT_VALID && !ui_has(kUIMultigrid) && msg_scrolled) {
was_invalidated = ui_comp_set_screen_valid(false);
for (int i = valid; i < Rows - p_ch; i++) {
grid_clear_line(&default_grid, default_grid.line_offset[i],
Columns, false);
}
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_floating) {
continue;
}
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_floating) {
continue;
}
if (W_ENDROW(wp) > valid) {
// TODO(bfredl): too pessimistic. type could be UPD_NOT_VALID
// only because windows that are above the separator.
wp->w_redr_type = MAX(wp->w_redr_type, UPD_NOT_VALID);
}
if (!is_stl_global && W_ENDROW(wp) + wp->w_status_height > valid) {
wp->w_redr_status = true;
}
if (W_ENDROW(wp) > valid) {
// TODO(bfredl): too pessimistic. type could be UPD_NOT_VALID
// only because windows that are above the separator.
wp->w_redr_type = MAX(wp->w_redr_type, UPD_NOT_VALID);
}
if (is_stl_global && Rows - p_ch - 1 > valid) {
curwin->w_redr_status = true;
if (!is_stl_global && W_ENDROW(wp) + wp->w_status_height > valid) {
wp->w_redr_status = true;
}
}
msg_grid_set_pos(Rows - (int)p_ch, false);
msg_grid_invalid = false;
if (was_invalidated) {
// screen was only invalid for the msgarea part.
// @TODO(bfredl): using the same "valid" flag
// for both messages and floats moving is bit of a mess.
ui_comp_set_screen_valid(true);
}
} else if (type != UPD_CLEAR) {
if (msg_scrolled > Rows - 5) { // redrawing is faster
type = UPD_NOT_VALID;
} else {
check_for_delay(false);
grid_ins_lines(&default_grid, 0, msg_scrolled, Rows, 0, Columns);
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_floating) {
continue;
}
if (wp->w_winrow < msg_scrolled) {
if (W_ENDROW(wp) > msg_scrolled
&& wp->w_redr_type < UPD_REDRAW_TOP
&& wp->w_lines_valid > 0
&& wp->w_topline == wp->w_lines[0].wl_lnum) {
wp->w_upd_rows = msg_scrolled - wp->w_winrow;
wp->w_redr_type = UPD_REDRAW_TOP;
} else {
wp->w_redr_type = UPD_NOT_VALID;
if (wp->w_winrow + wp->w_winbar_height <= msg_scrolled) {
wp->w_redr_status = true;
}
}
}
}
if (is_stl_global && Rows - p_ch - 1 <= msg_scrolled) {
curwin->w_redr_status = true;
}
redraw_cmdline = true;
redraw_tabline = true;
if (is_stl_global && Rows - p_ch - 1 > valid) {
curwin->w_redr_status = true;
}
}
msg_grid_set_pos(Rows - (int)p_ch, false);
msg_grid_invalid = false;
if (was_invalidated) {
// screen was only invalid for the msgarea part.
// @TODO(bfredl): using the same "valid" flag
// for both messages and floats moving is bit of a mess.
ui_comp_set_screen_valid(true);
}
msg_scrolled = 0;
msg_scrolled_at_flush = 0;
need_wait_return = false;
@@ -526,9 +493,8 @@ int update_screen(void)
default_grid.valid = true;
}
// After disabling msgsep the grid might not have been deallocated yet,
// hence we also need to check msg_grid.chars
if (type == UPD_NOT_VALID && (msg_use_grid() || msg_grid.chars)) {
// might need to clear space on default_grid for the message area.
if (type == UPD_NOT_VALID && clear_cmdline && !ui_has(kUIMessages)) {
grid_fill(&default_grid, Rows - (int)p_ch, Rows, 0, Columns, ' ', ' ', 0);
}

View File

@@ -6124,9 +6124,6 @@ static void ex_redrawstatus(exarg_T *eap)
} else {
status_redraw_curbuf();
}
if (msg_scrolled && !msg_use_msgsep() && (State & MODE_CMDLINE)) {
return; // redraw later
}
RedrawingDisabled = 0;
p_lz = false;

View File

@@ -775,7 +775,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
// Redraw the statusline in case it uses the current mode using the mode()
// function.
if (!cmd_silent && (msg_scrolled == 0 || msg_use_msgsep())) {
if (!cmd_silent) {
bool found_one = false;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {

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;

View File

@@ -492,7 +492,7 @@ EXTERN unsigned dy_flags;
#define DY_LASTLINE 0x001
#define DY_TRUNCATE 0x002
#define DY_UHEX 0x004
// code should use msg_use_msgsep() to check if msgsep is active
// legacy flag, not used
#define DY_MSGSEP 0x008
EXTERN int p_ed; // 'edcompatible'
EXTERN char *p_ead; // 'eadirection'

View File

@@ -660,7 +660,7 @@ return {
deny_duplicates=true,
redraw={'all_windows'},
varname='p_dy',
defaults={if_true="lastline,msgsep"}
defaults={if_true="lastline"}
},
{
full_name='eadirection', abbreviation='ead',