2007-10-21 20:55:29 -04:00
|
|
|
import color, method, mode
|
2007-10-21 20:50:11 -04:00
|
|
|
from point import Point
|
2007-07-21 11:40:53 -04:00
|
|
|
|
2007-10-21 20:55:29 -04:00
|
|
|
class Which(mode.Fundamental):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'Which'
|
2007-07-21 11:40:53 -04:00
|
|
|
def __init__(self, w):
|
2007-10-21 20:55:29 -04:00
|
|
|
mode.Fundamental.__init__(self, w)
|
2007-07-21 11:40:53 -04:00
|
|
|
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:
|
2007-10-21 20:55:29 -04:00
|
|
|
act = mode.Handler.handle_token(self, t)
|
2007-07-21 11:40:53 -04:00
|
|
|
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:
|
2007-10-21 20:55:29 -04:00
|
|
|
if mode.DEBUG:
|
2007-07-21 11:40:53 -04:00
|
|
|
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
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = Which.install
|