countMatchingLines method

int countMatchingLines(
  1. int ixLine,
  2. int step,
  3. int ixStop
)

Count the matching lines of the instance. ixLine is the index of the first line to inspect. step: +1 or -1: signals forward or backward searching. ixStop is the the first "forbidden" index: reaching this index the search stops. Returns the number of lines belonging to the sequence.

Implementation

int countMatchingLines(int ixLine, int step, int ixStop) {
  var rc = 0;
  switch (entryType) {
    case BlockEntryType.line:
      rc = 1;
      break;
    case BlockEntryType.sequence:
    case BlockEntryType.notSequence:
      rc = 1;
      while ((ixLine += step) != ixStop) {
        if (!match(searcher.searchEngine.lineByIndex(ixLine),
            searcher.searchEngine.startColumnByIndex(ixLine))) {
          break;
        }
        rc++;
      }
      break;
    case BlockEntryType.startEndSequence:
      if (step > 0) {
        rc = handleStartEndSequenceForward(ixLine, ixStop);
      } else {
        rc = handleStartEndSequenceBackward(ixLine, ixStop);
      }
      break;
  }
  return rc;
}