diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 897c9533e5..0485fbcdb0 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -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; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4392ea306f..4de4b7a080 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 6c6dc3fa43..957733ecd5 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -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'); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 437a05f61d..ae7abfc5e7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a24e8458a6..017787f238 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -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 diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 8ed9381bca..f5728d29c1 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -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,28 +2229,28 @@ 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 an error was displayed and the expression returns an empty - // string, generate a to allow for a redraw. - if (prev_did_emsg != did_emsg && (map_str == NULL || *map_str == NUL)) { - char buf[4]; - xfree(map_str); - buf[0] = (char)K_SPECIAL; - buf[1] = (char)KS_EXTRA; - buf[2] = KE_IGNORE; - buf[3] = NUL; - map_str = xstrdup(buf); - if (State & MODE_CMDLINE) { - // redraw the command below the error - msg_didout = true; - if (msg_row < cmdline_row) { - msg_row = cmdline_row; + if ((map_str == NULL || *map_str == NUL)) { + // If an error was displayed and the expression returns an empty + // string, generate a to allow for a redraw. + if (prev_did_emsg != did_emsg) { + char buf[4]; + xfree(map_str); + buf[0] = (char)K_SPECIAL; + buf[1] = (char)KS_EXTRA; + buf[2] = KE_IGNORE; + buf[3] = NUL; + map_str = xstrdup(buf); + if (State & MODE_CMDLINE) { + // redraw the command below the error + msg_didout = true; + if (msg_row < cmdline_row) { + msg_row = cmdline_row; + } + redrawcmd(); } - redrawcmd(); + } else if (State & (MODE_NORMAL | MODE_INSERT)) { + // otherwise, just put back the cursor + setcursor(); } } diff --git a/src/nvim/option.c b/src/nvim/option.c index 387b94533c..066ca8f003 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -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() } diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 245ce87865..45c1afd70e 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -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(); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index b22dc4a661..8172a46773 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -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);