summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-29 17:46:27 +0100
committerhut <hut@lavabit.com>2009-12-29 17:46:27 +0100
commit17f83af2f8ff958022902013b84f20b9eb9c3b70 (patch)
treef2759e1c5886932fb6473d70c78b456f9894ed28
parent23c450bf891ddf1da7ebee326e7fb1248448e84c (diff)
downloadranger-17f83af2f8ff958022902013b84f20b9eb9c3b70.tar.gz
a somewhat working version
-rw-r--r--ranger/gui/displayable.py27
-rw-r--r--ranger/gui/widgets/console.py4
-rw-r--r--ranger/gui/widgets/filelist.py41
3 files changed, 39 insertions, 33 deletions
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 6ce81df5..442a7d35 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -18,8 +18,6 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 
 		self.x = 0
 		self.y = 0
-		self.yy = 0
-		self.xx = 0
 		self.absx = 0
 		self.absy = 0
 		self.wid = 0
@@ -51,6 +49,12 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 		
 		return self.contains_point(y, x)
 
+	def addstr(self, *args):
+		try:
+			self.win.addstr(*args)
+		except:
+			pass
+	
 	def color(self, keylist = None, *keys):
 		"""Change the colors from now on."""
 		keys = combine(keylist, keys)
@@ -122,6 +126,7 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 
 	def resize(self, y, x, hei=None, wid=None):
 		"""Resize the widget"""
+		do_move = False
 		try:
 			maxy, maxx = self.env.termsize
 		except TypeError:
@@ -150,31 +155,31 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 
 		if hei != self.hei or wid != self.wid:
 			try:
+				log("resizing " + self.__class__.__name__)
 				self.win.resize(hei, wid)
 			except:
 				# Not enough space for resizing...
 				try:
 					self.win.mvderwin(0, 0)
-					self.absy, self.absx = self.win.getbegyx()
+					do_move = True
 					self.win.resize(hei, wid)
 				except:
 					pass
 					#raise OutOfBoundsException("Resizing Failed!")
 
-		if y != self.absy or x != self.absx:
+		if do_move or  y != self.absy or x != self.absx:
+			log("moving " + self.__class__.__name__)
 			try:
 				self.win.mvderwin(y, x)
 			except:
 				pass
 
-		self.yy, self.xx = y, x
-		if self.parent:
-			self.yy += self.parent.yy
-			self.xx += self.parent.xx
+			self.absy, self.absx = y, x
+			if self.parent:
+				self.absy += self.parent.absy
+				self.absx += self.parent.absx
 
-		self.absy, self.absx = self.win.getbegyx()
-		self.x = 0
-		self.y = 0
+		self.y, self.x = self.win.getbegyx()
 		self.hei, self.wid = self.win.getmaxyx()
 
 
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 52a8963b..ffabefcc 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -42,7 +42,9 @@ class Console(Widget):
 	def draw(self):
 		if self.mode is None:
 			return
-		self.win.addstr(self.y, self.x, self.prompt + self.line)
+		
+		self.addstr(0, 0, self.prompt)
+		self.addstr(self.line)
 
 	def finalize(self):
 		try:
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index 43f3834a..f38b4bee 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -33,7 +33,7 @@ class FileList(Widget, DisplayableContainer):
 			pass
 
 		elif self.target.type is T_DIRECTORY:
-			index = self.scroll_begin + event.y - self.yy
+			index = self.scroll_begin + event.y - self.absy
 
 			if event.pressed(1):
 				if not self.main_display:
@@ -96,8 +96,9 @@ class FileList(Widget, DisplayableContainer):
 
 	def draw_file(self):
 		"""Draw a preview of the file, if the settings allow it"""
+		self.win.move(0, 0)
 		if not self.target.accessible:
-			self.win.addnstr(self.y, self.x, "not accessible", self.wid)
+			self.win.addnstr("not accessible", self.wid)
 			return
 
 		if not self._preview_this_file(self.target):
@@ -120,6 +121,8 @@ class FileList(Widget, DisplayableContainer):
 
 		self.target.use()
 
+		self.win.move(0, 0)
+
 		if not self.target.load_content_if_outdated():
 			self.target.sort_if_outdated()
 
@@ -139,19 +142,19 @@ class FileList(Widget, DisplayableContainer):
 					and self.target.accessible \
 					and self.target.size > maxdirsize:
 				self.color(base_color, 'error')
