More WIP.

This commit is contained in:
Martín Lucas Golini
2025-01-01 01:44:33 -03:00
parent 469ca05e9f
commit e0eb9d9096
8 changed files with 161 additions and 10 deletions

View File

@@ -1,7 +1,9 @@
#include "../../projectbuild.hpp"
#include "../../uistatusbar.hpp"
#include "busprocess.hpp"
#include "dap/debuggerclientdap.hpp"
#include "debuggerplugin.hpp"
#include "statusdebuggercontroller.hpp"
#include <eepp/system/filesystem.hpp>
#include <eepp/system/scopedop.hpp>
#include <eepp/ui/uidropdownlist.hpp>
@@ -50,6 +52,11 @@ DebuggerPlugin::~DebuggerPlugin() {
if ( mSidePanel && mTab )
mSidePanel->removeTab( mTab );
if ( getManager()->getPluginContext()->getStatusBar() ) {
getManager()->getPluginContext()->getStatusBar()->removeStatusBarElement(
"status_app_debugger" );
}
mDebugger.reset();
mListener.reset();
}
@@ -180,11 +187,21 @@ void DebuggerPlugin::loadDAPConfig( const std::string& path, bool updateConfigFi
PluginRequestHandle DebuggerPlugin::processMessage( const PluginMessage& msg ) {
switch ( msg.type ) {
case PluginMessageType::WorkspaceFolderChanged: {
mProjectPath = msg.asJSON()["folder"];
if ( getUISceneNode() && mSidePanel )
getUISceneNode()->runOnMainThread( [this] {
if ( mProjectPath.empty() )
hideSidePanel();
} );
updateUI();
mInitialized = true;
break;
}
case ecode::PluginMessageType::UIReady: {
updateUI();
if ( !mInitialized )
updateUI();
break;
}
default:
@@ -197,16 +214,23 @@ void DebuggerPlugin::updateUI() {
if ( !getUISceneNode() )
return;
getUISceneNode()->runOnMainThread( [this] { buildSidePanelTab(); } );
getUISceneNode()->runOnMainThread( [this] {
buildSidePanelTab();
buildStatusBar();
} );
}
void DebuggerPlugin::buildSidePanelTab() {
if ( mTabContents && !mTab ) {
if ( mProjectPath.empty() )
return;
UIIcon* icon = findIcon( "debug" );
mTab = mSidePanel->add( i18n( "debugger", "Debugger" ), mTabContents,
icon ? icon->getSize( PixelDensity::dpToPx( 12 ) ) : nullptr );
mTab->setId( "debugger" );
mTab->setTextAsFallback( true );
updateSidePanelTab();
return;
}
if ( mTab )
@@ -229,7 +253,7 @@ void DebuggerPlugin::buildSidePanelTab() {
mTabContents = getUISceneNode()->loadLayoutFromString( STYLE );
mTab = mSidePanel->add( i18n( "debugger", "Debugger" ), mTabContents,
icon ? icon->getSize( PixelDensity::dpToPx( 12 ) ) : nullptr );
mTab->setId( "source_control" );
mTab->setId( "debugger_tab" );
mTab->setTextAsFallback( true );
mTabContents->bind( "debugger_list", mUIDebuggerList );
@@ -238,6 +262,29 @@ void DebuggerPlugin::buildSidePanelTab() {
updateSidePanelTab();
}
void DebuggerPlugin::buildStatusBar() {
if ( mProjectPath.empty() ) {
hideStatusBarElement();
return;
}
if ( getManager()->getPluginContext()->getStatusBar() ) {
auto but = getManager()->getPluginContext()->getStatusBar()->find( "status_app_debugger" );
if ( but ) {
but->setVisible( true );
return;
}
}
auto context = getManager()->getPluginContext();
UIStatusBar* statusBar = context->getStatusBar();
auto debuggerStatusElem = std::make_shared<StatusDebuggerController>(
context->getMainSplitter(), getUISceneNode(), context );
statusBar->insertStatusBarElement( "status_app_debugger", i18n( "debugger", "Debugger" ),
"icon(debug, 11dp)", debuggerStatusElem );
}
void DebuggerPlugin::updateSidePanelTab() {
mUIDebuggerList->getListBox()->clear();
@@ -393,4 +440,12 @@ void DebuggerPlugin::hideSidePanel() {
}
}
void DebuggerPlugin::hideStatusBarElement() {
if ( getManager()->getPluginContext()->getStatusBar() ) {
auto but = getManager()->getPluginContext()->getStatusBar()->find( "status_app_debugger" );
if ( but )
but->setVisible( false );
}
}
} // namespace ecode