Enable stuffing a window.
authorRui Guo <firemeteor.guo@gmail.com>
Mon, 22 Jun 2009 09:02:03 +0000 (22 17:02 +0800)
committerRui Guo <firemeteor.guo@gmail.com>
Mon, 22 Jun 2009 09:02:03 +0000 (22 17:02 +0800)
I would like to be able to stuff background windows without temporarily switch
the for layer.

src/lua.c
src/scripts/movewindow.lua

index f36d4da..6373061 100644 (file)
--- a/src/lua.c
+++ b/src/lua.c
@@ -429,8 +429,24 @@ window_get_monitor_status(lua_State *L)
   return 1;
 }
 
+static int
+window_stuff(lua_State *L)
+{
+  unsigned int len;
+  struct layer *oldflayer = flayer;
+  struct win *w = check_window(L, 1);
+  const char *str = luaL_checklstring(L, 2, &len);
+
+  flayer = &w->w_layer;
+  while(len)
+    LayProcess((char **)&str, (int *) &len);
+  flayer = oldflayer;
+  return 0;
+}
+
 static const luaL_reg window_methods[] = {
   {"get_monitor_status", window_get_monitor_status},
+  {"stuff", window_stuff},
   {"hook", LuaRegEvent},
   {0, 0}
 };
index d084f4f..65cca2a 100644 (file)
@@ -30,3 +30,10 @@ function newonright()
 
   screen.command("screen")
 end
+
+function list()
+  local wl = screen.windows()
+  if wl[1] ~=nil then
+    wl[1]:stuff("ls\n")
+  end
+end