31 lines
867 B
Python
31 lines
867 B
Python
|
from buffer import Buffer
|
||
|
|
||
|
# console is another singleton
|
||
|
console = None
|
||
|
class ConsoleBuffer(Buffer):
|
||
|
btype = 'console'
|
||
|
modename = 'console'
|
||
|
def __new__(cls, *args, **kwargs):
|
||
|
global console
|
||
|
if console is None:
|
||
|
b = object.__new__(ConsoleBuffer, *args, **kwargs)
|
||
|
console = b
|
||
|
return console
|
||
|
def __init__(self):
|
||
|
Buffer.__init__(self)
|
||
|
self.clear()
|
||
|
def clear(self):
|
||
|
lines = ['Python Console\n',
|
||
|
"Evaluate python expressions in the editor's context (self)\n",
|
||
|
'Press Control-] to exit\n']
|
||
|
console.set_data(''.join(lines), force=True)
|
||
|
def name(self):
|
||
|
return '*Console*'
|
||
|
def changed(self):
|
||
|
return False
|
||
|
def close(self):
|
||
|
global console
|
||
|
console = None
|
||
|
def readonly(self):
|
||
|
return True
|