aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui/tui.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-03-15 10:21:05 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-03-15 10:30:59 -0300
commitc546875daf36936b9a6c0886a71c9edd1fdae6db (patch)
treeb20e159ef39a89e67c0a7738d96ef1f4afccd284 /src/nvim/tui/tui.c
parentdbe719317cf71dd1951d8d478256b8735db12db0 (diff)
downloadrneovim-c546875daf36936b9a6c0886a71c9edd1fdae6db.tar.gz
rneovim-c546875daf36936b9a6c0886a71c9edd1fdae6db.tar.bz2
rneovim-c546875daf36936b9a6c0886a71c9edd1fdae6db.zip
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).
Diffstat (limited to 'src/nvim/tui/tui.c')
-rw-r--r--src/nvim/tui/tui.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index b95a22d48b..610419d12c 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -45,6 +45,7 @@ typedef struct {
int out_fd;
int old_height;
bool can_use_terminal_scroll;
+ bool busy;
HlAttrs attrs, print_attrs;
Cell **screen;
struct {
@@ -80,6 +81,7 @@ typedef struct {
void tui_start(void)
{
TUIData *data = xcalloc(1, sizeof(TUIData));
+ data->busy = true;
UI *ui = xcalloc(1, sizeof(UI));
ui->data = data;
data->attrs = data->print_attrs = EMPTY_ATTRS;
@@ -134,8 +136,8 @@ void tui_start(void)
ui->clear = tui_clear;
ui->eol_clear = tui_eol_clear;
ui->cursor_goto = tui_cursor_goto;
- ui->cursor_on = tui_cursor_on;
- ui->cursor_off = tui_cursor_off;
+ ui->busy_start = tui_busy_start;
+ ui->busy_stop = tui_busy_stop;
ui->mouse_on = tui_mouse_on;
ui->mouse_off = tui_mouse_off;
ui->insert_mode = tui_insert_mode;
@@ -342,14 +344,14 @@ static void tui_cursor_goto(UI *ui, int row, int col)
unibi_goto(ui, row, col);
}
-static void tui_cursor_on(UI *ui)
+static void tui_busy_start(UI *ui)
{
- unibi_out(ui, unibi_cursor_normal);
+ ((TUIData *)ui->data)->busy = true;
}
-static void tui_cursor_off(UI *ui)
+static void tui_busy_stop(UI *ui)
{
- unibi_out(ui, unibi_cursor_invisible);
+ ((TUIData *)ui->data)->busy = false;
}
static void tui_mouse_on(UI *ui)
@@ -527,7 +529,13 @@ static void tui_flush(UI *ui)
}
unibi_goto(ui, data->row, data->col);
+
+ if (!data->busy) {
+ unibi_out(ui, unibi_cursor_normal);
+ }
+
flush_buf(ui);
+ unibi_out(ui, unibi_cursor_invisible);
}
static void tui_suspend(UI *ui)