159 tw = self.ui.termwidth() |
160 tw = self.ui.termwidth() |
160 return min(int(self.ui.config('progress', 'width', default=tw)), tw) |
161 return min(int(self.ui.config('progress', 'width', default=tw)), tw) |
161 |
162 |
162 def progress(self, topic, pos, item='', unit='', total=None): |
163 def progress(self, topic, pos, item='', unit='', total=None): |
163 if pos is None: |
164 if pos is None: |
164 if self.topics and self.topics[-1] == topic and self.printed: |
165 self.topicstates.pop(topic, None) |
|
166 # reset the progress bar if this is the outermost topic |
|
167 if self.topics and self.topics[0] == topic and self.printed: |
165 self.complete() |
168 self.complete() |
166 self.resetstate() |
169 self.resetstate() |
|
170 # truncate the list of topics assuming all topics within |
|
171 # this one are also closed |
|
172 if topic in self.topics: |
|
173 self.topics = self.topics[:self.topics.index(topic)] |
167 else: |
174 else: |
168 if topic not in self.topics: |
175 if topic not in self.topics: |
169 self.topics.append(topic) |
176 self.topics.append(topic) |
170 now = time.time() |
177 now = time.time() |
171 if (now - self.lastprint >= self.refresh |
178 self.topicstates[topic] = pos, item, unit, total |
172 and topic == self.topics[-1]): |
179 if now - self.lastprint >= self.refresh and self.topics: |
173 self.lastprint = now |
180 self.lastprint = now |
174 self.show(topic, pos, item, unit, total) |
181 current = self.topics[-1] |
|
182 self.show(current, *self.topicstates[current]) |
175 |
183 |
176 def uisetup(ui): |
184 def uisetup(ui): |
177 class progressui(ui.__class__): |
185 class progressui(ui.__class__): |
178 _progbar = None |
186 _progbar = None |
179 |
187 |