From f535aa128645b49b40777d7a44cc2b8c75cccc4f Mon Sep 17 00:00:00 2001 From: moculus Date: Wed, 4 Mar 2009 17:23:20 +0000 Subject: [PATCH] console colors --HG-- branch : pmacs2 --- buffer/console.py | 51 ++++++++++++++++++--------------------------- mode/consolemini.py | 20 +++++++++--------- 2 files changed, 30 insertions(+), 41 deletions(-) diff --git a/buffer/console.py b/buffer/console.py index a81ff73..4301ecd 100644 --- a/buffer/console.py +++ b/buffer/console.py @@ -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 diff --git a/mode/consolemini.py b/mode/consolemini.py index 71b4863..78f9864 100644 --- a/mode/consolemini.py +++ b/mode/consolemini.py @@ -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)