-				self.win.addnstr(self.y, self.x, "no preview", self.wid)
+				self.win.addnstr("no preview", self.wid)
 				self.color_reset()
 				return
 
 			if self.settings.auto_load_preview:
 				self.color(base_color)
-				self.win.addnstr(self.y, self.x, "...", self.wid)
+				self.win.addnstr("...", self.wid)
 				self.postpone_drawing = True
 				self.color_reset()
 				return
 			else:
 				self.color(base_color, 'error')
-				self.win.addnstr(self.y, self.x, "not loaded", self.wid)
+				self.win.addnstr("not loaded", self.wid)
 				self.color_reset()
 				return
 
@@ -160,13 +163,13 @@ class FileList(Widget, DisplayableContainer):
 
 		if not self.target.accessible:
 			self.color(base_color, 'error')
-			self.win.addnstr(self.y, self.x, "not accessible", self.wid)
+			self.win.addnstr("not accessible", self.wid)
 			self.color_reset()
 			return
 
 		if self.target.empty():
 			self.color(base_color, 'empty')
-			self.win.addnstr(self.y, self.x, "empty", self.wid)
+			self.win.addnstr("empty", self.wid)
 			self.color_reset()
 			return
 
@@ -212,31 +215,27 @@ class FileList(Widget, DisplayableContainer):
 			try:
 				if self.main_display:
 					if tagged:
-						if self.wid > 1:
-							self.win.addnstr(self.y + line, self.x,
-									text, self.wid - 2)
-					elif self.wid > 2:
-						self.win.addnstr(self.y + line, self.x + 1,
-								text, self.wid - 2)
+						self.win.addnstr(line, 0, text, self.wid - 2)
+					elif self.wid > 1:
+						self.win.addnstr(line, 1, text, self.wid - 2)
 				else:
-					self.win.addnstr(self.y + line, self.x, text, self.wid)
+					self.win.addnstr(line, 0, text, self.wid)
 
 				if self.display_infostring and drawed.infostring:
 					info = drawed.infostring
-					x = self.x + self.wid - 1 - len(info)
+					x = self.wid - 1 - len(info)
 					if x > self.x:
-						self.win.addstr(self.y + line, x, str(info) + ' ')
+						self.win.addstr(line, x, str(info) + ' ')
 			except:
-				# the last string will cause an error because
-				# ncurses tries to move out of the bounds
+				# the drawing of the last string will cause an error
+				# because ncurses tries to move out of the bounds
 				pass
 
-			self.color_at(self.y + line, self.x, self.wid, this_color)
+			self.color_at(line, 0, self.wid, this_color)
 
 			if self.main_display and tagged and self.wid > 2:
 				this_color.append('tag_marker')
-				self.color_at(self.y + line, self.x,
-						len(self.tagged_marker), this_color)
+				self.color_at(line, 0, len(self.tagged_marker), this_color)
 
 			self.color_reset()
 
@akkartik.com> 2016-03-13 20:26:47 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2016-03-13 20:26:47 -0700 2773 - switch to 'int'' href='/akkartik/mu/commit/020run.cc?h=hlt&id=b24eb4766ad12eceaafa2ee0d620e070e21a3293'>b24eb476 ^
363be37f ^
69e14325 ^
95b2a140 ^
1228ec73 ^

7da71d03 ^
0edf822f ^
ec99eb7a ^
07b54625 ^
7da71d03 ^
9fc64bbc ^
d8509b41 ^
b75e94b3 ^


07b54625 ^
9fc64bbc ^

b3899909 ^
49620728 ^
a7d70735 ^
6c96a437 ^
9f95c745 ^
3b776ac3 ^
795f5244 ^
1b76245c ^
795f5244 ^
35064671 ^
dc269891 ^
fca0ebbe ^
e74a2940 ^
6c96a437 ^
e74a2940 ^
0487a30e ^
dc269891 ^
fca0ebbe ^
59874868 ^





dcfca05e ^
f1a6f323 ^
d241c9c4 ^
827898fc ^
d241c9c4 ^

f1a6f323 ^
d241c9c4 ^
15152795 ^
d241c9c4 ^
9cf71627 ^
f404eb55 ^
59874868 ^
59874868 ^



514f0e34 ^

59874868 ^
514f0e34 ^
59874868 ^
0487a30e ^
3eb81335 ^
59874868 ^

9fc64bbc ^
9d670bb5 ^
9fc64bbc ^

