diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-18 12:31:33 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-18 15:07:02 +0200 |
| commit | 0d1152340ccb3c6a0a8b4160fda34cc6687b236e (patch) | |
| tree | 054c0110c76227e8aae96e1fec3a5a2a37aa9e99 /vis.h | |
| parent | ffe11d4cd4a4c81395b3272706cf696b93710c61 (diff) | |
| download | vis-0d1152340ccb3c6a0a8b4160fda34cc6687b236e.tar.gz vis-0d1152340ccb3c6a0a8b4160fda34cc6687b236e.tar.xz | |
vis: add an interactive mode to vis_pipe{,_collect}(...)
Previously the interactive mode was implicitly enabled by passing
an invalid range. However for some use cases (e.g. completion) we
need to be able to pipe a given text range to an external process
without also redirecting stderr (which is used to draw the slmenu
interface on top of vis).
Diffstat (limited to 'vis.h')
| -rw-r--r-- | vis.h | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -410,6 +410,10 @@ bool vis_prompt_cmd(Vis*, const char *cmd); /* pipe a given file range to an external process * + * in interactive mode stdin and stderr are not redirected, hence they + * can be used to read keyboard input and draw a user interface on top + * of vis. Attempting to pipe an invalid range enables interactive mode. + * * if argv contains only one non-NULL element the command is executed using * /bin/sh -c (i.e. argument expansion is performed by the shell). In contrast * if argv contains more than one non-NULL element execvp(argv[0], argv); will @@ -418,14 +422,14 @@ bool vis_prompt_cmd(Vis*, const char *cmd); * if read_std{out,err} are non-NULL they will be called when output from * the forked process is available. */ -int vis_pipe(Vis *vis, Filerange *range, const char *argv[], +int vis_pipe(Vis *vis, Filerange *range, bool interactive, const char *argv[], void *stdout_context, ssize_t (*read_stdout)(void *stdout_context, char *data, size_t len), void *stderr_context, ssize_t (*read_stderr)(void *stderr_context, char *data, size_t len)); /* pipe a range to an external application, return its exit status and store * everything that is written to stdout/stderr in the gitven char pointers * which have to be free(3)-ed by the caller */ -int vis_pipe_collect(Vis *vis, Filerange *range, const char *argv[], char **out, char **err); +int vis_pipe_collect(Vis *vis, Filerange *range, bool interactive, const char *argv[], char **out, char **err); /* given the start of a key, returns a pointer to the start of the one immediately * following as will be processed by the input system. skips over special keys |
