Skip to content

Commit

Permalink
Keyboard manager: store in the new configuration the resource ID stri…
Browse files Browse the repository at this point in the history
…ng rather than its integer value ( the integer value may change between runs )
  • Loading branch information
eranif committed Oct 29, 2014
1 parent 5891042 commit 3ee43d3
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 231 deletions.
4 changes: 2 additions & 2 deletions LiteEditor.workspace
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<Project Name="PHPParserUnitTests" Path="codelitephp/PHPParserUnitTests/PHPParserUnitTests.project" Active="No"/>
<Project Name="PHPPlugin" Path="codelitephp/php-plugin/PHPPlugin.project" Active="No"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Win Release Unicode" Selected="yes">
<WorkspaceConfiguration Name="Win Release Unicode" Selected="no">
<Project Name="abbreviation" ConfigName="WinReleaseUnicode"/>
<Project Name="CallGraph" ConfigName="WinReleaseUnicode"/>
<Project Name="CMakePlugin" ConfigName="WinReleaseUnicode"/>
Expand Down Expand Up @@ -135,7 +135,7 @@
<Project Name="wxsqlite3" ConfigName="WinDebugUnicode"/>
<Project Name="ZoomNavigator" ConfigName="WinDebugUnicode"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="CMake_Release" Selected="no">
<WorkspaceConfiguration Name="CMake_Release" Selected="yes">
<Project Name="ZoomNavigator" ConfigName="DebugUnicode"/>
<Project Name="wxsqlite3" ConfigName="WinReleaseUnicode"/>
<Project Name="wxshapeframework" ConfigName="WinReleaseUnicode"/>
Expand Down
6 changes: 1 addition & 5 deletions LiteEditor/acceltabledlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ struct AccelItemData : public wxClientData {
, isPluginAccel(fromPlugin)
{
}

int GetActionID() const {
return menuItemData.id;
}
};

//-------------------------------------------------------------------------------
Expand Down Expand Up @@ -181,7 +177,7 @@ void AccelTableDlg::DoItemActivated()
m_dataviewModel->UpdateItem(sel, cols);

// and update the map
MenuItemDataMap_t::iterator iter = m_accelMap.find(itemData->GetActionID());
MenuItemDataMap_t::iterator iter = m_accelMap.find(itemData->menuItemData.resourceID);
if(iter != m_accelMap.end()) {
iter->second.accel = itemData->menuItemData.accel;
}
Expand Down
124 changes: 83 additions & 41 deletions LiteEditor/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,8 @@ void clMainFrame::OnClose(wxCloseEvent& event)

// Stop any debugging session if any
IDebugger* debugger = DebuggerMgr::Get().GetActiveDebugger();
if(debugger && debugger->IsRunning()) ManagerST::Get()->DbgStop();
if(debugger && debugger->IsRunning())
ManagerST::Get()->DbgStop();

SaveLayoutAndSession();

Expand Down Expand Up @@ -2574,7 +2575,8 @@ void clMainFrame::OnProjectNewWorkspace(wxCommandEvent& event)
// let the plugins handle this event first
wxCommandEvent e(wxEVT_CMD_CREATE_NEW_WORKSPACE, GetId());
e.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(e)) return;
if(EventNotifier::Get()->ProcessEvent(e))
return;

wxUnusedVar(event);
NewWorkspaceDlg* dlg = new NewWorkspaceDlg(this);
Expand Down Expand Up @@ -2795,19 +2797,23 @@ void clMainFrame::ToggleToolBars(bool std)
wxAuiPaneInfoArray& allPanes = m_mgr.GetAllPanes();
for(size_t i = 0; i < allPanes.GetCount(); ++i) {
wxAuiPaneInfo& pane = allPanes.Item(i);
if(!pane.IsOk() || !pane.IsToolbar()) continue;
if(!pane.IsOk() || !pane.IsToolbar())
continue;

if(std) {
// collect core toolbars
if(m_coreToolbars.count(pane.name)) toolbars.insert(pane.name);
if(m_coreToolbars.count(pane.name))
toolbars.insert(pane.name);
} else {
// collect plugins toolbars
if(m_coreToolbars.count(pane.name) == 0) toolbars.insert(pane.name);
if(m_coreToolbars.count(pane.name) == 0)
toolbars.insert(pane.name);
}
}
}

