// ---------------------------------------------------------------------------- void JumpTracker::OnEditorUpdateEvent(CodeBlocksEvent& event) // ---------------------------------------------------------------------------- { event.Skip(); if ( m_bShuttingDown ) return; if (m_bJumpInProgress) return; cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if(not ed) return; wxString edFilename = ed->GetFilename(); cbStyledTextCtrl* edstc = ed->GetControl(); if(edstc->GetCurrentLine() == wxSCI_INVALID_POSITION) return; long edLine = edstc->GetCurrentLine(); long edPosn = edstc->GetCurrentPos(); long topLine = edstc->GetFirstVisibleLine(); long scnSize = edstc->LinesOnScreen(); long botLine = (topLine+scnSize)-1; // In keeping with top line == 0 origin botLine = (botLine < 0) ? 0 : botLine; botLine = (botLine > edstc->GetLineCount()) ? edstc->GetLineCount() : botLine; #if defined(LOGGING) //LOGIT( _T("JT OnEditorUpdateEvent Filename[%s] line[%ld] pos[%ld] "), edFilename.c_str(), edLine, edPosn); //LOGIT( _T("JT \ttopLine[%ld] botLine[%ld] OnScrn[%ld] "), topLine, botLine, edstc->LinesOnScreen()); #endif // New editor activated? if (m_FilenameLast not_eq edFilename) { m_PosnLast = edPosn; m_FilenameLast = edFilename; //if ( m_Cursor not_eq JumpDataContains(edFilename, edPosn) ) JumpDataAdd(edFilename, edPosn, edLine); } // If new line within half screen of old line, don't record current line long lineLast = edstc->LineFromPosition(m_PosnLast); //bool bIsVis = ( edstc->GetLineVisible(lineLast) ); doesnt work //if ( (lineLast >= topLine) && doesnt work // (lineLast < botLine) ) int halfPageSize = edstc->LinesOnScreen()>>1; if ( halfPageSize > abs(edLine - lineLast)) return; // record new posn m_PosnLast = edPosn; m_FilenameLast = edFilename; //if ( m_Cursor not_eq JumpDataContains(edFilename, edPosn) ) JumpDataAdd(edFilename, edPosn, edLine); return; }//OnEditorUpdateEvent
// ---------------------------------------------------------------------------- void Navigator::OnCursorMove(CodeBlocksEvent& event) // ---------------------------------------------------------------------------- { event.Skip(); cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if(not ed) return; wxString edFilename = ed->GetFilename(); cbStyledTextCtrl* edstc = ed->GetControl(); if(edstc->GetCurrentLine() == wxSCI_INVALID_POSITION) return; long edLine = edstc->GetCurrentLine(); long edPosn = edstc->GetCurrentPos(); JumpDataAdd(edFilename, edPosn, edLine ); }//OnEditorUpdateEvent
// ---------------------------------------------------------------------------- void JumpTracker::OnEditorActivated(CodeBlocksEvent& event) // ---------------------------------------------------------------------------- { // Record this activation event and place activation in history event.Skip(); if (m_bShuttingDown) return; if (not IsAttached()) return; // Don't record closing editor activations if (m_bProjectClosing) return; EditorBase* eb = event.GetEditor(); wxString edFilename = eb->GetFilename(); cbEditor* cbed = Manager::Get()->GetEditorManager()->GetBuiltinEditor(eb); if (not cbed) { // Since wxAuiNotebook added, there's no cbEditor associated during // an initial cbEVT_EDITOR_ACTIVATED event. So we ignore the inital // call and get OnEditorOpened() to re-issue OnEditorActivated() when // it does have a cbEditor, but no cbProject associated; #if defined(LOGGING) LOGIT( _T("JT [OnEditorActivated ignored:no cbEditor[%s]"), edFilename.c_str()); #endif return; } #if defined(LOGGING) LOGIT( _T("JT Editor Activated[%s]"), eb->GetShortName().c_str() ); #endif cbStyledTextCtrl* edstc = cbed->GetControl(); if(edstc->GetCurrentLine() == wxSCI_INVALID_POSITION) return; long edPosn = edstc->GetCurrentPos(); //if ( m_Cursor not_eq JumpDataContains(edFilename, edPosn) ) JumpDataAdd(edFilename, edPosn); return; }//OnEditorActivated