pmacs3/minibuffer.py

40 lines
1.0 KiB
Python
Raw Normal View History

import buffer
2007-03-06 10:05:38 -05:00
class MiniBufferError(Exception):
pass
2007-03-06 10:05:38 -05:00
# minibuffer is a singleton
mini = None
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:
2008-03-16 16:26:32 -04:00
mini = object.__new__(MiniBuffer)
2007-03-06 10:05:38 -05:00
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
2007-03-06 10:05:38 -05:00
self.callback = func
self.method = method
self.tabber = tabber
self.modename = modename
self.queue = queue
self.parentw = parentw
2007-03-06 10:05:38 -05:00
def name(self):
return "*Minibuffer*"
def add_callback(self, f):
cb = self.callback
def newcb(s):
cb(s)
f(s)
self.callback = newcb
2007-03-06 10:05:38 -05:00
def do_callback(self):
self.callback(self.make_string())
def close(self):
global mini
mini = None