aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/shell.c
Commit message (Collapse)AuthorAge
...
* eval: Fix jobwait() to process multiple jobs concurrentlyThiago de Arruda2015-08-13
| | | | | | | | | | | | | The new event processing architecture changed `jobwait()` semantics: Only one job is processed at time since process_wait only focuses on one queue. This fixes the problem with a few changes: - Allow the event queue polled by `process_wait` to be overriden by a new argument. - Allow the parent queue to be overriden with `queue_replace_parent` - Create a temporary queue that serves as the parent for all jobs passed to `jobwait()`
* 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.
* process: Pass loop reference during initializationThiago de Arruda2015-08-13
| | | | | Change the API so that it is passed to {uv,pty}_process_init instead of `process_spawn`.
* shell.c: A full RBuffer with no NL can freeze shell output. #3156oni-link2015-08-11
| | | | | | | | | | | | | | | out_data_cb() can return without emptying the full RBuffer (no NL was seen). Because the shell output stream is stopped until space in the Rbuffer is freed up, no more shell output is written. To prevent this, output the full RBuffer when write_output() did not write anything. write_output() can also process the same RBuffer content more than once, if no NL was seen. To prevent NUL bytes from producing new lines (if lines are not written to a buffer), translate NUL to SOH(1). Fixes #2983
* job: Replace by a better process abstraction layerThiago de Arruda2015-07-17
| | | | | | | | | | | | | - New libuv/pty process abstraction with simplified API and no globals. - Remove nvim/os/job*. Jobs are now a concept that apply only to programs spawned by vimscript job* functions. - Refactor shell.c/channel.c to use the new module, which brings a number of advantages: - Simplified API, less code - No slots in the user job table are used - Not possible to acidentally receive data from vimscript - Implement job table in eval.c, which is now a hash table with unilimited job slots and unique job ids.
* 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>
* Fix warnings: shell.c: do_os_system(): Nonnull passed null: FP. #2923Eliseo Martínez2015-06-28
| | | | | | | | | | | | Problem : Argument with 'nonnull' attribute passed null @ 203. Diagnostic : False positive. Rationale : Problem is supposed to appear when argv[0] is NULL within do_os_system. But argv is being generated by shell_build_argv(), which implies argv[0] is the current value for 'shell' option. Now, option has a non-null default ($SHELL or "sh"), and, if set by the user, it can be empty, but not NULL. So, argv[0] can never be NULL. Resolution : Assert shell_build_argv() postcondition.
* unify jobstart, termopen, and system interfacesScott Prager2015-05-02
| | | | | | | | | | | | | | | | | For any of these functions, if {cmd} is a string, execute "&shell &shellcmdflag '{cmd}'", or simply {cmd} if it's a list. In termopen(), if the 'name' option is not supplied, try to guess using '{cmd}' (string) or {cmd}[0] (list). Simplify ex_terminal to use the string form of termopen(). termopen: get name from argument Convert list_to_argv to tv_to_argv. Helped-by: Björn Linse <@bfredl> Helped-by: oni-link <knil.ino@gmail.com> Helped-by: Thiago de Arruda <@tarruda>
* memory: Add `free` wrapper and refactor project to use itThiago de Arruda2015-04-13
| | | | | | We already use wrappers for allocation, the new `xfree` function is the equivalent for deallocation and provides a way to fully replace the malloc implementation used by Neovim.
* 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).
* 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.
* 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
* 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.
* Revert "[WIP] "abstract_ui" fixes and improvements"Justin M. Keyes2015-01-12
|
* shell: When executing command, use screen functions to display outputThiago de Arruda2015-01-12
| | | | | By calling ui_write directly, the internal screen isn't updated and invalid bytes aren't handled, which breaks the abstract UI model.
* 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.
* coverity/74718: invalid FUNC_ATTR_NONNULL_ARGJustin M. Keyes2014-12-20
| | | | | | | - avoid null passed to ELOG format string - receive (char *) internally - modify identifier names for consistency - edit comments for concision and consistency
* shell: Fix shell command outputThiago de Arruda2014-12-06
| | | | | | | | | Shell command output was broken in @8a5a8db, which refactored nvim to no longer switch to cooked mode(linefeeds are processed differently). Fix the problem by refactoring write_output to accept to extra arguments that control the flushing behavior and where data will be written to: buffer or directly to the screen.
* term: Remove most calls to settmodeThiago de Arruda2014-12-02
| | | | | | Nvim now relies much less on setting terminal mode to cooked mode, remove most calls to settmode, except for those that happen on startup or when suspending. Eventually even those will be handled by the UI layer.
* shell: Use job_write_cb for closing stdinThiago de Arruda2014-11-10
| | | | | | | | | | Commit @45525853d352 removed usage of the `job_write_cb` for closing stdin due to a memory error, but that doesn't work anymore because `job_close_in` closes stdin immediately, possibly trimming input data before it is fully written. Since most memory issues with jobs have been fixed, re-add the `job_write_cb` call to ensure stdin is only closed when it should. Also add tests for scenarios where using the callback makes a difference.
* job/shell: Refactor os_call_shell/os_system to share codeThiago de Arruda2014-10-31
|
* shell: Rename dyn_buffer_t to DynamicBufferThiago de Arruda2014-10-31
| | | | To follow our coding conventions
* job: Let job_start callers to selectively ignore stdioThiago de Arruda2014-10-31
| | | | | | | | Passing NULL as the callback for stdout/stderr will result in job_start ignoring stdout/stderr, respectively. A 'writable' boolean argument was also added, and when false `job_start` will ignore stdin. Also, refactor os_system to allow passing NULL as the `output` argument.
* event: Remove direct calls to `uv_run` from job.c/shell.cThiago de Arruda2014-10-21
|
* compilation: Add -Wconversion to more files and validate CONV_SOURCESThiago de Arruda2014-10-21
| | | | | | All files under the os, api and msgpack_rpc directories have -Wconversion automatically applied. CONV_SOURCES is also checked for missing files(when renaming, for example)
* rstream: Extract some RStream functionality to RBufferThiago de Arruda2014-10-18
| | | | | | | | RBuffer instances represent the internal buffer used by RStreams. This changes RStream constructor to receive RBuffer pointers and adds a set of RBuffer methods that expose the lower level buffer manipulation to consumers of the RStream API.
* wstream/shell: Fix memory errors caused by os_systemThiago de Arruda2014-10-01
| | | | | | | | | | | | | | The os_system function uses a write callback to close the input stream when the write completes, but this causes a memory error because the callback is invoked right before the stream is freed by the caller. This fixes the problem by removing the callback set by os_system. Instead, it calls job_close_in immediately after writing(the stream will only close after the write completes). The 'pending' parameter was also removed from the 'write_cb' as it should be hidden by the wstream module. While the `wstream_set_write_cb` and `job_write_cb` are no longer used, they will remain in the codebase for future use.
* Remove unused arg 'defer' in 'job_start' #1000oni-link2014-07-29
| | | | | | | | | * With the changes in commit "events: Refactor how event deferral is handled" (2e4ea29d2c7b62eb8baf1c41cd43433e085dda0) the function argument 'defer' of 'job_start' and member variable 'defer' of 'struct job' can be removed. * Update/Fix the documentation for function 'job_start'.
* os/shell: implement os_systemNicolas Hillegeer2014-07-27
| | | | | | | | | | | | | | | | | With the goal to support pipe-only system() calls. Notes on the second (vim) argument to f_system() (i.e.: redirected input) and its implications: - When calling system('cat -', ['some', 'list']), vanilla vim (before a recent patch that added support for passing lists) just passes an empty file to the process. This is the same as immediately closing the pipe, which os_system does when no input is given. If we wouldn't close the pipe, the process will linger forever (as is the case with `cat -`). As of now, it's not allowed to pass a non-NULL pointer as the `output` parameter. In other words, it's not possible to signal disinterst in the process output. That may change in the future.
* os/shell: constify argumentsNicolas Hillegeer2014-07-27
| | | | Minor fixes
* move ascii.h include out of vim.hBrandon Coleman2014-07-09
|
* spelling fixes #827Will Stamper2014-06-12
|
* Add automatic generation of headersZyX2014-06-02
| | | | | | | | | | | | | | | | | - The 'stripdecls.py' script replaces declarations in all headers by includes to generated headers. `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'` was used for this. - Add and integrate gendeclarations.lua into the build system to generate the required includes. - Add -Wno-unused-function - Made a bunch of old-style definitions ANSI This adds a requirement: all type and structure definitions must be present before INCLUDE_GENERATED_DECLARATIONS-protected include. Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is the only exception.
* Move documentation from function declarations to definitionsZyX2014-06-02
| | | | Uses a perl script to move it (scripts/movedocs.pl)
* Replace ga->ga_len > 0 checks with !GA_EMPTY(ga)Felipe Oliveira Carvalho2014-05-17
| | | | | | | | | | | | | | | | | | | | | | Used Coccinelle to perform the changes ```diff @@ expression E; @@ <... ( - E.ga_len > 0 + !GA_EMPTY(&E) | - E->ga_len > 0 + !GA_EMPTY(E) ) ...> ``` `spatch --in-place --sp-file ga_empty.cocci <C_FILE>`
* Introduce nvim namespace: Fix unmasked strings.h issue.Eliseo Martínez2014-05-15
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: Now that nvim/strings.h is correctly namespaced, an issue that had been masked until now arises: When compiling, we get a lot of errors because of everywhere the functions in nvim/strings.h are used, there's no include to import them. But, how could this compile and work previously, then? It turns out that: - In every such case, we are also including vim.h, which in turn includes os_unix_defs.h. - os_unix_defs.h includes <string.h> and also <strings.h> in some systems (e.g. OSX). - Build had been modified previously to (even when importing system headers), prefer equally-named local ones. That was in fact done as a previous attempt to solve the same issue we are trying to solve another way now. So, we were including our "strings.h" as a side-effect of including <strings.h> through "vim.h" --> "os_unix_defs.h". Solution: Correctly include "nvim/strings.h" in every file needing it.
* Introduce nvim namespace: Fix project-local includes.Eliseo Martínez2014-05-15
| | | | Prepend 'nvim/' in all project-local (non-system) includes.
* Introduce nvim namespace: Move files.Eliseo Martínez2014-05-15
Move files from src/ to src/nvim/. - src/nvim/ becomes the new root dir for nvim executable sources. - src/libnvim/ is planned to become root dir of the neovim library.