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 const QString &getForegroundColor() const { 00158 return foregroundColor; 00159 } 00160 00164 const QString &getBackgroundColor() const { 00165 return backgroundColor; 00166 } 00167 00168 void setForegroundColor(const QString &f) { 00169 foregroundColor = f; 00170 } 00171 00172 void setBackgroundColor(const QString &b) { 00173 backgroundColor = b; 00174 } 00175 00179 bool isReadOnly() const { 00180 return readOnly; 00181 } 00182 00190 void setReadOnly(bool r) { 00191 readOnly = r; 00192 } 00193 00194 bool isDefaultToMonosapce() const { 00195 return defaultToMonospace; 00196 } 00197 00204 void setDefaultToMonosapce(bool d) { 00205 defaultToMonospace = d; 00206 } 00207 }; 00208 00209 } 00210 00211 #endif /* GNUSYNTAXHIGHLIGHTER_H_ */