Add a demo function.
authorRui Guo <firemeteor.guo@gmail.com>
Mon, 22 Jun 2009 08:37:08 +0000 (22 16:37 +0800)
committerRui Guo <firemeteor.guo@gmail.com>
Mon, 22 Jun 2009 08:37:08 +0000 (22 16:37 +0800)
Illustrates creating window immediately to the right of the current one.

src/scripts/movewindow.lua

index 4ef8083..d084f4f 100644 (file)
@@ -9,3 +9,24 @@ function toright()
   local w = screen.display().fore
   w.number = w.number + 1
 end
+
+function newonright()
+  local w = screen.display().fore
+  local wl = screen.windows()
+  local n = w.number
+  while true do
+    local wn = wl[w.number + 1]
+    if wn == nil then
+      break
+    else
+      w = wn
+    end
+  end
+  while w.number > n do
+    local wn = wl[w.number - 1]
+    w.number = w.number + 1
+    w = wn
+  end
+
+  screen.command("screen")
+end