Skip to content

Instantly share code, notes, and snippets.

@bdonlan
Created May 17, 2009 04:24
Show Gist options
  • Save bdonlan/112920 to your computer and use it in GitHub Desktop.
Save bdonlan/112920 to your computer and use it in GitHub Desktop.
function KeyMap:process(key)--{{{
keybuf = keybuf .. key
local found_key, func, index, dirn = mapping:find_near(key)
if found_key == nil then
-- No keys defined??
return
end
if dirn == 0 then
func()
keybuf = ""
elseif dirn < 0 then
index = index + 1
found_key, func = mapping:lookup_index(index + 1)
end
if found_key == nil or string.find(found_key, self.keybuf) ~= 1 then
-- not a prefix of anything
screen:keypress(self.keybuf)
keybuf = ""
else
-- prefix of something, keep going
end
end--}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment