in reply to Re: Proof of concept: color tty window in Tk
in thread Proof of concept: color tty window in Tk

I figured I would use non-printing control codes at least as the delimiters, so nothing needs to be escaped. Perhaps the classic ESCape.

I like having an "end" tag instead of having to change back to the old way, because you might not know or care what it was before. But, I also want to prevent accidental runons when something doesn't match. If an intended string is not sent, and that contained a close, or if the error is in something that's rarely printed like an error message, I don't want it to bamboozle the whole thing from there on.

So, perhaps controls can last only until the end of the line, even if you leave off an end code.

It might be nice to have implicit ends noted when you start. In the case of "very important", have a code that means "emphasize just the next word, then stop". Maybe have common cases, plus match the specified pattern or natural delimiter that will be in the text.

FWIW, I'm doing it by breaking up the string into runs and adding one run at a time to the widget.

I don't particularly care to emulate a famous terminal, since I'm not porting terminal output programs to run here.

I think the "syntax" of what gets put into the string might be completely hidden from the user, too. Maybe:

my $warnline= $tty->newcode ( [-foreground => 'red'], # parameters for Tk's configure 'line' #scope ); # later... print "${warnline}Houston, we have a problem.\n";
—John

Replies are listed 'Best First'.
Re: Re: Re: Proof of concept: color tty window in Tk
by traveler (Parson) on Dec 13, 2002 at 16:23 UTC
    Sounds good. Mostly what I was suggesting was to try to avoid ${warnline} in the string. If your code could parse/translate the string sent to print, it seems to me it would be easier to use/read.

    Just my $0.02, --traveler

      I don't understand.
        Well, in your case the variable is interpreted by Perl. I was suggesting a string not interpreted by Perl, but by your code. This gets the variable notation ($foo) out of the string. That way someone reading the code later doesn't think the user is printing out a user variable.

        --traveler