2009-02-22 21:51:31 -05:00
|
|
|
from buffer import Buffer, ACT_NORM
|
2009-06-10 16:07:03 -04:00
|
|
|
from buffer.colors import ColorDataBuffer
|
2008-10-29 10:58:06 -04:00
|
|
|
|
|
|
|
# console is another singleton
|
|
|
|
console = None
|
2009-03-10 10:43:04 -04:00
|
|
|
class ConsoleBuffer(Buffer):
|
2009-03-04 12:23:20 -05:00
|
|
|
btype = 'console'
|
2009-04-01 20:14:34 -04:00
|
|
|
#modename = 'ipython'
|
|
|
|
modename = 'console'
|
2009-03-04 12:23:20 -05:00
|
|
|
bannerlines = [
|
2009-03-10 10:43:04 -04:00
|
|
|
'# Python Console\n',
|
|
|
|
"# Evaluate python expressions in the editor's context (self)\n",
|
|
|
|
'# Press Control-] to exit\n',
|
2009-03-04 12:23:20 -05:00
|
|
|
]
|
|
|
|
banner = ''.join(bannerlines)
|
2008-10-29 10:58:06 -04:00
|
|
|
def __new__(cls, *args, **kwargs):
|
|
|
|
global console
|
|
|
|
if console is None:
|
|
|
|
b = object.__new__(ConsoleBuffer, *args, **kwargs)
|
|
|
|
console = b
|
|
|
|
return console
|
2009-03-10 10:43:04 -04:00
|
|
|
def __init__(self):
|
|
|
|
Buffer.__init__(self)
|
|
|
|
self.set_data(self.banner, force=True)
|
2009-02-22 21:51:31 -05:00
|
|
|
|
2009-03-04 12:23:20 -05:00
|
|
|
def clear(self): console.set_data(self.banner, force=True)
|
|
|
|
def name(self): return '*Console*'
|
|
|
|
def changed(self): return False
|
|
|
|
def close(self): global console; console = None
|
|
|
|
def readonly(self): return True
|