import color, method, mode from point import Point class Which(mode.Fundamental): modename = 'Which' def __init__(self, w): mode.Fundamental.__init__(self, w) old_mode = w.buffer.method.old_window.mode self.bindings = dict(old_mode.bindings) def handle_token(self, t): '''self.handle_token(token): handles input "token"''' self.window.active_point = None try: act = mode.Handler.handle_token(self, t) if act is None: return else: s = '%r is %r: %s' % (self.last_sequence, act.name, act.help) self.window.application.set_error(s) self._end() except Exception, e: if mode.DEBUG: raise else: err = "%s in mode '%s'" % (e, self.name()) self.window.application.set_error(err) self._end() def _end(self): self.window.application.close_mini_buffer() self.window.buffer.method.old_cursor = None self.window.buffer.method.old_window = None install = Which.install