[PATCH 1 of 2] ui: add ui.write() label API

Steve Borho steve at borho.org
Tue Mar 30 17:18:02 CDT 2010


On Tue, Mar 30, 2010 at 5:10 PM, Matt Mackall <mpm at selenic.com> wrote:
> On Fri, 2010-03-26 at 15:14 -0400, Brodie Rao wrote:
>> # HG changeset patch
>> # User Brodie Rao <me+hg at dackz.net>
>> # Date 1266550756 18000
>> # Node ID c5eaa1e8207881ad48aaeaf98fcd642bdb6c76b3
>> # Parent  bd36e5c0ccb110c11bf0bda72ea77171d6844f18
>> ui: add ui.write() label 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.style(msg, label)
>
> Why are we adding ui.style? Isn't it just ui.write?

I can answer this question.  The intent for ui.style() is to allow the
ui to decorate the provided message as per the specified label (in the
path, the naming is reversed as ui.label(msg, label)).  The ui is not
supposed to output anything based on a ui.style() call.  The caller
can take the decorated string and combine it with other output that is
later passed to ui.write().

And yes, it does require some in-line color markup, like ANSI codes.

Only a couple of the extensions used this method in the original patch.

--
Steve Borho


More information about the Mercurial-devel mailing list