From: Rui Guo Date: Mon, 10 Aug 2009 16:37:52 +0000 (+0800) Subject: Set title bas on the output found on the screen. X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/19b2c99c31bb7593b65dc95094d3ac85cafaf089 Set title bas on the output found on the screen. --- 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)