diff options
author | Liang Qi <liang.qi@qt.io> | 2017-02-16 21:46:20 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-02-16 21:51:11 +0100 |
commit | c577f6edafef7c40a5f78092ec4fcd78bb820b2c (patch) | |
tree | 9ca3819e5cca9b7e61f305a874b682e5a2085e83 /src/gui/text | |
parent | 99ce1d3d97c0423c3ee63ccf58deed964db0770e (diff) | |
parent | de225ccdf95efb57866d62bc80872c1a2ab99703 (diff) |
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
src/corelib/plugin/qlibrary_unix.cpp
src/plugins/platforms/xcb/qxcbconnection.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qcssparser_p.h | 4 | ||||
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.cpp | 39 |
2 files changed, 14 insertions, 29 deletions
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 9f79e9934e..c1594531ea 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -75,6 +75,10 @@ QT_END_NAMESPACE #if defined(Q_OS_INTEGRITY) # undef Value #endif +// Hurd has #define TILDE 0x00080000 from <sys/ioctl.h> +#if defined(TILDE) +# undef TILDE +#endif #define QT_CSS_DECLARE_TYPEINFO(Class, Type) \ } /* namespace QCss */ \ diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index d5541b0df1..8834afc80e 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -243,6 +243,8 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) \snippet code/src_gui_text_qsyntaxhighlighter.cpp 1 + \target QSyntaxHighlighter multiblock + Some syntaxes can have constructs that span several text blocks. For example, a C++ syntax highlighter should be able to cope with \c{/}\c{*...*}\c{/} multiline comments. To deal with @@ -267,12 +269,12 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) \snippet code/src_gui_text_qsyntaxhighlighter.cpp 2 In the example above, we first set the current block state to - 0. Then, if the previous block ended within a comment, we higlight + 0. Then, if the previous block ended within a comment, we highlight from the beginning of the current block (\c {startIndex = 0}). Otherwise, we search for the given start expression. If the specified end expression cannot be found in the text block, we change the current block state by calling setCurrentBlockState(), - and make sure that the rest of the block is higlighted. + and make sure that the rest of the block is highlighted. In addition you can query the current formatting and user data using the format() and currentBlockUserData() functions @@ -411,33 +413,12 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block) setFormat() as often as necessary to apply any font and color changes that you require. For example: - \snippet code/src_gui_text_qsyntaxhighlighter.cpp 3 - - Some syntaxes can have constructs that span several text - blocks. For example, a C++ syntax highlighter should be able to - cope with \c{/}\c{*...*}\c{/} multiline comments. To deal with - these cases it is necessary to know the end state of the previous - text block (e.g. "in comment"). - - Inside your highlightBlock() implementation you can query the end - state of the previous text block using the previousBlockState() - function. After parsing the block you can save the last state - using setCurrentBlockState(). - - The currentBlockState() and previousBlockState() functions return - an int value. If no state is set, the returned value is -1. You - can designate any other value to identify any given state using - the setCurrentBlockState() function. Once the state is set the - QTextBlock keeps that value until it is set set again or until the - corresponding paragraph of text gets deleted. + \snippet code/src_gui_text_qsyntaxhighlighter.cpp 1 - For example, if you're writing a simple C++ syntax highlighter, - you might designate 1 to signify "in comment". For a text block - that ended in the middle of a comment you'd set 1 using - setCurrentBlockState, and for other paragraphs you'd set 0. - In your parsing code if the return value of previousBlockState() - is 1, you would highlight the text as a C++ comment until you - reached the closing \c{*}\c{/}. + See the \l{QSyntaxHighlighter multiblock}{Detailed Description} for + examples of using setCurrentBlockState(), currentBlockState() + and previousBlockState() to handle syntaxes with constructs that + span several text blocks \sa previousBlockState(), setFormat(), setCurrentBlockState() */ @@ -581,7 +562,7 @@ void QSyntaxHighlighter::setCurrentBlockState(int newState) and store their relative position and the actual QChar in a simple class derived from QTextBlockUserData: - \snippet code/src_gui_text_qsyntaxhighlighter.cpp 4 + \snippet code/src_gui_text_qsyntaxhighlighter.cpp 3 During cursor navigation in the associated editor, you can ask the current QTextBlock (retrieved using the QTextCursor::block() |