diff options
author | hut <hut@lavabit.com> | 2010-04-07 23:13:57 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-07 23:13:57 +0200 |
commit | c4e869ddc99c6737a5429705ed949c54c37f9ece (patch) | |
tree | c9afccaea0e850bce61ead8c781853d0bd45ecb1 | |
parent | 3ec6f466744a45135c4e592e003f99f775da5e3e (diff) | |
download | ranger-c4e869ddc99c6737a5429705ed949c54c37f9ece.tar.gz |
integrated new keyparser in pager + taskview
-rw-r--r-- | ranger/gui/widgets/console.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 35 | ||||
-rw-r--r-- | ranger/gui/widgets/taskview.py | 37 |
3 files changed, 43 insertions, 31 deletions
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index 77ba4424..0e949d3b 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -159,8 +159,6 @@ class Console(Widget): kbuf = self.env.keybuffer cmd = kbuf.command - self.fm.hide_bookmarks() - if kbuf.failure: kbuf.clear() return diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index b99bf5db..e478c7be 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -19,6 +19,7 @@ The pager displays text and allows you to scroll inside it. import re from . import Widget from ranger.ext.direction import Direction +from ranger.container.keymap import CommandArgs BAR_REGEXP = re.compile(r'\|\d+\?\|') QUOTES_REGEXP = re.compile(r'"[^"]+?"') @@ -132,22 +133,28 @@ class Pager(Widget): offset=-self.hei) def press(self, key): - try: - tup = self.env.keybuffer.tuple_without_numbers() - if tup: - cmd = self.keymap[tup] - else: - return + self.env.keymanager.use_context(self.embedded and 'embedded_pager' or 'pager') + self.env.key_append(key) + kbuf = self.env.keybuffer + cmd = kbuf.command + + if kbuf.failure: + kbuf.clear() + return + elif not cmd: + return - except KeyError: - self.env.key_clear() + self.env.cmd = cmd + + if cmd.function: + try: + cmd.function(CommandArgs.from_widget(self)) + except Exception as error: + self.fm.notify(error) + if kbuf.done: + kbuf.clear() else: - if hasattr(cmd, 'execute'): - try: - cmd.execute_wrap(self) - except Exception as error: - self.fm.notify(error) - self.env.key_clear() + kbuf.clear() def set_source(self, source, strip=False): if self.source and self.source_is_stream: diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index fe31646d..9ef86b07 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -22,6 +22,7 @@ from collections import deque from . import Widget from ranger.ext.accumulator import Accumulator +from ranger.container.keymap import CommandArgs class TaskView(Widget, Accumulator): old_lst = None @@ -94,22 +95,28 @@ class TaskView(Widget, Accumulator): self.fm.loader.move(_from=i, to=absolute) def press(self, key): - try: - tup = self.env.keybuffer.tuple_without_numbers() - if tup: - cmd = self.commandlist[tup] - else: - return - - except KeyError: - self.env.key_clear() + self.env.keymanager.use_context('taskview') + self.env.key_append(key) + kbuf = self.env.keybuffer + cmd = kbuf.command + + if kbuf.failure: + kbuf.clear() + return + elif not cmd: + return + + self.env.cmd = cmd + + if cmd.function: + try: + cmd.function(CommandArgs.from_widget(self)) + except Exception as error: + self.fm.notify(error) + if kbuf.done: + kbuf.clear() else: - if hasattr(cmd, 'execute'): - try: - cmd.execute_wrap(self) - except Exception as error: - self.fm.notify(error) - self.env.key_clear() + kbuf.clear() def get_list(self): return self.fm.loader.queue |