mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 18:46:29 +03:00
Register debugger commands globally.
This commit is contained in:
@@ -176,6 +176,8 @@ DebuggerPlugin::~DebuggerPlugin() {
|
||||
|
||||
if ( SceneManager::existsSingleton() && !SceneManager::instance()->isShuttingDown() &&
|
||||
getPluginContext() && getPluginContext()->getMainLayout() ) {
|
||||
getPluginContext()->getMainLayout()->unsetCommands( mRegisteredCommands );
|
||||
|
||||
for ( const auto& kb : mKeyBindings )
|
||||
getPluginContext()->getMainLayout()->getKeyBindings().removeCommandKeybind( kb.first );
|
||||
}
|
||||
@@ -695,6 +697,7 @@ PluginRequestHandle DebuggerPlugin::processMessage( const PluginMessage& msg ) {
|
||||
break;
|
||||
}
|
||||
case ecode::PluginMessageType::UIReady: {
|
||||
registerCommands( getPluginContext()->getMainLayout() );
|
||||
for ( const auto& kb : mKeyBindings ) {
|
||||
getPluginContext()->getMainLayout()->getKeyBindings().addKeybindString( kb.second,
|
||||
kb.first );
|
||||
@@ -1394,8 +1397,15 @@ DebuggerPlugin::needsToResolveInputs( nlohmann::json& json,
|
||||
return inputs;
|
||||
}
|
||||
|
||||
void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) {
|
||||
doc->setCommand( "debugger-continue-interrupt", [this] {
|
||||
template <typename TCommandRegister, typename Cmd, typename CmdCb>
|
||||
void DebuggerPlugin::registerCommand( TCommandRegister* doc, Cmd cmd, CmdCb cb ) {
|
||||
doc->setCommand( cmd, cb );
|
||||
mRegisteredCommands.push_back( cmd );
|
||||
}
|
||||
|
||||
template <typename TCommandRegister>
|
||||
void DebuggerPlugin::registerCommands( TCommandRegister* executer ) {
|
||||
registerCommand( executer, "debugger-continue-interrupt", [this] {
|
||||
if ( mDebugger && mListener ) {
|
||||
if ( mListener->isStopped() ) {
|
||||
resume( mListener->getCurrentThreadId() );
|
||||
@@ -1431,15 +1441,15 @@ void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) {
|
||||
}
|
||||
} );
|
||||
|
||||
doc->setCommand( "debugger-start", [this] {
|
||||
registerCommand( executer, "debugger-start", [this] {
|
||||
if ( mDebugger )
|
||||
exitDebugger( true );
|
||||
runCurrentConfig();
|
||||
} );
|
||||
|
||||
doc->setCommand( "debugger-stop", [this] { exitDebugger( true ); } );
|
||||
registerCommand( executer, "debugger-stop", [this] { exitDebugger( true ); } );
|
||||
|
||||
doc->setCommand( "debugger-start-stop", [this] {
|
||||
registerCommand( executer, "debugger-start-stop", [this] {
|
||||
if ( mDebugger && mDebugger->started() ) {
|
||||
exitDebugger( true );
|
||||
} else {
|
||||
@@ -1447,6 +1457,35 @@ void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) {
|
||||
}
|
||||
} );
|
||||
|
||||
registerCommand( executer, "debugger-step-over", [this] {
|
||||
if ( mDebugger && mListener && mListener->isStopped() )
|
||||
mDebugger->stepOver( mListener->getCurrentThreadId() );
|
||||
} );
|
||||
|
||||
registerCommand( executer, "debugger-step-into", [this] {
|
||||
if ( mDebugger && mListener && mListener->isStopped() )
|
||||
mDebugger->stepInto( mListener->getCurrentThreadId() );
|
||||
} );
|
||||
|
||||
registerCommand( executer, "debugger-step-out", [this] {
|
||||
if ( mDebugger && mListener && mListener->isStopped() )
|
||||
mDebugger->stepOut( mListener->getCurrentThreadId() );
|
||||
} );
|
||||
|
||||
registerCommand( executer, "toggle-status-app-debugger", [this] {
|
||||
if ( getStatusDebuggerController() )
|
||||
getStatusDebuggerController()->toggle();
|
||||
} );
|
||||
|
||||
registerCommand( executer, "show-debugger-tab", [this] {
|
||||
if ( mTab )
|
||||
mTab->setTabSelected();
|
||||
} );
|
||||
}
|
||||
|
||||
void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) {
|
||||
registerCommands( doc );
|
||||
|
||||
doc->setCommand( "debugger-breakpoint-toggle", [doc, this] {
|
||||
if ( setBreakpoint( doc, doc->getSelection().start().line() + 1 ) )
|
||||
getUISceneNode()->getRoot()->invalidateDraw();
|
||||
@@ -1457,31 +1496,6 @@ void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) {
|
||||
getUISceneNode()->getRoot()->invalidateDraw();
|
||||
} );
|
||||
|
||||
doc->setCommand( "debugger-step-over", [this] {
|
||||
if ( mDebugger && mListener && mListener->isStopped() )
|
||||
mDebugger->stepOver( mListener->getCurrentThreadId() );
|
||||
} );
|
||||
|
||||
doc->setCommand( "debugger-step-into", [this] {
|
||||
if ( mDebugger && mListener && mListener->isStopped() )
|
||||
mDebugger->stepInto( mListener->getCurrentThreadId() );
|
||||
} );
|
||||
|
||||
doc->setCommand( "debugger-step-out", [this] {
|
||||
if ( mDebugger && mListener && mListener->isStopped() )
|
||||
mDebugger->stepOut( mListener->getCurrentThreadId() );
|
||||
} );
|
||||
|
||||
doc->setCommand( "toggle-status-app-debugger", [this] {
|
||||
if ( getStatusDebuggerController() )
|
||||
getStatusDebuggerController()->toggle();
|
||||
} );
|
||||
|
||||
doc->setCommand( "show-debugger-tab", [this]() {
|
||||
if ( mTab )
|
||||
mTab->setTabSelected();
|
||||
} );
|
||||
|
||||
Lock l( mClientsMutex );
|
||||
mClients[doc] = std::make_unique<DebuggerPluginClient>( this, doc );
|
||||
doc->registerClient( mClients[doc].get() );
|
||||
|
||||
@@ -135,6 +135,7 @@ class DebuggerPlugin : public PluginBase {
|
||||
std::string mLastStateJsonDump;
|
||||
std::string mCurDebugger;
|
||||
std::string mCurConfiguration;
|
||||
std::vector<std::string> mRegisteredCommands;
|
||||
|
||||
class DebuggerPluginClient : public TextDocument::Client {
|
||||
public:
|
||||
@@ -290,6 +291,12 @@ class DebuggerPlugin : public PluginBase {
|
||||
|
||||
bool replaceInVal( std::string& val, const std::optional<ProjectBuildStep>& runConfig,
|
||||
ProjectBuild* buildConfig, int randomPort );
|
||||
|
||||
template<typename TCommandRegister, typename Cmd, typename CmdCb>
|
||||
void registerCommand( TCommandRegister* doc, Cmd cmd, CmdCb cb );
|
||||
|
||||
template<typename TCommandRegister>
|
||||
void registerCommands( TCommandRegister* doc );
|
||||
};
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
Reference in New Issue
Block a user