refactor(ui): remove some superfluous ui_flush() calls

- <expr> mapping has no business saving and restoring the
  low-level UI cursor. The cursor will be put in a reasonable
  position after input is processed, chill out.
- TUI handles output needed for suspend
- vgetc() family of function does flushing
This commit is contained in:
bfredl
2023-02-09 20:56:30 +01:00
parent 257765d9e0
commit 30b29a36e8
8 changed files with 23 additions and 40 deletions

View File

@@ -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;

View File

@@ -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');

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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()
}

View File

@@ -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();

View File

@@ -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);