aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/input.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-10-05 10:13:18 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-10-26 10:52:01 -0300
commite5165bae1139221ef752bccd582c7bd7474e6747 (patch)
tree42799e7a113b8e441bb14df724d4dece73974b1d /src/nvim/os/input.c
parentd8055f8eab7b1c3fb90f69e9795e9e2a88d0cd68 (diff)
downloadrneovim-e5165bae1139221ef752bccd582c7bd7474e6747.tar.gz
rneovim-e5165bae1139221ef752bccd582c7bd7474e6747.tar.bz2
rneovim-e5165bae1139221ef752bccd582c7bd7474e6747.zip
input: Remove CURSORHOLD key
Refactor input.c, normal.c and edit.c to use the K_EVENT special key to trigger the CURSORHOLD event. In normal and edit mode, K_EVENT is treated as K_CURSORHOLD, which enables better handling of arbitrary actions in those states(eg: In normal mode the previous operator counts will be restored). Also fix a test in vim_spec.lua. The test had a wrong assumption: cmdheight is only used to determine when the press enter screen will be shown, not to limit how many lines or control pagination.
Diffstat (limited to 'src/nvim/os/input.c')
-rw-r--r--src/nvim/os/input.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index e2cff2f9c0..9061a5ce2e 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -73,6 +73,21 @@ void input_stop(void)
stream_close(&read_stream, NULL);
}
+static void cursorhold_event(void **argv)
+{
+ event_T event = State & INSERT ? EVENT_CURSORHOLDI : EVENT_CURSORHOLD;
+ apply_autocmds(event, NULL, NULL, false, curbuf);
+ did_cursorhold = true;
+}
+
+static void create_cursorhold_event(void)
+{
+ // If the queue had any items, this function should not have been
+ // called(inbuf_poll would return kInputAvail)
+ assert(queue_empty(loop.events));
+ queue_put(loop.events, cursorhold_event, 0);
+}
+
// Low level input function
int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
{
@@ -87,16 +102,12 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
}
} else {
if ((result = inbuf_poll((int)p_ut)) == kInputNone) {
- if (trigger_cursorhold() && maxlen >= 3
- && !typebuf_changed(tb_change_cnt)) {
- buf[0] = K_SPECIAL;
- buf[1] = KS_EXTRA;
- buf[2] = KE_CURSORHOLD;
- return 3;
+ if (trigger_cursorhold() && !typebuf_changed(tb_change_cnt)) {
+ create_cursorhold_event();
+ } else {
+ before_blocking();
+ result = inbuf_poll(-1);
}
-
- before_blocking();
- result = inbuf_poll(-1);
}
}