aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/input.c
Commit message (Collapse)AuthorAge
* tui: check stty/termios for kbsJustin M. Keyes2016-12-23
| | | | | | | | | | | Requires libtermkey 0.19+ Closes #2048 Closes #5693 See https://github.com/neovim/libtermkey/compare/a9b61424aae9f7548162ff112393c5f706cf54f1%5E...c0eb4e4a05f49ad8fee0195c77f2c29d09cc36af See https://bugzilla.redhat.com/show_bug.cgi?id=142659 See https://github.com/tmux/tmux/blob/fe4e9470bb504357d073320f5d305b22663ee3fd/tty-keys.c#L625-L632
* event/multiqueue.c: Rename "queue" to "multiqueue".Justin M. Keyes2016-10-02
| | | | | | | | | | | | | | `lib/queue.h` implements a basic queue. `event/queue.c` implements a specialized data structure on top of lib/queue.h; it is not a "normal" queue. Rename the specialized multi-level queue implemented in event/queue.c to "multiqueue", to avoid confusion when reading the code. Before this change one can eventually notice that "macros (uppercase symbols) are for the normal queue, lowercase operations are for the multi-level queue", but that is unnecessary friction for new developers (or existing developers just visiting this part of the codebase).
* refactor: eliminate misc2.cJustin M. Keyes2016-09-13
| | | | | | | | | | move `call_shell` to misc1.c Move some fns to state.c Move some fns to option.c Move some fns to memline.c Move `vim_chdir*` fns to file_search.c Move some fns to new module, bytes.c Move some fns to fileio.c
* stream: set data together with callbackBjörn Linse2016-08-20
|
* lintsach1t2016-08-07
|
* input.c: restore double clicksach1t2016-08-07
|
* *: Rename main loop variable from loop to main_loopZyX2016-05-30
| | | | | | | | | | | | | | | | Current name is inappropriate for the following reasons: 1. It is often masked by local `loop` variables. 2. It cannot be searched for. There are many `loop` variables where `loop` is some local variable. There are many cases when “loop” word is used in a comment. 3. It is in any case bad idea to use a generic name as a name of the global variable. Best if global has module prefix: this is why it is in `main.h`: `main_loop` both stands for “a main loop” and “a loop defined in `main.*`”. Since I have no idea how to list every occurrence of this variable method used to rename it is “remove it from globals.h, try to compile, fix errors”. Thus if some occurrence was hidden under false `#if` branch it was not replaced.
* *: Fix new linter errorsZyX2016-05-01
| | | | Originally there were 128 new errors, so I thought this is a good idea to fix all of them. Of course, this commit also fixes many suppressed errors.
* keymap: Make replace_termcodes and friends accept length and cpo_flagsZyX2016-04-18
| | | | | | | Reasons: - One does not have to do `s[len] = NUL` to work with these functions if they do not need to replace the whole string: thus `s` may be const. - One does not have to save/restore p_cpo to work with them.
* vim-patch:7.4.936 #4271watiko2016-02-22
| | | | | | | | | | | | | | | Problem: Crash when dragging with the mouse. Solution: Add safety check for NULL pointer. Check mouse position for valid value. (Hirohito Higashi) https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946 --- see: "Crash while mouse-selecting in two-buffer mode" https://github.com/vim/vim/issues/486 Fix #3704
* vim-patch:7.4.569/573Shougo Matsushita2016-01-13
| | | | | | | | | | | | | | | | | vim-patch:7.4.569 vim-patch:7.4.573 Helped-by: @glts https://github.com/neovim/neovim/pull/2621 Problem: Having CTRL-C interrupt or not does not check the mode of the mapping. (Ingo Karkat) Solution: Use a bitmask with the map mode. (Christian Brabandt) https://github.com/vim/vim/commit/651863c94a882a97aec7968fc87a638ff78e56ff Problem: Mapping CTRL-C in Visual mode doesn't work. (Ingo Karkat) Solution: Call get_real_state() instead of using State directly. https://github.com/vim/vim/commit/5000869712f799d9ca25c0e45dc21d332edae5f4
* os/input.c: Fix assertion in `create_cursorhold_event`Thiago de Arruda2015-10-29
| | | | The assertion now considers the case where events are disabled.
* main: Refactor normal_enter to call `os_inchar` directlyThiago de Arruda2015-10-26
| | | | | | | | | 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.
* input: Remove CURSORHOLD keyThiago de Arruda2015-10-26
| | | | | | | | | | | 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.
* os/input: Don't advance past incomplete sequences in input_enqueueThiago de Arruda2015-10-01
| | | | | This allows callers to incrementally process buffers that are filled by incomplete chunks more easily.
* rstream: Pass read count to read eventsThiago de Arruda2015-08-13
| | | | This is necessary to keep events in the same order received from the OS.
* event: Refactor async event processingThiago de Arruda2015-08-13
| | | | | | | | | | - Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
* loop: Simplify loop.c and move some code to input.cThiago de Arruda2015-08-13
| | | | | | - Declare poll timer in Loop structure instead of a loop_poll_events local variable. - Move deferred event management to input.c
* rstream/wstream: Unify structures and simplify APIThiago de Arruda2015-07-17
| | | | | | | | | | | | | - Simplify RStream/WStream API and make it more consistent with libuv. - Move into the event loop layer(event subdirectory) - Remove uv_helpers module. - Simplify job/process internal modules/API. - Unify RStream and WStream into a single structure. This is necessary because libuv streams can be readable and writable at the same time(and because the uv_helpers.c hack to associate multiple streams with libuv handle was removed) - Make struct definition public, allowing more flexible/simple memory management by users of the module. - Adapt channel/job modules to cope with the changes.
* event loop: New abstraction layer with refactored time/signal APIThiago de Arruda2015-07-17
| | | | | | | | | | - Add event loop abstraction module under src/nvim/event. The src/nvim/event/loop module replaces src/nvim/os/event - Remove direct dependency on libuv signal/timer API and use the new abstraction instead. - Replace all references to uv_default_loop() by &loop.uv, a new global variable that wraps libuv main event loop but allows the event loop functions to be reused in other contexts.
* rbuffer: Reimplement as a ring buffer and decouple from rstreamThiago de Arruda2015-07-01
| | | | | | | | | | | | | | | | | | | | Extract the RBuffer class from rstream.c and reimplement it as a ring buffer, a more efficient version that doesn't need to relocate memory. The old rbuffer_read/rbuffer_write interfaces are kept for simple reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to hide wrapping logic when more control is required(such as passing the buffer pointer to a library function that writes directly to the pointer) Also add a basic infrastructure for writing helper C files that are only compiled in the unit test library, and use this to write unit tests for RBuffer which contains some macros that can't be accessed directly by luajit. Helped-by: oni-link <knil.ino@gmail.com> Reviewed-by: oni-link <knil.ino@gmail.com> Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Justin M. Keyes <justinkz@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com>
* input: rename input_{start,stop}_stdin()Justin M. Keyes2015-05-27
| | | | | - "stdin" is misleading because it may read from stdout or stderr - also remove some unused includes
* input: stream_set_blocking(): libuv implJustin M. Keyes2015-05-27
| | | | | | | | | - Create a private libuv loop instead of re-using uv_default_loop(), to avoid conflict[1] with existing watcher(s) on the fd. - Expose the global "input" fd as a getter instead of a mutable global. [1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
* input: set input stream to blocking on exitJustin M. Keyes2015-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If stdin is non-blocking, many tools (e.g. cat(1), read(1)) which assume that stdin is blocking, will break in odd ways: read: read error: 0: Resource temporarily unavailable cat: -: Resource temporarily unavailable rm: error closing file libuv puts stdin in nonblocking mode, and leaves it that way at exit (this is apparently by design). So, before this commit, this always works (because the shell clobbers O_NONBLOCK): $ nvim --cmd q $ read ...but these forms do _not_ work: $ nvim --cmd q && read $ echo foo | nvim --cmd q && read $ nvim && read After this commit, all of the above forms work. Background: https://github.com/fish-shell/fish-shell/commit/437b4397b9cf273922ce7b414bf6626845f15ad0#diff-41f4d294430cd8c36538999d62681ae2 https://github.com/fish-shell/fish-shell/issues/176#issuecomment-15800155 - bash (and other shells: zsh, tcsh, fish), upon returning to the foreground, always sets fd 0 back to blocking mode. This practice only applies to stdin, _not_ stdout or stderr (in practice these fds may be affected anyways). - bash/zsh/tcsh/fish do _not_ restore the non-blocking status of stdin when _resuming a job_. - We do _not_ save/restore the original flags visible to fcntl(F_[SG]ETFL), because (counterintuitively) that isn't expected. Helped-by: oni-link <knil.ino@gmail.com> Closes #2086 Closes #2377 --- Note: The following implementation of stream_set_blocking() was discarded, because it resulted in a failed libuv assertion[1]: int stream_set_blocking(int fd, bool blocking) { uv_pipe_t stream; uv_pipe_init(uv_default_loop(), &stream, 0); uv_pipe_open(&stream, fd); int retval = uv_stream_set_blocking((uv_stream_t *)&stream, blocking); uv_close((uv_handle_t *)&stream, NULL); return retval; } [1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
* Rename var eof as input_eof #2728Rui Abreu Ferreira2015-05-24
| | | | | - In Windows eof is a function, renamed the eof var in input.c to input_eof
* os/input.c: Eliminate conversion warning from gcc 5 #2617Björn Linse2015-05-09
|
* eval: Fix `jobwait()`Thiago de Arruda2015-04-11
| | | | | | - Properly save job event deferring state for recursive calls - Disable breakcheck while running. Breakcheck can invoke job callbacks in unexpected places.
* main: Simplify code that deals with early user inputThiago de Arruda2015-03-18
| | | | | | | | | A read stream will be started before the first ex command is processed. This stream will be used to read early user input before handling control over to the UI module. Which stdio stream will be used depends on which types of file descriptors are connected, and whether the "-" argument was passed.
* input: Escape utf8 sequences that contain CSI/K_SPECIALThiago de Arruda2015-02-18
|
* ui: Remove/adapt some old code for a big UI refactorThiago de Arruda2015-02-16
| | | | | | | | | | | | | - Remove abstract_ui global, now it is always active - Remove some terminal handling code - Remove unused functions - Remove HAVE_TGETENT/TERMINFO/TERMIOS/IOCTL #ifdefs - Remove tgetent/terminfo from version.c - Remove curses/terminfo dependencies - Only start/stop termcap when starting/exiting the program - msg_use_printf will return true if there are no attached UIs( messages will be written to stdout) - Remove `ex_winpos`(implement `:winpos` with `ex_ni`)
* input: Remove input_buffer_{save,restore}Thiago de Arruda2015-02-16
| | | | | | | The input buffer is only used for data that really came from another process and is only visible to os/input.c. Remove the input_buffer_{save,restore} functions, they are not necessary(Also can result in problems if data comes while the typeahead is saved).
* input: Fix handle_mouse_event functionThiago de Arruda2015-02-16
| | | | Ignore all keys that aren't prefixed with KS_EXTRA.
* input: Prefer keycodes in input_enqueue key translationThiago de Arruda2015-02-16
| | | | This is required to correctly handle certain keys such as <delete>
* input: Fix check for mouse coordinatesThiago de Arruda2015-01-15
| | | | Must check for EOF which will result in row/col being uninitialized.
* input: Read row/col position when processing mouse wheelThiago de Arruda2015-01-14
|
* input: Ignore invalid "<" key sequencesThiago de Arruda2015-01-13
| | | | | Ignoring invalid key sequences simplifies input handling in UIs. The only downside is having to use "<lt>" everytime a "<" is needed on functional tests.
* Revert "[WIP] "abstract_ui" fixes and improvements"Justin M. Keyes2015-01-12
|
* input: Ignore invalid "<" key sequencesThiago de Arruda2015-01-12
| | | | | Ignoring invalid key sequences simplifies input handling in UIs. The only downside is having to use "<lt>" everytime a "<" is needed on functional tests.
* Remove long_u: term: Enable -Wconversion.Eliseo Martínez2015-01-10
|
* input: Recognize mouse events for abstract_uiThiago de Arruda2014-12-10
|
* ui: Add abstract_ui termcap and split UI layerThiago de Arruda2014-12-08
| | | | | | | | | | | | | | | | | | This is how Nvim behaves when the "abstract_ui" termcap is activated: - No data is written/read to stdout/stdin by default. - Instead of sending data to stdout, ui_write will parse the termcap codes and invoke dispatch functions in the ui.c module. - The dispatch functions will forward the calls to all attached UI instances(each UI instance is an implementation of the UI layer and is registered with ui_attach). - Like with the "builtin_gui" termcap, "abstract_ui" does not contain any key sequences. Instead, vim key strings(<cr>, <esc>, etc) are parsed directly by input_enqueue and the translated strings are pushed to the input buffer. With this new input model, its not possible to send mouse events yet. Thats because mouse sequence parsing happens in term.c/check_termcodes which must return early when "abstract_ui" is activated.
* ui: Remove redundant ui.h includesThiago de Arruda2014-11-27
| | | | Also move read_error_exit to os/input.c
* ui: Remove ui_inchar/ui_char_availThiago de Arruda2014-11-27
| | | | | | | | | Also: - Remove NO_CONSOLE_INPUT/NO_CONSULE preprocessor conditionals - Remove ctrl_c_interrupts variable, check for mapped_ctrl_c directly in process_interrupts() - Move ui_inchar profiling to input_poll which is where Nvim blocks for input.
* input: Refactor to ensure user input has higher priorityThiago de Arruda2014-11-21
|
* event: Ensure the event loop has been cleaned up in event_teardownThiago de Arruda2014-11-02
| | | | | | | | | | - Add input_teardown/signal_teardown to take care of closing signal/stdin handles. - Call those functions in event_teardown, and ensure there are no active handles by entering an infinite loop when there are unclosed handles(think of this as an assertion that can't go unoticed on travis). - Move event_teardown call to the end of mch_exit. That is required because event_poll may still be called in that function.
* api: Add vim_input function and mark vim_feedkeys as deferredThiago de Arruda2014-10-29
| | | | | | | | The `vim_feedkeys` must be deferred because it can potentially free the buffer passed to `os_inchar`(which in turns calls `vim_feedkeys` indirectly). The new `vim_input` function can be used to emulate user input(Since it does not mess with the typeahead, it is safe to execute without deferring).
* input: Fix sizes of input/read buffersThiago de Arruda2014-10-29
| | | | | Input buffer must be bigger than read buffer to ensure it always has space for converted data.
* input/job: process ctrl+c and do conversion in the read callbackThiago de Arruda2014-10-29
| | | | | | | | | - Extract `process_interrupts` out of `convert_input` - Instead of waiting for os_breakcheck/os_inchar calls, call `convert_input` and `process_interrupts` directly from the read callback in input.c. - Remove the `settmode` calls from `job_wait`. Now that interrupts are processed in the event loop, there's no need to set the terminal to cooked which introduces other problems(ref 7.4.427)
* input: Fix conversion error in `convert_input()`Thiago de Arruda2014-10-28
| | | | | | | The `rbuffer_consumed` was being passed a consumed count from another buffer, causing integer overflow in `rbuffer_relocate`. Fixes #1343
* input: Fix ctrl+c handling in convert_inputThiago de Arruda2014-10-22
|