Source-highlight Qt Library
GNUSyntaxHighlighter.h
1 /*
2  * Copyright (C) 2008-2010 Lorenzo Bettini, http://www.lorenzobettini.it
3  * License: See COPYING file that comes with this distribution
4  */
5 
6 #ifndef GNUSYNTAXHIGHLIGHTER_H_
7 #define GNUSYNTAXHIGHLIGHTER_H_
8 
9 #include <srchilite/highlightstate.h>
10 #include <srchilite/formattermanager.h>
11 #include <srchilite/sourcehighlighter.h>
12 #include <srchilite/formatterparams.h>
13 #include <srchilite/langdefmanager.h>
14 #include <srchilite/langmap.h>
15 
16 #include "TextFormatterFactory.h"
17 #include "HighlightStateData.h"
18 
19 namespace srchiliteqt {
20 
28  QString langFile;
29 
31  srchilite::SourceHighlighter *sourceHighlighter;
32 
37  srchilite::FormatterParams formatterParams;
38 
40  QString foregroundColor;
41 
43  QString backgroundColor;
44 
46  bool readOnly;
47 
50 
51 protected:
55  srchilite::FormatterManager *formatterManager;
56 
57 public:
59  virtual ~GNUSyntaxHighlighter();
60 
61  const QString &getLangFile() const { return langFile; }
62 
70  srchilite::HighlightStatePtr getHighlightState(const QString &file);
71 
78  void initHighlighter(const QString &file);
79 
88  const QString getLangDefFileFromFileName(const QString &filename);
89 
93  srchilite::SourceHighlighter *getHighlighter() const {
94  return sourceHighlighter;
95  }
96 
110  const TextFormatterMap &getTextFormatterMap(
111  TextFormatterFactory &formatterFactory,
112  const QString &styleFile = "default.style");
113 
117  srchilite::FormatterManager *getFormatterManager() const {
118  return formatterManager;
119  }
120 
139  void highlightLine(const QString &line, HighlightStateData *&stateData);
140 
144  srchilite::LangDefManager *getLangDefManager() const;
145 
149  srchilite::LangMap *getLangMap() const;
150 
154  srchilite::LangMap *getOutLangMap() const;
155 
159  const QString &getForegroundColor() const {
160  return foregroundColor;
161  }
162 
166  const QString &getBackgroundColor() const {
167  return backgroundColor;
168  }
169 
170  void setForegroundColor(const QString &f) {
171  foregroundColor = f;
172  }
173 
174  void setBackgroundColor(const QString &b) {
175  backgroundColor = b;
176  }
177 
181  bool isReadOnly() const {
182  return readOnly;
183  }
184 
192  void setReadOnly(bool r) {
193  readOnly = r;
194  }
195 
196  bool isDefaultToMonospace() const {
197  return defaultToMonospace;
198  }
199 
206  void setDefaultToMonospace(bool d) {
207  defaultToMonospace = d;
208  }
209 };
210 
211 }
212 
213 #endif /* GNUSYNTAXHIGHLIGHTER_H_ */