1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.syntaxhighlighter; 15 extern(C++): 16 17 import qt.config; 18 import qt.helpers; 19 static if(!defined!"QT_NO_SYNTAXHIGHLIGHTER") 20 { 21 import qt.core.object; 22 import qt.core.string; 23 import qt.gui.color; 24 import qt.gui.font; 25 import qt.gui.textdocument; 26 import qt.gui.textformat; 27 import qt.gui.textobject; 28 } 29 30 static if(!defined!"QT_NO_SYNTAXHIGHLIGHTER") 31 { 32 33 34 35 /+ class QTextDocument; +/ 36 extern(C++, class) struct QSyntaxHighlighterPrivate; 37 /+ class QTextCharFormat; 38 class QFont; 39 class QColor; 40 class QTextBlockUserData; +/ 41 42 class /+ Q_GUI_EXPORT +/ QSyntaxHighlighter : QObject 43 { 44 mixin(Q_OBJECT); 45 /+ Q_DECLARE_PRIVATE(QSyntaxHighlighter) +/ 46 public: 47 /+ explicit +/this(QObject parent); 48 /+ explicit +/this(QTextDocument parent); 49 ~this(); 50 51 final void setDocument(QTextDocument doc); 52 final QTextDocument document() const; 53 54 public /+ Q_SLOTS +/: 55 @QSlot final void rehighlight(); 56 @QSlot final void rehighlightBlock(ref const(QTextBlock) block); 57 58 protected: 59 /+ virtual +/ abstract void highlightBlock(ref const(QString) text); 60 61 final void setFormat(int start, int count, ref const(QTextCharFormat) format); 62 final void setFormat(int start, int count, ref const(QColor) color); 63 final void setFormat(int start, int count, ref const(QFont) font); 64 final QTextCharFormat format(int pos) const; 65 66 final int previousBlockState() const; 67 final int currentBlockState() const; 68 final void setCurrentBlockState(int newState); 69 70 final void setCurrentBlockUserData(QTextBlockUserData data); 71 final QTextBlockUserData currentBlockUserData() const; 72 73 final QTextBlock currentBlock() const; 74 75 private: 76 /+ Q_DISABLE_COPY(QSyntaxHighlighter) +/ 77 /+ Q_PRIVATE_SLOT(d_func(), void _q_reformatBlocks(int from, int charsRemoved, int charsAdded)) 78 Q_PRIVATE_SLOT(d_func(), void _q_delayedRehighlight()) +/ 79 } 80 81 82 } 83