00001
00002
00003
00004
00005
00006 #ifndef QT4SYNTAXHIGHLIGHTER_H_
00007 #define QT4SYNTAXHIGHLIGHTER_H_
00008
00009 #include <QSyntaxHighlighter>
00010 #include <QTextDocument>
00011 #include <QTextCharFormat>
00012 #include <QMap>
00013
00014 #include "GNUSyntaxHighlighter.h"
00015 #include "Qt4TextFormatter.h"
00016
00017 namespace srchiliteqt {
00018
00020 typedef QMap<QString, Qt4TextFormatter *> Qt4TextFormatterMap;
00021
00023 typedef QMapIterator<QString, Qt4TextFormatter *> Qt4TextFormatterMapIterator;
00024
00038 class Qt4SyntaxHighlighter: public QSyntaxHighlighter,
00039 public GNUSyntaxHighlighter {
00040
00042 QString currentStyleFile;
00043
00044 protected:
00048 void highlightBlock(const QString &text);
00049
00056 void setFormatters(const TextFormatterMap &formatterMap);
00057
00058 public:
00059 Qt4SyntaxHighlighter(QTextDocument *doc = 0);
00060 virtual ~Qt4SyntaxHighlighter();
00061
00069 void init(const QString &langFile, const QString &styleFile =
00070 "default.style");
00071
00079 bool initFromFileName(const QString &fileName);
00080
00096 void formatString(int start, int count, const QTextCharFormat & format) {
00097 setFormat(start, count, format);
00098 }
00099
00109 void setFormattingStyle(const QString &styleFile);
00110
00112 const QString getFormattingStyle() const {
00113 return currentStyleFile;
00114 }
00115
00133 const srchilite::FormatterMap &getFormatterMap() const {
00134 return formatterManager->getFormatterMap();
00135 }
00136
00143 Qt4TextFormatterMap getQt4TextFormatterMap();
00144 };
00145
00146 }
00147
00148 #endif