Re: Now for some actual euphoria/linux questions...

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

On Mon, 17 Apr 2000 15:45:10 -0400, Paul <draegur at WSERV.COM> wrote:

>Pete Eberlein wrote:
>
>>
>>
>> kat already pointed out ANSI codes, and that's the way to go.
>> http://www.linuxdoc.org/HOWTO/Bash-Prompt-HOWTO-6.html
>>
>> Pete Eberlein
>
>Well.. umm.. Did I happen to mention that I am slow? :)
>I read the link and have seen the ansi tag codes, yet when I try to use
them
>in
>Euphoria it errors with 'unknown escape character' after the initial \ in
>codes such as
>\[\033[1;30m\]. I am missing the entire point, ain't I?
>Any chance for the idiots guide to what I am doing wrong here? :)
>(man do I hate to seem this lost...)

The trick is representing the escape character (ASCII 27 decimal, 033 octal)
Since Euphoria doesn't support strings with octal escape codes, you have to
do it with something like:
 27&"[1;30m"

Here's some graphics.e-ish code to print colors using ANSI:

global constant
    BLACK = 0,
    BLUE  = 1,
    GREEN = 2,
    CYAN =  3,
    RED   = 4,
    MAGENTA = 5,
    BROWN = 6,
    WHITE = 7,
    GRAY  = 8,
    BRIGHT_BLUE = 9,
    BRIGHT_GREEN = 10,
    BRIGHT_CYAN = 11,
    BRIGHT_RED = 12,
    BRIGHT_MAGENTA = 13,
    YELLOW = 14,
    BRIGHT_WHITE = 15


global procedure clear_screen()
    putc(1, 27)
    puts(1, "[2J")
end procedure


constant text_color_map = {
    "[0;30",
    "[0;34",
    "[0;32",
    "[0;36",
    "[0;31",
    "[0;35",
    "[0;33",
    "[0;37",
    "[0;1;30",
    "[0;1;34",
    "[0;1;32",
    "[0;1;36",
    "[0;1;31",
    "[0;1;35",
    "[0;1;33",
    "[0;1;37",
    "[1;7;40",
    "[1;7;44",
    "[1;7;42",
    "[1;7;46",
    "[1;7;41",
    "[1;7;45",
    "[1;7;43",
    "[1;7;47"
}

constant bk_color_map = {
    ";40m",
    ";44m",
    ";42m",
    ";46m",
    ";41m",
    ";45m",
    ";43m",
    ";47m",
    ";40m",
    ";44m",
    ";42m",
    ";46m",
    ";41m",
    ";45m",
    ";43m",
    ";47m",
    ";30m",
    ";34m",
    ";32m",
    ";36m",
    ";31m",
    ";35m",
    ";33m",
    ";37m"
}


integer textc, bkc
textc = 16
bkc = 1

global procedure text_color(integer color)
    textc = color + 1
    putc(1, 27)
    if bkc <= 8 or textc > 8 then
        puts(1, text_color_map[textc])
        puts(1, bk_color_map[bkc])
    else
        puts(1, text_color_map[textc+16])
        puts(1, bk_color_map[bkc+8])
    end if
end procedure

global procedure bk_color(integer color)
    bkc = color + 1
    putc(1, 27)
    if bkc <= 8 or textc > 8 then
        puts(1, text_color_map[textc])
        puts(1, bk_color_map[bkc])
    else
        puts(1, text_color_map[textc+16])
        puts(1, bk_color_map[bkc+8])
    end if
end procedure

global procedure position(integer line, integer column)
    puts(1, 27)
    printf(1, "%d;%df", {line, column})
--    printf(1, "%d;%dH", {line, column})
end procedure

-------------------------------------------------------
Hope this helps,

Pete Eberlein

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

Search



Quick Links

User menu

Not signed in.

Misc Menu