summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/colorschemes/jungle.py8
-rw-r--r--ranger/fsobject/fsobject.py29
-rw-r--r--ranger/gui/colorscheme.py4
-rw-r--r--ranger/gui/widgets/filelist.py26
-rw-r--r--ranger/gui/widgets/statusbar.py34
5 files changed, 71 insertions, 30 deletions
diff --git a/ranger/colorschemes/jungle.py b/ranger/colorschemes/jungle.py
index d2b9efd2..c70d95c7 100644
--- a/ranger/colorschemes/jungle.py
+++ b/ranger/colorschemes/jungle.py
@@ -31,7 +31,7 @@ class Default(ColorScheme):
 				fg = yellow # banananas
 
 			if context.link:
-				fg = cyan
+				fg = context.good and cyan or magenta
 
 			if context.maindisplay and context.selected:
 				attr |= bold
@@ -53,10 +53,10 @@ class Default(ColorScheme):
 				attr = normal
 
 		elif context.in_statusbar:
-			if context.permissions:
-				if context.allowed:
+			if context.permissions or context.link:
+				if context.good:
 					fg = cyan
-				elif context.denied:
+				elif context.bad:
 					fg = magenta
 
 		return fg, bg, attr
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 728ff46d..30ed7839 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -17,7 +17,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 	loaded = False
 	runnable = False
 	islink = False
-	brokenlink = False
+	readlink = None
 	stat = None
 	infostring = None
 	permissions = None
@@ -90,13 +90,22 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 		"""reads useful information about the filesystem-object from the filesystem
 and caches it for later use"""
 		import os
+		import stat
 		from ranger.ext.human_readable import human_readable
 
 		self.loaded = True
 
+		try:
+			self.stat = os.lstat(self.path)
+		except OSError:
+			self.stat = None
+			self.islink = False
+			self.accessible = False
+		else:
+			self.islink = stat.S_ISLNK(self.stat.st_mode)
+			self.accessible = True
+
 		if os.access(self.path, os.F_OK):
-			self.stat = os.stat(self.path)
-			self.islink = os.path.islink(self.path)
 			self.exists = True
 			self.accessible = True
 
