File: codelite_vim.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (82 lines) | stat: -rw-r--r-- 2,193 bytes parent folder | download
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
#include <iostream>
#include "codelite_vim.h"
#include <wx/xrc/xmlres.h>
#include <wx/app.h>
#include <wx/menu.h>
#include <wx/settings.h>
#include <wx/dialog.h>
#include "macros.h"
#include "vim_manager.h"
#include "VimSettingsDlg.h"
#include "event_notifier.h"
#include "VimSettings.h"

static CodeliteVim* thePlugin = NULL;

// Define the plugin entry point
CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager)
{
    if(thePlugin == NULL) {
        thePlugin = new CodeliteVim(manager);
    }
    return thePlugin;
}

CL_PLUGIN_API PluginInfo* GetPluginInfo()
{
    static PluginInfo info;
    info.SetAuthor(wxT("bau"));
    info.SetName(wxT("CodeLite Vim"));
    info.SetDescription(_("vim bindings for CodeLite"));
    info.SetVersion(wxT("v1.0"));
    return &info;
}

CL_PLUGIN_API int GetPluginInterfaceVersion() { return PLUGIN_INTERFACE_VERSION; }

CodeliteVim::CodeliteVim(IManager* manager)
    : IPlugin(manager)
{
    m_longName = _("vim bindings for CodeLite");
    m_shortName = wxT("CodeLite Vim");

    wxTheApp->Bind(wxEVT_MENU, &CodeliteVim::onVimSetting, this, XRCID("vim_settings"));
    
    // Load the settings from the file system    
    m_settings.Load();
    m_vimM = new VimManager(manager, m_settings);
}

CodeliteVim::~CodeliteVim() {}

clToolBar* CodeliteVim::CreateToolBar(wxWindow* parent)
{
    // Create the toolbar to be used by the plugin
    clToolBar* tb(NULL);

    return tb;
}

void CodeliteVim::CreatePluginMenu(wxMenu* pluginsMenu)
{
    wxMenu* menu = new wxMenu();
    menu->Append(new wxMenuItem(menu, XRCID("vim_settings"), _("Settings...")));
    pluginsMenu->Append(wxID_ANY, GetShortName(), menu);
    wxTheApp->Bind(wxEVT_MENU, &CodeliteVim::onVimSetting, this, XRCID("vim_settings"));
}

void CodeliteVim::UnPlug()
{
    wxTheApp->Unbind(wxEVT_MENU, &CodeliteVim::onVimSetting, this, XRCID("vim_settings"));
    wxDELETE(m_vimM);
}

void CodeliteVim::onVimSetting(wxCommandEvent& event) 
{
    VimSettingsDlg dlg(EventNotifier::Get()->TopFrame());
    if(dlg.ShowModal() == wxID_OK) {
        // Store the settings
        m_settings.SetEnabled(dlg.GetCheckBoxEnabled()->IsChecked()).Save();
        m_vimM->SettingsUpdated();
    }
}