diff options
author | hut <hut@lavabit.com> | 2010-04-08 01:35:18 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-08 01:35:18 +0200 |
commit | 21da5a5ffbe325930ef2c01b016ce68c8cff6eca (patch) | |
tree | c523c99eb2ce283ffa8d6f01158bbb63eb53f95b | |
parent | ef011c914dcf6061af7b30c85db53336594cab81 (diff) | |
parent | ea5a2b987dfdfa43dc302582bcf38b6953d0657b (diff) | |
download | ranger-21da5a5ffbe325930ef2c01b016ce68c8cff6eca.tar.gz |
Merge branch 'devel' into newkey
Conflicts: ranger/defaults/keys.py
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | ranger/api/keys.py | 4 | ||||
-rw-r--r-- | ranger/core/actions.py | 2 | ||||
-rw-r--r-- | ranger/defaults/commands.py | 2 | ||||
-rw-r--r-- | ranger/ext/accumulator.py | 42 | ||||
-rw-r--r-- | ranger/ext/direction.py | 2 | ||||
-rw-r--r-- | ranger/fsobject/directory.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 8 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/taskview.py | 4 |
10 files changed, 29 insertions, 41 deletions
diff --git a/TODO b/TODO index a0c7f03a..d715c991 100644 --- a/TODO +++ b/TODO @@ -49,6 +49,8 @@ General (X) #66 10/02/28 explain how colorschemes work (X) #70 10/03/14 mouse handler for titlebar (X) #71 10/03/21 previews: black/whitelist + read file + ( ) #79 10/04/08 tab number zero + ( ) #80 10/04/08 when closing tabs, avoid gaps? Bugs diff --git a/ranger/api/keys.py b/ranger/api/keys.py index 86911569..d1011d22 100644 --- a/ranger/api/keys.py +++ b/ranger/api/keys.py @@ -55,9 +55,9 @@ class Wrapper(object): # If the method has an argument named "narg", pressing a number before # the key will pass that number as the narg argument. If you want the # same behaviour in a custom lambda function, you can write: -# bind('gg', fm.move_pointer(absolute=0)) +# bind('gg', fm.move(to=0)) # as: -# bind('gg', lambda arg: narg(arg.n, arg.fm.move_pointer, absolute=0)) +# bind('gg', lambda arg: narg(arg.n, arg.fm.move, to=0)) fm = Wrapper('fm') wdg = Wrapper('wdg') diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 99df7875..b0ec289f 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -168,7 +168,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): maximum=len(self.env.cwd), current=self.env.cwd.pointer, pagesize=self.ui.browser.hei) - self.env.cwd.move(absolute=newpos) + self.env.cwd.move(to=newpos) def history_go(self, relative): """Move back and forth in the history""" diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index f653168f..89b1a3cb 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -227,7 +227,7 @@ class find(Command): if arg in filename: self.count += 1 if self.count == 1: - cwd.move(absolute=(cwd.pointer + i) % len(cwd.files)) + cwd.move(to=(cwd.pointer + i) % len(cwd.files)) self.fm.env.cf = cwd.pointed_obj if self.count > 1: return False diff --git a/ranger/ext/accumulator.py b/ranger/ext/accumulator.py index c65370d5..2e599c85 100644 --- a/ranger/ext/accumulator.py +++ b/ranger/ext/accumulator.py @@ -13,41 +13,27 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from ranger.ext.direction import Direction + class Accumulator(object): def __init__(self): self.pointer = 0 self.pointed_obj = None - def move(self, relative=0, absolute=None, pages=None, narg=None): - i = self.pointer + def move(self, narg=None, **keywords): + direction = Direction(keywords) lst = self.get_list() if not lst: return self.pointer - length = len(lst) - - if isinstance(absolute, int): - if isinstance(narg, int): - absolute = narg - if absolute < 0: # wrap - i = absolute + length - else: - i = absolute - - if relative != 0: - if isinstance(pages, int): - relative *= pages * self.get_height() - if isinstance(narg, int): - relative *= narg - i = int(i + relative) - - if i >= length: - i = length - 1 - if i < 0: - i = 0 - - self.pointer = i + pointer = direction.move( + direction=direction.down(), + maximum=len(lst), + override=narg, + pagesize=self.get_height(), + current=self.pointer) + self.pointer = pointer self.correct_pointer() - return self.pointer + return pointer def move_to_obj(self, arg, attr=None): if not arg: @@ -77,10 +63,10 @@ class Accumulator(object): test = obj if test == good: - self.move(absolute=i) + self.move(to=i) return True - return self.move(absolute=self.pointer) + return self.move(to=self.pointer) def correct_pointer(self): lst = self.get_list() diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 417f3add..0b3f55f7 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -132,4 +132,4 @@ class Direction(dict): pos += maximum else: pos += current - return int(max(min(pos, maximum + offset), minimum)) + return int(max(min(pos, maximum + offset - 1), minimum)) diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 79e32bff..bf626004 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -215,7 +215,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): if self.pointed_obj is not None: self.sync_index() else: - self.move(absolute=0) + self.move(to=0) else: self.filenames = None self.files = None diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 0d46ee06..4e93ed3e 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -358,11 +358,11 @@ class BrowserColumn(Pager): self.scroll_begin = self._get_scroll_begin() self.target.scroll_begin = self.scroll_begin - def scroll(self, relative): - """scroll by n lines""" + def scroll(self, n): + """scroll down by n lines""" self.need_redraw = True - self.target.move(relative=relative) - self.target.scroll_begin += 3 * relative + self.target.move(down=n) + self.target.scroll_begin += 3 * n def __str__(self): return self.__class__.__name__ + ' at level ' + str(self.level) diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index e478c7be..85022a01 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -184,7 +184,7 @@ class Pager(Widget): n = event.ctrl() and 1 or 3 direction = event.mouse_wheel_direction() if direction: - self.move(relative=direction) + self.move(down=direction * n) return True def _get_line(self, n, attempt_to_read=True): diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index 9ef86b07..475b903c 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -88,11 +88,11 @@ class TaskView(Widget, Accumulator): self.fm.loader.remove(index=i) - def task_move(self, absolute, i=None): + def task_move(self, to, i=None): if i is None: i = self.pointer - self.fm.loader.move(_from=i, to=absolute) + self.fm.loader.move(_from=i, to=to) def press(self, key): self.env.keymanager.use_context('taskview') |