Example #1
0
static bool finderWordAt(QTextBoundaryFinder &finder,
                         int at,
                         QString &word, int &bufferStart)
{
    int oldPosition = finder.position();

    finder.setPosition(at);
    if (!finder.isAtBoundary() || (finder.boundaryReasons() & QTextBoundaryFinder::EndWord)) {
        if (finder.toPreviousBoundary() <= 0) {
            /* QTextBoundaryIterator doesn't consider start of the string
             * a boundary so we need to rewind to the beginning to catch
             * the first word */
            if (at > 0 && finder.string().length() > 0) {
                finder.toStart();
            } else
                return false;
        }
    }
    bool ret = finderNextWord(finder, word, bufferStart);
    finder.setPosition(oldPosition);
    return ret;
}