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

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.