src/Edit.c
void EditMarkAll(char* pszFind, int sFlags, DocPos rangeStart, DocPos rangeEnd)
{
  char txtBuffer[FNDRPL_BUFFER] = { '\0' };
  char* pszText = (pszFind != NULL) ? pszFind : txtBuffer;

  DocPos iFindLength = 0;

  if (StrIsEmptyA(pszText))
  {
    if (SciCall_IsSelectionEmpty()) {
      // nothing selected, get word under caret if flagged
      if (Settings.MarkOccurrencesCurrentWord && (sFlags & SCFIND_WHOLEWORD))
      {
        DocPos const iCurPos = SciCall_GetCurrentPos();
        DocPos iWordStart = SciCall_WordStartPosition(iCurPos, true);
        DocPos iWordEnd = SciCall_WordEndPosition(iCurPos, true);
        if (iWordStart == iWordEnd) { return; }
        iFindLength = (iWordEnd - iWordStart);
        StringCchCopyNA(txtBuffer, COUNTOF(txtBuffer), SciCall_GetRangePointer(iWordStart, iFindLength), iFindLength);
      }
      else {
        return; // no pattern, no selection and no word mark chosen
      }
    }
    else // we have a selection
    {
      if (Sci_IsMultiSelection()) { return; }

      // get current selection
      DocPos const iSelStart = SciCall_GetSelectionStart();
      DocPos const iSelEnd = SciCall_GetSelectionEnd();
      DocPos const iSelCount = (iSelEnd - iSelStart);

      // if multiple lines are selected exit
      if ((SciCall_LineFromPosition(iSelStart) != SciCall_LineFromPosition(iSelEnd)) || (iSelCount >= COUNTOF(txtBuffer))) {
        return;
      }

      iFindLength = SciCall_GetSelText(pszText) - 1;

      // exit if selection is not a word and Match whole words only is enabled
      if (sFlags & SCFIND_WHOLEWORD) {
        DocPos iSelStart2 = 0;
        const char* delims = (Settings.AccelWordNavigation ? DelimCharsAccel : DelimChars);
        while ((iSelStart2 <= iSelCount) && pszText[iSelStart2]) {
          if (StrChrIA(delims, pszText[iSelStart2])) {
            return;
          }
          ++iSelStart2;
        }
      }
    }
  }
  else {
    iFindLength = (DocPos)StringCchLenA(pszFind, FNDRPL_BUFFER);
  }

  if (iFindLength > 0) {

    DocPos const iTextEnd = Sci_GetDocEndPosition();
    rangeStart = max_p(0, rangeStart);
    rangeEnd = min_p(rangeEnd, iTextEnd);

    DocPos start = rangeStart;
    DocPos end = rangeEnd;

    DocPos iPos = (DocPos)-1;
    do {

      iPos = _FindInTarget(pszText, iFindLength, sFlags, &start, &end, (start == iPos), FRMOD_IGNORE);

      if (iPos < 0) {
        break; // not found
      }
      // mark this match if not done before
      SciCall_SetIndicatorCurrent(INDIC_NP3_MARK_OCCURANCE);
      SciCall_IndicatorFillRange(iPos, (end - start));
      SciCall_SetIndicatorCurrent(INDIC_NP3_FOCUS_VIEW);
      SciCall_IndicatorFillRange(Sci_GetLineStartPosition(iPos), 1);

      start = end;
      end = rangeEnd;

    } while ((++Globals.iMarkOccurrencesCount < (DocPos)Settings2.MarkOccurrencesMaxCount) && (start < end));
  }
}
//=============================================================================
//
//  EditMarkAll()
//  Mark all occurrences of the matching text in range (by Aleksandar Lekov)
//

