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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : editor_config.h
//
// -------------------------------------------------------------------------
// 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.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef LITEEDITOR_EDITOR_CONFIG_H
#define LITEEDITOR_EDITOR_CONFIG_H
#include "cl_config.h"
#include "codelite_exports.h"
#include "lexer_configuration.h"
#include "map"
#include "optionsconfig.h"
#include "plugin.h"
#include "serialized_object.h"
#include "singleton.h"
#include "wx/xml/xml.h"
#include <vector>
#include <wx/filename.h>
enum {
View_Show_Workspace_Tab = 0x00000001,
View_Show_Explorer_Tab = 0x00000002,
View_Show_Tabs_Tab = 0x00000004,
View_Show_Tabgroups_Tab = 0x00000008,
View_Show_Default = View_Show_Workspace_Tab | View_Show_Explorer_Tab | View_Show_Tabs_Tab | View_Show_Tabgroups_Tab
};
// Helper macro for getting the correct wxMBConv object from the user settings
#define clMBConv(converter) \
wxCSConv __fontEncConv(EditorConfigST::Get()->GetOptions()->GetFileFontEncoding()); \
bool __useBuiltIn = (EditorConfigST::Get()->GetOptions()->GetFileFontEncoding() == wxFONTENCODING_UTF8); \
wxMBConv* converter = (__useBuiltIn ? (wxMBConv*)&wxConvUTF8 : (wxMBConv*)&__fontEncConv);
class WXDLLIMPEXP_SDK SimpleLongValue : public SerializedObject
{
long m_value;
public:
SimpleLongValue();
~SimpleLongValue();
void DeSerialize(Archive& arch);
void Serialize(Archive& arch);
// Setters
void SetValue(const long& value) { this->m_value = value; }
// Getters
const long& GetValue() const { return m_value; }
};
class WXDLLIMPEXP_SDK SimpleStringValue : public SerializedObject
{
wxString m_value;
public:
SimpleStringValue();
~SimpleStringValue();
void DeSerialize(Archive& arch);
void Serialize(Archive& arch);
void SetValue(const wxString& value) { this->m_value = value; }
const wxString& GetValue() const { return m_value; }
};
class WXDLLIMPEXP_SDK SimpleRectValue : public SerializedObject
{
wxRect m_rect;
public:
SimpleRectValue();
~SimpleRectValue();
void DeSerialize(Archive& arch);
void Serialize(Archive& arch);
void SetRect(const wxRect& rect) { this->m_rect = rect; }
const wxRect& GetRect() const { return m_rect; }
};
/**
* \ingroup LiteEditor
* \brief EditorConfig a singleton class that manages the liteeditor.xml configuration file
*
* \version 1.0
* first version
*
* \date 04-19-2007
*
* \author Eran
*/
class WXDLLIMPEXP_SDK EditorConfig : public IConfigTool
{
friend class EditorConfigST;
wxXmlDocument* m_doc;
wxFileName m_fileName;
bool m_transcation;
wxString m_svnRevision;
wxString m_version;
wxString m_installDir;
std::map<wxString, long> m_cacheLongValues;
std::map<wxString, wxString> m_cacheStringValues;
std::map<wxString, wxArrayString> m_cacheRecentItems;
private:
bool DoSave() const;
bool DoLoadDefaultSettings();
public:
void Init(const wxString& revision, const wxString& version)
{
this->m_svnRevision = revision;
this->m_version = version;
}
public:
void Begin();
void Save();
/**
* Load the configuration file
* \param fileName configuration file name
* \return true on success false otherwise
*/
bool Load();
/**
* Find lexer configuration and return a pointer to a LexerConf object
* \param lexer lexer name (e.g. Cpp, Java, Default etc..)
* \return LexerConf::Ptr_t
*/
LexerConf::Ptr_t GetLexer(const wxString& lexer);
/**
* @brief return the proper lexer based on the file's extension
* @param filename
* @return the file's lexer or the "Text" lexer
*/
LexerConf::Ptr_t GetLexerForFile(const wxString& filename);
/**
* Get the outputview's foreground colour, which is global to a theme
* \return the colour as a wxString
*/
wxString GetCurrentOutputviewFgColour() const;
/**
* Get the outputview's background colour, which is global to a theme
* \return the colour as a wxString
*/
wxString GetCurrentOutputviewBgColour() const;
/**
* Test if this configuration is loaded properly
* \return true of a file is loaded into the configuration manager false otherwise
*/
bool IsOk() const { return m_doc->IsOk(); }
/**
* Read the editor options from the configuration file
* and return them as an object
*/
OptionsConfigPtr GetOptions() const;
/**
* Set options to the configuration file, override them if they does not exist
*/
void SetOptions(OptionsConfigPtr opts);
/**
* Return the database that should be used by the editor
* \return
*/
wxString GetTagsDatabase() const;
/**
* Set tags database to be use by editor (in addition to the workspace one)
* \param &dbName
*/
void SetTagsDatabase(const wxString& dbName);
/**
* save lexers settings
*/
void SaveLexers();
/**
* get an array of recently opened items e.g. workspaces
* \param files [output] a place holder for the output
* \param nodename the type of item to get
*/
void GetRecentItems(wxArrayString& files, const wxString& nodeName);
/**
* Set an array of recently opened items e.g. workspaces
* \param files list of files to save
* \param nodename the type of item to set
*/
void SetRecentItems(const wxArrayString& files, const wxString& nodeName);
/**
* \brief write an archived object to the xml configuration
* \param name object name
* \param arch the archived object container
*/
virtual bool WriteObject(const wxString& name, SerializedObject* obj);
/**
* \brief read an archived object from the configuration
* \param name object to read
* \param arch [output]
*/
virtual bool ReadObject(const wxString& name, SerializedObject* obj);
/**
* Return the configuration version
*/
wxString GetRevision() const;
/**
* Set the current configuration revision
*/
void SetRevision(const wxString& rev);
void SetInstallDir(const wxString& instlDir);
/**
* \brief convinience methods to store a single long value
* \param name variable name
* \param value value to store
*/
void SetInteger(const wxString& name, long value);
/**
* \brief convinience methods to retrieve a single long value stored using
* the 'SaveLongValue()' method
* \param name variable name
* \param value value
* \return return true on success, false otherwise
*/
long GetInteger(const wxString& name, long defaultValue = wxNOT_FOUND);
/**
* \brief get string from the configuration identified by key
* \param key key identifiying the string
* \return wxEmptyString or the value
*/
wxString GetString(const wxString& key, const wxString& defaultValue = "");
/**
* \brief
* \param key
* \param value
*/
void SetString(const wxString& key, const wxString& value);
/**
* \brief should this pane remain open despite an editor click
* \param caption string to identify the pane
* \return true if the pane should stay open
*/
bool GetPaneStickiness(const wxString& caption);
/**
* \brief sets whether this pane should remain open despite an editor click
* \param caption string to identify the pane
* \param stickiness true if the pane should stay open
*/
void SetPaneStickiness(const wxString& caption, bool stickiness);
private:
EditorConfig();
virtual ~EditorConfig();
wxXmlNode* GetLexerNode(const wxString& lexer);
};
class WXDLLIMPEXP_SDK EditorConfigST
{
public:
static EditorConfig* Get();
static void Free();
};
#endif // LITEEDITOR_EDITOR_CONFIG_H
|