From 80fbb7e1ead4d16f1f4d511d30df18eeb65ceafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Bakker?= Date: Fri, 16 Jun 2023 11:59:25 +0200 Subject: Add fullscreen param to vis_pipe_collect() and Lua API vis:pipe() This enables restoring the terminal from a fullscreen command like curses based program. Use cases are e.g. a file picker based on some external program like nnn (https://github.com/jarun/nnn). --- vis.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'vis.h') diff --git a/vis.h b/vis.h index 85a458a..f8c5680 100644 --- a/vis.h +++ b/vis.h @@ -898,6 +898,10 @@ bool vis_prompt_cmd(Vis*, const char *cmd); * If the ``read_stdout`` and ``read_stderr`` callbacks are non-NULL they * will be invoked when output from the forked process is available. * + * If ``fullscreen`` is set to ``true`` the external process is assumed to + * be a fullscreen program (e.g. curses based) and the ui context is + * restored accordingly. + * * @rst * .. warning:: The editor core is blocked until this function returns. * @endrst @@ -906,7 +910,8 @@ bool vis_prompt_cmd(Vis*, const char *cmd); */ int vis_pipe(Vis*, File*, Filerange*, 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)); + void *stderr_context, ssize_t (*read_stderr)(void *stderr_context, char *data, size_t len), + bool fullscreen); /** * Pipe a Filerange to an external process, return its exit status and capture @@ -914,12 +919,13 @@ int vis_pipe(Vis*, File*, Filerange*, const char *argv[], * @param argv Argument list, must be ``NULL`` terminated. * @param out Data written to ``stdout``, will be ``NUL`` terminated. * @param err Data written to ``stderr``, will be ``NUL`` terminated. + * @param fullscreen Whether the external process is a fullscreen program (e.g. curses based) * @rst * .. warning:: The pointers stored in ``out`` and ``err`` need to be `free(3)`-ed * by the caller. * @endrst */ -int vis_pipe_collect(Vis*, File*, Filerange*, const char *argv[], char **out, char **err); +int vis_pipe_collect(Vis*, File*, Filerange*, const char *argv[], char **out, char **err, bool fullscreen); /** * @} -- cgit v1.2.3