ui: Replace cursor_{on,off} by busy_{stop,start}

Switching cursor off is only necessary in two occasions:

- When redrawing to avoid terminal flickering
- When the editor is busy

The first can now be handled by the TUI, so most calls to ui_cursor_off can be
removed from the core.

So, before this commit it was only necessary to switch the cursor off to notify
the user that nvim was running some long operation. Now the cursor_{on,off}
functions have been replaced by busy_{stop,start} which can be handled in a
UI-specific way(turning the cursor off or showing a busy indicator, for
example).

To make things even more simpler, nvim is always busy except when waiting for
user input or other asynchronous events: It automatically switches to a non-busy
state when the event loop is about to be entered for more than 100 milliseconds.

`ui_busy_start` can be called when its not desired to change the busy state in
the event loop (As its now done by functions that perform blocking shell
invocations).
This commit is contained in:
Thiago de Arruda
2015-03-15 10:21:05 -03:00
parent dbe719317c
commit c546875daf
21 changed files with 57 additions and 76 deletions

View File

@@ -416,7 +416,6 @@ void update_screen(int type)
search_hl.rm.regprog = NULL;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_redr_type != 0) {
ui_cursor_off();
if (!did_one) {
did_one = TRUE;
start_search_hl();
@@ -426,7 +425,6 @@ void update_screen(int type)
/* redraw status line after the window to minimize cursor movement */
if (wp->w_redr_status) {
ui_cursor_off();
win_redr_status(wp);
}
}
@@ -521,7 +519,6 @@ void update_single_line(win_T *wp, linenr_T lnum)
*/
static void update_prepare(void)
{
ui_cursor_off();
updating_screen = TRUE;
start_search_hl();
}
@@ -6566,7 +6563,6 @@ int showmode(void)
/* Position on the last line in the window, column 0 */
msg_pos_mode();
ui_cursor_off();
attr = hl_attr(HLF_CM); /* Highlight mode */
if (do_mode) {
MSG_PUTS_ATTR("--", attr);
@@ -7015,7 +7011,6 @@ static void win_redr_ruler(win_T *wp, int always)
|| wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count
|| wp->w_topfill != wp->w_ru_topfill
|| empty_line != wp->w_ru_empty) {
ui_cursor_off();
int width;
int row;
@@ -7238,7 +7233,6 @@ void screen_resize(int width, int height)
setcursor();
}
}
ui_cursor_on(); /* redrawing may have switched it off */
}
ui_flush();
--busy;