[Tutor] Print to std output with color

Karim karim.liateni at free.fr
Wed Jan 26 20:41:09 CET 2011


Thanks Alan!
I will go there have a look.

Regards
Karim

On 01/26/2011 07:24 PM, Alan Gauld wrote:
>
> "Karim" <karim.liateni at free.fr> wrote
>
>> Is there a simple way to print with color to stdout like the unix/linux
>> example below:
>>
>> *print( '^[[1;31mThis is a warning!^[[0m' )
>
> Not generically since stdout is a data stream which may not be
> printed (it could be spoken for example - how does the synthesiser
> interpret colour?) and the terminal may have a colour scheme that
> makes your output invisible!
>
> Also different terminals have different capabilities, many do
> not support colour but do support bold/italic/underline etc.
> Thats why curses exists, it does a best endeavours attempt
> at rendering what you want but reverts to defaults for cases
> where it is not supported. but even curses is not able to work
> with all terminals - for example line oriented terminals/teletypes.
>
>> *I see thing with curses module. But is there an more simple object in
>> other module to do the trick?
>> Kind of _/decorate_output( mode=WARNING, *'This is a warning!')*/_
>
> There are some attempts at providing easier terminal control
> functions. The effbot did one I seem to recall....
>
> http://effbot.org/zone/console-handbook.htm
>
> That might suffice for you?
>
>



More information about the Tutor mailing list