1 /*************************************************************************** 2 * copyright : (C) 2003-2017 by Pascal Brachet * 3 * http://www.xm1math.net/texmaker/ * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 ***************************************************************************/ 11 12 13 #ifndef LATEXHIGHLIGHTER_H 14 #define LATEXHIGHLIGHTER_H 15 16 17 #include <QSyntaxHighlighter> 18 #include <QHash> 19 #include <QTextCharFormat> 20 #include <QColor> 21 #include <QTextBlockUserData> 22 //#include "latexeditor.h" 23 #include "hunspell/hunspell.hxx" 24 25 class QTextDocument; 26 class LatexEditor; 27 28 class LatexHighlighter : public QSyntaxHighlighter 29 { 30 Q_OBJECT 31 32 public: 33 LatexHighlighter(QTextDocument *parent = 0,bool spelling=false, QString ignoredWords="",Hunspell *spellChecker=0); 34 ~LatexHighlighter(); 35 QColor ColorStandard, ColorComment, ColorMath, ColorCommand, ColorKeyword, ColorVerbatim, ColorTodo, ColorKeywordGraphic, ColorNumberGraphic; 36 QStringList KeyWords, KeyWordsGraphic, KeyWordsGraphicBis; 37 QTextCharFormat spellingErrorFormat; 38 QStringList alwaysignoredwordList; 39 public slots: 40 void SetAlwaysIgnoredWords(QString ignoredWords); 41 void setColors(QList<QColor> colors); 42 void setSpellChecker(Hunspell * checker); 43 void activateInlineSpell(bool enable); 44 void SetEditor(LatexEditor *ed); 45 void setModeGraphic(bool m); 46 private : 47 QString spell_dic, spell_encoding; 48 QStringList ignoredwordList, hardignoredwordList; 49 Hunspell * pChecker; 50 bool checkSpelling; 51 bool isWordSeparator(QChar c) const; 52 bool isSpace(QChar c) const; 53 bool isGraphic; 54 protected: 55 LatexEditor *editor; 56 void highlightBlock(const QString &text); 57 }; 58 59 60 #endif 61