summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-01 20:47:43 +0100
committerhut <hut@lavabit.com>2010-01-01 20:47:43 +0100
commit45076ed423871a379b3f4e586b58c98e01744398 (patch)
tree8ebcaa2b5dd91b41fdd0f82bc4e1252c1a30f010
parent6f43de0af345c63216b03b1e2611abf98266d80a (diff)
downloadranger-45076ed423871a379b3f4e586b58c98e01744398.tar.gz
pager: fixed keys and redrawing
-rw-r--r--ranger/container/commandlist.py4
-rw-r--r--ranger/defaults/keys.py11
-rw-r--r--ranger/gui/widgets/browserview.py1
-rw-r--r--ranger/gui/widgets/pager.py34
4 files changed, 35 insertions, 15 deletions
diff --git a/ranger/container/commandlist.py b/ranger/container/commandlist.py
index e90f298e..ecb8cd4b 100644
--- a/ranger/container/commandlist.py
+++ b/ranger/container/commandlist.py
@@ -71,8 +71,8 @@ class CommandList(object):
 		Remove dummie objects in case you have to rebuild a path dictionary
 		which already contains dummie objects.
 		"""
-		for k in tuple(paths.keys()):
-			if paths[k] == self.dummy_object: del paths[k]
+		for k in tuple(self.paths.keys()):
+			if self.paths[k] == self.dummy_object: del self.paths[k]
 		self.dummies_in_paths = False
 
 
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 7cd92004..805287bf 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -234,7 +234,13 @@ def initialize_taskview_commands(command_list):
 def initialize_pager_commands(command_list):
 	bind, hint = make_abbreviations(command_list)
 	initialize_embedded_pager_commands(command_list)
+
 	bind('q', 'i', ESC, KEY_F1, lambda arg: arg.fm.ui.close_pager())
+	command_list.rebuild_paths()
+
+def initialize_embedded_pager_commands(command_list):
+	system_functions(command_list)
+	bind, hint = make_abbreviations(command_list)
 
 	bind('j', KEY_DOWN, nwrap.move(relative=1))
 	bind('k', KEY_DOWN, nwrap.move(relative=-1))
@@ -243,11 +249,6 @@ def initialize_pager_commands(command_list):
 
 	bind('h', wdg.move_horizontal(relative=-4))
 	bind('l', wdg.move_horizontal(relative=4))
-	command_list.rebuild_paths()
-
-def initialize_embedded_pager_commands(command_list):
-	system_functions(command_list)
-	bind, hint = make_abbreviations(command_list)
 
 	bind('q', 'i', ESC, lambda arg: arg.fm.ui.close_embedded_pager())
 	command_list.rebuild_paths()
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index 3fae7715..642ad198 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -42,6 +42,7 @@ class BrowserView(Widget, DisplayableContainer):
 			self.main_column.main_column = True
 
 		self.pager = Pager(self.win, embedded=True)
+		self.pager.visible = False
 		self.add_child(self.pager)
 
 	def draw(self):
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index 85871431..ab6220db 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -8,6 +8,10 @@ from ranger.ext.move import move_between
 class Pager(Widget):
 	source = None
 	source_is_stream = False
+
+	old_source = None
+	old_scroll_begin = 0
+	old_startx = 0
 	def __init__(self, win, embedded=False):
 		Widget.__init__(self, win)
 		self.embedded = embedded
@@ -27,20 +31,34 @@ class Pager(Widget):
 	def open(self):
 		self.scroll_begin = 0
 		self.startx = 0
+		self.need_redraw = True
 	
 	def close(self):
 		if self.source and self.source_is_stream:
 			self.source.close()
 	
 	def draw(self):
-		line_gen = self._generate_lines(
-				starty=self.scroll_begin, startx=self.startx)
-
-		for line, i in zip(line_gen, range(self.hei)):
-			try:
-				self.addstr(i, 0, line)
-			except TypeError:
-				pass
+		if self.old_source != self.source:
+			self.old_source = self.source
+			self.need_redraw = True
+
+		if self.old_scroll_begin != self.scroll_begin or \
+				self.old_startx != self.startx:
+			self.old_startx = self.startx
+			self.old_scroll_begin = self.scroll_begin
+		self.need_redraw = True
+
+		if self.need_redraw:
+			self.win.erase()
+			line_gen = self._generate_lines(
+					starty=self.scroll_begin, startx=self.startx)
+
+			for line, i in zip(line_gen, range(self.hei)):
+				try:
+					self.addstr(i, 0, line)
+				except TypeError:
+					pass
+			self.need_redraw = False
 	
 	def move(self, relative=0, absolute=None):
 		i = self.scroll_begin