mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
More WIP.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "lspclientplugin.hpp"
|
||||
#include "../../version.hpp"
|
||||
#include "lspclientplugin.hpp"
|
||||
#include <eepp/graphics/primitives.hpp>
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
#include <eepp/system/lock.hpp>
|
||||
@@ -642,11 +642,12 @@ bool LSPClientPlugin::onMouseClick( UICodeEditor* editor, const Vector2i& pos,
|
||||
const bool breadcrumbClick = mBreadcrumb && ( flags & EE_BUTTON_LMASK );
|
||||
const Vector2f localPos( breadcrumbClick ? editor->convertToNodeSpace( pos.asFloat() )
|
||||
: Vector2f::Zero );
|
||||
if ( breadcrumbClick && localPos.y < mPluginTopSpace &&
|
||||
if ( breadcrumbClick && localPos.y >= 0 && localPos.y < mPluginTopSpace &&
|
||||
localPos.x < editor->getTopAreaWidth() ) {
|
||||
const Vector2f downLocalPos( editor->convertToNodeSpace(
|
||||
editor->getEventDispatcher()->getMouseDownPos().asFloat() ) );
|
||||
if ( downLocalPos.y < mPluginTopSpace && downLocalPos.x < editor->getTopAreaWidth() ) {
|
||||
if ( downLocalPos.y >= 0 && downLocalPos.y < mPluginTopSpace &&
|
||||
downLocalPos.x < editor->getTopAreaWidth() ) {
|
||||
editor->getDocument().execute( "lsp-show-document-symbols", editor );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ using namespace EE::UI::Tools;
|
||||
|
||||
namespace ecode {
|
||||
|
||||
class App;
|
||||
|
||||
class StatusAppOutputController : public StatusBarElement {
|
||||
public:
|
||||
StatusAppOutputController( UISplitter* mainSplitter, UISceneNode* uiSceneNode,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "uistatusbar.hpp"
|
||||
#include "globalsearchcontroller.hpp"
|
||||
#include "plugins/plugincontextprovider.hpp"
|
||||
#include "statusappoutputcontroller.hpp"
|
||||
#include "statusbuildoutputcontroller.hpp"
|
||||
#include "statusterminalcontroller.hpp"
|
||||
#include "uistatusbar.hpp"
|
||||
#include "universallocator.hpp"
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <eepp/window/window.hpp>
|
||||
@@ -185,6 +185,7 @@ UIPushButton* UIStatusBar::insertStatusBarElement( std::string id, const String&
|
||||
button->beginAttributesTransaction();
|
||||
button->setText( text );
|
||||
button->setParent( this )->setId( id );
|
||||
button->setClass( "status_but" );
|
||||
UIWidget* statusSep = findByClass( "status_sep" );
|
||||
if ( statusSep )
|
||||
button->toPosition( statusSep->getNodeIndex() );
|
||||
@@ -198,7 +199,11 @@ UIPushButton* UIStatusBar::insertStatusBarElement( std::string id, const String&
|
||||
}
|
||||
|
||||
void UIStatusBar::removeStatusBarElement( const std::string& id ) {
|
||||
mElements.erase( id );
|
||||
auto elemIt = mElements.find( id );
|
||||
if ( elemIt != mElements.end() ) {
|
||||
elemIt->second.first->close();
|
||||
mElements.erase( elemIt );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
Reference in New Issue
Block a user