Elijah has asked for the wisdom of the Perl Monks concerning the following question:
I also have the same code for when a file is saved, to update the new text. I would like to able to color the text as it is input though. Would this be possible? Would any of the existing code to color commented string be of any help in doing so? I know of a way I can color the code by splitting the string on each character input but do not know how to monitor the textbox for character input. Any ideas?my $browse = $t->getOpenFile(-title => "Browse For A File!"); if ($browse) { $t->delete("1.0", "end"); $status->delete("1.0", "end"); if (!open(TARGET, "$browse")) { $info = "Error!"; $status->insert("end", "ERROR: Could not open $browse\n"); return; } $line_count = 1; $filename = $browse; my @ext = split(/\./, $filename); my $ext = "\." . $ext[1]; $info = "Loading file '$filename'..."; while (<TARGET>) { #$t->insert("end", "$line_count "); $t->insert("end", $_); if ($ext eq ".pl") { if ($_ =~ /\#/) { my @comment = split(//, $_); my $i = 0; foreach my $comment (@comment) { my $range = length($_); if ($comment eq "#") { my $offset = "$line_count\.$i"; my $end = "$line_count\.$range"; $t->tagAdd("orange", $offset, $end); }else{ $i++; } } } } $line_count++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Scrolled textbox, parse on input?
by pg (Canon) on Dec 08, 2003 at 00:24 UTC | |
by Elijah (Hermit) on Dec 08, 2003 at 04:37 UTC | |
by Mr. Muskrat (Canon) on Dec 08, 2003 at 05:16 UTC | |
by pg (Canon) on Dec 08, 2003 at 06:19 UTC | |
by Elijah (Hermit) on Dec 08, 2003 at 14:21 UTC | |
by pg (Canon) on Dec 08, 2003 at 05:16 UTC |