40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
import buffer
|
|
|
|
class MiniBufferError(Exception):
|
|
pass
|
|
|
|
# minibuffer is a singleton
|
|
mini = None
|
|
class MiniBuffer(buffer.Buffer):
|
|
btype = 'mini'
|
|
def __new__(cls, *args, **kwargs):
|
|
global mini
|
|
if mini is None:
|
|
mini = object.__new__(MiniBuffer)
|
|
return mini
|
|
# the callback function should take one argument (window)
|
|
def __init__(self, func, app, method=None, tabber=None, modename=None,
|
|
queue=None, parentw=None):
|
|
buffer.Buffer.__init__(self)
|
|
self.app = app
|
|
self.callback = func
|
|
self.method = method
|
|
self.tabber = tabber
|
|
self.modename = modename
|
|
self.queue = queue
|
|
self.parentw = parentw
|
|
|
|
def name(self):
|
|
return "*Minibuffer*"
|
|
def add_callback(self, f):
|
|
cb = self.callback
|
|
def newcb(s):
|
|
cb(s)
|
|
f(s)
|
|
self.callback = newcb
|
|
def do_callback(self):
|
|
self.callback(self.make_string())
|
|
def close(self):
|
|
global mini
|
|
mini = None
|