How about colors and terminal graphics in std.format?

Chad J chadjoan at __spam.is.bad__gmail.com
Sun Mar 11 20:27:43 PDT 2012


On 03/11/2012 11:05 PM, Adam D. Ruppe wrote:
> One concern I have with this is format() creates a
> string, which isn't necessarily output; color is
> a thing of output.
>
> The unix implementation will use the ansi escape
> sequences, surely, which isn't correct almost
> anywhere else.
>

I was kind of intending to /not/ do that, for exactly the reasons you 
mention.  ASCII escape sequences should work anyways.  I don't think 
anyone will panic if I waste a byte or two for every 3+ on fairly rare 
coloring/gfx operations.  And then there's always terminfo in the long 
picture.

> Of course, you could choose to not use these
> special specifiers, and put a note in the
> documentation explaining what it is, so
> not a big deal... but I just think it is
> somewhat wrong to put special control
> sequences in the middle of a regular string
> that might be used anywhere.

The primary intent of this is to be used with writefln or any other 
routines that will be writing to the terminal.

That this can emit escape sequences to other targets is a consequence of 
std.format being abstracted from the I/O routines.  I think it is fine. 
  I doubt people will put color formatting into strings that they know 
will not end up on a terminal.  And if they don't realize that 
limitation, then perhaps I should change the way it's documented so that 
it's /really obvious/ that the resulting strings will only colorize on 
process's attached terminal, and produce gobbledygook otherwise.



More information about the Digitalmars-d mailing list