Make it possible to bind a function to a key

This commit is contained in:
Jorgen Stenarson
2010-02-22 19:51:08 +01:00
parent 3721005ad9
commit a4e4163575
2 changed files with 6 additions and 3 deletions
+2 -2
View File
@@ -157,9 +157,9 @@ class BaseMode(object):
def _bind_key(self, key, func):
u"""setup the mapping from key to call the function."""
if type(func) != type(self._bind_key):
if not callable(func):
print u"Trying to bind non method to keystroke:%s,%s"%(key,func)
raise PyreadlineError(u"Trying to bind non method to keystroke:%s,%s,%s,%s"%(key,func,type(func),type(self._bind_key)))
raise ReadlineError(u"Trying to bind non method to keystroke:%s,%s,%s,%s"%(key,func,type(func),type(self._bind_key)))
keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()
log(u">>>%s -> %s<<<"%(keyinfo,func.__name__))
self.key_dispatch[keyinfo] = func