1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
-- History completion support for the line editor
local function historyi()
function gn(s)
local i=s.i
s.i=s.i+1
return mod_query.history_get(i)
end
return gn, {i=0}
end
local function complhist(tocompl)
local res={}
local res2={}
for str in historyi() do
local s, e=string.find(str, tocompl, 1, true)
if s then
table.insert(res2, str)
end
if s==1 and e>=1 then
table.insert(res, str)
end
end
return (#res>0 and res) or res2
end
function history_completor(wedln)
wedln:set_completions(complhist(wedln:contents()))
end
defbindings("WEdln", {
kpress("Shift+Tab", history_completor),
})
|