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