From 424b50b7e88249fd5e7fd96d7c4bdf5abdb5189f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 5 Jan 2025 17:22:21 -0300 Subject: [PATCH] Register global keybindings. --- src/tools/ecode/ecode.cpp | 3 +-- src/tools/ecode/plugins/debugger/debuggerplugin.cpp | 13 +++++++++++++ src/tools/ecode/plugins/debugger/debuggerplugin.hpp | 10 ++++++++-- src/tools/ecode/plugins/plugincontextprovider.hpp | 4 ++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 7dcc32ca1..33c35831c 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -15,7 +15,6 @@ #include #include #include -#include //! Plugins #include "plugins/autocomplete/autocompleteplugin.hpp" @@ -715,7 +714,7 @@ std::string App::getKeybind( const std::string& command ) { auto it = mKeybindingsInvert.find( command ); if ( it != mKeybindingsInvert.end() ) return KeyBindings::keybindFormat( it->second ); - return ""; + return mMainLayout->getKeyBindings().getCommandKeybindString( command ); } ProjectDirectoryTree* App::getDirTree() const { diff --git a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp index 66aaabd9e..ff102f827 100644 --- a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp +++ b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp @@ -2,8 +2,10 @@ #include "../../notificationcenter.hpp" #include "../../projectbuild.hpp" #include "../../uistatusbar.hpp" +#include "../../widgetcommandexecuter.hpp" #include "busprocess.hpp" #include "dap/debuggerclientdap.hpp" +#include "debuggerclientlistener.hpp" #include "statusdebuggercontroller.hpp" #include #include @@ -111,6 +113,11 @@ DebuggerPlugin::~DebuggerPlugin() { mDebugger.reset(); mListener.reset(); + + if ( !isShuttingDown() && getPluginContext()->getMainLayout() ) { + for ( const auto& kb : mKeyBindings ) + getPluginContext()->getMainLayout()->getKeyBindings().removeCommandKeybind( kb.first ); + } } void DebuggerPlugin::load( PluginManager* pluginManager ) { @@ -294,8 +301,14 @@ PluginRequestHandle DebuggerPlugin::processMessage( const PluginMessage& msg ) { break; } case ecode::PluginMessageType::UIReady: { + for ( const auto& kb : mKeyBindings ) { + getPluginContext()->getMainLayout()->getKeyBindings().addKeybindString( kb.second, + kb.first ); + } + if ( !mInitialized ) updateUI(); + break; } default: diff --git a/src/tools/ecode/plugins/debugger/debuggerplugin.hpp b/src/tools/ecode/plugins/debugger/debuggerplugin.hpp index 29bcc63ab..a893d532d 100644 --- a/src/tools/ecode/plugins/debugger/debuggerplugin.hpp +++ b/src/tools/ecode/plugins/debugger/debuggerplugin.hpp @@ -2,13 +2,19 @@ #include "../plugin.hpp" #include "../pluginmanager.hpp" -#include "debuggerclientlistener.hpp" +#include "statusdebuggercontroller.hpp" using namespace EE::UI::Models; using namespace EE::UI; namespace ecode { +class DebuggerClient; +class DebuggerClientListener; +namespace dap { +class SourceBreakpointStateful; +} + struct DapRunConfig { std::string command; std::vector args; @@ -66,7 +72,7 @@ class DebuggerPlugin : public PluginBase { UIDropDownList* mUIDebuggerList{ nullptr }; UIDropDownList* mUIDebuggerConfList{ nullptr }; UIPushButton* mRunButton{ nullptr }; - UnorderedMap> mBreakpoints; + UnorderedMap> mBreakpoints; UnorderedSet mPendingBreakpoints; Mutex mBreakpointsMutex; diff --git a/src/tools/ecode/plugins/plugincontextprovider.hpp b/src/tools/ecode/plugins/plugincontextprovider.hpp index 57d0391b3..aa5481ea1 100644 --- a/src/tools/ecode/plugins/plugincontextprovider.hpp +++ b/src/tools/ecode/plugins/plugincontextprovider.hpp @@ -49,6 +49,7 @@ class ProjectBuildManager; class NotificationCenter; class ProjectDirectoryTree; struct TerminalConfig; +class UIMainLayout; class PluginContextProvider { public: @@ -120,6 +121,9 @@ class PluginContextProvider { virtual void focusOrLoadFile( const std::string& path, const TextRange& range = {} ) = 0; virtual void runCommand( const std::string& command ) = 0; + + virtual UIMainLayout* getMainLayout() const = 0; + }; } // namespace ecode