if(toolbars.empty()) return;
if(toolbars.empty())
return;

// determine that state based on the first toolbar
bool currentStateVisible = m_mgr.GetPane((*toolbars.begin())).IsShown();
Expand Down Expand Up @@ -3080,7 +3086,8 @@ void clMainFrame::OnStopBuild(wxCommandEvent& event)
void clMainFrame::OnStopExecutedProgram(wxCommandEvent& event)
{
wxCommandEvent evtExecute(wxEVT_CMD_STOP_EXECUTED_PROGRAM);
if(EventNotifier::Get()->ProcessEvent(evtExecute)) return;
if(EventNotifier::Get()->ProcessEvent(evtExecute))
return;

wxUnusedVar(event);
Manager* mgr = ManagerST::Get();
Expand Down Expand Up @@ -3116,7 +3123,8 @@ void clMainFrame::OnExecuteNoDebug(wxCommandEvent& event)
// set the project name
evtExecute.SetTargetName(WorkspaceST::Get()->GetActiveProject()->GetName());
}
if(EventNotifier::Get()->ProcessEvent(evtExecute)) return;
if(EventNotifier::Get()->ProcessEvent(evtExecute))
return;

if(!WorkspaceST::Get()->IsOpen()) {
return;
Expand Down Expand Up @@ -3229,7 +3237,8 @@ void clMainFrame::UpdateParserSearchPathsFromDefaultCompiler()

// Try to locate the paths automatically
CompilerPtr pCompiler = BuildSettingsConfigST::Get()->GetDefaultCompiler(wxEmptyString);
if(!pCompiler) return;
if(!pCompiler)
return;

wxArrayString paths;
paths = pCompiler->GetDefaultIncludePaths();
Expand Down Expand Up @@ -3269,12 +3278,15 @@ void clMainFrame::OnQuickOutline(wxCommandEvent& event)
evt.SetEventObject(this);
evt.SetEditor(activeEditor);

if(EventNotifier::Get()->ProcessEvent(evt)) return;
if(EventNotifier::Get()->ProcessEvent(evt))
return;

wxUnusedVar(event);
if(ManagerST::Get()->IsWorkspaceOpen() == false) return;
if(ManagerST::Get()->IsWorkspaceOpen() == false)
return;

if(activeEditor->GetProject().IsEmpty()) return;
if(activeEditor->GetProject().IsEmpty())
return;

QuickOutlineDlg dlg(::wxGetTopLevelParent(activeEditor),
activeEditor->GetFileName().GetFullPath(),
Expand Down Expand Up @@ -3583,7 +3595,8 @@ void clMainFrame::OnDebug(wxCommandEvent& e)
dbgEvent.SetDebuggerName(buildConfig->GetDebuggerType());
}
}
if(EventNotifier::Get()->ProcessEvent(dbgEvent)) return;
if(EventNotifier::Get()->ProcessEvent(dbgEvent))
return;
}

