summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-30 17:03:41 +0100
committerhut <hut@lavabit.com>2009-12-30 17:03:41 +0100
commit328c656557583152ecb58a5083581f433ec31f14 (patch)
tree6b5db052d156923f7782fad26dc26e21ce102ba6 /ranger
parent316421545abeb50d5bd7d3ffdbab51f44fdda45e (diff)
downloadranger-328c656557583152ecb58a5083581f433ec31f14.tar.gz
filelist widget optimization
instead of containing another pager widget, filelist now inherits
the pagers properties for displaying the content of files
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/widgets/filelist.py35
-rw-r--r--ranger/gui/widgets/pager.py5
2 files changed, 16 insertions, 24 deletions
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index 8d37b92a..4dd04ed1 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -1,10 +1,9 @@
 """The FileList widget displays the contents of a directory or file."""
 from . import Widget
-from ..displayable import DisplayableContainer
 from .pager import Pager
 from ranger import log
 
-class FileList(Widget, DisplayableContainer):
+class FileList(Pager, Widget):
 	main_display = False
 	display_infostring = False
 	scroll_begin = 0
@@ -13,14 +12,12 @@ class FileList(Widget, DisplayableContainer):
 	tagged_marker = '*'
 
 	def __init__(self, win, level):
-		DisplayableContainer.__init__(self, win)
-		self.pager = Pager(self.win)
-		self.add_obj(self.pager)
+		Pager.__init__(self, win)
+		Widget.__init__(self, win)
 		self.level = level
 	
 	def resize(self, y, x, hei, wid):
-		DisplayableContainer.resize(self, y, x, hei, wid)
-		self.pager.resize(0, 0, hei, wid)
+		Widget.resize(self, y, x, hei, wid)
 
 	def click(self, event):
 		"""Handle a MouseEvent"""
@@ -75,15 +72,15 @@ class FileList(Widget, DisplayableContainer):
 		from ranger.fsobject.file import File
 		from ranger.fsobject.directory import Directory
 
-		self.pager.visible = False
+#		self.pager.visible = False
 		if self.target is None:
 			pass
 		elif type(self.target) == File:
+			Pager.open(self)
 			self._draw_file()
 		elif type(self.target) == Directory:
 			self._draw_directory()
-
-		DisplayableContainer.draw(self)
+			Widget.draw(self)
 
 	def _preview_this_file(self, target):
 		return target.document and not self.settings.preview_files
@@ -93,18 +90,20 @@ class FileList(Widget, DisplayableContainer):
 		self.win.move(0, 0)
 		if not self.target.accessible:
 			self.win.addnstr("not accessible", self.wid)
+			Pager.close(self)
 			return
 
 		if not self._preview_this_file(self.target):
+			Pager.close(self)
 			return
 		
 		try:
 			f = open(self.target.path, 'r')
 		except:
-			pass
+			Pager.close(self)
 		else:
-			self.pager.visible = True
-			self.pager.set_source(f)
+			self.set_source(f)
+			Pager.draw(self)
 
 	def _draw_directory(self):
 		"""Draw the contents of a directory"""
@@ -121,16 +120,6 @@ class FileList(Widget, DisplayableContainer):
 			self.target.sort_if_outdated()
 
 		if not self.target.content_loaded:
-#			if self.target.force_load:
-#				self.target.stopped = False
-#
-#			else:
-#				if not self.target.stopped:
-#					
-#					if maxdirsize is not None and self.target.accessible \
-#							and self.target.size > maxdirsize:
-#						self.target.stopped = True
-#
 			maxdirsize = self.settings.max_dirsize_for_autopreview
 			if not self.target.force_load and maxdirsize is not None \
 					and self.target.accessible \
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index 1664cc4b..85871431 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -37,7 +37,10 @@ class Pager(Widget):
 				starty=self.scroll_begin, startx=self.startx)
 
 		for line, i in zip(line_gen, range(self.hei)):
-			self.addstr(i, 0, line)
+			try:
+				self.addstr(i, 0, line)
+			except TypeError:
+				pass
 	
 	def move(self, relative=0, absolute=None):
 		i = self.scroll_begin
CAPS LOCK?' href='/akspecs/ranger/commit/CHANGELOG?h=v1.7.0-emacs&id=efd7c0c16203cdeafcd58201d509325129397a67'>efd7c0c1 ^
cbcd3325 ^






81f5ac9e ^
cbcd3325 ^
d3bcb234 ^

cbcd3325 ^
81f5ac9e ^











cbcd3325 ^
90018274 ^




cbcd3325 ^
95e021ae ^

c928a9eb ^
95e021ae ^
cbcd3325 ^
95e021ae ^















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154