console colors

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-03-04 17:23:20 +00:00
parent 52c0ecbe7d
commit f535aa1286
2 changed files with 30 additions and 41 deletions

View File

@ -1,42 +1,31 @@
from buffer import Buffer, ACT_NORM from buffer import Buffer, ACT_NORM
from buffer.color import ColorDataBuffer
# console is another singleton # console is another singleton
console = None console = None
class ConsoleBuffer(Buffer): class ConsoleBuffer(ColorDataBuffer):
btype = 'console' btype = 'console'
#modename = 'ipython' #modename = 'ipython'
modename = 'colortext' modename = 'colortext'
bannerlines = [
'[r:d:*]# Python Console\n',
"[r:d:*]# Evaluate python expressions in the editor's context (self)\n",
'[r:d:*]# Press Control-] to exit\n',
]
banner = ''.join(bannerlines)
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
global console global console
if console is None: if console is None:
b = object.__new__(ConsoleBuffer, *args, **kwargs) b = object.__new__(ConsoleBuffer, *args, **kwargs)
console = b console = b
return console 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']
lines = ['[r:d:*]# 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
#new def __init__(self): ColorDataBuffer.__init__(self, '*Console*', self.banner)
def input_insert_lines(self, p, lines, act=ACT_NORM, force=False): def clear(self): console.set_data(self.banner, force=True)
pass def name(self): return '*Console*'
def output_insert_lines(self, p, lines, act=ACT_NORM, force=False): def changed(self): return False
pass def close(self): global console; console = None
def result_insert_lines(self, p, lines, act=ACT_NORM, force=False): def readonly(self): return True
pass def input_insert_lines(self, p, lines, act=ACT_NORM, force=False): pass
def output_insert_lines(self, p, lines, act=ACT_NORM, force=False): pass
def result_insert_lines(self, p, lines, act=ACT_NORM, force=False): pass

View File

@ -23,7 +23,7 @@ class ConsoleExec(method.Method):
if a.window().buffer is not b: if a.window().buffer is not b:
a.switch_buffer(b) a.switch_buffer(b)
p = a.get_mini_buffer_prompt() p = a.get_mini_buffer_prompt()
b.insert_string(b.get_buffer_end(), p + s + '\n', force=True) b.insert_string(b.get_buffer_end(), '[c:d:*]' + p + '[d:d]' + s + '\n', force=True)
if w.mode.saved_input: if w.mode.saved_input:
s = w.mode.saved_input + '\n' + s s = w.mode.saved_input + '\n' + s