diff --git a/ChangeLog b/ChangeLog index f833908..555937d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 1.2.1.2 + + Click on the error message to jump to the error location * Bug #99 fix desktop file (Marco Rodrigues) 1.2.1.1 2014/05/04 diff --git a/src/myhtmlpane.cpp b/src/myhtmlpane.cpp index 2b68eb6..9710ff9 100644 --- a/src/myhtmlpane.cpp +++ b/src/myhtmlpane.cpp @@ -21,7 +21,6 @@ #include "xmlcopyeditor.h" BEGIN_EVENT_TABLE ( MyHtmlPane, wxHtmlWindow ) - EVT_LEFT_DCLICK ( MyHtmlPane::OnLeftDoubleClick ) END_EVENT_TABLE() MyHtmlPane::MyHtmlPane ( @@ -29,27 +28,52 @@ MyHtmlPane::MyHtmlPane ( wxWindowID id, const wxPoint& position, const wxSize& size ) : wxHtmlWindow ( parent, id, position, size ) -{} - -/* -void MyHtmlPane::OnCellClicked( - wxHtmlCell *cell, - wxCoord x, - wxCoord y, - const wxMouseEvent& event) { - int width = GetSize().GetWidth(); - if (x < (width*9/10)) - return; - - MyFrame *frame = (MyFrame *)GetParent(); - if (frame) - { - wxCommandEvent e; - frame->OnClosePane(e); - } } -*/ -void MyHtmlPane::OnLeftDoubleClick ( wxMouseEvent& WXUNUSED ( event ) ) -{ } +bool MyHtmlPane::OnCellClicked(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& event) +{ + if ( mLastFile.empty() ) + return false; + + wxHtmlContainerCell *parent = cell->GetParent(); + if (!parent) + return false; + + // Expect "FatalError at line 6, column 0:" + wxString msg; + wxHtmlCell *p = parent->GetFirstChild(); + for (; p != NULL; p = p->GetNext() ) + msg << p->ConvertToText ( NULL ); + + const static wxString anchor = _T(" at line "); + size_t pos = msg.find ( anchor ); + if ( pos == wxString::npos ) + return false; + pos += anchor.length(); + + size_t comma = msg.find ( ',', pos ); + if ( comma == wxString::npos ) + return false; + msg = msg.Mid ( pos, comma - pos); + + wxChar *psz = NULL; + int line = wxStrtoul ( msg, &psz, 10 ); + if ( line <= 0 ) + return false; + + MyFrame *frame = ( MyFrame * ) wxTheApp->GetTopWindow(); + XmlDoc *doc = frame->getActiveDocument(); + if ( ( !doc ) || !frame->activateTab ( mLastFile ) ) + return false; + + doc->GotoLine ( line - 1 ); + doc->SetFocus(); + + return true; +} + +void MyHtmlPane::setLastFile ( const wxString &file ) +{ + mLastFile = file; +} diff --git a/src/myhtmlpane.h b/src/myhtmlpane.h index ad99a52..f607486 100644 --- a/src/myhtmlpane.h +++ b/src/myhtmlpane.h @@ -31,16 +31,16 @@ class MyHtmlPane : public wxHtmlWindow wxWindowID id = wxID_ANY, const wxPoint& position = wxDefaultPosition, const wxSize& size = wxDefaultSize ); + void setLastFile ( const wxString &file ); private: - /* - void OnCellClicked( - wxHtmlCell *cell, - wxCoord x, - wxCoord y, - const wxMouseEvent& event); - */ - void OnLeftDoubleClick ( wxMouseEvent& event ); + bool OnCellClicked( + wxHtmlCell *cell, + wxCoord x, + wxCoord y, + const wxMouseEvent& event); DECLARE_EVENT_TABLE() + + wxString mLastFile; }; #endif diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index b1b65ec..ee94a5f 100644 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -5576,6 +5576,9 @@ void MyFrame::messagePane ( const wxString& s, int iconType, bool forcePane ) htmlBuffer += htmlString; htmlBuffer += _T ( "" ); + XmlDoc *doc = getActiveDocument(); + if ( doc ) + htmlReport->setLastFile ( doc->getFullFileName() ); htmlReport->SetPage ( htmlBuffer ); manager.Update();