summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-01 16:38:41 +0100
committerhut <hut@lavabit.com>2010-01-01 16:38:41 +0100
commit08f21ae5ad8d92d3f1819a95db3e5bdce603f4da (patch)
tree27c735f5d32825eb2a00a7304e7953e99094b976 /ranger
parent5a528b93e78d51552e9247d1a4d5183c43e1cf53 (diff)
downloadranger-08f21ae5ad8d92d3f1819a95db3e5bdce603f4da.tar.gz
draw a list of bookmarks when pressing ` or '
Diffstat (limited to 'ranger')
-rw-r--r--ranger/container/bookmarks.py3
-rw-r--r--ranger/gui/widgets/browserview.py25
2 files changed, 28 insertions, 0 deletions
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py
index b16180a0..2d58c1d8 100644
--- a/ranger/container/bookmarks.py
+++ b/ranger/container/bookmarks.py
@@ -65,6 +65,9 @@ class Bookmarks(object):
 		self["`"] = value
 		self["'"] = value
 		if self.autosave: self.save()
+	
+	def __iter__(self):
+		return iter(self.dct.items())
 
 	def __getitem__(self, key):
 		"""Get the bookmark associated with the key"""
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index ffca34c6..488b7cfd 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -9,6 +9,7 @@ class BrowserView(Widget, DisplayableContainer):
 	preview = True
 	preview_available = True
 	stretch_ratios = None
+	need_clear = False
 
 	def __init__(self, win, ratios, preview = True):
 		DisplayableContainer.__init__(self, win)
@@ -42,6 +43,30 @@ class BrowserView(Widget, DisplayableContainer):
 
 		self.pager = Pager(self.win, embedded=True)
 		self.add_child(self.pager)
+
+	def draw(self):
+		if str(self.env.keybuffer) in ("`", "'"):
+			self._draw_bookmarks()
+		else:
+			if self.need_clear:
+				self.win.erase()
+				self.need_redraw = True
+				self.need_clear = False
+			DisplayableContainer.draw(self)
+	
+	def _draw_bookmarks(self):
+		self.need_clear = True
+
+		def generator():
+			return zip(range(self.hei), self.fm.bookmarks)
+
+		maxlen = max(len(item[1].path) for i, item in generator())
+		maxlen = min(maxlen + 5, self.wid)
+
+		for line, items in generator():
+			key, mark = items
+			string = " " + key + ": " + mark.path
+			self.addstr(line, 0, string.ljust(maxlen))
 	
 	def resize(self, y, x, hei, wid):
 		"""Resize all the columns according to the given ratio"""