private boolean isOffsetInSelection(int offset) {
      for (int i = 0; i < caretCount; ++i) {
        if (offset >= selectionStarts[i] && offset < selectionEnds[i]) return true;
      }
      return false;
    }
private boolean isOffsetInSelection(int offset)