/*! Returns the reasons for the boundary finder to have chosen the current position as a boundary. */ QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons() const { if (!d) return NotAtBoundary; if (! isAtBoundary()) return NotAtBoundary; if (pos == 0) { if (d->attributes[pos].whiteSpace) return NotAtBoundary; return StartWord; } if (pos == length) { if (d->attributes[length-1].whiteSpace) return NotAtBoundary; return EndWord; } const bool nextIsSpace = d->attributes[pos].whiteSpace; const bool prevIsSpace = d->attributes[pos - 1].whiteSpace; if (prevIsSpace && !nextIsSpace) return StartWord; else if (!prevIsSpace && nextIsSpace) return EndWord; else if (!prevIsSpace && !nextIsSpace) return BoundaryReasons(StartWord | EndWord); else return NotAtBoundary; }
bool Cursor::isLocationEquivalent(bool otherNotLocationEquivalent, CursorType otherType, bool otherIsAtBoundary, Item* otherOwner) { if (otherNotLocationEquivalent || notLocationEquivalent() ) return false; if (otherType != type() || otherType == BoxCursor) return false; if (!otherIsAtBoundary && ! isAtBoundary()) return false; if (owner() == otherOwner) return false; if (!( owner()->isAncestorOf(otherOwner) && allowEquivalentCursorsAcrossBoundaries(owner(), otherOwner)) && !(otherOwner->isAncestorOf(owner()) && allowEquivalentCursorsAcrossBoundaries(otherOwner, owner()) ) ) return false; return true; }
/*! Returns the reasons for the boundary finder to have chosen the current position as a boundary. */ QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons() const { if (!d) return NotAtBoundary; if (! isAtBoundary()) return NotAtBoundary; if (pos == 0) { if (d->attributes[pos].whiteSpace) return NotAtBoundary; return StartWord; } if (pos >= length - 1) { if (d->attributes[length-1].whiteSpace) return NotAtBoundary; return EndWord; } BoundaryReasons answer; const bool nextIsSpace = d->attributes[pos + 1].whiteSpace; const bool prevIsSpace = d->attributes[pos - 1].whiteSpace; if (d->attributes[pos].whiteSpace) answer = EndWord; else if (!prevIsSpace) { answer = StartWord; answer |= EndWord; } if (prevIsSpace) answer |= StartWord; if (nextIsSpace) answer |= EndWord; if (answer == 0) { answer = StartWord; answer |= EndWord; } return answer; }