mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
Merge pull request #22194 from bfredl/noflush
refactor(ui): remove some superfluous redraw and ui_flush() calls
This commit is contained in:
commit
84328bae08
@ -2740,14 +2740,12 @@ void do_autocmd_focusgained(bool gained)
|
||||
{
|
||||
static bool recursive = false;
|
||||
static Timestamp last_time = (time_t)0;
|
||||
bool need_redraw = false;
|
||||
|
||||
if (recursive) {
|
||||
return; // disallow recursion
|
||||
}
|
||||
recursive = true;
|
||||
need_redraw |= apply_autocmds((gained ? EVENT_FOCUSGAINED : EVENT_FOCUSLOST),
|
||||
NULL, NULL, false, curbuf);
|
||||
apply_autocmds((gained ? EVENT_FOCUSGAINED : EVENT_FOCUSLOST), NULL, NULL, false, curbuf);
|
||||
|
||||
// When activated: Check if any file was modified outside of Vim.
|
||||
// Only do this when not done within the last two seconds as:
|
||||
@ -2755,32 +2753,10 @@ void do_autocmd_focusgained(bool gained)
|
||||
// has a granularity of 2 seconds.
|
||||
// 2. We could get multiple notifications in a row.
|
||||
if (gained && last_time + (Timestamp)2000 < os_now()) {
|
||||
need_redraw = check_timestamps(true);
|
||||
check_timestamps(true);
|
||||
last_time = os_now();
|
||||
}
|
||||
|
||||
if (need_redraw) {
|
||||
// Something was executed, make sure the cursor is put back where it
|
||||
// belongs.
|
||||
need_wait_return = false;
|
||||
|
||||
if (State & MODE_CMDLINE) {
|
||||
redrawcmdline();
|
||||
} else if ((State & MODE_NORMAL) || (State & MODE_INSERT)) {
|
||||
if (must_redraw != 0) {
|
||||
update_screen();
|
||||
}
|
||||
|
||||
setcursor();
|
||||
}
|
||||
|
||||
ui_flush();
|
||||
}
|
||||
|
||||
if (need_maketitle) {
|
||||
maketitle();
|
||||
}
|
||||
|
||||
recursive = false;
|
||||
}
|
||||
|
||||
|
@ -7469,7 +7469,6 @@ void ex_execute(exarg_T *eap)
|
||||
if (eap->cmdidx == CMD_echomsg) {
|
||||
msg_ext_set_kind("echomsg");
|
||||
msg_attr(ga.ga_data, echo_attr);
|
||||
ui_flush();
|
||||
} else if (eap->cmdidx == CMD_echoerr) {
|
||||
// We don't want to abort following commands, restore did_emsg.
|
||||
int save_did_emsg = did_emsg;
|
||||
|
@ -2150,8 +2150,7 @@ void ex_function(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
msg_prt_line(FUNCLINE(fp, j), false);
|
||||
ui_flush(); // show a line at a time
|
||||
os_breakcheck();
|
||||
line_breakcheck(); // show multiple lines at a time!
|
||||
}
|
||||
if (!got_int) {
|
||||
msg_putchar('\n');
|
||||
|
@ -1507,7 +1507,6 @@ void print_line(linenr_T lnum, int use_number, int list)
|
||||
print_line_no_prefix(lnum, use_number, list);
|
||||
if (save_silent) {
|
||||
msg_putchar('\n');
|
||||
ui_flush();
|
||||
silent_mode = save_silent;
|
||||
}
|
||||
info_message = false;
|
||||
|
@ -4838,13 +4838,9 @@ static void ex_stop(exarg_T *eap)
|
||||
}
|
||||
apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, false, NULL);
|
||||
|
||||
// TODO(bfredl): the TUI should do this on suspend
|
||||
ui_cursor_goto(Rows - 1, 0);
|
||||
ui_call_grid_scroll(1, 0, Rows, 0, Columns, 1, 0);
|
||||
ui_call_suspend();
|
||||
ui_flush();
|
||||
ui_call_suspend(); // call machine specific function
|
||||
|
||||
ui_flush();
|
||||
maketitle();
|
||||
resettitle(); // force updating the title
|
||||
ui_refresh(); // may have resized window
|
||||
|
@ -2218,9 +2218,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
if (mp->m_expr) {
|
||||
const int save_vgetc_busy = vgetc_busy;
|
||||
const bool save_may_garbage_collect = may_garbage_collect;
|
||||
const int save_cursor_row = ui_current_row();
|
||||
const int save_cursor_col = ui_current_col();
|
||||
const handle_T save_cursor_grid = ui_cursor_grid();
|
||||
const int prev_did_emsg = did_emsg;
|
||||
|
||||
vgetc_busy = 0;
|
||||
@ -2232,14 +2229,10 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
}
|
||||
map_str = eval_map_expr(mp, NUL);
|
||||
|
||||
// The mapping may do anything, but we expect it to take care of
|
||||
// redrawing. Do put the cursor back where it was.
|
||||
ui_grid_cursor_goto(save_cursor_grid, save_cursor_row, save_cursor_col);
|
||||
ui_flush();
|
||||
|
||||
if ((map_str == NULL || *map_str == NUL)) {
|
||||
// If an error was displayed and the expression returns an empty
|
||||
// string, generate a <Nop> to allow for a redraw.
|
||||
if (prev_did_emsg != did_emsg && (map_str == NULL || *map_str == NUL)) {
|
||||
if (prev_did_emsg != did_emsg) {
|
||||
char buf[4];
|
||||
xfree(map_str);
|
||||
buf[0] = (char)K_SPECIAL;
|
||||
@ -2255,6 +2248,10 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
}
|
||||
redrawcmd();
|
||||
}
|
||||
} else if (State & (MODE_NORMAL | MODE_INSERT)) {
|
||||
// otherwise, just put back the cursor
|
||||
setcursor();
|
||||
}
|
||||
}
|
||||
|
||||
vgetc_busy = save_vgetc_busy;
|
||||
|
@ -1549,7 +1549,6 @@ int do_set(char *arg, int opt_flags)
|
||||
silent_mode = false;
|
||||
info_message = true; // use os_msg(), not os_errmsg()
|
||||
msg_putchar('\n');
|
||||
ui_flush();
|
||||
silent_mode = true;
|
||||
info_message = false; // use os_msg(), not os_errmsg()
|
||||
}
|
||||
|
@ -1092,7 +1092,6 @@ void pum_show_popupmenu(vimmenu_T *menu)
|
||||
pum_is_drawn = true;
|
||||
pum_redraw();
|
||||
setcursor_mayforce(true);
|
||||
ui_flush();
|
||||
|
||||
int c = vgetc();
|
||||
|
||||
|
@ -472,11 +472,6 @@ int ui_current_col(void)
|
||||
return cursor_col;
|
||||
}
|
||||
|
||||
handle_T ui_cursor_grid(void)
|
||||
{
|
||||
return cursor_grid_handle;
|
||||
}
|
||||
|
||||
void ui_flush(void)
|
||||
{
|
||||
assert(!ui_client_channel_id);
|
||||
|
Loading…
Reference in New Issue
Block a user