diff --git a/EditorConfigPlugin/EditorConfigPlugin.project b/EditorConfigPlugin/EditorConfigPlugin.project index 712eeb3039..4e5c556a8c 100644 --- a/EditorConfigPlugin/EditorConfigPlugin.project +++ b/EditorConfigPlugin/EditorConfigPlugin.project @@ -4,6 +4,10 @@ + + + + @@ -84,4 +88,14 @@ + + + + + + + + + + diff --git a/EditorConfigPlugin/EditorConfigSettings.cpp b/EditorConfigPlugin/EditorConfigSettings.cpp new file mode 100644 index 0000000000..05236f3200 --- /dev/null +++ b/EditorConfigPlugin/EditorConfigSettings.cpp @@ -0,0 +1,21 @@ +#include "EditorConfigSettings.h" +#include "cl_config.h" + +EditorConfigSettings::EditorConfigSettings() + : m_flags(kEnabled) +{ +} + +EditorConfigSettings::~EditorConfigSettings() {} + +EditorConfigSettings& EditorConfigSettings::Load() +{ + m_flags = clConfig::Get().Read("EditorConfig/Flags", m_flags); + return *this; +} + +EditorConfigSettings& EditorConfigSettings::Save() +{ + clConfig::Get().Write("EditorConfig/Flags", m_flags); + return *this; +} diff --git a/EditorConfigPlugin/EditorConfigSettings.h b/EditorConfigPlugin/EditorConfigSettings.h new file mode 100644 index 0000000000..0068f5b8c2 --- /dev/null +++ b/EditorConfigPlugin/EditorConfigSettings.h @@ -0,0 +1,36 @@ +#ifndef EDITORCONFIGSETTINGS_H +#define EDITORCONFIGSETTINGS_H + +#include + +class EditorConfigSettings +{ + int m_flags; + + enum eFlags { + kEnabled = (1 << 0), + }; + +private: + void SetFlag(EditorConfigSettings::eFlags flag, bool b) + { + if(b) { + m_flags |= flag; + + } else { + m_flags &= flag; + } + } + +public: + EditorConfigSettings(); + virtual ~EditorConfigSettings(); + + bool IsEnabled() const { return m_flags & kEnabled; } + void SetEnabled(bool b) { SetFlag(kEnabled, b); } + + EditorConfigSettings& Load(); + EditorConfigSettings& Save(); +}; + +#endif // EDITORCONFIGSETTINGS_H diff --git a/EditorConfigPlugin/EditorConfigSettingsDlg.cpp b/EditorConfigPlugin/EditorConfigSettingsDlg.cpp new file mode 100644 index 0000000000..a852a2827f --- /dev/null +++ b/EditorConfigPlugin/EditorConfigSettingsDlg.cpp @@ -0,0 +1,13 @@ +#include "EditorConfigSettingsDlg.h" +#include "cl_config.h" +#include "EditorConfigSettings.h" + +EditorConfigSettingsDlg::EditorConfigSettingsDlg(wxWindow* parent) + : EditorConfigSettingsDlgBase(parent) +{ + EditorConfigSettings settings; + settings.Load(); + m_checkBoxEnable->SetValue(settings.IsEnabled()); +} + +EditorConfigSettingsDlg::~EditorConfigSettingsDlg() {} diff --git a/EditorConfigPlugin/EditorConfigSettingsDlg.h b/EditorConfigPlugin/EditorConfigSettingsDlg.h new file mode 100644 index 0000000000..4bb66456e0 --- /dev/null +++ b/EditorConfigPlugin/EditorConfigSettingsDlg.h @@ -0,0 +1,13 @@ +#ifndef EDITORCONFIGSETTINGSDLG_H +#define EDITORCONFIGSETTINGSDLG_H +#include "EditorConfigUI.h" + +class EditorConfigSettingsDlg : public EditorConfigSettingsDlgBase +{ +public: + EditorConfigSettingsDlg(wxWindow* parent); + virtual ~EditorConfigSettingsDlg(); + + bool IsPluginEnabled() const { return m_checkBoxEnable->IsChecked(); } +}; +#endif // EDITORCONFIGSETTINGSDLG_H diff --git a/EditorConfigPlugin/EditorConfigUI.cpp b/EditorConfigPlugin/EditorConfigUI.cpp new file mode 100644 index 0000000000..bbeb04bcab --- /dev/null +++ b/EditorConfigPlugin/EditorConfigUI.cpp @@ -0,0 +1,73 @@ +////////////////////////////////////////////////////////////////////// +// This file was auto-generated by codelite's wxCrafter Plugin +// wxCrafter project file: EditorConfigUI.wxcp +// Do not modify this file by hand! +////////////////////////////////////////////////////////////////////// + +#include "EditorConfigUI.h" + + +// Declare the bitmap loading function +extern void wxCE9B9InitBitmapResources(); + +static bool bBitmapLoaded = false; + + +EditorConfigSettingsDlgBase::EditorConfigSettingsDlgBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) + : wxDialog(parent, id, title, pos, size, style) +{ + if ( !bBitmapLoaded ) { + // We need to initialise the default bitmap handler + wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler); + wxCE9B9InitBitmapResources(); + bBitmapLoaded = true; + } + + wxBoxSizer* boxSizer2 = new wxBoxSizer(wxVERTICAL); + this->SetSizer(boxSizer2); + + wxFlexGridSizer* flexGridSizer10 = new wxFlexGridSizer(0, 2, 0, 0); + flexGridSizer10->SetFlexibleDirection( wxBOTH ); + flexGridSizer10->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + boxSizer2->Add(flexGridSizer10, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5)); + + m_checkBoxEnable = new wxCheckBox(this, wxID_ANY, _("Enable .editorconfig support"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0); + m_checkBoxEnable->SetValue(false); + + flexGridSizer10->Add(m_checkBoxEnable, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5)); + + m_stdBtnSizer4 = new wxStdDialogButtonSizer(); + + boxSizer2->Add(m_stdBtnSizer4, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, WXC_FROM_DIP(5)); + + m_button6 = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0); + m_button6->SetDefault(); + m_stdBtnSizer4->AddButton(m_button6); + + m_button8 = new wxButton(this, wxID_CANCEL, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0); + m_stdBtnSizer4->AddButton(m_button8); + m_stdBtnSizer4->Realize(); + + SetName(wxT("EditorConfigSettingsDlgBase")); + SetSize(-1,-1); + if (GetSizer()) { + GetSizer()->Fit(this); + } + if(GetParent()) { + CentreOnParent(wxBOTH); + } else { + CentreOnScreen(wxBOTH); + } +#if wxVERSION_NUMBER >= 2900 + if(!wxPersistenceManager::Get().Find(this)) { + wxPersistenceManager::Get().RegisterAndRestore(this); + } else { + wxPersistenceManager::Get().Restore(this); + } +#endif +} + +EditorConfigSettingsDlgBase::~EditorConfigSettingsDlgBase() +{ +} diff --git a/EditorConfigPlugin/EditorConfigUI.h b/EditorConfigPlugin/EditorConfigUI.h new file mode 100644 index 0000000000..60ec0d3bc2 --- /dev/null +++ b/EditorConfigPlugin/EditorConfigUI.h @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////// +// This file was auto-generated by codelite's wxCrafter Plugin +// wxCrafter project file: EditorConfigUI.wxcp +// Do not modify this file by hand! +////////////////////////////////////////////////////////////////////// + +#ifndef _CODELITE_EDITORCONFIGPLUGIN_EDITORCONFIGUI_BASE_CLASSES_H +#define _CODELITE_EDITORCONFIGPLUGIN_EDITORCONFIGUI_BASE_CLASSES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if wxVERSION_NUMBER >= 2900 +#include +#include +#include +#include +#endif + +#ifdef WXC_FROM_DIP +#undef WXC_FROM_DIP +#endif +#if wxVERSION_NUMBER >= 3100 +#define WXC_FROM_DIP(x) wxWindow::FromDIP(x, NULL) +#else +#define WXC_FROM_DIP(x) x +#endif + + +class EditorConfigSettingsDlgBase : public wxDialog +{ +protected: + wxCheckBox* m_checkBoxEnable; + wxStdDialogButtonSizer* m_stdBtnSizer4; + wxButton* m_button6; + wxButton* m_button8; + +protected: + +public: + wxCheckBox* GetCheckBoxEnable() { return m_checkBoxEnable; } + EditorConfigSettingsDlgBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("EditorConfig Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER); + virtual ~EditorConfigSettingsDlgBase(); +}; + +#endif diff --git a/EditorConfigPlugin/EditorConfigUI.wxcp b/EditorConfigPlugin/EditorConfigUI.wxcp new file mode 100644 index 0000000000..ba1ae660d4 --- /dev/null +++ b/EditorConfigPlugin/EditorConfigUI.wxcp @@ -0,0 +1,402 @@ +{ + "metadata": { + "m_generatedFilesDir": ".", + "m_objCounter": 12, + "m_includeFiles": [], + "m_bitmapFunction": "wxCE9B9InitBitmapResources", + "m_bitmapsFile": "EditorConfigUI_editorconfigplugin_bitmaps.cpp", + "m_GenerateCodeTypes": 1, + "m_outputFileName": "", + "m_firstWindowId": 10000, + "m_useEnum": true, + "m_useUnderscoreMacro": true, + "m_addHandlers": true, + "m_templateClasses": [] + }, + "windows": [{ + "m_type": 4421, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxDEFAULT_DIALOG_STYLE", "wxRESIZE_BORDER"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "EditorConfigSettingsDlgBase" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Enable Window Persistency:", + "m_value": true + }, { + "type": "string", + "m_label": "Title:", + "m_value": "EditorConfig Settings" + }, { + "type": "virtualFolderPicker", + "m_label": "Virtual Folder:", + "m_path": "EditorConfigPlugin:src" + }, { + "type": "choice", + "m_label": "Centre:", + "m_selection": 1, + "m_options": ["", "wxBOTH", "wxVERTICAL", "wxHORIZONTAL"] + }, { + "type": "string", + "m_label": "Inherited Class", + "m_value": "EditorConfigSettingsDlg" + }, { + "type": "string", + "m_label": "File:", + "m_value": "EditorConfigSettingsDlg" + }, { + "type": "string", + "m_label": "Class Decorator", + "m_value": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (16x16) :", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (32x32) :", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (64x64) :", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (128x128):", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (256x256):", + "m_path": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer2" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4403, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer10" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "2" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBoxEnable" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Enable .editorconfig support" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4467, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_stdBtnSizer4" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4468, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "choice", + "m_label": "ID:", + "m_selection": 0, + "m_options": ["wxID_OK", "wxID_YES", "wxID_SAVE", "wxID_APPLY", "wxID_CLOSE", "wxID_NO", "wxID_CANCEL", "wxID_HELP", "wxID_CONTEXT_HELP"] + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button6" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": true + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4468, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "choice", + "m_label": "ID:", + "m_selection": 6, + "m_options": ["wxID_OK", "wxID_YES", "wxID_SAVE", "wxID_APPLY", "wxID_CLOSE", "wxID_NO", "wxID_CANCEL", "wxID_HELP", "wxID_CONTEXT_HELP"] + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button8" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }] +} \ No newline at end of file diff --git a/EditorConfigPlugin/EditorConfigUI_editorconfigplugin_bitmaps.cpp b/EditorConfigPlugin/EditorConfigUI_editorconfigplugin_bitmaps.cpp new file mode 100644 index 0000000000..3fc1571856 --- /dev/null +++ b/EditorConfigPlugin/EditorConfigUI_editorconfigplugin_bitmaps.cpp @@ -0,0 +1,49 @@ +// +// This file was automatically generated by wxrc, do not edit by hand. +// + +#include + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include +#include +#include +#include + +#if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805 + #define XRC_ADD_FILE(name, data, size, mime) \ + wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime) +#else + #define XRC_ADD_FILE(name, data, size, mime) \ + wxMemoryFSHandler::AddFile(name, data, size) +#endif + +static size_t xml_res_size_0 = 137; +static unsigned char xml_res_file_0[] = { +60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101, +110,99,111,100,105,110,103,61,34,85,84,70,45,56,34,63,62,10,60,114,101, +115,111,117,114,99,101,32,120,109,108,110,115,61,34,104,116,116,112,58, +47,47,119,119,119,46,119,120,119,105,100,103,101,116,115,46,111,114,103, +47,119,120,120,114,99,34,62,10,32,32,60,33,45,45,32,72,97,110,100,108,101, +114,32,71,101,110,101,114,97,116,105,111,110,32,105,115,32,79,78,32,45, +45,62,10,60,47,114,101,115,111,117,114,99,101,62,10}; + +void wxCE9B9InitBitmapResources() +{ + + // Check for memory FS. If not present, load the handler: + { + wxMemoryFSHandler::AddFile(wxT("XRC_resource/dummy_file"), wxT("dummy one")); + wxFileSystem fsys; + wxFSFile *f = fsys.OpenFile(wxT("memory:XRC_resource/dummy_file")); + wxMemoryFSHandler::RemoveFile(wxT("XRC_resource/dummy_file")); + if (f) delete f; + else wxFileSystem::AddHandler(new wxMemoryFSHandlerBase); + } + + XRC_ADD_FILE(wxT("XRC_resource/EditorConfigUI_editorconfigplugin_bitmaps.cpp$C__src_codelite_EditorConfigPlugin_EditorConfigUI_editorconfigplugin_bitmaps.xrc"), xml_res_file_0, xml_res_size_0, wxT("text/xml")); + wxXmlResource::Get()->Load(wxT("memory:XRC_resource/EditorConfigUI_editorconfigplugin_bitmaps.cpp$C__src_codelite_EditorConfigPlugin_EditorConfigUI_editorconfigplugin_bitmaps.xrc")); +} diff --git a/EditorConfigPlugin/editorconfigplugin.cpp b/EditorConfigPlugin/editorconfigplugin.cpp index 44ba23f3ae..af4693e280 100644 --- a/EditorConfigPlugin/editorconfigplugin.cpp +++ b/EditorConfigPlugin/editorconfigplugin.cpp @@ -3,6 +3,10 @@ #include "event_notifier.h" #include "codelite_events.h" #include +#include "cl_config.h" +#include "EditorConfigSettingsDlg.h" +#include "EditorConfigSettings.h" +#include static EditorConfigPlugin* thePlugin = NULL; @@ -32,7 +36,10 @@ EditorConfigPlugin::EditorConfigPlugin(IManager* manager) { m_longName = _("Support for .editorconfig files in CodeLite"); m_shortName = wxT("EditorConfig"); - + + // Load the settings + m_settings.Load(); + // Bind events EventNotifier::Get()->Bind(wxEVT_EDITOR_CONFIG_LOADING, &EditorConfigPlugin::OnEditorConfigLoading, this); EventNotifier::Get()->Bind(wxEVT_ACTIVE_EDITOR_CHANGED, &EditorConfigPlugin::OnActiveEditorChanged, this); @@ -47,7 +54,13 @@ clToolBar* EditorConfigPlugin::CreateToolBar(wxWindow* parent) return tb; } -void EditorConfigPlugin::CreatePluginMenu(wxMenu* pluginsMenu) {} +void EditorConfigPlugin::CreatePluginMenu(wxMenu* pluginsMenu) +{ + wxMenu* menu = new wxMenu(); + menu->Append(new wxMenuItem(menu, XRCID("editor_config_settings"), _("Settings..."))); + pluginsMenu->Append(wxID_ANY, "EditorConfig", menu); + menu->Bind(wxEVT_MENU, &EditorConfigPlugin::OnSettings, this, XRCID("editor_config_settings")); +} void EditorConfigPlugin::UnPlug() { @@ -58,6 +71,8 @@ void EditorConfigPlugin::UnPlug() void EditorConfigPlugin::OnEditorConfigLoading(clEditorConfigEvent& event) { event.Skip(); + if(!m_settings.IsEnabled()) return; + clEditorConfigSection section; wxFileName fn(event.GetFileName()); if(!DoGetEditorConfigForFile(fn, section)) { @@ -71,6 +86,8 @@ void EditorConfigPlugin::OnEditorConfigLoading(clEditorConfigEvent& event) void EditorConfigPlugin::OnActiveEditorChanged(wxCommandEvent& event) { event.Skip(); + if(!m_settings.IsEnabled()) return; + IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); @@ -102,3 +119,13 @@ bool EditorConfigPlugin::DoGetEditorConfigForFile(const wxFileName& filename, cl m_cache.Add(filename, section); return true; } + +void EditorConfigPlugin::OnSettings(wxCommandEvent& event) +{ + EditorConfigSettingsDlg dlg(wxTheApp->GetTopWindow()); + if(dlg.ShowModal() == wxID_OK) { + // Store the settings + m_settings.SetEnabled(dlg.IsEnabled()); + m_settings.Save(); + } +} diff --git a/EditorConfigPlugin/editorconfigplugin.h b/EditorConfigPlugin/editorconfigplugin.h index dd42a0c0f7..3c6b714229 100644 --- a/EditorConfigPlugin/editorconfigplugin.h +++ b/EditorConfigPlugin/editorconfigplugin.h @@ -6,10 +6,12 @@ #include "EditorConfigCache.h" #include #include "clEditorConfig.h" +#include "EditorConfigSettings.h" class EditorConfigPlugin : public IPlugin { EditorConfigCache m_cache; + EditorConfigSettings m_settings; protected: bool DoGetEditorConfigForFile(const wxFileName& filename, clEditorConfigSection& section); @@ -34,6 +36,7 @@ class EditorConfigPlugin : public IPlugin void OnEditorConfigLoading(clEditorConfigEvent& event); void OnActiveEditorChanged(wxCommandEvent& event); + void OnSettings(wxCommandEvent& event); }; #endif // EditorConfigPlugin diff --git a/LiteEditor.workspace b/LiteEditor.workspace index 0fb55e88b1..39bdc55430 100644 --- a/LiteEditor.workspace +++ b/LiteEditor.workspace @@ -322,7 +322,7 @@ - + WXWIN=D:\src\wxWidgets WXCFG=gcc_dll\mswu @@ -374,7 +374,7 @@ WXCFG=gcc_dll\mswu - +