6a7ff61c ^
49620728 ^
ccba6718 ^




e74a2940 ^




23d3a022 ^


























3c435756 ^
49620728 ^
2199940a ^
49620728 ^
d41955c1 ^
8eff7919 ^
ec926027 ^

49620728 ^
b2f699e1 ^




d41955c1 ^
795f5244 ^
ec926027 ^

49620728 ^
58a08ed3 ^



49620728 ^
d41955c1 ^
795f5244 ^
dcfca05e ^

49620728 ^
d41955c1 ^
795f5244 ^
ec926027 ^

49620728 ^
d41955c1 ^
95b2a140 ^


e5e9f7db ^

257add0f ^
2429c65c ^
8aa4b664 ^

e5e9f7db ^

b39ceb27 ^
2186422c ^
e7f76736 ^
cea49fde ^
7fd01071 ^

cea49fde ^
6d6c37fe ^
cea49fde ^
6d6c37fe ^

2429c65c ^
60e11efc ^

e7f76736 ^
ae5f0b6f ^
b39ceb27 ^
2429c65c ^
df0f36fb ^
ce9b2b05 ^
6dd67576 ^

257add0f ^




472e4ce9 ^
2429c65c ^
e7f76736 ^
e5e9f7db ^

b39ceb27 ^
ae5f0b6f ^
0d3f30c2 ^
6573fe1f ^
6f69d5d9 ^
7858a06a ^
cea49fde ^
cea49fde ^
cea49fde ^

ae5f0b6f ^
e7f76736 ^
e7f76736 ^

f78f92c5 ^
2429c65c ^
9f78ec2d ^
2429c65c ^
9f78ec2d ^

267ebb59 ^
f5f4b698 ^
5ea70e95 ^
f5f4b698 ^

b2ec0969 ^
8c9e97ae ^
267ebb59 ^


9f78ec2d ^





2429c65c ^
9f78ec2d ^

6c96a437 ^
9f78ec2d ^
745a6dee ^
2429c65c ^
9f78ec2d ^




745a6dee ^








9f78ec2d ^
385ff136 ^

9f78ec2d ^
7284d503 ^

e5e9f7db ^
3473c63a ^
43b866d1 ^
fca0ebbe ^
23d3a022 ^
ab6ed192 ^
a4ef18b1 ^
a26cc359 ^

43b866d1 ^
b24eb476 ^
6c96a437 ^
6700f9f2 ^
a89c1bed ^
b291f85b ^

cae5461b ^


1cd2691b ^

43b866d1 ^
0c0bc3ae ^
9dcbec39 ^
0c0bc3ae ^

6b6dfb0c ^
18429d40 ^
43b866d1 ^
4588af97 ^
2b250717 ^
4588af97 ^

70179d1f ^
2b250717 ^
35064671 ^
70179d1f ^
43b866d1 ^
6c96a437 ^
6700f9f2 ^
a89c1bed ^
3b776ac3 ^
6700f9f2 ^
b291f85b ^
cae5461b ^

c1a50c82 ^
ce9b2b05 ^
3c163ef7 ^
1211a3ab ^
c6034af3 ^
3076bab4 ^
b24eb476 ^
3c163ef7 ^
f4647409 ^





4ecab182 ^



23d3a022 ^
f4647409 ^

1211a3ab ^
f48f6c14 ^
eaa75c87 ^
decaddb4 ^
70179d1f ^
3c163ef7 ^
1211a3ab ^
6c1376f8 ^
70179d1f ^


d41955c1 ^
af023b32 ^





a0fc38c9 ^

d41955c1 ^
78164bab ^

d41955c1 ^
78164bab ^


e5e9f7db ^
19695cc7 ^
e5e9f7db ^


08a8cb2a ^
257add0f ^
08a8cb2a ^

390f4097 ^





e5e9f7db ^

decaddb4 ^
1ead3562 ^
decaddb4 ^
192d59d3 ^

decaddb4 ^
acc4792d ^

d7494165 ^
fc55fea0 ^

1ead3562 ^
bc643692 ^
fc55fea0 ^
acc4792d ^
18429d40 ^
23d3a022 ^




bc643692 ^
5f98a10c ^
1ead3562 ^
192d59d3 ^
18429d40 ^
bc643692 ^
6d2b1168 ^
9a81d746 ^
677fa104 ^


1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
b2f699e1 ^










7d07cd1d ^
b2f699e1 ^






























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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503