diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-07 16:37:14 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-08 14:17:18 -0300 |
commit | fe38baed3830415bc16b7e6c718a80ebe0c29fff (patch) | |
tree | f100e84d8bd64a28daa7c3cc3e145d6949109b1b /src/ex_getln.c | |
parent | 1fc7d6a0c514257cee9fb204cb83564b17354c11 (diff) | |
download | rneovim-fe38baed3830415bc16b7e6c718a80ebe0c29fff.tar.gz rneovim-fe38baed3830415bc16b7e6c718a80ebe0c29fff.tar.bz2 rneovim-fe38baed3830415bc16b7e6c718a80ebe0c29fff.zip |
Define special key for asynchronous events
K_EVENT/KE_EVENT are used to signal any loop that reads user input(scattered
across normal.c edit.c , ex_getln.c and message.c) of asynchronous events that
were not initiated by the user.
Representing non-user asynchronous events as special keys has the following
advantages:
- We reuse the normal vim redrawing code. As far as the rest of the code in
edit.c/normal.c is concerned, it's just the user pressing another key.
- Assume less about vim tolerance for "out-of-band" modifications to its
internal state.
- We still have a very complex codebase and it's hard to predict what bugs may
be introduced by these changes. With this we implement asynchronicity in a way
that will be more "natural" to the editor and has less chance of causing
unpredictable behavior.
As the code is refactored, we will be able to treat user input as an 'event
type' and not the other way around(With this we are treating arbitrary events as
a special case of user input).
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index 498d53904c..51c596e1ce 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -56,6 +56,7 @@ #include "window.h" #include "ui.h" #include "os/os.h" +#include "os/event.h" /* * Variables shared between getcmdline(), redrawcmdline() and others. @@ -788,6 +789,11 @@ getcmdline ( * Big switch for a typed command line character. */ switch (c) { + case K_EVENT: + event_process(); + // Force a redraw even though the command line didn't change + shell_resized(); + goto cmdline_not_changed; case K_BS: case Ctrl_H: case K_DEL: @@ -1904,9 +1910,12 @@ redraw: continue; } - /* Ignore special key codes: mouse movement, K_IGNORE, etc. */ - if (IS_SPECIAL(c1)) + if (IS_SPECIAL(c1)) { + // Process pending events + event_process(); + // Ignore other special key codes continue; + } } if (IS_SPECIAL(c1)) |