Manager* mgr = ManagerST::Get();
Expand Down Expand Up @@ -3635,7 +3648,8 @@ void clMainFrame::OnDebugUI(wxUpdateUIEvent& e)
void clMainFrame::OnDebugRestart(wxCommandEvent& e)
{
clDebugEvent event(wxEVT_DBG_UI_RESTART);
if(EventNotifier::Get()->ProcessEvent(event)) return;
if(EventNotifier::Get()->ProcessEvent(event))
return;

IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
if(dbgr && dbgr->IsRunning() && ManagerST::Get()->DbgCanInteract()) {
Expand Down Expand Up @@ -3852,9 +3866,13 @@ void clMainFrame::CompleteInitialization()
}

// Register C++ keyboard shortcuts
wxMenu* editorCppMenu = wxXmlResource::Get()->LoadMenu("editor_right_click");
clKeyboardManager::Get()->AddGlobalAccelerators(editorCppMenu, "C++::");
wxDELETE(editorCppMenu);
clKeyboardManager::Get()->AddGlobalAccelerator("swap_files", "F12", "C++::Swap Header/Implementation file");
clKeyboardManager::Get()->AddGlobalAccelerator(
"insert_doxy_comment", "C++::Ctrl-Shift-D", "Insert Doxygen Comment");
clKeyboardManager::Get()->AddGlobalAccelerator("comment_selection", "Ctrl-Shift-/", "C++::Comment Selection");
clKeyboardManager::Get()->AddGlobalAccelerator("comment_line", "Ctrl-/", "C++::Toggle Line Comment");
clKeyboardManager::Get()->AddGlobalAccelerator("rename_symbol", "Ctrl-Shift-H", "C++::Rename Symbol");
clKeyboardManager::Get()->AddGlobalAccelerator("rename_local_variable", "Ctrl-Shift-L", "C++::Rename Local Variable");

// Load the plugins
PluginManager::Get()->Load();
Expand Down Expand Up @@ -4365,7 +4383,8 @@ void clMainFrame::OnReloadWorkspace(wxCommandEvent& event)
// let the plugins close any custom workspace
clCommandEvent e(wxEVT_CMD_RELOAD_WORKSPACE, GetId());
e.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(e)) return; // this event was handled by a plugin
if(EventNotifier::Get()->ProcessEvent(e))
return; // this event was handled by a plugin

IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
if(dbgr && dbgr->IsRunning()) {
Expand Down Expand Up @@ -4831,7 +4850,8 @@ void clMainFrame::OnRetagWorkspace(wxCommandEvent& event)
bool fullRetag = !(event.GetId() == XRCID("retag_workspace"));
wxCommandEvent e(fullRetag ? wxEVT_CMD_RETAG_WORKSPACE_FULL : wxEVT_CMD_RETAG_WORKSPACE, GetId());
e.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(e)) return;
if(EventNotifier::Get()->ProcessEvent(e))
return;

TagsManager::RetagType type = TagsManager::Retag_Quick_No_Scan;
if(event.GetId() == XRCID("retag_workspace"))
Expand Down Expand Up @@ -4927,7 +4947,8 @@ bool clMainFrame::ReloadExternallyModifiedProjectFiles()
}
}

if(!project_modified && !workspace_modified) return false;
if(!project_modified && !workspace_modified)
return false;

