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.color import ColorDataBuffer
# console is another singleton
console = None
class ConsoleBuffer(Buffer):
btype = 'console'
#modename = 'ipython'
modename = 'colortext'
class ConsoleBuffer(ColorDataBuffer):
btype = 'console'
#modename = 'ipython'
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):
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']
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 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
def __init__(self): ColorDataBuffer.__init__(self, '*Console*', self.banner)
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
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:
a.switch_buffer(b)
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:
s = w.mode.saved_input + '\n' + s
@ -219,16 +219,16 @@ class ConsoleMini(mode.Fundamental):
ConsoleHistoryNext, ConsoleTab,
ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd]
_bindings = {
'console-exec': ('RETURN',),
'console-clear': ('C-l',),
'console-cancel': ('C-]', 'C-g'),
'console-history-prev': ('C-p', 'UP'),
'console-history-next': ('C-n', 'DOWN'),
'console-tab': ('TAB',),
'console-page-up': ('M-v',),
'console-page-down': ('C-v',),
'console-exec': ('RETURN',),
'console-clear': ('C-l',),
'console-cancel': ('C-]', 'C-g'),
'console-history-prev': ('C-p', 'UP'),
'console-history-next': ('C-n', 'DOWN'),
'console-tab': ('TAB',),
'console-page-up': ('M-v',),
'console-page-down': ('C-v',),
'console-goto-beginning': ('M-<',),
'console-goto-end': ('M->',),
'console-goto-end': ('M->',),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)