def _bind_key(self, key, func): """setup the mapping from key to call the function.""" if not callable(func): print("Trying to bind non method to keystroke:%s,%s"%(key,func)) raise ReadlineError("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(">>>%s -> %s<<<"%(keyinfo,func.__name__)) self.key_dispatch[keyinfo] = func
def bind_key(self, key, name): import types if callable(name): self.mode._bind_key(key, types.MethodType(name, self.mode)) else: self.mode._bind_key(key, getattr(self.mode, name)) log("Trying to bind unknown command '%s' to key '%s'" % (name, key))