Re: Controlling gets(0) color

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

>This problem is most vexing.
>
>I use gets(0) to get input from the keyboard.  I want that text to be
>displayed in a certain color.  For example, I put the prompt in the
>standard dos white on black, then I use gets.  As I type, gets()
>displays=
>
>the input.  I've tried text_color(), I've tried shading prior to the
>gets(0) call.  No matter what I do, gets overwrites what I've shaded;
>it insists on displaying white on black.  No changing of foreground or
>background color.  What can I do?
>
>This is one of the few times where I wish this library routine wasn't
>built into the interpreter.

-- Untested code
-- thisthat.e
include get.e
include graphics.e

global procedure getstring()
    -- Get input from keyboard, uses current colors for input
    -- Set color to use before calling routine.
    sequence string, pos
    integer c

    string = {}
    while string[length(string)] != '\n' do
        c = wait_key()
        if c = 8 and length(string)>0 then   -- backspace?
            pos = get_position()
            position(pos[1], pos[2]-1)
            puts(1, " ")
            position(pos[1], pos[2]-1)
            string = string[1..length(string)-1]
        else
            string = append(string, c)
            puts(1, c)
        end if
    end while
    return string
end procedure

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

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

Search



Quick Links

User menu

Not signed in.

Misc Menu