{
QTextBlock it = blocksFind(position);
int start = it.position();
- return it.layout()->leftCursorPosition(position-start) + start;
+ return it.layout()->previousCursorPosition(position-start) + start;
}
int QTextDocumentPrivate::rightCursorPosition(int position) const
{
QTextBlock it = blocksFind(position);
int start = it.position();
- return it.layout()->rightCursorPosition(position-start) + start;
+ return it.layout()->nextCursorPosition(position-start) + start;
}
void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format)
return si->position + end;
}
-int QTextEngine::previousLogicalPosition(int oldPos) const
-{
- const HB_CharAttributes *attrs = attributes();
- if (!attrs || oldPos < 0)
- return oldPos;
-
- if (oldPos <= 0)
- return 0;
- oldPos--;
- while (oldPos && !attrs[oldPos].charStop)
- oldPos--;
- return oldPos;
-}
-
-int QTextEngine::nextLogicalPosition(int oldPos) const
-{
- const HB_CharAttributes *attrs = attributes();
- int len = block.isValid() ? block.length() - 1
- : layoutData->string.length();
- Q_ASSERT(len <= layoutData->string.length());
- if (!attrs || oldPos < 0 || oldPos >= len)
- return oldPos;
-
- oldPos++;
- while (oldPos < len && !attrs[oldPos].charStop)
- oldPos++;
- return oldPos;
-}
-
int QTextEngine::lineNumberForTextPosition(int pos)
{
if (!layoutData)
return -1;
}
-int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation op)
-{
- if (!layoutData)
- itemize();
-
- bool moveRight = (op == QTextCursor::Right);
-
- return (moveRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos));
-}
-
QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format)
: justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),
num_chars(0), chars(0), logClusters(0), f(0), fontEngine(0)
QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos);
int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos, bool cursorOnCharacter);
- int previousLogicalPosition(int oldPos) const;
- int nextLogicalPosition(int oldPos) const;
int lineNumberForTextPosition(int pos);
- int positionAfterVisualMovement(int oldPos, QTextCursor::MoveOperation op);
private:
void setBoundary(int strPos) const;
return oldPos;
}
-/*!
- \since 4.8
-
- Returns the cursor position to the right of \a oldPos, next to it.
- The position is dependent on the visual position of characters, after
- bi-directional reordering.
-
- \sa leftCursorPosition(), nextCursorPosition()
-*/
-int QTextLayout::rightCursorPosition(int oldPos) const
-{
- int newPos = d->positionAfterVisualMovement(oldPos, QTextCursor::Right);
-// qDebug("%d -> %d", oldPos, newPos);
- return newPos;
-}
-
-/*!
- \since 4.8
-
- Returns the cursor position to the left of \a oldPos, next to it.
- The position is dependent on the visual position of characters, after
- bi-directional reordering.
-
- \sa rightCursorPosition(), previousCursorPosition()
-*/
-int QTextLayout::leftCursorPosition(int oldPos) const
-{
- int newPos = d->positionAfterVisualMovement(oldPos, QTextCursor::Left);
-// qDebug("%d -> %d", oldPos, newPos);
- return newPos;
-}
-
/*!/
Returns true if position \a pos is a valid cursor position.
bool isValidCursorPosition(int pos) const;
int nextCursorPosition(int oldPos, CursorMode mode = SkipCharacters) const;
int previousCursorPosition(int oldPos, CursorMode mode = SkipCharacters) const;
- int leftCursorPosition(int oldPos) const;
- int rightCursorPosition(int oldPos) const;
void draw(QPainter *p, const QPointF &pos, const QVector<FormatRange> &selections = QVector<FormatRange>(),
const QRectF &clip = QRectF()) const;
int c = m_cursor;
if (steps > 0) {
while (steps--)
- c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c)
- : m_textLayout.nextCursorPosition(c);
+ c = m_textLayout.nextCursorPosition(c);
} else if (steps < 0) {
while (steps++)
- c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c)
- : m_textLayout.previousCursorPosition(c);
+ c = m_textLayout.previousCursorPosition(c);
}
moveCursor(c, mark);
}