mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
screen: showcmd should never move the cursor
Also restore the symmetry between grid_puts_line_start and grid_puts_line_flush.
This commit is contained in:
parent
cc4d463cad
commit
21cf4b0ce6
@ -3386,8 +3386,8 @@ bool add_to_showcmd(int c)
|
||||
|
||||
void add_to_showcmd_c(int c)
|
||||
{
|
||||
if (!add_to_showcmd(c))
|
||||
setcursor();
|
||||
add_to_showcmd(c);
|
||||
setcursor();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3448,18 +3448,18 @@ static void display_showcmd(void)
|
||||
return;
|
||||
}
|
||||
|
||||
int showcmd_row = (int)Rows - 1;
|
||||
grid_puts_line_start(&default_grid, showcmd_row);
|
||||
|
||||
if (!showcmd_is_clear) {
|
||||
grid_puts(&default_grid, showcmd_buf, (int)Rows - 1, sc_col, 0);
|
||||
grid_puts(&default_grid, showcmd_buf, showcmd_row, sc_col, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* clear the rest of an old message by outputting up to SHOWCMD_COLS
|
||||
* spaces
|
||||
*/
|
||||
grid_puts(&default_grid, (char_u *)" " + len, (int)Rows - 1,
|
||||
// clear the rest of an old message by outputting up to SHOWCMD_COLS spaces
|
||||
grid_puts(&default_grid, (char_u *)" " + len, showcmd_row,
|
||||
sc_col + len, 0);
|
||||
|
||||
setcursor(); /* put cursor back where it belongs */
|
||||
grid_puts_line_flush(false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -412,7 +412,7 @@ void pum_redraw(void)
|
||||
idx = i + pum_first;
|
||||
attr = (idx == pum_selected) ? attr_select : attr_norm;
|
||||
|
||||
screen_puts_line_start(row);
|
||||
grid_puts_line_start(&pum_grid, row);
|
||||
|
||||
// prepend a space if there is room
|
||||
if (extra_space) {
|
||||
@ -564,7 +564,7 @@ void pum_redraw(void)
|
||||
? attr_thumb : attr_scroll);
|
||||
}
|
||||
}
|
||||
grid_puts_line_flush(&pum_grid, false);
|
||||
grid_puts_line_flush(false);
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
@ -5141,7 +5141,7 @@ win_redr_custom (
|
||||
/*
|
||||
* Draw each snippet with the specified highlighting.
|
||||
*/
|
||||
screen_puts_line_start(row);
|
||||
grid_puts_line_start(&default_grid, row);
|
||||
|
||||
curattr = attr;
|
||||
p = buf;
|
||||
@ -5164,7 +5164,7 @@ win_redr_custom (
|
||||
grid_puts(&default_grid, p >= buf + len ? (char_u *)"" : p, row, col,
|
||||
curattr);
|
||||
|
||||
grid_puts_line_flush(&default_grid, false);
|
||||
grid_puts_line_flush(false);
|
||||
|
||||
if (wp == NULL) {
|
||||
// Fill the tab_page_click_defs array for clicking in the tab pages line.
|
||||
@ -5310,18 +5310,20 @@ void grid_puts(ScreenGrid *grid, char_u *text, int row, int col, int attr)
|
||||
grid_puts_len(grid, text, -1, row, col, attr);
|
||||
}
|
||||
|
||||
static ScreenGrid *put_dirty_grid = NULL;
|
||||
static int put_dirty_row = -1;
|
||||
static int put_dirty_first = INT_MAX;
|
||||
static int put_dirty_last = 0;
|
||||
|
||||
/// Start a group of screen_puts_len calls that builds a single screen line.
|
||||
/// Start a group of grid_puts_len calls that builds a single grid line.
|
||||
///
|
||||
/// Must be matched with a screen_puts_line_flush call before moving to
|
||||
/// Must be matched with a grid_puts_line_flush call before moving to
|
||||
/// another line.
|
||||
void screen_puts_line_start(int row)
|
||||
void grid_puts_line_start(ScreenGrid *grid, int row)
|
||||
{
|
||||
assert(put_dirty_row == -1);
|
||||
put_dirty_row = row;
|
||||
put_dirty_grid = grid;
|
||||
}
|
||||
|
||||
/// like grid_puts(), but output "text[len]". When "len" is -1 output up to
|
||||
@ -5353,10 +5355,10 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
|
||||
}
|
||||
|
||||
if (put_dirty_row == -1) {
|
||||
screen_puts_line_start(row);
|
||||
grid_puts_line_start(grid, row);
|
||||
do_flush = true;
|
||||
} else {
|
||||
if (row != put_dirty_row) {
|
||||
if (grid != put_dirty_grid || row != put_dirty_row) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
@ -5459,31 +5461,31 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
|
||||
}
|
||||
|
||||
if (do_flush) {
|
||||
grid_puts_line_flush(grid, true);
|
||||
grid_puts_line_flush(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// End a group of screen_puts_len calls and send the screen buffer to the UI
|
||||
/// End a group of grid_puts_len calls and send the screen buffer to the UI
|
||||
/// layer.
|
||||
///
|
||||
/// @param grid The grid which contains the buffer.
|
||||
/// @param set_cursor Move the visible cursor to the end of the changed region.
|
||||
/// This is a workaround for not yet refactored code paths
|
||||
/// and shouldn't be used in new code.
|
||||
void grid_puts_line_flush(ScreenGrid *grid, bool set_cursor)
|
||||
void grid_puts_line_flush(bool set_cursor)
|
||||
{
|
||||
assert(put_dirty_row != -1);
|
||||
if (put_dirty_first < put_dirty_last) {
|
||||
if (set_cursor) {
|
||||
ui_grid_cursor_goto(grid->handle, put_dirty_row,
|
||||
MIN(put_dirty_last, grid->Columns-1));
|
||||
ui_grid_cursor_goto(put_dirty_grid->handle, put_dirty_row,
|
||||
MIN(put_dirty_last, put_dirty_grid->Columns-1));
|
||||
}
|
||||
ui_line(grid, put_dirty_row, put_dirty_first, put_dirty_last,
|
||||
ui_line(put_dirty_grid, put_dirty_row, put_dirty_first, put_dirty_last,
|
||||
put_dirty_last, 0, false);
|
||||
put_dirty_first = INT_MAX;
|
||||
put_dirty_last = 0;
|
||||
}
|
||||
put_dirty_row = -1;
|
||||
put_dirty_grid = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user