Mercurial > hg
comparison hgext/progress.py @ 10815:32b213b9b22c
ui: add ui.write() output labeling API
This adds output labeling support with the following methods:
- ui.write(..., label='topic.name topic2.name2 ...')
- ui.write_err(.., label=...)
- ui.popbuffer(labeled=False)
- ui.label(msg, label)
By adding an API to label output directly, the color extension can forgo
parsing command output and instead override the above methods to insert
ANSI color codes. GUI tools can also override the above methods and use
the labels to do GUI-specific styling.
popbuffer gains a labeled argument that, when set to True, returns its
buffered output with labels handled. In the case of the color extension,
this would return output with color codes embedded. For existing users
that use this method to capture and parse output, labels are discarded
and output returned as normal when labeled is False (the default).
Existing wrappers of ui.write() and ui.write_err() should make sure to
accept its new **opts argument.
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Fri, 02 Apr 2010 15:22:00 -0500 |
parents | ca6ba6cac6cd |
children | 83af68e38be3 |
comparison
equal
deleted
inserted
replaced
10814:cd0c49bdbfd9 | 10815:32b213b9b22c |
---|---|
163 and topic == self.topics[-1]): | 163 and topic == self.topics[-1]): |
164 self.lastprint = now | 164 self.lastprint = now |
165 self.show(topic, pos, item, unit, total) | 165 self.show(topic, pos, item, unit, total) |
166 return orig(topic, pos, item=item, unit=unit, total=total) | 166 return orig(topic, pos, item=item, unit=unit, total=total) |
167 | 167 |
168 def write(self, orig, *args): | 168 def write(self, orig, *args, **opts): |
169 if self.printed: | 169 if self.printed: |
170 self.clear() | 170 self.clear() |
171 return orig(*args) | 171 return orig(*args, **opts) |
172 | 172 |
173 sharedprog = None | 173 sharedprog = None |
174 | 174 |
175 def uisetup(ui): | 175 def uisetup(ui): |
176 # Apps that derive a class from ui.ui() can use | 176 # Apps that derive a class from ui.ui() can use |