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