summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/environment.py36
1 files changed, 6 insertions, 30 deletions
diff --git a/ranger/environment.py b/ranger/environment.py
index be39fbb6..d8a535ab 100644
--- a/ranger/environment.py
+++ b/ranger/environment.py
@@ -5,6 +5,7 @@ class Environment():
 	# A collection of data which is relevant for more than
 	# one class.
 	def __init__(self, path, opt):
+		from ranger.history import History
 		self.path = abspath(expanduser(path))
 		self.opt = opt
 		self.pathway = ()
@@ -15,8 +16,7 @@ class Environment():
 		self.keybuffer = ()
 		self.copy = None
 		self.termsize = (24, 80)
-		self.history = []
-		self.history_position = -1
+		self.history = History(opt['max_history_size'])
 
 	def key_append(self, key):
 		self.keybuffer += (key, )
@@ -58,35 +58,11 @@ class Environment():
 			last_path = path
 	
 	def history_go(self, relative):
-		if not self.history:
-			return
-
-		if self.history_position == -1:
-			if relative > 0:
-				return
-			elif relative < 0:
-				self.history_position = max( 0, len(self.history) - 1 + relative )
-		else:
-			self.history_position += relative
-			if self.history_position < 0:
-				self.history_position = 0
-
-		if self.history_position >= len(self.history) - 1:
-			self.history_position = -1
-
-		self.enter_dir(self.history[self.history_position], history=False)
-
-	def history_add(self, path):
-		if self.opt['max_history_size']:
-			if len(self.history) > self.history_position > (-1):
-				self.history = self.history[0 : self.history_position + 1]
-			if not self.history or (self.history and self.history[-1] != path):
-				self.history_position = -1
-				self.history.append(path)
-			if len(self.history) > self.opt['max_history_size']:
-				self.history.pop(0)
+		if self.history:
+			self.enter_dir(self.history.move(relative))
 
 	def enter_dir(self, path, history = True):
+		if path is None: return
 		path = str(path)
 
 		# get the absolute path
@@ -122,7 +98,7 @@ class Environment():
 		self.cf = self.pwd.pointed_file
 
 		if history:
-			self.history_add(path)
+			self.history.add(path)
 
 		return True
 
or: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
== Ranger v.1

Ranger is a filemanager that integrates well into the linux shell and
gives you a quick way of doing operations that would otherwise require
a lot of typing, without starting up a bloated environment.

Ranger is written in Python and uses ncurses for the user interface.

The version 1 is a rewrite from scratch and offers very limited
functionality as of now.