about summary refs log tree commit diff stats
path: root/ranger/container
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-17 19:35:15 +0100
committerhut <hut@lavabit.com>2009-12-17 19:35:15 +0100
commit3dbefa71785bf61b8f28d4a780064f3f4e04dcb5 (patch)
treed2272b52303287ece416c33d568d24f15234ff84 /ranger/container
parent16246965082ce5d319f5cef07da3ff533ca50cc2 (diff)
downloadranger-3dbefa71785bf61b8f28d4a780064f3f4e04dcb5.tar.gz
extended history by a couple of methods
Diffstat (limited to 'ranger/container')
-rw-r--r--ranger/container/history.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/ranger/container/history.py b/ranger/container/history.py
index bd9a575f..355c7c72 100644
--- a/ranger/container/history.py
+++ b/ranger/container/history.py
@@ -11,16 +11,31 @@ class History(object):
 		if len(self.history) == 0 or self.history[-1] != item:
 			self.history.append(item)
 			self.history_forward.clear()
+	
+	def modify(self, item):
+		try:
+			self.history[-1] = item
+		except IndexError:
+			raise HistoryEmptyException
 
 	def __len__(self):
 		return len(self.history)
 
-	def top(self):
+	def current(self):
 		try:
 			return self.history[-1]
 		except IndexError:
 			raise HistoryEmptyException()
 
+	def top(self):
+		try:
+			return self.history_forward[0]
+		except IndexError:
+			try:
+				return self.history[-1]
+			except IndexError:
+				raise HistoryEmptyException()
+
 	def bottom(self):
 		try:
 			return self.history[0]
@@ -30,7 +45,7 @@ class History(object):
 	def back(self):
 		if len(self.history) > 1:
 			self.history_forward.append( self.history.pop() )
-		return self.top()
+		return self.current()
 
 	def move(self, n):
 		if n > 0:
@@ -47,4 +62,9 @@ class History(object):
 	def forward(self):
 		if len(self.history_forward) > 0:
 			self.history.append( self.history_forward.pop() )
-		return self.top()
+		return self.current()
+
+	def fast_forward(self):
+		if self.history_forward:
+			self.history.extend(self.history_forward)
+			self.history_forward.clear()