summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/api/keys.py4
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/defaults/commands.py2
-rw-r--r--ranger/ext/accumulator.py42
-rw-r--r--ranger/fsobject/directory.py2
-rw-r--r--ranger/gui/widgets/browsercolumn.py8
-rw-r--r--ranger/gui/widgets/pager.py2
-rw-r--r--ranger/gui/widgets/taskview.py4
8 files changed, 26 insertions, 40 deletions
diff --git a/ranger/api/keys.py b/ranger/api/keys.py
index 87186378..5f12e75d 100644
--- a/ranger/api/keys.py
+++ b/ranger/api/keys.py
@@ -54,9 +54,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 6910871b..0f8b74e5 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -167,7 +167,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/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 49a1df7e..91383a18 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -187,7 +187,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 6e86465c..6d025048 100644
--- a/ranger/gui/widgets/taskview.py
+++ b/ranger/gui/widgets/taskview.py
@@ -90,11 +90,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):
 		try: