Code::Blocks  SVN r11506
editorcolourset.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef EDITORCOLORSET_H
7 #define EDITORCOLORSET_H
8 
9 #include <wx/dynarray.h>
10 #include <wx/hashmap.h>
11 #include <wx/intl.h>
12 #include <wx/wxscintilla.h> // wxSCI_KEYWORDSET_MAX
13 #include "settings.h"
14 #include "globals.h" // HighlightLanguage
15 
16 #include <set>
17 
18 // forward decls
19 class cbEditor;
20 class cbStyledTextCtrl;
21 
22 #define COLORSET_DEFAULT _T("default")
23 
24 const int cbHIGHLIGHT_LINE = -98; // highlight line under caret virtual style
25 const int cbSELECTION = -99; // selection virtual style
26 
28 {
30  int value;
33  bool bold;
34  bool italics;
35  bool underlined;
36  bool isStyle;
37 
44 };
45 WX_DEFINE_ARRAY(OptionColour*, OptionColours);
46 
47 struct CommentToken {
57 };
58 
59 struct OptionSet
60 {
62  OptionColours m_Colours;
63  wxString m_Keywords[wxSCI_KEYWORDSET_MAX + 1]; // wxSCI_KEYWORDSET_MAX+1 keyword sets
65  int m_Lexers;
70 
71  wxString m_originalKeywords[wxSCI_KEYWORDSET_MAX + 1]; // wxSCI_KEYWORDSET_MAX+1 keyword sets
73 
76 };
78 
80 {
81  public:
82  EditorColourSet(const wxString& setName = COLORSET_DEFAULT);
83  EditorColourSet(const EditorColourSet& other); // copy ctor
84  ~EditorColourSet();
85 
86  HighlightLanguage AddHighlightLanguage(int lexer, const wxString& name);
87  HighlightLanguage GetHighlightLanguage(int lexer); // from scintilla lexer (wxSCI_LEX_*)
88  HighlightLanguage GetHighlightLanguage(const wxString& name);
89  wxArrayString GetAllHighlightLanguages();
90 
91  void AddOption(HighlightLanguage lang,
92  const wxString& name,
93  int value,
96  bool bold = false,
97  bool italics = false,
98  bool underlined = false,
99  bool isStyle = true);
100  bool AddOption(HighlightLanguage lang, OptionColour* option, bool checkIfExists = true);
101 
102  OptionColour* GetOptionByName(HighlightLanguage lang, const wxString& name);
103  OptionColour* GetOptionByValue(HighlightLanguage lang, int value);
104  OptionColour* GetOptionByIndex(HighlightLanguage lang, int index);
105 
106  void UpdateOptionsWithSameName(HighlightLanguage lang, OptionColour* base);
107  int GetOptionCount(HighlightLanguage lang);
108 
109  HighlightLanguage GetLanguageForFilename(const wxString& filename);
110  wxString GetLanguageName(HighlightLanguage lang);
111  wxString GetName(){ return m_Name; }
112  void SetName(const wxString& name){ m_Name = name; }
113 
114  HighlightLanguage Apply(cbEditor* editor, HighlightLanguage lang, bool colourise);
115  void Apply(HighlightLanguage lang, cbStyledTextCtrl* control, bool isC, bool colourise);
116  void Save();
117  void Reset(HighlightLanguage lang);
118 
119  wxString& GetKeywords(HighlightLanguage lang, int idx);
120  void SetKeywords(HighlightLanguage lang, int idx, const wxString& keywords);
121 
122  const wxArrayString& GetFileMasks(HighlightLanguage lang);
123  void SetFileMasks(HighlightLanguage lang, const wxString& masks, const wxString& = _(","));
124 
125  wxString GetSampleCode(HighlightLanguage lang, int* breakLine, int* debugLine, int* errorLine);
126  void SetSampleCode(HighlightLanguage lang, const wxString& sample, int breakLine, int debugLine, int errorLine);
127 
128  CommentToken GetCommentToken(HighlightLanguage lang);
129  void SetCommentToken(HighlightLanguage lang, CommentToken token);
130 
131  bool GetCaseSensitivity(HighlightLanguage lang);
132  void SetCaseSensitivity(HighlightLanguage lang, bool CaseSensitive);
133  void SetStringLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
134  void SetCommentLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
135  void SetCharacterLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
136  void SetPreprocessorLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
137 
138  private:
139  void DoApplyStyle(cbStyledTextCtrl* control, int value, OptionColour* option);
140  void LoadAvailableSets();
141  void Load();
142  void ClearAllOptionColours();
143 
145 
146 
148  OptionSetsMap m_Sets;
149 
153 };
154 
155 #endif // EDITORCOLORSET_H
156 
OptionSetsMap m_Sets
wxString doxygenLineComment
wxString lineComment
wxColour originalfore
OptionColours m_Colours
#define COLORSET_DEFAULT
WX_DEFINE_ARRAY(OptionColour *, OptionColours)
bool originalunderlined
wxColour wxNullColour
wxString m_PlainTextLexerID
Stores the id of the plain text file lexer (see lexer_plain.xml).
static OptionColour * GetDefaultOption(OptionSet &mset)
wxString GetName()
wxString m_SampleCode
void SetName(const wxString &name)
#define DLLIMPORT
Definition: settings.h:16
wxString streamCommentStart
wxString boxCommentStart
wxString doxygenStreamCommentEnd
wxString boxCommentEnd
const int cbHIGHLIGHT_LINE
const wxString & _(const wxString &string)
#define wxSCI_KEYWORDSET_MAX
Maximum value of keywordSet parameter of SetKeyWords.
Definition: wxscintilla.h:404
wxArrayString m_originalFileMasks
bool m_CaseSensitive
wxString boxCommentMid
A file editor.
Definition: cbeditor.h:43
const int cbSELECTION
wxColour originalback
wxArrayString m_FileMasks
WX_DECLARE_STRING_HASH_MAP(OptionSet, OptionSetsMap)
wxString doxygenStreamCommentStart
CommentToken comment
wxString m_Langs
wxString streamCommentEnd