Index: lib/Padre/Wx/Output.pm =================================================================== --- lib/Padre/Wx/Output.pm (revision 10053) +++ lib/Padre/Wx/Output.pm (working copy) @@ -13,7 +13,8 @@ use Padre::Wx (); our $VERSION = '0.53'; -our @ISA = 'Wx::TextCtrl'; +use Wx::RichText; +our @ISA = 'Wx::RichTextCtrl'; sub new { my $class = shift; @@ -39,6 +40,37 @@ # see #351: output should be blank by default at start-up. #$self->AppendText( Wx::gettext('No output') ); + + use Padre::Logger; + Wx::Event::EVT_TEXT_URL( + $self, + $self, + sub { + my $self = shift; + my $event = shift; + my $uri_string = $event->GetString or return; + require URI; + require Path::Class; + require Path::Class::URI; + my $uri = URI->new($uri_string) or return; + TRACE(" Detected onclick for URI: $uri") if DEBUG; + + my $file = Path::Class::File->from_uri($uri) or return; + my $path = $file->absolute; + my $line = $uri->fragment || 1; + TRACE(" path: $path") if DEBUG; + TRACE(" line: $line") if DEBUG; + + return unless -e $path; + + $self->main->setup_editor($path); + if ($self->main->current->document->filename eq $path) { + $self->main->current->editor->goto_line_centerize($line - 1); + } else { + TRACE(" Current doc does not match our expectations") if DEBUG; + } + }, + ); return $self; } @@ -194,7 +226,7 @@ my $ctrl = $2; # first print the text preceding the control sequence - $self->SUPER::AppendText($1); + $self->_handle_links($1); # split the sequence on ; -- this may be specific to the graphics 'm' sequences, but # we don't handle any others at the moment (see regexp above) @@ -257,9 +289,43 @@ # the remaining text if ( defined( pos($newtext) ) ) { + $self->_handle_links( substr( $newtext, pos($newtext) ) ); + } + unless ($ansi_found) { + $self->_handle_links($newtext); + } + } + + sub _handle_links { + my $self = shift; + my $newtext = shift; + + my $link_found = 0; + while ( $newtext =~ m{ \G (.*?) \s at \s (.*) \s line \s (\d+).$ }xcg ) { + $link_found = 1; + my ($file, $line) = ($2, $3); + + # first print the text preceding the link + $self->SUPER::AppendText($1); + $self->SUPER::AppendText(' at '); + + # Turn the filename into a file: uri + $self->BeginURL( "file:$file#$line" ); + $self->BeginUnderline; + $self->BeginTextColour($bg_colors->[4]); + $self->AppendText("$file"); + $self->EndTextColour; + $self->EndUnderline; + $self->EndURL; + + $self->AppendText(" line $line."); + } + + # the remaining text + if ( defined( pos($newtext) ) ) { $self->SUPER::AppendText( substr( $newtext, pos($newtext) ) ); } - unless ($ansi_found) { + unless ($link_found) { $self->SUPER::AppendText($newtext); } }