Click on the error message to jump to the error location

This commit is contained in:
Zane U. Ji 2014-05-12 19:56:41 +08:00
parent fb698e20cd
commit 14ffcc8d23
4 changed files with 58 additions and 30 deletions

View File

@ -1,4 +1,5 @@
1.2.1.2 1.2.1.2
+ Click on the error message to jump to the error location
* Bug #99 fix desktop file (Marco Rodrigues) * Bug #99 fix desktop file (Marco Rodrigues)
1.2.1.1 2014/05/04 1.2.1.1 2014/05/04

View File

@ -21,7 +21,6 @@
#include "xmlcopyeditor.h" #include "xmlcopyeditor.h"
BEGIN_EVENT_TABLE ( MyHtmlPane, wxHtmlWindow ) BEGIN_EVENT_TABLE ( MyHtmlPane, wxHtmlWindow )
EVT_LEFT_DCLICK ( MyHtmlPane::OnLeftDoubleClick )
END_EVENT_TABLE() END_EVENT_TABLE()
MyHtmlPane::MyHtmlPane ( MyHtmlPane::MyHtmlPane (
@ -29,27 +28,52 @@ MyHtmlPane::MyHtmlPane (
wxWindowID id, wxWindowID id,
const wxPoint& position, const wxPoint& position,
const wxSize& size ) : wxHtmlWindow ( parent, id, position, size ) 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;
}

View File

@ -31,16 +31,16 @@ class MyHtmlPane : public wxHtmlWindow
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxPoint& position = wxDefaultPosition, const wxPoint& position = wxDefaultPosition,
const wxSize& size = wxDefaultSize ); const wxSize& size = wxDefaultSize );
void setLastFile ( const wxString &file );
private: private:
/* bool OnCellClicked(
void OnCellClicked(
wxHtmlCell *cell, wxHtmlCell *cell,
wxCoord x, wxCoord x,
wxCoord y, wxCoord y,
const wxMouseEvent& event); const wxMouseEvent& event);
*/
void OnLeftDoubleClick ( wxMouseEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
wxString mLastFile;
}; };
#endif #endif

View File

@ -5576,6 +5576,9 @@ void MyFrame::messagePane ( const wxString& s, int iconType, bool forcePane )
htmlBuffer += htmlString; htmlBuffer += htmlString;
htmlBuffer += _T ( "</td></tr></table></body></html>" ); htmlBuffer += _T ( "</td></tr></table></body></html>" );
XmlDoc *doc = getActiveDocument();
if ( doc )
htmlReport->setLastFile ( doc->getFullFileName() );
htmlReport->SetPage ( htmlBuffer ); htmlReport->SetPage ( htmlBuffer );
manager.Update(); manager.Update();