diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2025-01-03 09:13:24 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2025-01-03 09:13:24 +0100 |
commit | a6e7cb553f9cc136cb7358385ca266d40a33523d (patch) | |
tree | b41430474459a3928afd7686179bc2d7033b35c9 /tools/wdye/wdye.c | |
parent | 66733cef1cf1af2f2610f1cb816a9e39caf01202 (diff) | |
download | liberty-a6e7cb553f9cc136cb7358385ca266d40a33523d.tar.gz liberty-a6e7cb553f9cc136cb7358385ca266d40a33523d.tar.xz liberty-a6e7cb553f9cc136cb7358385ca266d40a33523d.zip |
WIP
Diffstat (limited to 'tools/wdye/wdye.c')
-rw-r--r-- | tools/wdye/wdye.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/wdye/wdye.c b/tools/wdye/wdye.c index 47e485b..31652c6 100644 --- a/tools/wdye/wdye.c +++ b/tools/wdye/wdye.c @@ -31,6 +31,7 @@ #include <stropts.h> #endif +#include <curses.h> #include <term.h> // --- Pseudoterminal ---------------------------------------------------------- @@ -316,6 +317,31 @@ environ_map_serialize (struct str_map *env, struct strv *envv) xstrdup_printf ("%s=%s", iter.link->key, value)); } +static bool +xlua_load_terminal (lua_State *L, const char *term) +{ + // TODO(p): See if we can get away with using a bogus FD. + int err = 0; + TERMINAL *saved_term = set_curterm (NULL); + if (setupterm ((char *) term, STDOUT_FILENO, &err) != OK) + { + set_curterm (saved_term); + return false; + } + + for (size_t i = 0; strfnames[i]; i++) + { + const char *name = strfnames[i]; + const char *value = tigetstr (strnames[i]); + if (value && value != (char *) -1) + continue; + } + + del_curterm (set_curterm (saved_term)); + + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static int @@ -323,12 +349,18 @@ xlua_spawn_protected (lua_State *L) { struct xlua_spawn_context *ctx = lua_touserdata (L, 1); + // TODO(p): Consider taking the TERM from the passed environ, + // or defaulting to inherited TERM. These should match anyway. + // Step 1: Prepare a terminal object. (void) xlua_getfield (L, 1, "term", LUA_TSTRING, true); const char *term = lua_tostring (L, -1); + + // TODO(p): Process the terminal name, // possibly by creating another indexable Lua object/table. // - Remember to use a default when `term == NULL`. + lua_pop (L, 1); // Step 2: Prepare process environment. |