Yes that appears to be what I am looking for. Here is some code I will be applying this to:
sub open { my $browse = $t->getOpenFile(-title => "Browse For A File!"); if ($browse ne "") { $t->delete("1.0", "end"); if (!open(TARGET, "$browse")) { $info = "Error!"; $t->insert("end", "ERROR: Could not open $browse\n"); return; } #$line_count = 1; $filename = $browse; $info = "Loading file '$filename'..."; while (<TARGET>) { #$t->insert("end", "$line_count "); $t->insert("end", $_); $line_count++; } close(TARGET); $info = "File '$filename' loaded"; }else{ if (!$filename) { $info = "Error!"; $t->delete("1.0", "end"); $t->insert("end", "ERROR: Could not open $browse\n"); return; }else{ return; } } }
I want to incorporate the coloring of the text while the file is being parsed during opening. As of now I am using $_ to insert each line while traversing the while loop. If I wanted to color specific words ine ach line would I have to parse each line further into each word? From what I read on your link from CPAN was that you have to designate certain words to certain colors.
use Term::ANSIColor; $red = color('red'); # Retrieve color codes $bold = color('bold'); $wid->insert('end', "$red red text $bold with bold\n");
Here I would designate "red text" as being red by assigning $red to it in front of the target text. In my implementation now I would have to use something like:
$wid->insert("end", $red $_);
which would color the entire line. ANy suggestion on how to parse the file down to word level and still insert correctly?

In reply to Re: Re: Coloring text using TK? by Elijah
in thread Coloring text using TK? by Elijah

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.