2007-10-21 20:50:11 -04:00
|
|
|
import buffer
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2007-06-18 14:50:48 -04:00
|
|
|
class MiniBufferError(Exception):
|
|
|
|
pass
|
|
|
|
|
2007-03-06 10:05:38 -05:00
|
|
|
# minibuffer is a singleton
|
|
|
|
mini = None
|
2007-10-21 20:50:11 -04:00
|
|
|
class MiniBuffer(buffer.Buffer):
|
2007-07-19 14:37:39 -04:00
|
|
|
btype = 'mini'
|
2007-03-06 10:05:38 -05:00
|
|
|
def __new__(cls, *args, **kwargs):
|
|
|
|
global mini
|
|
|
|
if mini is None:
|
|
|
|
mini = object.__new__(MiniBuffer, *args, **kwargs)
|
|
|
|
return mini
|
|
|
|
# the callback function should take one argument (window)
|
|
|
|
def __init__(self, func, method=None, tabber=None, modename=None):
|
2007-10-21 20:50:11 -04:00
|
|
|
buffer.Buffer.__init__(self)
|
2007-03-06 10:05:38 -05:00
|
|
|
self.callback = func
|
|
|
|
self.method = method
|
|
|
|
self.tabber = tabber
|
|
|
|
self.modename = modename
|
|
|
|
def name(self):
|
|
|
|
return "*Minibuffer*"
|
|
|
|
def do_callback(self):
|
|
|
|
self.callback(self.make_string())
|
|
|
|
def close(self):
|
|
|
|
global mini
|
|
|
|
mini = None
|