// Make sure we don't have the mouse captured in any editor or we might get a crash somewhere
wxStandardID res = ::PromptForYesNoDialogWithCheckbox(_("Workspace or project settings have been modified outside "
Expand Down Expand Up @@ -5035,7 +5056,8 @@ void clMainFrame::OnFindResourceXXX(wxCommandEvent& e)
// Let the plugins a chance before we handle this event
wxCommandEvent eventOpenResource(wxEVT_CMD_OPEN_RESOURCE, GetId());
eventOpenResource.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(eventOpenResource)) return;
if(EventNotifier::Get()->ProcessEvent(eventOpenResource))
return;

OpenResourceDialog dlg(this, PluginManager::Get());
if(dlg.ShowModal() == wxID_OK) {
Expand Down Expand Up @@ -5444,11 +5466,13 @@ void clMainFrame::OnGrepWord(wxCommandEvent& e)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor();
if(!editor || editor->GetSelectedText().IsEmpty()) return;
if(!editor || editor->GetSelectedText().IsEmpty())
return;

// Prepare the search data
bool singleFileSearch(true);
if(e.GetId() == XRCID("grep_current_workspace")) singleFileSearch = false;
if(e.GetId() == XRCID("grep_current_workspace"))
singleFileSearch = false;

SearchData data;
data.SetFindString(editor->GetSelectedText());
Expand Down Expand Up @@ -5674,7 +5698,8 @@ void clMainFrame::OnFileSaveUI(wxUpdateUIEvent& event)
void clMainFrame::OnActivateEditor(wxCommandEvent& e)
{
LEditor* editor = dynamic_cast<LEditor*>(e.GetEventObject());
if(editor) editor->SetActive();
if(editor)
editor->SetActive();
}

void clMainFrame::OnActiveEditorChanged(wxCommandEvent& e)
Expand Down Expand Up @@ -5827,23 +5852,32 @@ void clMainFrame::OnShowDebuggerWindow(wxCommandEvent& e)
conf.ReadItem(&item);

bool show = e.IsChecked();
if(e.GetId() == XRCID("debugger_win_locals")) item.ShowDebuggerWindow(DebuggerPaneConfig::Locals, show);
if(e.GetId() == XRCID("debugger_win_locals"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Locals, show);

if(e.GetId() == XRCID("debugger_win_watches")) item.ShowDebuggerWindow(DebuggerPaneConfig::Watches, show);
if(e.GetId() == XRCID("debugger_win_watches"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Watches, show);

if(e.GetId() == XRCID("debugger_win_output")) item.ShowDebuggerWindow(DebuggerPaneConfig::Output, show);
if(e.GetId() == XRCID("debugger_win_output"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Output, show);

if(e.GetId() == XRCID("debugger_win_threads")) item.ShowDebuggerWindow(DebuggerPaneConfig::Threads, show);
if(e.GetId() == XRCID("debugger_win_threads"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Threads, show);

if(e.GetId() == XRCID("debugger_win_callstack")) item.ShowDebuggerWindow(DebuggerPaneConfig::Callstack, show);
if(e.GetId() == XRCID("debugger_win_callstack"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Callstack, show);

if(e.GetId() == XRCID("debugger_win_memory")) item.ShowDebuggerWindow(DebuggerPaneConfig::Memory, show);
if(e.GetId() == XRCID("debugger_win_memory"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Memory, show);

if(e.GetId() == XRCID("debugger_win_breakpoints")) item.ShowDebuggerWindow(DebuggerPaneConfig::Breakpoints, show);
if(e.GetId() == XRCID("debugger_win_breakpoints"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Breakpoints, show);

if(e.GetId() == XRCID("debugger_win_asciiview")) item.ShowDebuggerWindow(DebuggerPaneConfig::AsciiViewer, show);
if(e.GetId() == XRCID("debugger_win_asciiview"))
item.ShowDebuggerWindow(DebuggerPaneConfig::AsciiViewer, show);

if(e.GetId() == XRCID("debugger_win_disassemble")) item.ShowDebuggerWindow(DebuggerPaneConfig::Disassemble, show);
if(e.GetId() == XRCID("debugger_win_disassemble"))
item.ShowDebuggerWindow(DebuggerPaneConfig::Disassemble, show);

conf.WriteItem(&item);
// Reload the perspective
Expand All @@ -5859,21 +5893,29 @@ void clMainFrame::OnShowDebuggerWindowUI(wxUpdateUIEvent& e)

DebuggerPaneConfig::eDebuggerWindows winid = DebuggerPaneConfig::None;

if(e.GetId() == XRCID("debugger_win_locals")) winid = DebuggerPaneConfig::Locals;
if(e.GetId() == XRCID("debugger_win_locals"))
winid = DebuggerPaneConfig::Locals;

if(e.GetId() == XRCID("debugger_win_watches")) winid = DebuggerPaneConfig::Watches;
if(e.GetId() == XRCID("debugger_win_watches"))
winid = DebuggerPaneConfig::Watches;

if(e.GetId() == XRCID("debugger_win_output")) winid = DebuggerPaneConfig::Output;
if(e.GetId() == XRCID("debugger_win_output"))
winid = DebuggerPaneConfig::Output;

if(e.GetId() == XRCID("debugger_win_threads")) winid = DebuggerPaneConfig::Threads;
if(e.GetId() == XRCID("debugger_win_threads"))
winid = DebuggerPaneConfig::Threads;

if(e.GetId() == XRCID("debugger_win_callstack")) winid = DebuggerPaneConfig::Callstack;
if(e.GetId() == XRCID("debugger_win_callstack"))
winid = DebuggerPaneConfig::Callstack;

if(e.GetId() == XRCID("debugger_win_memory")) winid = DebuggerPaneConfig::Memory;
if(e.GetId() == XRCID("debugger_win_memory"))
winid = DebuggerPaneConfig::Memory;

if(e.GetId() == XRCID("debugger_win_breakpoints")) winid = DebuggerPaneConfig::Breakpoints;
if(e.GetId() == XRCID("debugger_win_breakpoints"))
winid = DebuggerPaneConfig::Breakpoints;

if(e.GetId() == XRCID("debugger_win_asciiview")) winid = DebuggerPaneConfig::AsciiViewer;
if(e.GetId() == XRCID("debugger_win_asciiview"))
winid = DebuggerPaneConfig::AsciiViewer;

if(winid != DebuggerPaneConfig::None) {
e.Check(item.IsDebuggerWindowShown(winid));
Expand Down
23 changes: 10 additions & 13 deletions Plugin/clKeyboardBindingConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ clKeyboardBindingConfig& clKeyboardBindingConfig::Load()
binding.action = item.namedObject("description").toString();
binding.accel = item.namedObject("accelerator").toString();
binding.parentMenu = item.namedObject("parentMenu").toString();
binding.id = item.namedObject("actionId").toInt(wxNOT_FOUND);
if(binding.id != wxNOT_FOUND) {
m_bindings.insert(std::make_pair(binding.id, binding));
}
binding.resourceID = item.namedObject("resourceID").toString();
m_bindings.insert(std::make_pair(binding.resourceID, binding));
}
}

#if 0
{
JSONElement globals = root.toElement().namedObject("globals");
int arrSize = globals.arraySize();
Expand All @@ -41,13 +39,11 @@ clKeyboardBindingConfig& clKeyboardBindingConfig::Load()
binding.action = item.namedObject("description").toString();
binding.accel = item.namedObject("accelerator").toString();
binding.parentMenu = item.namedObject("parentMenu").toString();
binding.id = item.namedObject("actionId").toInt(wxNOT_FOUND);
if(binding.id != wxNOT_FOUND) {
m_globalBindings.insert(std::make_pair(binding.id, binding));
}
binding.resourceID = item.namedObject("actionId").toString();
m_globalBindings.insert(std::make_pair(binding.resourceID, binding));
}
}

#endif
return *this;
}

Expand All @@ -61,11 +57,11 @@ clKeyboardBindingConfig& clKeyboardBindingConfig::Save()
JSONElement binding = JSONElement::createObject();
binding.addProperty("description", iter->second.action);
binding.addProperty("accelerator", iter->second.accel);
binding.addProperty("actionId", iter->second.id);
binding.addProperty("resourceID", iter->second.resourceID);
binding.addProperty("parentMenu", iter->second.parentMenu);
menuArr.arrayAppend(binding);
}

#if 0
JSONElement globalsArr = JSONElement::createArray("globals");
mainObj.append(globalsArr);

Expand All @@ -74,10 +70,11 @@ clKeyboardBindingConfig& clKeyboardBindingConfig::Save()
JSONElement binding = JSONElement::createObject();
binding.addProperty("description", iter->second.action);
binding.addProperty("accelerator", iter->second.accel);
binding.addProperty("actionId", iter->second.id);
binding.addProperty("resourceID", iter->second.resourceID);
binding.addProperty("parentMenu", iter->second.parentMenu);
globalsArr.arrayAppend(binding);
}
#endif

wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "keybindings.conf");
fn.AppendDir("config");
Expand Down
Loading

0 comments on commit 3ee43d3

Please sign in to comment.