How about colors and terminal graphics in std.format?

James Miller james at aatch.net
Mon Mar 12 23:03:57 PDT 2012


On 13 March 2012 18:50, Chad J <chadjoan at __spam.is.bad__gmail.com> wrote:
> On 03/13/2012 01:41 AM, James Miller wrote:
>>
>> On 13 March 2012 18:24, Chad J<chadjoan at __spam.is.bad__gmail.com>  wrote:
>>>
>>> I'm not sure I agree with resetting to a default color.  What if I want
>>> to
>>>
>>> write to the stream without altering the terminal's graphics settings?
>>
>>
>> Actually, I meant more to make sure that any output is reset to the
>> terminal's default. I'm pretty sure there is a way to do this. The
>> point is that not undoing mode changes is bad form.
>>
>> Otherwise, I can live with the colourings being nested, but I would
>> suggest a change in syntax, I understand that yours is mostly just for
>> show, but using parenthesis will be annoying, I'd probably use braces
>> ('{' and '}') instead, since they are less common.
>>
>> writefln('%Cred(\(this is in color\))');
>>  vs
>> writefln('%Cred{(this is in color)}');
>>
>> Neither are /that/ pretty, but at least the second one requires less
>> escaping in the common case.
>>
>> --
>> James Miller
>
>
> Oh, I see what you mean.
>
> This is why the second paren always had a % before it:
>
> writefln('%Cred((this is in color)%)');
>
> Is this OK?  I know that escaping is still involved, but the text itself
> does not need escaping: only the special closing element does.
>
> I like this constraint because it means that the only character you ever
> have to escape in your normal text is %, which you write by using %%
> instead.

That works, and I think it matches zsh's style. I still think that
'{', '}' would be better, but I'm not dead-set on it.

--
James Miller


More information about the Digitalmars-d mailing list