00001 /* 00002 * GNUSyntaxHighlighter.h 00003 * 00004 * Created on: Dec 3, 2008 00005 * Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2008 00006 * Copyright: See COPYING file that comes with this distribution 00007 */ 00008 00009 #ifndef GNUSYNTAXHIGHLIGHTER_H_ 00010 #define GNUSYNTAXHIGHLIGHTER_H_ 00011 00012 #include <srchilite/highlightstate.h> 00013 #include <srchilite/formattermanager.h> 00014 #include <srchilite/sourcehighlighter.h> 00015 #include <srchilite/formatterparams.h> 00016 #include <srchilite/langdefmanager.h> 00017 #include <srchilite/langmap.h> 00018 00019 #include "TextFormatterFactory.h" 00020 #include "HighlightStateData.h" 00021 00022 namespace srchiliteqt { 00023 00029 class GNUSyntaxHighlighter { 00031 QString langFile; 00032 00034 srchilite::SourceHighlighter *sourceHighlighter; 00035 00040 srchilite::FormatterParams formatterParams; 00041 00043 QString foregroundColor; 00044 00046 QString backgroundColor; 00047 00049 bool readOnly; 00050 00052 bool defaultToMonospace; 00053 00054 protected: 00058 srchilite::FormatterManager *formatterManager; 00059 00060 public: 00061 GNUSyntaxHighlighter(); 00062 virtual ~GNUSyntaxHighlighter(); 00063 00064 const QString &getLangFile() const { return langFile; } 00065 00073 srchilite::HighlightStatePtr getHighlightState(const QString &file); 00074 00081 void initHighlighter(const QString &file); 00082 00091 const QString getLangDefFileFromFileName(const QString &filename); 00092 00096 srchilite::SourceHighlighter *getHighlighter() const { 00097 return sourceHighlighter; 00098 } 00099 00113 const TextFormatterMap &getTextFormatterMap( 00114 TextFormatterFactory &formatterFactory, 00115 const QString &styleFile = "default.style"); 00116 00120 srchilite::FormatterManager *getFormatterManager() const { 00121 return formatterManager; 00122 } 00123 00142 void highlightLine(const QString &line, HighlightStateData *&stateData); 00143 00147 srchilite::LangDefManager *getLangDefManager() const; 00148 00152 srchilite::LangMap *getLangMap() const; 00153 00157 srchilite::LangMap *getOutLangMap() const; 00158 00162 const QString &getForegroundColor() const { 00163 return foregroundColor; 00164 } 00165 00169 const QString &getBackgroundColor() const { 00170 return backgroundColor; 00171 } 00172 00173 void setForegroundColor(const QString &f) { 00174 foregroundColor = f; 00175 } 00176 00177 void setBackgroundColor(const QString &b) { 00178 backgroundColor = b; 00179 } 00180 00184 bool isReadOnly() const { 00185 return readOnly; 00186 } 00187 00195 void setReadOnly(bool r) { 00196 readOnly = r; 00197 } 00198 00199 bool isDefaultToMonosapce() const { 00200 return defaultToMonospace; 00201 } 00202 00209 void setDefaultToMonosapce(bool d) { 00210 defaultToMonospace = d; 00211 } 00212 }; 00213 00214 } 00215 00216 #endif /* GNUSYNTAXHIGHLIGHTER_H_ */