diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-10-05 12:02:13 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-10-26 10:52:01 -0300 |
commit | 350ffc63dbd26e17c389b35d4b8b36e4ef362137 (patch) | |
tree | e9294c3189e45f77649447eada66a544810cb861 /src/nvim/os/input.c | |
parent | 32594a33a3d815b0da6634cb41692e412276cb91 (diff) | |
download | rneovim-350ffc63dbd26e17c389b35d4b8b36e4ef362137.tar.gz rneovim-350ffc63dbd26e17c389b35d4b8b36e4ef362137.tar.bz2 rneovim-350ffc63dbd26e17c389b35d4b8b36e4ef362137.zip |
main: Refactor normal_enter to call `os_inchar` directly
This makes it impossible for K_EVENT to interfere with mappings, but it also
disables processing of events while in the middle of a mapping (Though this will
be fixed later as this refactoring progresses).
`may_sync_undo` is now called when K_EVENT is received. This is necessary to
correctly update undo entry lists before executing some action.
Diffstat (limited to 'src/nvim/os/input.c')
-rw-r--r-- | src/nvim/os/input.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 9061a5ce2e..df803609ae 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -91,7 +91,7 @@ static void create_cursorhold_event(void) // Low level input function int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt) { - if (rbuffer_size(input_buffer)) { + if (maxlen && rbuffer_size(input_buffer)) { return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen); } @@ -116,14 +116,14 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt) return 0; } - if (rbuffer_size(input_buffer)) { + if (maxlen && rbuffer_size(input_buffer)) { // Safe to convert rbuffer_read to int, it will never overflow since we use // relatively small buffers. return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen); } // If there are events, return the keys directly - if (pending_events()) { + if (maxlen && pending_events()) { return push_event_key(buf, maxlen); } @@ -324,6 +324,11 @@ void input_done(void) input_eof = true; } +bool input_available(void) +{ + return rbuffer_size(input_buffer) != 0; +} + // This is a replacement for the old `WaitForChar` function in os_unix.c static InbufPollResult inbuf_poll(int ms) { |