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

I missed the earlier lament (and I did not find it searching thru your home node, and the closest I found using Search was this), so if I'm off base, please just ignore this. Anyway I presume you do one of two things: a) mark the text to effect and then apply the effect, or b) break up the string and send it to the widget in parts. In either case, I guess your question is along the lines of "what should the user send to print?" Is that right?

I think xml style markup might be pretty readable and not too hard to do, particularly if you use the last example below.

and if you don't like HTML

Of course, this means escaping < and so forth. I guess you could do something like use character codes from a famous color terminal...

If I misinterpreted the question, just ignore this, OK?

Just my USD0.02, --traveler

Replies are listed 'Best First'.
Re: Re: Proof of concept: color tty window in Tk
by John M. Dlugosz (Monsignor) on Dec 13, 2002 at 15:45 UTC
    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
      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.