summary refs log tree commit diff stats
path: root/ranger/ext/direction.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/ext/direction.py')
-rw-r--r--ranger/ext/direction.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py
index 1cdaa97b..8be4fcaa 100644
--- a/ranger/ext/direction.py
+++ b/ranger/ext/direction.py
@@ -30,8 +30,14 @@ print(bool(d.horizontal())) # False, since no horizontal direction is defined
 class Direction(dict):
 	__doc__ = __doc__  # for nicer pydoc
 
-	def __init__(self, **keywords):
-		dict.__init__(self, keywords)
+	def __init__(self, dictionary=None, **keywords):
+		if dictionary is not None:
+			dict.__init__(self, dictionary)
+		else:
+			dict.__init__(self, keywords)
+		if 'to' in self:
+			self['down'] = self['to']
+			self['absolute'] = True
 
 	def copy(self):
 		return Direction(**self)
@@ -71,3 +77,15 @@ class Direction(dict):
 
 	def horizontal(self):
 		return set(self) & set(['left', 'right'])
+
+	def multiply(self, n):
+		for key in ('up', 'right', 'down', 'left'):
+			try:
+				self[key] *= n
+			except:
+				pass
+
+	def set(self, n):
+		for key in ('up', 'right', 'down', 'left'):
+			if key in self:
+				self[key] = n