mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(grid): use batched updates for statusline and ruler
This commit is contained in:
parent
0b2667ed36
commit
10cabf7877
@ -1094,8 +1094,11 @@ int showmode(void)
|
||||
// If the current or last window has no status line and global statusline is disabled,
|
||||
// the ruler is after the mode message and must be redrawn
|
||||
win_T *ruler_win = curwin->w_status_height == 0 ? curwin : lastwin_nofloating();
|
||||
if (redrawing() && ruler_win->w_status_height == 0 && global_stl_height() == 0) {
|
||||
if (redrawing() && ruler_win->w_status_height == 0 && global_stl_height() == 0
|
||||
&& !(p_ch == 0 && !ui_has(kUIMessages))) {
|
||||
grid_line_start(&msg_grid_adj, Rows - 1);
|
||||
win_redr_ruler(ruler_win);
|
||||
grid_line_flush(false);
|
||||
}
|
||||
|
||||
redraw_cmdline = false;
|
||||
|
@ -953,6 +953,7 @@ void win_grid_alloc(win_T *wp)
|
||||
if ((resizing_screen || was_resized) && want_allocation) {
|
||||
ui_call_grid_resize(grid_allocated->handle,
|
||||
grid_allocated->cols, grid_allocated->rows);
|
||||
ui_check_cursor_grid(grid_allocated->handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,6 @@ typedef enum {
|
||||
/// If inversion is possible we use it. Else '=' characters are used.
|
||||
void win_redr_status(win_T *wp)
|
||||
{
|
||||
int row;
|
||||
int col;
|
||||
char *p;
|
||||
int len;
|
||||
int fillchar;
|
||||
@ -151,16 +149,15 @@ void win_redr_status(win_T *wp)
|
||||
}
|
||||
}
|
||||
|
||||
row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp);
|
||||
col = is_stl_global ? 0 : wp->w_wincol;
|
||||
int width = grid_puts(&default_grid, p, -1, row, col, attr);
|
||||
grid_fill(&default_grid, row, row + 1, width + col,
|
||||
this_ru_col + col, fillchar, fillchar, attr);
|
||||
grid_line_start(&default_grid, is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp));
|
||||
int col = is_stl_global ? 0 : wp->w_wincol;
|
||||
|
||||
int width = grid_line_puts(col, p, -1, attr);
|
||||
grid_line_fill(width + col, this_ru_col + col, fillchar, attr);
|
||||
|
||||
if (get_keymap_str(wp, "<%s>", NameBuff, MAXPATHL)
|
||||
&& this_ru_col - len > (int)(strlen(NameBuff) + 1)) {
|
||||
grid_puts(&default_grid, NameBuff, -1, row,
|
||||
(int)((size_t)this_ru_col - strlen(NameBuff) - 1), attr);
|
||||
grid_line_puts((int)((size_t)this_ru_col - strlen(NameBuff) - 1), NameBuff, -1, attr);
|
||||
}
|
||||
|
||||
win_redr_ruler(wp);
|
||||
@ -170,10 +167,11 @@ void win_redr_status(win_T *wp)
|
||||
const int sc_width = MIN(10, this_ru_col - len - 2);
|
||||
|
||||
if (sc_width > 0) {
|
||||
grid_puts(&default_grid, showcmd_buf, sc_width, row,
|
||||
wp->w_wincol + this_ru_col - sc_width - 1, attr);
|
||||
grid_line_puts(wp->w_wincol + this_ru_col - sc_width - 1, showcmd_buf, sc_width, attr);
|
||||
}
|
||||
}
|
||||
|
||||
grid_line_flush(false);
|
||||
}
|
||||
|
||||
// May need to draw the character below the vertical separator.
|
||||
@ -419,7 +417,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler)
|
||||
int start_col = col;
|
||||
|
||||
// Draw each snippet with the specified highlighting.
|
||||
grid_line_start(grid, row);
|
||||
if (!draw_ruler) {
|
||||
grid_line_start(grid, row);
|
||||
}
|
||||
|
||||
int curattr = attr;
|
||||
char *p = buf;
|
||||
@ -448,7 +448,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler)
|
||||
// fill up with "fillchar"
|
||||
grid_line_fill(col, maxcol, fillchar, curattr);
|
||||
|
||||
grid_line_flush(false);
|
||||
if (!draw_ruler) {
|
||||
grid_line_flush(false);
|
||||
}
|
||||
|
||||
// Fill the tab_page_click_defs, w_status_click_defs or w_winbar_click_defs array for clicking
|
||||
// in the tab page line, status line or window bar
|
||||
@ -481,6 +483,7 @@ void win_redr_winbar(win_T *wp)
|
||||
entered = false;
|
||||
}
|
||||
|
||||
/// must be called after a grid_line_start() at the intended row
|
||||
void win_redr_ruler(win_T *wp)
|
||||
{
|
||||
bool is_stl_global = global_stl_height() > 0;
|
||||
@ -516,36 +519,28 @@ void win_redr_ruler(win_T *wp)
|
||||
&& *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum) == NUL;
|
||||
|
||||
int width;
|
||||
int row;
|
||||
int fillchar;
|
||||
int attr;
|
||||
int off;
|
||||
bool part_of_status = false;
|
||||
|
||||
if (wp->w_status_height) {
|
||||
row = W_ENDROW(wp);
|
||||
fillchar = fillchar_status(&attr, wp);
|
||||
off = wp->w_wincol;
|
||||
width = wp->w_width;
|
||||
part_of_status = true;
|
||||
} else if (is_stl_global) {
|
||||
row = Rows - (int)p_ch - 1;
|
||||
fillchar = fillchar_status(&attr, wp);
|
||||
off = 0;
|
||||
width = Columns;
|
||||
part_of_status = true;
|
||||
} else {
|
||||
row = Rows - 1;
|
||||
fillchar = ' ';
|
||||
attr = HL_ATTR(HLF_MSG);
|
||||
width = Columns;
|
||||
off = 0;
|
||||
}
|
||||
|
||||
if (!part_of_status && p_ch == 0 && !ui_has(kUIMessages)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// In list mode virtcol needs to be recomputed
|
||||
colnr_T virtcol = wp->w_virtcol;
|
||||
if (wp->w_p_list && wp->w_p_lcs_chars.tab1 == NUL) {
|
||||
@ -617,11 +612,8 @@ void win_redr_ruler(win_T *wp)
|
||||
}
|
||||
}
|
||||
|
||||
ScreenGrid *grid = part_of_status ? &default_grid : &msg_grid_adj;
|
||||
grid_puts(grid, buffer, -1, row, this_ru_col + off, attr);
|
||||
grid_fill(grid, row, row + 1,
|
||||
this_ru_col + off + (int)strlen(buffer), off + width, fillchar,
|
||||
fillchar, attr);
|
||||
int w = grid_line_puts(this_ru_col + off, buffer, -1, attr);
|
||||
grid_line_fill(this_ru_col + off + w, off + width, fillchar, attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2887,7 +2887,7 @@ describe('ext_multigrid', function()
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
^Lorem i|
|
||||
Lorem i|
|
||||
psum do|
|
||||
lor sit|
|
||||
amet, |
|
||||
@ -2896,7 +2896,7 @@ describe('ext_multigrid', function()
|
||||
ipiscin|
|
||||
g elit,|
|
||||
sed do|
|
||||
eiusmo|
|
||||
^eiusmo|
|
||||
{1:~ }|
|
||||
## grid 5
|
||||
some text |
|
||||
|
Loading…
Reference in New Issue
Block a user