Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/hgext/progress.py Thu Apr 01 17:51:59 2010 -0500 +++ b/hgext/progress.py Fri Apr 02 15:22:00 2010 -0500 @@ -165,10 +165,10 @@ self.show(topic, pos, item, unit, total) return orig(topic, pos, item=item, unit=unit, total=total) - def write(self, orig, *args): + def write(self, orig, *args, **opts): if self.printed: self.clear() - return orig(*args) + return orig(*args, **opts) sharedprog = None