source: trunk/src/widgets/qsyntaxhighlighter_p.h@ 81

Last change on this file since 81 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1/****************************************************************************
2** $Id: qsyntaxhighlighter_p.h 2 2005-11-16 15:49:26Z dmik $
3**
4** Definition of the internal QSyntaxHighlighterInternal class
5**
6** Created : 031111
7**
8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9**
10** This file is part of the widgets module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QSYNTAXHIGHLIGHTER_P_H
39#define QSYNTAXHIGHLIGHTER_P_H
40
41#ifndef QT_NO_SYNTAXHIGHLIGHTER
42#include "qsyntaxhighlighter.h"
43#include "private/qrichtext_p.h"
44
45class QSyntaxHighlighterPrivate
46{
47public:
48 QSyntaxHighlighterPrivate() :
49 currentParagraph( -1 )
50 {}
51
52 int currentParagraph;
53};
54
55class QSyntaxHighlighterInternal : public QTextPreProcessor
56{
57public:
58 QSyntaxHighlighterInternal( QSyntaxHighlighter *h ) : highlighter( h ) {}
59 void process( QTextDocument *doc, QTextParagraph *p, int, bool invalidate ) {
60 if ( p->prev() && p->prev()->endState() == -1 )
61 process( doc, p->prev(), 0, FALSE );
62
63 highlighter->para = p;
64 QString text = p->string()->toString();
65 int endState = p->prev() ? p->prev()->endState() : -2;
66 int oldEndState = p->endState();
67 highlighter->d->currentParagraph = p->paragId();
68 p->setEndState( highlighter->highlightParagraph( text, endState ) );
69 highlighter->d->currentParagraph = -1;
70 highlighter->para = 0;
71
72 p->setFirstPreProcess( FALSE );
73 QTextParagraph *op = p;
74 p = p->next();
75 if ( (!!oldEndState || !!op->endState()) && oldEndState != op->endState() &&
76 invalidate && p && !p->firstPreProcess() && p->endState() != -1 ) {
77 while ( p ) {
78 if ( p->endState() == -1 )
79 return;
80 p->setEndState( -1 );
81 p = p->next();
82 }
83 }
84 }
85 QTextFormat *format( int ) { return 0; }
86
87private:
88 QSyntaxHighlighter *highlighter;
89
90 friend class QTextEdit;
91};
92
93#endif // QT_NO_SYNTAXHIGHLIGHTER
94#endif // QSYNTAXHIGHLIGHTER_P_H
Note: See TracBrowser for help on using the repository browser.