void QuickFindBar::DoMarkAll(bool useIndicators) { if(!m_sci) return; LEditor* editor = dynamic_cast<LEditor*>(m_sci); if(!editor) return; wxString findWhat = m_findWhat->GetValue(); if(findWhat.IsEmpty()) { return; } // Save the caret position long savedPos = m_sci->GetCurrentPos(); size_t flags = DoGetSearchFlags(); int pos(0); int match_len(0); // remove reverse search flags &= ~wxSD_SEARCH_BACKWARD; int offset(0); wchar_t* pinput = DoGetSearchStringPtr(); if(!pinput) return; int fixed_offset(0); // Clear markers editor->DelAllMarkers(smt_find_bookmark); // set the active indicator to be 1 editor->SetIndicatorCurrent(1); size_t count(0); int firstMatchPos(wxNOT_FOUND); while(StringFindReplacer::Search(pinput, offset, findWhat.wc_str(), flags, pos, match_len)) { int matchStart = fixed_offset + pos; int matchEnd = matchStart + match_len; if(useIndicators) { editor->MarkerAdd(editor->LineFromPosition(fixed_offset + pos), smt_find_bookmark); // add indicator as well editor->IndicatorFillRange(fixed_offset + pos, match_len); } else { // Use multiple selections if(count) { // we already have the main selection, add secondary selections editor->AddSelection(matchStart, matchEnd); } else { // clear and set the first selection editor->ClearSelections(); editor->SetSelection(matchStart, matchEnd); firstMatchPos = matchStart; } } ++count; offset = pos + match_len; } // Restore the caret if(useIndicators) { editor->SetCurrentPos(savedPos); editor->EnsureCaretVisible(); } if(firstMatchPos != wxNOT_FOUND) { editor->SetMainSelection(0); editor->SetLineVisible(editor->LineFromPos(firstMatchPos)); } if(!useIndicators) { // Hide the bar Show(false); } }