pmacs3/mode_which.py

33 lines
1.1 KiB
Python
Raw Normal View History

2007-06-23 21:41:18 -04:00
import color, method, mode2
from point2 import Point
2007-03-06 10:05:38 -05:00
2007-06-23 21:41:18 -04:00
class Which(mode2.Fundamental):
2007-03-06 10:05:38 -05:00
def __init__(self, w):
2007-06-23 21:41:18 -04:00
mode2.Fundamental.__init__(self, w)
2007-03-06 10:05:38 -05: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-06-23 21:41:18 -04:00
act = mode2.Handler.handle_token(self, t)
2007-03-06 10:05:38 -05:00
if act is None:
return
else:
2007-06-23 21:41:18 -04:00
s = '%r is %r: %s' % (self.last_sequence, act.name, act.help)
self.window.application.set_error(s)
self._end()
2007-03-06 10:05:38 -05:00
except Exception, e:
2007-06-23 21:41:18 -04:00
if mode2.DEBUG:
raise
else:
err = "%s in mode '%s'" % (e, self.name())
self.window.application.set_error(err)
self._end()
def name(self):
return "Which"
def _end(self):
self.window.application.close_mini_buffer()
self.window.buffer.method.old_cursor = None
self.window.buffer.method.old_window = None