Source-highlight Qt Library
|
00001 /* 00002 * Copyright (C) 2008-2010 Lorenzo Bettini, http://www.lorenzobettini.it 00003 * License: See COPYING file that comes with this distribution 00004 */ 00005 00006 #ifndef QT3SYNTAXHIGHLIGHTER_H_ 00007 #define QT3SYNTAXHIGHLIGHTER_H_ 00008 00009 #include <qsyntaxhighlighter.h> 00010 #include <qtextedit.h> 00011 #include <qfont.h> 00012 #include <qcolor.h> 00013 00014 #include "GNUSyntaxHighlighter.h" 00015 #include "ParagraphMap.h" 00016 00017 namespace srchiliteqt { 00018 00032 class Qt3SyntaxHighlighter: public QSyntaxHighlighter, 00033 public GNUSyntaxHighlighter { 00034 protected: 00036 ParagraphMap paragraphMap; 00037 00038 int highlightParagraph(const QString & text, int endStateOfLastPara); 00039 00040 public: 00041 Qt3SyntaxHighlighter(QTextEdit *parent = 0); 00042 virtual ~Qt3SyntaxHighlighter(); 00043 00048 void init(const std::string &langFile); 00049 00065 void formatString(int start, int count, const QFont &font, 00066 const QColor &color) { 00067 setFormat(start, count, font, color); 00068 } 00069 00070 void formatString(int start, int count, const QFont &font) { 00071 setFormat(start, count, font); 00072 } 00073 00074 }; 00075 00076 } 00077 00078 #endif /* QT3SYNTAXHIGHLIGHTER_H_ */