Re: [DOS] How to set different text_colors?

new topic     » goto parent     » topic index » view thread      » older message » newer message

> I'd be grateful for advice on coding to do achieve the following...
> 1   display a prompt message in, say, yellow (eg: "Enter something here:
> ")
> 2   echo user's response on screen in, say, green (eg "This is user's
> input")
>
> I've tried this, but can't get the green colour:
>      ......
> text_color( YELLOW )
> puts( 1, "Enter something here: " )
> text_color( GREEN )
> user_input = gets( 0 )
>      ......
>
> Thank you
>
> Alex Caracatsanis

Hi,
If you set the text color to GREEN then puts spaces over the place
where the user is going to enter the text then you should get the
effect you want:

--------------------------------------------------

include graphics.e

function ColoredGets(atom color)
    sequence StartPos,VideoConfig
    --Ok, first find out where we're starting from
    StartPos = get_position()
    --Now find out how many colums there are in total
    VideoConfig = video_config()

    --Set the text color
    text_color(color)
--Fill the space where the user will be making they're input with spaces of
    that color
--If you want the input to be longer than to the end of the line then
    increas the length here
    puts(1,repeat(' ',VideoConfig[VC_COLUMNS]-StartPos[2]+1))

    --Set the cursor position back to the original location
    position(StartPos[1],StartPos[2])

    --get input and return
    return gets(0)
end function


sequence user_input
text_color( YELLOW )
puts( 1, "Enter something here: " )
user_input = ColoredGets( GREEN )

--------------------------------------------------

Hope this helps :)

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu