5#ifndef QTEXTBOUNDARYFINDER_H
6#define QTEXTBOUNDARYFINDER_H
8#include <QtCore/qchar.h>
9#include <QtCore/qstring.h>
11#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
17struct QCharAttributes;
22 QTextBoundaryFinder();
23 QTextBoundaryFinder(
const QTextBoundaryFinder &other);
24 QTextBoundaryFinder(QTextBoundaryFinder &&other)
noexcept
25 : s{std::move(other.s)},
28 attributes{std::exchange(other.attributes,
nullptr)}
31 freeBuffer = other.freeBuffer;
32 QT7_ONLY(reserved = other.reserved;)
34 QTextBoundaryFinder &operator=(
const QTextBoundaryFinder &other);
35 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QTextBoundaryFinder)
36 ~QTextBoundaryFinder();
38 void swap(QTextBoundaryFinder &other)
noexcept
40 std::swap(t, other.t);
42 std::swap(sv, other.sv);
43 std::swap(pos, other.pos);
44 std::swap(freeBuffer, other.freeBuffer);
45 qt_ptr_swap(attributes, other.attributes);
46 QT7_ONLY(reserved.swap(other.reserved);)
49 enum BoundaryType QT7_ONLY(: quint8) {
58 BreakOpportunity = 0x1f,
61 MandatoryBreak = 0x80,
64 Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )
66 QTextBoundaryFinder(BoundaryType type,
const QString &string);
67 QTextBoundaryFinder(BoundaryType type,
const QChar *chars, qsizetype length,
unsigned char *buffer =
nullptr, qsizetype bufferSize = 0)
68 : QTextBoundaryFinder(type, QStringView(chars, length), buffer, bufferSize)
70 QTextBoundaryFinder(BoundaryType type, QStringView str,
unsigned char *buffer =
nullptr, qsizetype bufferSize = 0);
72 inline bool isValid()
const {
return attributes; }
74 inline BoundaryType type()
const {
return t; }
75 QString string()
const;
79 qsizetype position()
const;
80 void setPosition(qsizetype position);
82 qsizetype toNextBoundary();
83 qsizetype toPreviousBoundary();
85 bool isAtBoundary()
const;
86 BoundaryReasons boundaryReasons()
const;
89 QT6_ONLY(BoundaryType t = Grapheme;)
93 QT6_ONLY(uint freeBuffer =
true;)
94 QCharAttributes *attributes =
nullptr;
95#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
96 bool freeBuffer =
true;
97 BoundaryType t = Grapheme;
98 std::array<quint8,
sizeof(
void *) - 2> reserved = {};
104Q_DECLARE_OPERATORS_FOR_FLAGS(QTextBoundaryFinder::BoundaryReasons)
void initWithScriptItem(const QScriptItem &si)
QTextItemInt midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const
const unsigned short * logClusters
QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe, const QTextCharFormat &format=QTextCharFormat())
QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format=QTextCharFormat())
#define QStringLiteral(str)
QTransform qt_true_matrix(qreal w, qreal h, const QTransform &x)
Q_DECLARE_TYPEINFO(QJustificationPoint, Q_PRIMITIVE_TYPE)
@ Justification_Arabic_Alef
@ Justification_Arabic_Waw
@ Justification_Arabic_Kashida
@ Justification_Prohibited
@ Justification_Arabic_BaRa
@ Justification_Character
@ Justification_Arabic_Space
@ Justification_Arabic_HahDal
@ Justification_Arabic_Seen
@ Justification_Arabic_Normal
static bool prevCharJoins(const QString &string, int pos)
static QString stringMidRetainingBidiCC(const QString &string, const QString &ellidePrefix, const QString &ellideSuffix, int subStringFrom, int subStringTo, int midStart, int midLength)
static void applyVisibilityRules(ushort ucs, QGlyphLayout *glyphs, uint glyphPosition, QFontEngine *fontEngine)
static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, QFontEngine *fe)
static bool nextCharJoins(const QString &string, int pos)
static constexpr bool isRetainableControlCode(char16_t c) noexcept
static void releaseCachedFontEngine(QFontEngine *fontEngine)
QList< QScriptItem > QScriptItemArray
QGlyphJustification * justifications
void grow(char *address, int totalGlyphs)
void copy(QGlyphLayout *other)
QGlyphLayout(char *address, int totalGlyphs)
void clear(int first=0, int last=-1)
QGlyphAttributes * attributes
QGlyphLayout mid(int position, int n=-1) const
unsigned short num_glyphs
bool getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const