From 19b2c99c31bb7593b65dc95094d3ac85cafaf089 Mon Sep 17 00:00:00 2001 From: Rui Guo Date: Tue, 11 Aug 2009 00:37:52 +0800 Subject: [PATCH] Set title bas on the output found on the screen. --- src/scripts/autoaka.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/scripts/autoaka.lua diff --git a/src/scripts/autoaka.lua b/src/scripts/autoaka.lua new file mode 100644 index 0000000..5188754 --- /dev/null +++ b/src/scripts/autoaka.lua @@ -0,0 +1,30 @@ +-- not a full implementation, but demonstrates the idea. +-- A full implementation is not that easy... +function winhook(win) + local buf = "" + local saw_anchor = 0 + +function aka(win, out) + buf = buf .. out + title = string.match(buf, "\027k\027.$ (%w+).-\n") + if title ~= nil and title ~= win.title then + win.title = title + saw_anchor = 0 + buf = "" + return 0 + end + + new = string.match(buf, ".*\n(.*)") + if (new ~= nil) then + buf = new + else + if string.len(buf) >= 20 then + buf = "" + end + end + return 0 +end + win:hook("onoutput", aka) +end + +ticket1 = screen.hook("oncreatewindow", winhook) -- 2.11.4.GIT