Menu

[r7]: / Plugin / optionsconfig.cpp  Maximize  Restore  History

Download this file

185 lines (166 with data), 8.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : optionsconfig.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#include "optionsconfig.h"
#include <wx/fontmap.h>
#include "xmlutils.h"
#include "macros.h"
OptionsConfig::OptionsConfig(wxXmlNode *node)
: m_displayFoldMargin(true)
, m_underlineFoldLine(false)
, m_foldStyle(wxT("Arrows with Background Colour"))
, m_displayBookmarkMargin(true)
, m_bookmarkShape(wxT("Small Arrow"))
, m_bookmarkBgColour(wxColour(12, 133, 222))
, m_bookmarkFgColour(wxColour(66, 169, 244))
, m_highlightCaretLine(true)
, m_displayLineNumbers(false)
, m_showIndentationGuidelines(false)
, m_caretLineColour(wxT("LIGHT BLUE"))
, m_indentUsesTabs(true)
, m_indentWidth(4)
, m_tabWidth(4)
, m_iconsSize(24)
, m_showWhitspaces(0/*wxSCI_WS_INVISIBLE*/)
, m_foldCompact(false)
, m_foldAtElse(false)
, m_foldPreprocessor(false)
, m_edgeMode(0/*wxSCI_EDGE_NONE*/)
, m_edgeColumn(80)
, m_edgeColour(wxColour(wxT("LIGHT GREY")))
, m_highlightMatchedBraces(true)
, m_autoAddMatchedBraces(true)
, m_foldBgColour(wxColour(240, 240, 240))
, m_autoAdjustHScrollBarWidth(true)
, m_caretWidth(1)
, m_caretBlinkPeriod(500)
#if defined(__WXGTK__)
, m_programConsoleCommand(wxT("xterm -title '$(TITLE)' -e '$(CMD)'"))
#elif defined(__WXMAC__)
, m_programConsoleCommand(wxT("osascript -e 'tell application \"Terminal\"' -e 'activate' -e 'do script with command \"$(CMD)\"' -e 'end tell'"))
#else
, m_programConsoleCommand(wxT(""))
#endif
, m_eolMode(wxT("Default"))
{
//set the default font name to be UTF8
SetFileFontEncoding(wxFontMapper::GetEncodingName(wxFONTENCODING_UTF8));
if ( node ) {
m_displayFoldMargin = XmlUtils::ReadBool(node, wxT("DisplayFoldMargin"), m_displayFoldMargin);
m_underlineFoldLine = XmlUtils::ReadBool(node, wxT("UnderlineFoldedLine"), m_underlineFoldLine);
m_foldStyle = XmlUtils::ReadString(node, wxT("FoldStyle"), m_foldStyle);
m_displayBookmarkMargin = XmlUtils::ReadBool(node, wxT("DisplayBookmarkMargin"), m_displayBookmarkMargin);
m_bookmarkShape = XmlUtils::ReadString(node, wxT("BookmarkShape"),m_bookmarkShape);
m_bookmarkBgColour = XmlUtils::ReadString(node, wxT("BookmarkBgColour"), m_bookmarkBgColour.GetAsString(wxC2S_HTML_SYNTAX));
m_bookmarkFgColour = XmlUtils::ReadString(node, wxT("BookmarkFgColour"), m_bookmarkFgColour.GetAsString(wxC2S_HTML_SYNTAX));
m_highlightCaretLine = XmlUtils::ReadBool(node, wxT("HighlightCaretLine"), m_highlightCaretLine);
m_displayLineNumbers = XmlUtils::ReadBool(node, wxT("ShowLineNumber"), m_displayLineNumbers);
m_showIndentationGuidelines = XmlUtils::ReadBool(node, wxT("IndentationGuides"), m_showIndentationGuidelines);
m_caretLineColour = XmlUtils::ReadString(node, wxT("CaretLineColour"), m_caretLineColour.GetAsString(wxC2S_HTML_SYNTAX));
m_indentUsesTabs = XmlUtils::ReadBool(node, wxT("IndentUsesTabs"), m_indentUsesTabs);
m_indentWidth = XmlUtils::ReadLong(node, wxT("IndentWidth"), m_indentWidth);
m_tabWidth = XmlUtils::ReadLong(node, wxT("TabWidth"), m_tabWidth);
m_iconsSize = XmlUtils::ReadLong(node, wxT("ToolbarIconSize"), m_iconsSize);
m_showWhitspaces = XmlUtils::ReadLong(node, wxT("ShowWhitespaces"), m_showWhitspaces);
m_foldCompact = XmlUtils::ReadBool(node, wxT("FoldCompact"), m_foldCompact);
m_foldAtElse = XmlUtils::ReadBool(node, wxT("FoldAtElse"), m_foldAtElse);
m_foldPreprocessor = XmlUtils::ReadBool(node, wxT("FoldPreprocessor"), m_foldPreprocessor);
SetFileFontEncoding(XmlUtils::ReadString(node, wxT("FileFontEncoding"), wxFontMapper::GetEncodingName(wxFONTENCODING_UTF8)));
m_edgeMode = XmlUtils::ReadLong(node, wxT("EdgeMode"), m_edgeMode);
m_edgeColumn = XmlUtils::ReadLong(node, wxT("EdgeColumn"), m_edgeColumn);
m_edgeColour = XmlUtils::ReadString(node, wxT("EdgeColour"), m_edgeColour.GetAsString(wxC2S_HTML_SYNTAX));
m_highlightMatchedBraces = XmlUtils::ReadBool(node, wxT("HighlightMatchedBraces"), m_highlightMatchedBraces);
m_autoAddMatchedBraces = XmlUtils::ReadBool(node, wxT("AutoAddMatchedBraces"), m_autoAddMatchedBraces);
m_foldBgColour = XmlUtils::ReadString(node, wxT("FoldBgColour"), m_foldBgColour.GetAsString(wxC2S_HTML_SYNTAX));
m_autoAdjustHScrollBarWidth = XmlUtils::ReadBool(node, wxT("AutoAdjustHScrollBarWidth"), m_autoAdjustHScrollBarWidth);
m_caretBlinkPeriod = XmlUtils::ReadLong(node, wxT("CaretBlinkPeriod"), m_caretBlinkPeriod);
m_caretWidth = XmlUtils::ReadLong(node, wxT("CaretWidth"), m_caretWidth);
m_programConsoleCommand = XmlUtils::ReadString(node, wxT("ConsoleCommand"), m_programConsoleCommand);
m_eolMode = XmlUtils::ReadString(node, wxT("EOLMode"), m_eolMode);
}
}
OptionsConfig::~OptionsConfig(void)
{
}
wxXmlNode *OptionsConfig::ToXml() const
{
wxXmlNode *n = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("Options"));
n->AddProperty(wxT("DisplayFoldMargin"), BoolToString(m_displayFoldMargin));
n->AddProperty(wxT("UnderlineFoldedLine"), BoolToString(m_underlineFoldLine));
n->AddProperty(wxT("FoldStyle"), m_foldStyle);
n->AddProperty(wxT("DisplayBookmarkMargin"), BoolToString(m_displayBookmarkMargin));
n->AddProperty(wxT("BookmarkShape"), m_bookmarkShape);
n->AddProperty(wxT("BookmarkBgColour"), m_bookmarkBgColour.GetAsString(wxC2S_HTML_SYNTAX));
n->AddProperty(wxT("BookmarkFgColour"), m_bookmarkFgColour.GetAsString(wxC2S_HTML_SYNTAX));
n->AddProperty(wxT("HighlightCaretLine"), BoolToString(m_highlightCaretLine));
n->AddProperty(wxT("ShowLineNumber"), BoolToString(m_displayLineNumbers));
n->AddProperty(wxT("IndentationGuides"), BoolToString(m_showIndentationGuidelines));
n->AddProperty(wxT("CaretLineColour"), m_caretLineColour.GetAsString(wxC2S_HTML_SYNTAX));
n->AddProperty(wxT("IndentUsesTabs"), BoolToString(m_indentUsesTabs));
n->AddProperty(wxT("FoldCompact"), BoolToString(m_foldCompact));
n->AddProperty(wxT("FoldAtElse"), BoolToString(m_foldAtElse));
n->AddProperty(wxT("FoldPreprocessor"), BoolToString(m_foldPreprocessor));
n->AddProperty(wxT("HighlightMatchedBraces"), BoolToString(m_highlightMatchedBraces));
n->AddProperty(wxT("AutoAddMatchedBraces"), BoolToString(m_autoAddMatchedBraces));
n->AddProperty(wxT("FoldBgColour"), m_foldBgColour.GetAsString(wxC2S_HTML_SYNTAX));
n->AddProperty(wxT("AutoAdjustHScrollBarWidth"), BoolToString(m_autoAdjustHScrollBarWidth));
n->AddProperty(wxT("ConsoleCommand"), m_programConsoleCommand);
n->AddProperty(wxT("EOLMode"), m_eolMode);
wxString tmp;
tmp << m_indentWidth;
n->AddProperty(wxT("IndentWidth"), tmp);
tmp.clear();
tmp << m_tabWidth;
n->AddProperty(wxT("TabWidth"), tmp);
tmp.clear();
tmp << m_iconsSize;
n->AddProperty(wxT("ToolbarIconSize"), tmp);
tmp.clear();
tmp << m_showWhitspaces;
n->AddProperty(wxT("ShowWhitespaces"), tmp);
tmp.clear();
tmp << m_edgeMode;
n->AddProperty(wxT("EdgeMode"), tmp);
tmp.clear();
tmp << m_edgeColumn;
n->AddProperty(wxT("EdgeColumn"), tmp);
n->AddProperty(wxT("EdgeColour"), m_edgeColour.GetAsString(wxC2S_HTML_SYNTAX));
tmp.clear();
tmp << m_caretWidth;
n->AddProperty(wxT("CaretWidth"), tmp);
tmp.clear();
tmp << m_caretBlinkPeriod;
n->AddProperty(wxT("CaretBlinkPeriod"), tmp);
tmp.clear();
tmp = wxFontMapper::GetEncodingName(m_fileFontEncoding);
n->AddProperty(wxT("FileFontEncoding"), tmp);
return n;
}
void OptionsConfig::SetFileFontEncoding(const wxString& strFileFontEncoding)
{
this->m_fileFontEncoding = wxFontMapper::Get()->CharsetToEncoding(strFileFontEncoding, false);
if (wxFONTENCODING_SYSTEM == this->m_fileFontEncoding) {
this->m_fileFontEncoding = wxFONTENCODING_UTF8;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.