Created
May 17, 2009 04:24
-
-
Save bdonlan/112920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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