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:
—Johnmy $warnline= $tty->newcode ( [-foreground => 'red'], # parameters for Tk's configure 'line' #scope ); # later... print "${warnline}Houston, we have a problem.\n";
In reply to Re: Re: Proof of concept: color tty window in Tk
by John M. Dlugosz
in thread Proof of concept: color tty window in Tk
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |