diff options
author | hut <hut@lavabit.com> | 2010-04-07 03:17:37 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-07 03:17:37 +0200 |
commit | 748d38ca1750764088d2f5c0631d247738d9913f (patch) | |
tree | a4e0a27686ee1ba9a46cf2c1e82b2eafd364d350 | |
parent | a406a33dd9808f1a7e57ec96ca02423caf9cfc46 (diff) | |
download | ranger-748d38ca1750764088d2f5c0631d247738d9913f.tar.gz |
core.actions: use Direction in move()
-rw-r--r-- | ranger/core/actions.py | 23 | ||||
-rw-r--r-- | ranger/ext/direction.py | 6 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 2 |
3 files changed, 11 insertions, 20 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index ccd78fa7..cdd3718c 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -161,22 +161,13 @@ class Actions(EnvironmentAware, SettingsAware): self.open_console(cmode.OPEN_QUICK) elif direction.vertical(): - if narg is not None: - if direction.absolute(): - direction.set(narg) - else: - direction.multiply(narg) - if direction.pages(): - direction.multiply(self.env.termsize[0]) - elif direction.percentage(): - factor = len(self.env.cwd) / 100.0 - direction.multiply(factor) - dct = {} - if direction.absolute(): - dct['absolute'] = int(direction.down()) - else: - dct['relative'] = int(direction.down()) - self.env.cwd.move(**dct) + newpos = direction.move( + direction=direction.down(), + override=narg, + maximum=len(self.env.cwd), + current=self.env.cwd.pointer, + pagesize=self.ui.browser.hei) + self.env.cwd.move(absolute=newpos) def history_go(self, relative): """Move back and forth in the history""" diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 600476ff..2f9e1d96 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -104,8 +104,8 @@ class Direction(dict): if key in self: self[key] = n - def move(self, direction, override, minimum, maximum, - current, pagesize=10, offset=0): + def move(self, direction, override=0, minimum=0, maximum=9999, + current=0, pagesize=10, offset=0): pos = direction if override is not None: if self.absolute(): @@ -114,6 +114,8 @@ class Direction(dict): pos *= override if self.pages(): pos *= pagesize + elif self.percentage(): + pos *= maximum / 100.0 if self.absolute(): if pos < minimum: pos += maximum diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 34d01261..c3bff4ad 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -122,7 +122,6 @@ class Pager(Widget): self.startx = direction.move( direction=direction.right(), override=narg, - minimum=0, maximum=self._get_max_width(), current=self.startx, pagesize=self.wid, @@ -133,7 +132,6 @@ class Pager(Widget): self.scroll_begin = direction.move( direction=direction.down(), override=narg, - minimum=0, maximum=len(self.lines), current=self.scroll_begin, pagesize=self.hei, |