From c2f737e0b343667bacd3edf6be37ec94e834fd65 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 15 Apr 2010 17:20:44 +0200 Subject: widgets.console: added "prompt" keyword argument for console.open() --- ranger/core/actions.py | 4 ++-- ranger/gui/defaultui.py | 4 ++-- ranger/gui/widgets/console.py | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 2fd7d46d..4b4fc032 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -105,10 +105,10 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): """Redraw the window""" self.ui.redraw_window() - def open_console(self, mode=':', string=''): + def open_console(self, mode=':', string='', prompt=None): """Open the console if the current UI supports that""" if hasattr(self.ui, 'open_console'): - self.ui.open_console(mode, string) + self.ui.open_console(mode, string, prompt=prompt) def execute_file(self, files, **kw): """Execute a file. diff --git a/ranger/gui/defaultui.py b/ranger/gui/defaultui.py index 08e0b204..a0a5da4e 100644 --- a/ranger/gui/defaultui.py +++ b/ranger/gui/defaultui.py @@ -93,8 +93,8 @@ class DefaultUI(UI): def close_embedded_pager(self): self.browser.close_pager() - def open_console(self, mode, string=''): - if self.console.open(mode, string): + def open_console(self, mode, string='', prompt=None): + if self.console.open(mode, string, prompt=prompt): self.status.msg = None self.console.on_close = self.close_console self.console.visible = True diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index c93a4f38..9bd37c01 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -112,9 +112,14 @@ class Console(Widget): except: pass - def open(self, mode, string=''): + def open(self, mode, string='', prompt=None): if not is_valid_mode(mode): return False + if prompt is not None: + assert isinstance(prompt, str) + self.prompt = prompt + elif hasattr(self, 'prompt'): + del self.prompt cls = mode_to_class(mode) -- cgit 1.4.1-2-gfad0