EditMarkAll()
Mark all occurrences of the matching text in range (by Aleksandar Lekov)
EditMarkAll () Mark all occurrences of the matching text in range ( by Aleksandar Lekov )
void EditMarkAll(char* pszFind, int sFlags, DocPos rangeStart, DocPos rangeEnd)
{
  char txtBuffer[FNDRPL_BUFFER] = { '\0' };
  char* pszText = (pszFind != NULL) ? pszFind : txtBuffer;
  DocPos iFindLength = 0;
  if (StrIsEmptyA(pszText))
  {
    if (SciCall_IsSelectionEmpty()) {
      if (Settings.MarkOccurrencesCurrentWord && (sFlags & SCFIND_WHOLEWORD))
      {
        DocPos const iCurPos = SciCall_GetCurrentPos();
        DocPos iWordStart = SciCall_WordStartPosition(iCurPos, true);
        DocPos iWordEnd = SciCall_WordEndPosition(iCurPos, true);
        if (iWordStart == iWordEnd) { return; }
        iFindLength = (iWordEnd - iWordStart);
        StringCchCopyNA(txtBuffer, COUNTOF(txtBuffer), SciCall_GetRangePointer(iWordStart, iFindLength), iFindLength);
      }
      else {
        return; 
      }
    }
    else 
    {
      if (Sci_IsMultiSelection()) { return; }
      DocPos const iSelStart = SciCall_GetSelectionStart();
      DocPos const iSelEnd = SciCall_GetSelectionEnd();
      DocPos const iSelCount = (iSelEnd - iSelStart);
      if ((SciCall_LineFromPosition(iSelStart) != SciCall_LineFromPosition(iSelEnd)) || (iSelCount >= COUNTOF(txtBuffer))) {
        return;
      }
      iFindLength = SciCall_GetSelText(pszText) - 1;
      if (sFlags & SCFIND_WHOLEWORD) {
        DocPos iSelStart2 = 0;
        const char* delims = (Settings.AccelWordNavigation ? DelimCharsAccel : DelimChars);
        while ((iSelStart2 <= iSelCount) && pszText[iSelStart2]) {
          if (StrChrIA(delims, pszText[iSelStart2])) {
            return;
          }
          ++iSelStart2;
        }
      }
    }
  }
  else {
    iFindLength = (DocPos)StringCchLenA(pszFind, FNDRPL_BUFFER);
  }
  if (iFindLength > 0) {
    DocPos const iTextEnd = Sci_GetDocEndPosition();
    rangeStart = max_p(0, rangeStart);
    rangeEnd = min_p(rangeEnd, iTextEnd);
    DocPos start = rangeStart;
    DocPos end = rangeEnd;
    DocPos iPos = (DocPos)-1;
    do {
      iPos = _FindInTarget(pszText, iFindLength, sFlags, &start, &end, (start == iPos), FRMOD_IGNORE);
      if (iPos < 0) {
        break; 
      }
      SciCall_SetIndicatorCurrent(INDIC_NP3_MARK_OCCURANCE);
      SciCall_IndicatorFillRange(iPos, (end - start));
      SciCall_SetIndicatorCurrent(INDIC_NP3_FOCUS_VIEW);
      SciCall_IndicatorFillRange(Sci_GetLineStartPosition(iPos), 1);
      start = end;
      end = rangeEnd;
    } while ((++Globals.iMarkOccurrencesCount < (DocPos)Settings2.MarkOccurrencesMaxCount) && (start < end));
  }
}
void EditMarkAll ( char * pszFind , int sFlags , DocPos rangeStart , DocPos rangeEnd ) { char txtBuffer [ FNDRPL_BUFFER ] = { ' \0 ' } ; char * pszText = ( pszFind != NULL ) ? pszFind : txtBuffer ; DocPos iFindLength = 0 ; if ( StrIsEmptyA ( pszText ) ) { if ( SciCall_IsSelectionEmpty ( ) ) { if ( Settings . MarkOccurrencesCurrentWord && ( sFlags & SCFIND_WHOLEWORD ) ) { DocPos const iCurPos = SciCall_GetCurrentPos ( ) ; DocPos iWordStart = SciCall_WordStartPosition ( iCurPos , true ) ; DocPos iWordEnd = SciCall_WordEndPosition ( iCurPos , true ) ; if ( iWordStart == iWordEnd ) { return ; } iFindLength = ( iWordEnd - iWordStart ) ; StringCchCopyNA ( txtBuffer , COUNTOF ( txtBuffer ) , SciCall_GetRangePointer ( iWordStart , iFindLength ) , iFindLength ) ; } else { return ; } } else { if ( Sci_IsMultiSelection ( ) ) { return ; } DocPos const iSelStart = SciCall_GetSelectionStart ( ) ; DocPos const iSelEnd = SciCall_GetSelectionEnd ( ) ; DocPos const iSelCount = ( iSelEnd - iSelStart ) ; if ( ( SciCall_LineFromPosition ( iSelStart ) != SciCall_LineFromPosition ( iSelEnd ) ) || ( iSelCount >= COUNTOF ( txtBuffer ) ) ) { return ; } iFindLength = SciCall_GetSelText ( pszText ) - 1 ; if ( sFlags & SCFIND_WHOLEWORD ) { DocPos iSelStart2 = 0 ; const char * delims = ( Settings . AccelWordNavigation ? DelimCharsAccel : DelimChars ) ; while ( ( iSelStart2 <= iSelCount ) && pszText [ iSelStart2 ] ) { if ( StrChrIA ( delims , pszText [ iSelStart2 ] ) ) { return ; } ++ iSelStart2 ; } } } } else { iFindLength = ( DocPos ) StringCchLenA ( pszFind , FNDRPL_BUFFER ) ; } if ( iFindLength > 0 ) { DocPos const iTextEnd = Sci_GetDocEndPosition ( ) ; rangeStart = max_p ( 0 , rangeStart ) ; rangeEnd = min_p ( rangeEnd , iTextEnd ) ; DocPos start = rangeStart ; DocPos end = rangeEnd ; DocPos iPos = ( DocPos ) - 1 ; do { iPos = _FindInTarget ( pszText , iFindLength , sFlags , & start , & end , ( start == iPos ) , FRMOD_IGNORE ) ; if ( iPos < 0 ) { break ; } SciCall_SetIndicatorCurrent ( INDIC_NP3_MARK_OCCURANCE ) ; SciCall_IndicatorFillRange ( iPos , ( end - start ) ) ; SciCall_SetIndicatorCurrent ( INDIC_NP3_FOCUS_VIEW ) ; SciCall_IndicatorFillRange ( Sci_GetLineStartPosition ( iPos ) , 1 ) ; start = end ; end = rangeEnd ; } while ( ( ++ Globals . iMarkOccurrencesCount < ( DocPos ) Settings2 . MarkOccurrencesMaxCount ) && ( start < end ) ) ; } }
EditMarkAll()
Mark all occurrences of the matching text in range (by Aleksandar Lekov)
EditMarkAll () Mark all occurrences of the matching text in range ( by Aleksandar Lekov )
// nothing selected, get word under caret if flagged
 // no pattern, no selection and no word mark chosen
 // we have a selection
 // get current selection
 // if multiple lines are selected exit
 // exit if selection is not a word and Match whole words only is enabled
 // not found
 // mark this match if not done before
