From 6615467cb849207dd98fd307e4cc217cd05c9f09 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 8 Oct 2010 17:36:59 +0200 Subject: core.loader: simplified throbber logic --- ranger/core/loader.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ranger/core/loader.py b/ranger/core/loader.py index ae6436a1..cda578f2 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -18,14 +18,6 @@ from time import time from ranger.core.shared import FileManagerAware import math -def status_generator(): - """Generate a rotating line which can be used as a throbber""" - while True: - yield '/' - yield '-' - yield '\\' - yield '|' - class LoadableObject(object): def __init__(self, gen, descr): self.load_generator = gen @@ -37,11 +29,13 @@ class LoadableObject(object): class Loader(FileManagerAware): seconds_of_work_time = 0.03 + throbber_chars = r'/-\|' def __init__(self): self.queue = deque() self.item = None self.load_generator = None + self.throbber_status = 0 self.status_generator = status_generator() self.rotate() self.old_item = None @@ -49,7 +43,9 @@ class Loader(FileManagerAware): def rotate(self): """Rotate the throbber""" # TODO: move all throbber logic to UI - self.status = next(self.status_generator) + self.throbber_status = \ + (self.throbber_status + 1) % len(self.throbber_chars) + self.status = self.throbber_chars[self.throbber_status] def add(self, obj): """ -- cgit 1.4.1-2-gfad0 ef='/akspecs/ranger/commit/test/tc_displayable.py?h=v1.5.2&id=52cf9f19b3738d42878cb35f4eb88a6f0775ea89'>commit diff stats
path: root/test/tc_displayable.py
blob: 72e0507dd7fdecc164b287aad69451050ef475e1 (plain) (blame)
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