aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
diff options
context:
space:
mode:
authorJörg Bakker <captaingroove@openmultimedia.org>2023-06-16 11:59:25 +0200
committerRandy Palamar <palamar@ualberta.ca>2023-07-18 21:06:46 -0600
commit80fbb7e1ead4d16f1f4d511d30df18eeb65ceafa (patch)
tree106950ed5bdcfbc14b18c6bc8e96df92aa951268 /vis-lua.c
parent599ced0bfc378682053484a9658bd59c02c96973 (diff)
downloadvis-80fbb7e1ead4d16f1f4d511d30df18eeb65ceafa.tar.gz
vis-80fbb7e1ead4d16f1f4d511d30df18eeb65ceafa.tar.xz
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).
Diffstat (limited to 'vis-lua.c')
-rw-r--r--vis-lua.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/vis-lua.c b/vis-lua.c
index 735445b..e304dd7 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1331,6 +1331,7 @@ static int exit_func(lua_State *L) {
* @tparam[opt] File file the file to which the range applies
* @tparam[opt] Range range the range to pipe
* @tparam string command the command to execute
+ * @tparam[opt] bool fullscreen whether command is a fullscreen program (e.g. curses based)
* @treturn int code the exit status of the executed command
* @treturn string stdout the data written to stdout
* @treturn string stderr the data written to stderr
@@ -1348,7 +1349,8 @@ static int pipe_func(lua_State *L) {
range = getrange(L, 3);
}
const char *cmd = luaL_checkstring(L, cmd_idx);
- int status = vis_pipe_collect(vis, file, &range, (const char*[]){ cmd, NULL }, &out, &err);
+ bool fullscreen = lua_isboolean(L, cmd_idx + 1) && lua_toboolean(L, cmd_idx + 1);
+ int status = vis_pipe_collect(vis, file, &range, (const char*[]){ cmd, NULL }, &out, &err, fullscreen);
lua_pushinteger(L, status);
if (out)
lua_pushstring(L, out);
@@ -1363,6 +1365,7 @@ static int pipe_func(lua_State *L) {
vis_draw(vis);
return 3;
}
+
/***
* Redraw complete user interface.
*