6#ifndef QT_NO_SYNTAXHIGHLIGHTER
7#include <private/qobject_p.h>
9#include <private/qtextdocument_p.h>
40 int from =
cursor.position();
41 cursor.movePosition(operation);
50 q_func()->rehighlight();
62 bool formatsChanged =
false;
68 const int preeditAreaStart =
layout->preeditAreaPosition();
69 const int preeditAreaLength =
layout->preeditAreaText().size();
71 if (preeditAreaLength != 0) {
73 return range.start < preeditAreaStart
74 ||
range.start +
range.length > preeditAreaStart + preeditAreaLength;
76 if (ranges.
removeIf(isOutsidePreeditArea) > 0)
77 formatsChanged =
true;
80 formatsChanged =
true;
100 r.length =
i -
r.start;
102 if (preeditAreaLength != 0) {
103 if (
r.start >= preeditAreaStart)
104 r.start += preeditAreaLength;
105 else if (
r.start +
r.length >= preeditAreaStart)
106 r.length += preeditAreaLength;
110 formatsChanged =
true;
113 if (formatsChanged) {
114 layout->setFormats(ranges);
138 bool forceHighlightOfNextBlock =
false;
140 while (block.
isValid() && (block.
position() < endPosition || forceHighlightOfNextBlock)) {
141 const int stateBeforeHighlight = block.
userState();
145 forceHighlightOfNextBlock = (block.
userState() != stateBeforeHighlight);
147 block = block.
next();
162 q->highlightBlock(block.
text());
296 this,
SLOT(_q_reformatBlocks(
int,
int,
int)));
300 for (
QTextBlock blk =
d->doc->begin(); blk.isValid(); blk = blk.next())
301 blk.layout()->clearFormats();
307 this,
SLOT(_q_reformatBlocks(
int,
int,
int)));
308 if (!
d->doc->isEmpty()) {
309 d->rehighlightPending =
true;
340 d->rehighlightPending =
false;
356 const bool rehighlightPending =
d->rehighlightPending;
361 if (rehighlightPending)
362 d->rehighlightPending = rehighlightPending;
406 if (start < 0 || start >=
d->formatChanges.size())
459 if (pos < 0 || pos >=
d->formatChanges.size())
461 return d->formatChanges.at(
pos);
474 if (!
d->currentBlock.isValid())
477 const QTextBlock previous =
d->currentBlock.previous();
491 if (!
d->currentBlock.isValid())
494 return d->currentBlock.userState();
505 if (!
d->currentBlock.isValid())
548 if (!
d->currentBlock.isValid())
551 d->currentBlock.setUserData(
data);
563 if (!
d->currentBlock.isValid())
566 return d->currentBlock.userData();
577 return d->currentBlock;
582#include "moc_qsyntaxhighlighter.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
qsizetype size() const noexcept
QList< T > & fill(parameter_type t, qsizetype size=-1)
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype removeIf(Predicate pred)
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QVariant property(const char *name) const
Returns the value of the object's name property.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
void reformatBlock(const QTextBlock &block)
void _q_reformatBlocks(int from, int charsRemoved, int charsAdded)
void applyFormatChanges()
void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation)
void reformatBlocks(int from, int charsRemoved, int charsAdded)
QPointer< QTextDocument > doc
void _q_delayedRehighlight()
QList< QTextCharFormat > formatChanges
QSyntaxHighlighterPrivate()
\reentrant \inmodule QtGui
QTextBlock currentBlock() const
void setCurrentBlockState(int newState)
Sets the state of the current text block to newState.
QTextCharFormat format(int pos) const
Returns the format at position inside the syntax highlighter's current text block.
void setCurrentBlockUserData(QTextBlockUserData *data)
Attaches the given data to the current text block.
int previousBlockState() const
Returns the end state of the text block previous to the syntax highlighter's current block.
QTextBlockUserData * currentBlockUserData() const
Returns the QTextBlockUserData object previously attached to the current text block.
QSyntaxHighlighter(QObject *parent)
Constructs a QSyntaxHighlighter with the given parent.
QTextDocument * document() const
Returns the QTextDocument on which this syntax highlighter is installed.
void rehighlightBlock(const QTextBlock &block)
void setDocument(QTextDocument *doc)
Installs the syntax highlighter on the given QTextDocument doc.
void setFormat(int start, int count, const QTextCharFormat &format)
This function is applied to the syntax highlighter's current text block (i.e.
int currentBlockState() const
Returns the state of the current text block.
~QSyntaxHighlighter()
Destructor.
int length() const
Returns the length of the block in characters.
const QTextDocument * document() const
Returns the text document this text block belongs to, or \nullptr if the text block does not belong t...
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents.
int position() const
Returns the index of the block's first character within the document.
QString text() const
Returns the block's contents as plain text.
\reentrant \inmodule QtGui
MoveOperation
\value NoMove Keep the cursor where it is
static const QTextDocumentPrivate * get(const QTextDocument *document)
\reentrant \inmodule QtGui
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
void markContentsDirty(int from, int length)
Marks the contents specified by the given position and length as "dirty", informing the document that...
bool singleShot
whether the timer is a single-shot timer
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
#define Q_ASSERT_X(cond, x, msg)
myObject disconnect()
[26]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent