aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
Commit message (Collapse)AuthorAge
...
* 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.
* event: Only process if event_init has been run.Scott Prager2015-04-08
| | | | | | | | | Reported by @fourjay, a codepath that causes event_poll() to run before event_init() will trigger a segfault as the events list will not have been initialized. Exiting immediately from event_init() causes nvim to hang, so just exit before running the events. fixes #2339
* event.c: Simplify timer use in event_poll()oni-link2015-04-08
| | | | | | | | | | | | | | | | | event_poll() always leaves the libuv I/O loop after one iteration. The duration for how long the loop polls for I/O is given by the shortest timeout of all active timers. Is no timer active, I/O is/could be polled indefinitely. To make sure our timer is still active when I/O polling begins, a prepare handle is used to start the timer right before the polling. But by only using a timer that restarts after its timeout was reached, we also can assure that polling is done with (nearly) the same finite timeout. For a short explanation how the I/O loop is working, see http://docs.libuv.org/en/latest/design.html#the-i-o-loop.
* Fix a memory leak for WBuffers used in channel_write().oni-link2015-04-03
| | | | | | | channel_write() uses a ref-counted buffer for writing. This buffer should be released if it was used in "refcount" channel_write() calls. But calling channel_write() on a closed channel would return early and not decrease the refcount of the used buffer.
* Remove potential NULL dereference. #2316Prajjwal Bhandari2015-03-31
| | | | | | This also removes the `#elseif defined(MSWIN)` clause. Due to the enclosing `if` block, we will never get to this point when src starts with a '%', making the whole #elseif block dead code.
* os_scandir(), scandir_next(), and os_closedir()Scott Prager2015-03-31
|
* eval: Implement `jobclose()` vimscript functionThiago de Arruda2015-03-29
|
* eval: Implement `jobwait()` vimscript functionThiago de Arruda2015-03-29
|
* eval: Refactor vimscript job control APIThiago de Arruda2015-03-29
| | | | | | | | | | - Remove JobActivity autocmd and v:job_data variable - Simplify `jobstart` to receive: - An argument vector - An optional dictionary which may contain any of the current `jobstart` options plus `on_stdout`, `on_stderr` and `on_exit` callbacks. - Refactor and add more job tests - Update documentation
* tui: Fix reading when stdin is not a ttyThiago de Arruda2015-03-26
| | | | | | | | | | | | | | | | | | Instead of selecting stderr on startup if stdin is not a tty, first try reading from it and only switch to stderr when reading fails. With this behavior we support commands like: ``` echo q | nvim -es ``` and ``` ls *.md | xargs nvim ``` Fixed small bugs in rstream.c to make this happen.
* job: Close the process in a queued event handlerThiago de Arruda2015-03-25
| | | | | | Since all reads are queued by the event loop, we must also queue the exit event, or else the process_close function can close the job streams before received data is processed.
* terminal: New module that implements a terminal emulatorThiago de Arruda2015-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit integrates libvterm with Neovim and implements a terminal emulator with nvim buffers as the display mechanism. Terminal buffers can be created using any of the following methods: - Opening a file with name following the "term://[${cwd}//[${pid}:]]${cmd}" URI pattern where: - cwd is the working directory of the process - pid is the process id. This is just for use in session files where a pid would have been assigned to the saved buffer title. - cmd is the command to run - Invoking the `:terminal` ex command - Invoking the `termopen` function which returns a job id for automating the terminal window. Some extra changes were also implemented to adapt with terminal buffers. Here's an overview: - The `main` function now sets a BufReadCmd autocmd to intercept the term:// URI and spawn the terminal buffer instead of reading the file. - terminal buffers behave as if the following local buffer options were set: - `nomodifiable` - `swapfile` - `undolevels=-1` - `bufhidden=hide` - All commands that delete buffers(`:bun`, `:bd` and `:bw`) behave the same for terminal buffers, but only work when bang is passed(eg: `:bwipeout!`) - A new "terminal" mode was added. A consequence is that a new set of mapping commands were implemented with the "t" prefix(tmap, tunmap, tnoremap...) - The `edit` function(which enters insert mode) will actually enter terminal mode if the current buffer is a terminal - The `put` operator was adapted to send data to the terminal instead of modifying the buffer directly. - A window being resized will also trigger a terminal resize if the window displays the terminal.
* event: Ensure the loop is stopped when a event is pushed.Thiago de Arruda2015-03-25
|
* refactor: split some more functions from misc1.cbobtwinkles2015-03-24
| | | | | | | | | | | This commit pulls the some environment-variable handling functions out of misc1.c and in to os/env.c. Previously submited as #1231, this is the start of a patch series that does that work based on a more up-to-date master branch. Major tasks accomplished: - move functions and fix includes - fix clint/clang analysis warnings - correct documentation comments
* job: Fix memory erroroni-link2015-03-24
| | | | | Fix pointer passed to the handles in the uv_close() calls when process_spawn() fails.
* job: Fix process cleanup using SIGCHLD/waitpidThiago de Arruda2015-03-24
| | | | | Add a SIGCHLD handler for cleaning up pty processes passing the WNOHANG flag. It may also be used to cleanup processes spawned with uv_spawn.
* Passing-by: Add function attributes.Eliseo Martínez2015-03-22
|
* coverity/105985: Resource leak: RI.Eliseo Martínez2015-03-22
| | | | | | | | | | | | | | | | | | | | Problem : Resource leak @ 94, 98, 102. Diagnostic : Real issue. Rationale : Coverity doesn't know that uv_pipe_open will save file descriptor to close them later. So, it signals file descriptors being leaked. This would then seem like a false positive we can fix by teaching coverity about uv_pipe_open through model file. But then we realize that the above is only true if uv_pipe_open succeeds. It it fails, then descriptors are really being leaked, which is why this is considered a real issue and not a false positive after all. Resolution : Add error handling to correctly close descriptors if uv_pipe_open fails at any point. Add model for uv_pipe_open so that Coverity knows it will save descriptors when no error. Helped-by: oni-link <knil.ino@gmail.com>
* coverity/105982: Unckecked return value: RI.Eliseo Martínez2015-03-22
| | | | | | | | | Problem : Unchecked return value from library @ 91. Diagnostic : Real issue. Rationale : fcntl can fail, which is not being checked. Resolution : Add corresponding error handling. Helped-by: oni-link <knil.ino@gmail.com>
* Merge pull request #2144 from jszakmeister/fix-warning-in-releaseJohn Szakmeister2015-03-20
|\ | | | | Fix a couple warnings in the release build.
| * Fix unused variable in wstream.c for a release build.John Szakmeister2015-03-14
| |
* | 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.
* | ui: Refactor so that busy state won't be the defaultThiago de Arruda2015-03-18
| | | | | | | | | | | | | | | | | | | | | | Even though assuming nvim is busy most times is simpler, it has a problem: A lot of unnecessary busy_start/busy_stop notifications are sent to the UI. That's because in the majority of scenarios almost no time is spent between `event_poll` calls. This restores the normal behavior which is to call busy_start only when nvim is going to perform some task that can take a significant amount of time. Also improve the usage of buffering in the TUI when changing the cursor state.
* | ui: Replace cursor_{on,off} by busy_{stop,start}Thiago de Arruda2015-03-15
|/ | | | | | | | | | | | | | | | | | | | | | | | 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).
* Merge pull request #2114 from oni-link/remove.assertJohn Szakmeister2015-03-12
|\ | | | | Fixes for two compiler warnings
| * Remove unnecessary assert() in os_dirname().oni-link2015-03-08
| | | | | | | | | | | | | | | | | | Compiler warns about buf always being nonnull. buf is per function attribute always nonnull, so buf can be removed from the assert(). But a buffer length of zero is also no problem, because it makes uv_cwd() return a failure without writing into buf. So the remaining length check can also be removed.
* | os_unix_defs && os/unix_defs: Consistently use '~' over '$HOME' #2009Michael Reed2015-03-11
|/ | | | | | these path names are ridiculous... Based on #889, but also remove some unused #defines
* illumos requires the use of limits.h for things like INT_MAX #2049Mike Zeller2015-02-26
|
* job: Allow spawning jobs connected to pseudo terminalsThiago de Arruda2015-02-23
|
* job: Refactor process spawning and startup argumentsThiago de Arruda2015-02-23
| | | | | | | | - process spawning was decoupled from the rest of the job control logic. The goal is reusing it for spawning processes connected to pseudo terminal file descriptors. - job_start now receives a JobOptions structure containing all the startup options.
* job: Send SIGTERM before calling job_stop in job_teardownThiago de Arruda2015-02-23
| | | | | Send sigterm immediately since it can be caught by processes. If they don't respond and are still alive after a while, SIGKILL will be sent.
* refactor: Remove term modules and termcap optionsThiago de Arruda2015-02-21
| | | | | | | | | | | | | | | - Removed term.c, term.h and term_defs.h - Tests for T_* values were removed. screen.c was simplified as a consequence(the best strategy for drawing is implemented in the UI layer) - Redraw functions now call ui.c functions directly. Updates are flushed with `ui_flush()` - Removed all termcap options(they now return empty strings for compatibility) - &term/&ttybuiltin options return a constant value(nvim) - &t_Co is still available, but it mirrors t_colors directly - Remove cursor tracking from screen.c and the `screen_start` function. Now the UI is expected to maintain cursor state across any call, and reset it when resized. - Remove unused code
* 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>
* coverity/{68484,68485}: Read from pointer after free: RI.Thiago de Arruda2015-02-11
| | | | | | | | | Problem : Read from pointer after free @ {242, 391}. Diagnostic : Real issues. Rationale : Channel gets indeed freed on error case, producing incorrect accesses to freed pointer later on. Resolution : Implement reference counting mechanism to know when to free channel.
* Remove long_u: Remove type.Eliseo Martínez2015-01-19
|
* Merge pull request #1798 from oni-link/fix.job.waitJustin M. Keyes2015-01-18
|\ | | | | job.c: Prevent early return from job_wait().
| * job.c: Prevent early return from job_wait().oni-link2015-01-11
| | | | | | | | | | | | | | | | | | | | A blocking call job_wait(job, -1) can only return after job is finished and all handles of job are closed. But hitting CTRL-C makes job_wait() return early while handles can still be open. This can lead to problems with the job/handle callbacks if the caller (of job_wait()) already freed the memory that is used in the job callbacks. To fix this, only return after all handles of the job are closed.
* | 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
| |
* | shell: When executing command, use screen functions to display outputThiago de Arruda2015-01-13
| | | | | | | | | | By calling ui_write directly, the internal screen isn't updated and invalid bytes aren't handled, which breaks the abstract UI model.
* | 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.
* | Linting: Recommend os_* instead of POSIX functions.Florian Walch2015-01-11
|/
* Remove long_u: term: Enable -Wconversion.Eliseo Martínez2015-01-10
|
* Merge pull request #1684 from justinmk/coverity74717Justin M. Keyes2014-12-26
|\ | | | | [RFC] coverity/74717: FP: NULL Pointer Dereference
| * coverity/74717: FP: NULL Pointer DereferenceJustin M. Keyes2014-12-23
| | | | | | | | | | dynamic_buffer_ensure() allocates buf->data; add an assert to make this clear to coverity.
* | Linting: Suppress warnings in os/users.c.Florian Walch2014-12-24
| |