aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.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/ui.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/ui.c')
-rw-r--r--src/nvim/ui.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 62cc662b5b..0283e7bd62 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -44,7 +44,8 @@ static struct {
int top, bot, left, right;
} sr;
static int current_attr_code = 0;
-static bool cursor_enabled = true, pending_cursor_update = false;
+static bool pending_cursor_update = false;
+static int busy = 1;
static int height, width;
// This set of macros allow us to use UI_CALL to invoke any function on
@@ -150,24 +151,23 @@ void ui_resize(int new_width, int new_height)
UI_CALL(resize, width, height);
}
-void ui_cursor_on(void)
+void ui_busy_start(void)
{
- if (!cursor_enabled) {
- UI_CALL(cursor_on);
- cursor_enabled = true;
+ if (!(busy++)) {
+ UI_CALL(busy_start);
}
+ ui_flush();
}
-void ui_cursor_off(void)
+void ui_busy_stop(void)
{
- if (full_screen) {
- if (cursor_enabled) {
- UI_CALL(cursor_off);
- }
- cursor_enabled = false;
+ if (!(--busy)) {
+ UI_CALL(busy_stop);
}
+ ui_flush();
}
+
void ui_mouse_on(void)
{
UI_CALL(mouse_on);