in reply to coloring text in RichEdit takes long time

Try it this way:

sub Button1_Click { open my $file, '<', "bigfile.txt" or die "$!"; ## One line at a time while( <$file> ) { ## skip it if it doesn't contain the text next unless m[be]; my @posns; ## Find the positions push @posns, [ $-[0], $+[ 0 ] ] while m[be]g; ## Get the current length my $oldLen = $RichText->TextLength; ## Move the seletion to the end and insert the line $RichText->SetSel( -1, -1 ); $RichText->ReplaceSel( $_ ); ## for each position found for( @posns ) { ## Set the selection to it, ## adjusting for the length of the previous contents $RichText->SetSel( map $oldLen + $_, @$_ ); ## And highlight it $RichText->SetCharFormat( -color => "#ff0000" ); } } close $file; }

Ask if anything need clarifying.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."