From 40c07e7eb189e1fd718d9685f07c381aedb7be3a Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 21 Aug 2008 16:05:58 -0400 Subject: [PATCH] A sample script. With this script, the ':lua find_window XXX' command will switch to the split containing the window 'XXX' (instead of having to cycle through all the other windows). If no such split exists, then the window is selected in the current split. --- src/scripts/findwindow.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/scripts/findwindow.lua diff --git a/src/scripts/findwindow.lua b/src/scripts/findwindow.lua new file mode 100644 index 0000000..d1dbccc --- /dev/null +++ b/src/scripts/findwindow.lua @@ -0,0 +1,19 @@ +function find_window(name) + display = screen.display() + canvases = {display:get_canvases()} + for i, c in pairs(canvases) do + w = c.window + if w ~= nil and (w.title == name or tostring(w.number) == name) then c:select() return end + end + + -- Try partial matches, just like 'select' + for i, c in pairs(canvases) do + w = c.window + if w ~= nil and w.title:sub(1, name:len()) == name then c:select() return end + end + + -- We didn't find the desired window in any canvas + -- So switch to the window in the current canvas instead + screen.command("select " .. name) +end + -- 2.11.4.GIT