Set title bas on the output found on the screen.
[screen-lua.git] / src / scripts / autoaka.lua
blob5188754c64ab43f31328372482dd7f939d466b69
1 -- not a full implementation, but demonstrates the idea.
2 -- A full implementation is not that easy...
3 function winhook(win)
4 local buf = ""
5 local saw_anchor = 0
7 function aka(win, out)
8 buf = buf .. out
9 title = string.match(buf, "\027k\027.$ (%w+).-\n")
10 if title ~= nil and title ~= win.title then
11 win.title = title
12 saw_anchor = 0
13 buf = ""
14 return 0
15 end
17 new = string.match(buf, ".*\n(.*)")
18 if (new ~= nil) then
19 buf = new
20 else
21 if string.len(buf) >= 20 then
22 buf = ""
23 end
24 end
25 return 0
26 end
27 win:hook("onoutput", aka)
28 end
30 ticket1 = screen.hook("oncreatewindow", winhook)