Changeset 10594
- Timestamp:
- 02/07/10 07:34:37 (5 weeks ago)
- Files:
-
- 1 modified
-
trunk/Padre/lib/Padre/Wx/Dialog/RegexEditor.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Wx/Dialog/RegexEditor.pm
r10593 r10594 9 9 use Padre::Wx::Icon (); 10 10 use Padre::Wx::Role::MainChild (); 11 use Padre::Wx::HtmlWindow ();12 11 13 12 # RichTextCtrl … … 171 170 # Matched readonly text field 172 171 my $matched_label = Wx::StaticText->new( $self, -1, Wx::gettext('&Matched text:') ); 173 $self->{matched_text} = Padre::Wx::HtmlWindow->new( 174 $self, 175 -1, 176 Wx::wxDefaultPosition, 177 Wx::wxDefaultSize, 178 Wx::wxBORDER_STATIC 172 $self->{matched_text} = Wx::RichTextCtrl->new( 173 $self, -1, '', Wx::wxDefaultPosition, Wx::wxDefaultSize, 174 Wx::wxRE_MULTILINE | Wx::wxRE_READONLY | Wx::wxWANTS_CHARS # Otherwise arrows will not work on win32 179 175 ); 180 176 181 177 # Result from replace text field 182 178 my $result_label = Wx::StaticText->new( $self, -1, Wx::gettext('&Result from replace:') ); 183 $self->{result_text} = Padre::Wx::HtmlWindow->new( 184 $self, 185 -1, 186 Wx::wxDefaultPosition, 187 Wx::wxDefaultSize, 188 Wx::wxBORDER_STATIC 179 $self->{result_text} = Wx::RichTextCtrl->new( 180 $self, -1, '', Wx::wxDefaultPosition, Wx::wxDefaultSize, 181 Wx::wxRE_MULTILINE | Wx::wxRE_READONLY | Wx::wxWANTS_CHARS # Otherwise arrows will not work on win32 189 182 ); 190 183 … … 457 450 my $xism = "$start-$end"; 458 451 459 my $matched_html = ''; 460 my $result_html = ''; 461 452 $self->{matched_text}->Clear; 453 $self->{result_text}->Clear; 454 455 $self->{matched_text}->BeginTextColour(Wx::wxBLACK); 456 462 457 my $match; 463 458 my $match_start; … … 481 476 }; 482 477 if ($@) { 483 $matched_html .= '<font color="red">' . "Match failure in $regex: $@" . '</font>'; 484 $self->{matched_text}->SetPage($matched_html); 478 $self->{matched_text}->BeginTextColour(Wx::wxRED); 479 $self->{matched_text}->SetValue(sprintf(Wx::gettext("Match failure in %s: %s"), $regex, $@)); 480 $self->{matched_text}->EndTextColour; 485 481 return; 486 482 } 487 483 488 484 if ($warning) { 489 $matched_html .= '<font color="red">' . "Match warning in $regex: $warning" . '</font>'; 490 $self->{matched_text}->SetPage($matched_html); 485 $self->{matched_text}->BeginTextColour(Wx::wxRED); 486 $self->{matched_text}->SetValue(sprintf(Wx::gettext("Match warning in %s: %s"), $regex, $warning)); 487 $self->{matched_text}->EndTextColour; 491 488 return; 492 489 } … … 497 494 for my $char (@chars) { 498 495 if ( $pos == $match_start ) { 499 $ matched_html .= '<font color="red"><u>';496 $self->{matched_text}->BeginTextColour(Wx::wxRED); 500 497 } elsif ( $pos == $match_end ) { 501 $ matched_html .= '</u></font>';498 $self->{matched_text}->EndTextColour; 502 499 } 503 $ matched_html .= $char;500 $self->{matched_text}->AppendText($char); 504 501 $pos++; 505 502 } 506 503 } else { 507 $matched_html = Wx::gettext("No match"); 504 $self->{matched_text}->BeginTextColour(Wx::wxRED); 505 $self->{matched_text}->SetValue(Wx::gettext("No match")); 506 $self->{matched_text}->EndTextColour; 508 507 } 509 508 510 509 eval { $result_text =~ s{$regex}{$replace}; }; 511 510 if ($@) { 512 $result_html .= '<font color="red">' . "Replace failure in $regex: $@" . '</font>'; 511 $self->{result_text}->BeginTextColour(Wx::wxRED); 512 $self->{result_text}->AppendText("Replace failure in $regex: $@"); 513 $self->{result_text}->EndTextColour; 513 514 return; 514 515 } 515 516 516 517 if ( defined $result_text ) { 517 $result_html .= $result_text; 518 } 518 $self->{result_text}->SetValue($result_text); 519 } 520 521 $self->{matched_text}->EndTextColour; 519 522 520 523 require PPIx::Regexp; 521 524 my $regexp = PPIx::Regexp->new("/$regex/"); 522 525 $self->{description_text}->SetValue( $self->_dump_regex($regexp) ); 523 524 $self->{matched_text}->SetPage($matched_html);525 $self->{result_text}->SetPage($result_html);526 526 527 527 # $self->{regex}->Clear;
