aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-09-27 16:19:15 +0200
committerbfredl <bjorn.linse@gmail.com>2022-10-05 20:12:59 +0200
commit6ae144a92171cf9ae52bddddc3a081a4efaabe9f (patch)
treed8d62f23bf7e0d673c9f13a206e03a7d930a3d6c /src
parentcce0840cbfc3c4ee9ae1d3fc9b283d557d0204ab (diff)
downloadrneovim-6ae144a92171cf9ae52bddddc3a081a4efaabe9f.tar.gz
rneovim-6ae144a92171cf9ae52bddddc3a081a4efaabe9f.tar.bz2
rneovim-6ae144a92171cf9ae52bddddc3a081a4efaabe9f.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawscreen.c96
-rw-r--r--src/nvim/ex_docmd.c3
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/message.c70
-rw-r--r--src/nvim/option_defs.h2
-rw-r--r--src/nvim/options.lua2
6 files changed, 60 insertions, 115 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 7ad4193058..15a7294496 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -428,74 +428,41 @@ int update_screen(void)
msg_grid.cols, false);
}
}
- if (msg_use_msgsep()) {
- 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);
+ 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);
+ }
+ 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);
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 73ce92c823..5591b5f55d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index d1d0fe3f2a..6883dc5b14 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -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) {
diff --git a/src/nvim/message.c b/src/nvim/message.c
index d6835e04eb..fef5055c84 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -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);
-
- // 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;
+ 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_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;
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index e27607d7a8..4e48c992c2 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -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'
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 048d9e112b..82fd0d7428 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -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',