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-lua.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'vis-lua.c') 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. * -- cgit v1.2.3