1. Displaying colored text on console

In a console application, I need to display following text:

display("This is important notice.")

The word 'important' needs to be in red color. How can I achieve this?

I tried to check in manual and it seems I can do this only using graphics screen and not on regular terminal. Thanks for your help.

new topic     » topic index » view message » categorize

2. Re: Displaying colored text on console

Try this:

include std/graphics.e 
puts(1,"This is an ") 
text_color(BRIGHT_RED) 
puts(1,"important") 
text_color(WHITE) 
puts(1," notice.") 

Pete

new topic     » goto parent     » topic index » view message » categorize

3. Re: Displaying colored text on console

petelomax said...

Try this:

include std/graphics.e 
puts(1,"This is an ") 
text_color(BRIGHT_RED) 
puts(1,"important") 
text_color(WHITE) 
puts(1," notice.") 

Pete

The word 'important' came out in red but then there was error:

/usr/share/euphoria/include/std/graphics.e:97 in procedure text_color() type_check failure, c is {27,91,48,59,51,55,109}

The terminal color has become red and is not becoming black even on trying:

text_color(BLACK)

new topic     » goto parent     » topic index » view message » categorize

4. Re: Displaying colored text on console

rneu said...

The word 'important' came out in red but then there was error:

/usr/share/euphoria/include/std/graphics.e:97 in procedure text_color() type_check failure, c is {27,91,48,59,51,55,109}

The terminal color has become red and is not becoming black even on trying:

text_color(BLACK)

Not sure I can help.

On my system, WHITE is defined as the constant 7 in std\graphcst.e, but that value of {27,91,48,59,51,55,109} is the ansi sequence for white, "\e[0;37m".

Perhaps you could try text_color(7), and maybe text_color(0) instead of text_color(WHITE) and text_color(BLACK), see what that does.
Also the output of ?{WHITE,BLACK} may help someone else figure out what is wrong, maybe text_color() is broken on linux.
Someone else will have to explain where that value for WHITE is coming from.

Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu