aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/wdye/wdye.c32
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.