@@ -119,18 +128,24 @@ and caches it for later use"""
 				self.infostring = None
 
 		else:
-			self.stat = None
-			self.islink = False
-			self.infostring = None
+			if self.islink:
+				self.infostring = '->'
+			else:
+				self.infostring = None
 			self.type = T_NONEXISTANT
 			self.exists = False
 			self.runnable = False
-			self.accessible = False
+
+		if self.islink:
+			self.readlink = os.readlink(self.path)
 	
 	def get_permission_string(self):
 		if self.permissions is not None:
 			return self.permissions
 
+		if self.accessible is False:
+			return '----------'
+
 		import stat
 		perms = '-'
 		mode = self.stat.st_mode
diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py
index 537f4458..f7a2a2d7 100644
--- a/ranger/gui/colorscheme.py
+++ b/ranger/gui/colorscheme.py
@@ -3,8 +3,8 @@ CONTEXT_KEYS = [ 'reset', 'error',
 		'directory', 'file', 'hostname',
 		'executable', 'media', 'link',
 		'video', 'audio', 'image', 'media', 'document', 'container',
-		'broken', 'selected', 'empty', 'maindisplay',
-		'allowed', 'denied',
+		'selected', 'empty', 'maindisplay',
+		'good', 'bad',
 		'space', 'permissions', 'owner', 'group', 'mtime', 'nlink',
 		'scroll', 'all', 'bot', 'top', 'percentage',
 		'keybuffer']
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index 4f9a7149..7a5e38da 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -51,7 +51,7 @@ class FileList(Widget):
 			return False
 
 		if isinstance(self.target, File):
-			if not self.settings.preview_files:
+			if not self._preview_this_file(self.target):
 				return False
 
 		return True
@@ -72,22 +72,27 @@ class FileList(Widget):
 			self.draw_directory()
 #		else:
 #			self.win.addnstr(self.y, self.x, "unknown type.", self.wid)
+	
+	def _preview_this_file(self, target):
+		return target.document and not self.settings.preview_files
 
 	def draw_file(self):
 		"""Draw a preview of the file, if the settings allow it"""
 		if not self.target.accessible:
 			self.win.addnstr(self.y, self.x, "not accessible", self.wid)
 			return
+
+		if not self._preview_this_file(self.target):
+			return
 		
-		if self.settings.preview_files:
-			try:
-				if self.target.size < 1024 * 20:
-					f = open(self.target.path, 'r')
-					for line in range(self.hei):
-						read = f.readline().expandtabs()
-						self.win.addnstr(self.y + line, self.x, read, self.wid)
-			except:
-				pass
+		try:
+			if self.target.size < 1024 * 20:
+				f = open(self.target.path, 'r')
+				for line in range(self.hei):
+					read = f.readline().expandtabs()
+					self.win.addnstr(self.y + line, self.x, read, self.wid)
+		except:
+			pass
 
 	def draw_directory(self):
 		"""Draw the contents of a directory"""
@@ -141,6 +146,7 @@ class FileList(Widget):
 
 			if drawed.islink:
 				this_color.append('link')
+				this_color.append(drawed.exists and 'good' or 'bad')
 
 			string = drawed.basename
 			if self.main_display:
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 6153101c..41da7b06 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -21,6 +21,11 @@ class StatusBar(Widget):
 		self.filelist = filelist
 	
 	def draw(self):
+		"""Draw the statusbar"""
+
+		# each item in the returned array looks like:
+		# [ list_with_color_tags,       string       ]
+		# [ ['permissions', 'allowed'], '-rwxr-xr-x' ]
 		left = self._get_left_part()
 		right = self._get_right_part()
 		self._print_result(self._combine_parts(left, right))
@@ -28,16 +33,23 @@ class StatusBar(Widget):
 	def _get_left_part(self):
 		part = []
 
-		target = self.env.at_level(0).pointed_file
+		if self.filelist is not None:
+			target = self.filelist.target.pointed_file
+		else:
+			target = self.env.at_level(0).pointed_file
+
 		if target is None:
 			return part
 
+		if target.accessible is False:
+			return part
+
 		perms = target.get_permission_string()
 		color = ['permissions']
 		if getuid() == target.stat.st_uid:
-			color.append('allowed')
+			color.append('good')
 		else:
-			color.append('denied')
+			color.append('bad')
 		part.append([color, perms])
 
 		part.append([['space'], " "])
@@ -47,8 +59,13 @@ class StatusBar(Widget):
 		part.append([['space'], " "])
 		part.append([['group'], self._get_group(target)])
 		part.append([['space'], " "])
-		part.append([['mtime'], strftime(self.timeformat, \
-				localtime(target.stat.st_mtime))])
+		if target.islink:
+			color = ['link']
+			color.append(target.exists and 'good' or 'bad')
+			part.append([color, '-> ' + target.readlink])
+		else:
+			part.append([['mtime'], strftime(self.timeformat, \
+					localtime(target.stat.st_mtime))])
 		return part
 	
 	def _get_owner(self, target):
@@ -77,7 +94,10 @@ class StatusBar(Widget):
 
 	def _get_right_part(self):
 		part = []
-		target = self.env.at_level(0)
+		if self.filelist is not None:
+			target = self.filelist.target
+		else:
+			target = self.env.at_level(0)
 
 		if self.filelist is not None:
 			pos = target.scroll_begin
@@ -90,7 +110,7 @@ class StatusBar(Widget):
 					part.append([['scroll', 'bot'], 'Bot'])
 				else:
 					part.append([['scroll', 'percentage'], \
-						'{0:0>.0f}%'.format(100.0*pos/max_pos)])
+						'{0:0>.0f}%'.format(100.0 * pos / max_pos)])
 			else:
 				part.append([['scroll', 'all'], 'All'])
 		return part
ranger/commit/doc/pydoc/test.tc_displayable.html?h=v1.4.2&id=34a60763e79546e0f84e30fbcc430632f3dbb39e'>34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^



34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^

f07bb12f ^










34a60763 ^
f07bb12f ^




34a60763 ^
f07bb12f ^


34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^


34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^


34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^


34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^



34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^

f07bb12f ^










34a60763 ^
f07bb12f ^
34a60763 ^







f07bb12f ^
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367