summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-06-15 11:32:02 +0200
committerhut <hut@lavabit.com>2010-06-18 11:47:17 +0200
commit6613bf4181f3d6d4b612e98e865192b73ebbe90c (patch)
treea609e7f0eac9decb8985c361893f96465943b988 /ranger
parent9a41e0fc3695c2c7f9b07a93c48f72ee9838c698 (diff)
downloadranger-6613bf4181f3d6d4b612e98e865192b73ebbe90c.tar.gz
widgets.pager: more efficient width calculation
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/widgets/pager.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index 58fcdfd1..5e761a0f 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -35,6 +35,7 @@ class Pager(Widget):
 	old_source = None
 	old_scroll_begin = 0
 	old_startx = 0
+	max_width = None
 	def __init__(self, win, embedded=False):
 		Widget.__init__(self, win)
 		self.embedded = embedded
@@ -122,7 +123,7 @@ class Pager(Widget):
 			self.startx = direction.move(
 					direction=direction.right(),
 					override=narg,
-					maximum=self._get_max_width(),
+					maximum=self.max_width,
 					current=self.startx,
 					pagesize=self.wid,
 					offset=-self.wid + 1)
@@ -201,6 +202,8 @@ class Pager(Widget):
 			if attempt_to_read and self.source_is_stream:
 				try:
 					for l in self.source:
+						if len(l) > self.max_width:
+							self.max_width = len(l)
 						self.lines.append(l)
 						if len(self.lines) > n:
 							break
@@ -225,6 +228,3 @@ class Pager(Widget):
 			except IndexError:
 				raise StopIteration
 			i += 1
-
-	def _get_max_width(self):
-		return max(len(line) for line in self.lines)