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

View File

@@ -49,6 +49,9 @@ class DebuggerPlugin : public PluginBase {
protected:
friend class DebuggerClientListener;
bool mInitialized{ false };
std::string mProjectPath;
std::vector<DapTool> mDaps;
std::unique_ptr<DebuggerClient> mDebugger;
std::unique_ptr<DebuggerClientListener> mListener;
@@ -71,12 +74,16 @@ class DebuggerPlugin : public PluginBase {
void buildSidePanelTab();
void buildStatusBar();
void updateSidePanelTab();
void updateDebuggerConfigurationList();
void hideSidePanel();
void hideStatusBarElement();
void loadDAPConfig( const std::string& path, bool updateConfigFile );
void runConfig( const std::string& debugger, const std::string& configuration );

View File

@@ -0,0 +1,39 @@
#include "statusdebuggercontroller.hpp"
#include "../plugincontextprovider.hpp"
namespace ecode {
StatusDebuggerController::StatusDebuggerController( UISplitter* mainSplitter,
UISceneNode* uiSceneNode,
PluginContextProvider* pluginContext ) :
StatusBarElement( mainSplitter, uiSceneNode, pluginContext ) {}
UIWidget* StatusDebuggerController::getWidget() {
return mContainer;
}
UIWidget* StatusDebuggerController::createWidget() {
if ( nullptr == mContainer )
createContainer();
return mContainer;
}
void StatusDebuggerController::createContainer() {
if ( mContainer )
return;
const auto XML = R"xml(
<hbox id="app_debugger" lw="mp" lh="mp" visible="false">
</hbox>
)xml";
if ( mMainSplitter->getLastWidget() != nullptr ) {
mMainSplitter->getLastWidget()->setVisible( false );
mMainSplitter->getLastWidget()->setParent( mUISceneNode );
}
mContainer = mContext->getUISceneNode()
->loadLayoutFromString( XML, mMainSplitter )
->asType<UILinearLayout>();
}
} // namespace ecode

View File

@@ -0,0 +1,38 @@
#ifndef ECODE_STATUSDEBUGGERCONTROLLER_HPP
#define ECODE_STATUSDEBUGGERCONTROLLER_HPP
#include "../../uistatusbar.hpp"
#include <eepp/system/luapattern.hpp>
#include <eepp/ui/tools/uicodeeditorsplitter.hpp>
#include <eepp/ui/uicodeeditor.hpp>
#include <eepp/ui/uirelativelayout.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uisplitter.hpp>
#include <eepp/ui/uitableview.hpp>
using namespace EE;
using namespace EE::UI;
using namespace EE::UI::Tools;
namespace ecode {
class StatusDebuggerController : public StatusBarElement {
public:
StatusDebuggerController( UISplitter* mainSplitter, UISceneNode* uiSceneNode,
PluginContextProvider* pluginContext );
virtual ~StatusDebuggerController() {};
UIWidget* getWidget();
UIWidget* createWidget();
protected:
UILinearLayout* mContainer{ nullptr };
void createContainer();
};
} // namespace ecode
#endif // ECODE_STATUSDEBUGGERCONTROLLER_HPP