Register global keybindings.

This commit is contained in:
Martín Lucas Golini
2025-01-05 17:22:21 -03:00
parent dafd342960
commit 424b50b7e8
4 changed files with 26 additions and 4 deletions
+1 -2
View File
@@ -15,7 +15,6 @@
#include <eepp/ui/doc/languagessyntaxhighlighting.hpp>
#include <filesystem>
#include <iostream>
#include <nlohmann/json.hpp>
//! 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 {
@@ -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 <eepp/graphics/primitives.hpp>
#include <eepp/system/filesystem.hpp>
@@ -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:
@@ -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<std::string> args;
@@ -66,7 +72,7 @@ class DebuggerPlugin : public PluginBase {
UIDropDownList* mUIDebuggerList{ nullptr };
UIDropDownList* mUIDebuggerConfList{ nullptr };
UIPushButton* mRunButton{ nullptr };
UnorderedMap<std::string, UnorderedSet<SourceBreakpointStateful>> mBreakpoints;
UnorderedMap<std::string, UnorderedSet<dap::SourceBreakpointStateful>> mBreakpoints;
UnorderedSet<std::string> mPendingBreakpoints;
Mutex mBreakpointsMutex;
@@ -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