diff --git a/buffer2.py b/buffer2.py index 623fb78..9eb8e93 100644 --- a/buffer2.py +++ b/buffer2.py @@ -327,6 +327,8 @@ class ConsoleBuffer(Buffer): return console def __init__(self, nl='\n'): Buffer.__init__(self, nl) + self.clear() + def clear(self): lines = ['Python Console\n', "Evaluate python expressions in the editor's context (self)\n", 'Press Control-] to exit\n', diff --git a/mode_consolemini.py b/mode_consolemini.py index 264846f..eb772dc 100644 --- a/mode_consolemini.py +++ b/mode_consolemini.py @@ -41,6 +41,7 @@ class Console(mode2.Fundamental): self.add_bindings('insert-space', ('SPACE',)) self.add_bindings('insert-tab', ('TAB',)) self.add_action_and_bindings(ConsoleExec(), ('RETURN',)) + self.add_action_and_bindings(ConsoleClear(), ('C-l',)) self.add_action_and_bindings(ConsoleCancel(), ('C-]',)) self.add_action_and_bindings(ConsoleHistoryPrev(), ('C-p',)) self.add_action_and_bindings(ConsoleHistoryNext(), ('C-n',)) @@ -110,6 +111,13 @@ class ConsoleExec(method.Method): class ConsoleCancel(method.Method): def execute(self, w, **vargs): w.application.close_mini_buffer() +class ConsoleClear(method.Method): + def execute(self, w, **vargs): + a = w.application + if not a.has_buffer_name('*Console*'): + raise Exception, "No console found!" + b = a.bufferlist.get_buffer_by_name('*Console*') + b.clear() class ConsoleHistoryPrev(method.Method): def execute(self, w, **vargs):