mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 02:26:29 +03:00
More improvements.
This commit is contained in:
@@ -281,7 +281,8 @@ void UIAbstractTableView::updateHeaderSize() {
|
||||
Float totalWidth = 0;
|
||||
for ( size_t i = 0; i < count; i++ ) {
|
||||
const ColumnData& col = columnData( i );
|
||||
totalWidth += col.width;
|
||||
if ( col.visible )
|
||||
totalWidth += col.width;
|
||||
}
|
||||
mHeader->setPixelsSize( totalWidth, getHeaderHeight() );
|
||||
}
|
||||
|
||||
@@ -578,9 +578,7 @@ void App::initPluginManager() {
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef EE_DEBUG
|
||||
mPluginManager->registerPlugin( DebuggerPlugin::Definition() );
|
||||
#endif
|
||||
mPluginManager->registerPlugin( LinterPlugin::Definition() );
|
||||
mPluginManager->registerPlugin( FormatterPlugin::Definition() );
|
||||
mPluginManager->registerPlugin( AutoCompletePlugin::Definition() );
|
||||
|
||||
@@ -22,23 +22,20 @@ class ThreadsModel : public Model {
|
||||
mThreads( threads ), mi18nFn( std::move( fn ) ) {}
|
||||
|
||||
virtual size_t rowCount( const ModelIndex& ) const { return mThreads.size(); }
|
||||
virtual size_t columnCount( const ModelIndex& ) const { return 2; }
|
||||
virtual size_t columnCount( const ModelIndex& ) const { return 1; }
|
||||
|
||||
virtual std::string columnName( const size_t& colIdx ) const {
|
||||
switch ( colIdx ) {
|
||||
case 0:
|
||||
return mi18nFn( "id", "ID" );
|
||||
case 1:
|
||||
return mi18nFn( "name", "Name" );
|
||||
return mi18nFn( "thread_id", "Thread ID" );
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual Variant data( const ModelIndex& modelIndex, ModelRole role ) const {
|
||||
if ( role == ModelRole::Display ) {
|
||||
return modelIndex.column() == 0
|
||||
? Variant( String::toString( mThreads[modelIndex.row()].id ) )
|
||||
: Variant( mThreads[modelIndex.row()].name.c_str() );
|
||||
if ( role == ModelRole::Display && modelIndex.column() == 0 ) {
|
||||
return Variant( String::format( "#%d (%s)", mThreads[modelIndex.row()].id,
|
||||
mThreads[modelIndex.row()].name.c_str() ) );
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -60,6 +57,22 @@ class ThreadsModel : public Model {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
const Thread& getThread( size_t index ) const {
|
||||
Lock l( mResourceLock );
|
||||
eeASSERT( index < mThreads.size() );
|
||||
return mThreads[index];
|
||||
}
|
||||
|
||||
ModelIndex fromThreadId( int id ) {
|
||||
Lock l( mResourceLock );
|
||||
for ( size_t i = 0; i < mThreads.size(); i++ ) {
|
||||
const Thread& thread = mThreads[i];
|
||||
if ( thread.id == id )
|
||||
return index( i );
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<Thread> mThreads;
|
||||
i18nFn mi18nFn;
|
||||
@@ -136,6 +149,12 @@ class StackModel : public Model {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
const StackFrame& getStack( size_t index ) const {
|
||||
Lock l( mResourceLock );
|
||||
eeASSERT( index < mStack.stackFrames.size() );
|
||||
return mStack.stackFrames[index];
|
||||
}
|
||||
|
||||
protected:
|
||||
StackTraceInfo mStack;
|
||||
i18nFn mi18nFn;
|
||||
@@ -148,6 +167,10 @@ DebuggerClientListener::DebuggerClientListener( DebuggerClient* client, Debugger
|
||||
|
||||
DebuggerClientListener::~DebuggerClientListener() {
|
||||
resetState();
|
||||
if ( !mPlugin->isShuttingDown() && getStatusDebuggerController() ) {
|
||||
getStatusDebuggerController()->getUIThreads()->removeEventsOfType( Event::OnModelEvent );
|
||||
getStatusDebuggerController()->getUIStack()->removeEventsOfType( Event::OnModelEvent );
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerClientListener::stateChanged( DebuggerClient::State state ) {
|
||||
@@ -174,8 +197,27 @@ void DebuggerClientListener::stateChanged( DebuggerClient::State state ) {
|
||||
} );
|
||||
}
|
||||
|
||||
getStatusDebuggerController()->getUIThreads()->setModel( mThreadsModel );
|
||||
getStatusDebuggerController()->getUIStack()->setModel( mStackModel );
|
||||
UITableView* uiThreads = getStatusDebuggerController()->getUIThreads();
|
||||
uiThreads->setModel( mThreadsModel );
|
||||
|
||||
uiThreads->removeEventsOfType( Event::OnModelEvent );
|
||||
uiThreads->onModelEvent( [this]( const ModelEvent* modelEvent ) {
|
||||
if ( modelEvent->getModelEventType() == Abstract::ModelEventType::Open ) {
|
||||
auto model = static_cast<const ThreadsModel*>( modelEvent->getModel() );
|
||||
mClient->stackTrace( model->getThread( modelEvent->getModelIndex().row() ).id );
|
||||
}
|
||||
} );
|
||||
|
||||
UITableView* uiStack = getStatusDebuggerController()->getUIStack();
|
||||
uiStack->setModel( mStackModel );
|
||||
uiStack->removeEventsOfType( Event::OnModelEvent );
|
||||
uiStack->onModelEvent( [this]( const ModelEvent* modelEvent ) {
|
||||
if ( modelEvent->getModelEventType() == Abstract::ModelEventType::Open ) {
|
||||
auto model = static_cast<const StackModel*>( modelEvent->getModel() );
|
||||
const auto& stack = model->getStack( modelEvent->getModelIndex().row() );
|
||||
changeScope( stack );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -199,8 +241,11 @@ void DebuggerClientListener::debuggeeTerminated() {}
|
||||
void DebuggerClientListener::capabilitiesReceived( const Capabilities& /*capabilities*/ ) {}
|
||||
|
||||
void DebuggerClientListener::resetState() {
|
||||
mStoppedData = {};
|
||||
mCurrentScopePos = {};
|
||||
mThreadsModel->resetThreads();
|
||||
mStackModel->resetStack();
|
||||
mScope.clear();
|
||||
}
|
||||
|
||||
void DebuggerClientListener::debuggeeExited( int /*exitCode*/ ) {
|
||||
@@ -212,7 +257,7 @@ void DebuggerClientListener::debuggeeStopped( const StoppedEvent& event ) {
|
||||
Log::debug( "DebuggerClientListener::debuggeeStopped: reason %s", event.reason );
|
||||
|
||||
mStoppedData = event;
|
||||
mCurrentThreadId = mStoppedData->threadId ? *mStoppedData->threadId : 1;
|
||||
changeThread( mStoppedData->threadId ? *mStoppedData->threadId : 1 );
|
||||
|
||||
if ( mPausedToRefreshBreakpoints ) {
|
||||
mPlugin->sendPendingBreakpoints();
|
||||
@@ -229,12 +274,6 @@ void DebuggerClientListener::debuggeeStopped( const StoppedEvent& event ) {
|
||||
}
|
||||
|
||||
void DebuggerClientListener::debuggeeContinued( const ContinuedEvent& ) {
|
||||
mStoppedData = {};
|
||||
mCurrentScopePos = {};
|
||||
|
||||
// Reset models
|
||||
mScope.clear();
|
||||
|
||||
resetState();
|
||||
|
||||
UISceneNode* sceneNode = mPlugin->getUISceneNode();
|
||||
@@ -261,21 +300,40 @@ void DebuggerClientListener::threads( std::vector<Thread>&& threads ) {
|
||||
mThreadsModel->setThreads( std::move( threads ) );
|
||||
}
|
||||
|
||||
void DebuggerClientListener::stackTrace( const int /*threadId*/, StackTraceInfo&& stack ) {
|
||||
if ( !stack.stackFrames.empty() ) {
|
||||
auto& f = stack.stackFrames[0];
|
||||
void DebuggerClientListener::changeScope( const StackFrame& f ) {
|
||||
mClient->scopes( f.id );
|
||||
|
||||
// mClient->scopes( f.id );
|
||||
if ( !f.source )
|
||||
return;
|
||||
|
||||
TextRange range{ { f.line - 1, f.column }, { f.line - 1, f.column } };
|
||||
std::string path( f.source->path );
|
||||
|
||||
mPlugin->getUISceneNode()->runOnMainThread(
|
||||
[this, path, range] { mPlugin->getPluginContext()->focusOrLoadFile( path, range ); } );
|
||||
|
||||
mCurrentScopePos = { f.source->path, f.line };
|
||||
|
||||
if ( getStatusDebuggerController() && getStatusDebuggerController()->getUIStack() )
|
||||
getStatusDebuggerController()->getUIStack()->setSelection( mStackModel->index( f.id ) );
|
||||
}
|
||||
|
||||
void DebuggerClientListener::changeThread( int id ) {
|
||||
mCurrentThreadId = id;
|
||||
if ( getStatusDebuggerController() && getStatusDebuggerController()->getUIThreads() ) {
|
||||
getStatusDebuggerController()->getUIThreads()->setSelection(
|
||||
mThreadsModel->fromThreadId( id ) );
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerClientListener::stackTrace( const int threadId, StackTraceInfo&& stack ) {
|
||||
changeThread( threadId );
|
||||
|
||||
for ( const auto& f : stack.stackFrames ) {
|
||||
// Jump to the first stack frame that can be read
|
||||
if ( f.source ) {
|
||||
TextRange range{ { f.line - 1, f.column }, { f.line - 1, f.column } };
|
||||
std::string path( f.source->path );
|
||||
|
||||
mPlugin->getUISceneNode()->runOnMainThread( [this, path, range] {
|
||||
mPlugin->getPluginContext()->focusOrLoadFile( path, range );
|
||||
} );
|
||||
|
||||
mCurrentScopePos = { f.source->path, f.line };
|
||||
changeScope( f );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,10 @@ class DebuggerClientListener : public DebuggerClient::Listener {
|
||||
StatusDebuggerController* getStatusDebuggerController() const;
|
||||
|
||||
void resetState();
|
||||
|
||||
void changeScope( const StackFrame& f );
|
||||
|
||||
void changeThread( int id );
|
||||
};
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
@@ -607,7 +607,7 @@ void DebuggerPlugin::drawLineNumbersBefore( UICodeEditor* editor,
|
||||
|
||||
Float dim = radius * 2;
|
||||
Float gutterSpace = editor->getGutterSpace( this );
|
||||
lnPos.x += ( gutterSpace - dim ) * 0.5f;
|
||||
lnPos.x += editor->getLineNumberPaddingLeft() + ( gutterSpace - dim ) * 0.5f;
|
||||
lnPos.y += ( lineHeight - dim ) * 0.5f;
|
||||
|
||||
Triangle2f tri;
|
||||
@@ -774,7 +774,6 @@ void DebuggerPlugin::hideStatusBarElement() {
|
||||
StatusDebuggerController* DebuggerPlugin::getStatusDebuggerController() const {
|
||||
auto debuggerElement =
|
||||
getPluginContext()->getStatusBar()->getStatusBarElement( "status_app_debugger" );
|
||||
eeASSERT( debuggerElement );
|
||||
return static_cast<StatusDebuggerController*>( debuggerElement.get() );
|
||||
}
|
||||
} // namespace ecode
|
||||
|
||||
@@ -34,12 +34,13 @@ void StatusDebuggerController::createContainer() {
|
||||
if ( mContainer )
|
||||
return;
|
||||
const auto XML = R"xml(
|
||||
<TabWidget id="app_debugger" layout_width="match_parent" layout_height="0dp" layout_weight="1">
|
||||
<TableView id="debugger_stack" layout_width="mp" layout_height="mp" />
|
||||
<TableView id="debugger_threads" layout_width="mp" layout_height="mp" />
|
||||
<TabWidget id="app_debugger" layout_width="mp" layout_height="mp">
|
||||
<Splitter id="debugger_threads_and_stack" layout_width="mp" lh="mp" splitter-partition="15%">
|
||||
<TableView id="debugger_threads" layout_width="mp" layout_height="mp" />
|
||||
<TableView id="debugger_stack" layout_width="mp" layout_height="mp" />
|
||||
</Splitter>
|
||||
<TableView id="debugger_breakpoints" layout_width="mp" layout_height="mp" />
|
||||
<Tab text="@string(stack, Stack)" owns="debugger_stack" />
|
||||
<Tab text="@string(threads, Threads)" owns="debugger_threads" />
|
||||
<Tab text="@string(threads_and_stack, Threads & Stack)" owns="debugger_threads_and_stack" />
|
||||
<Tab text="@string(breakpoints, Breakpoints)" owns="debugger_breakpoints" />
|
||||
</TabWidget>
|
||||
)xml";
|
||||
@@ -53,32 +54,18 @@ void StatusDebuggerController::createContainer() {
|
||||
->loadLayoutFromString( XML, mMainSplitter )
|
||||
->asType<UILinearLayout>();
|
||||
|
||||
mContainer->bind( "debugger_threads_and_stack", mUIThreadsSplitter );
|
||||
mContainer->bind( "debugger_threads", mUIThreads );
|
||||
mContainer->bind( "debugger_stack", mUIStack );
|
||||
mContainer->bind( "debugger_breakpoints", mUIBreakpoints );
|
||||
|
||||
mContainer->on( Event::OnSizeChange, [this]( const Event* event ) {
|
||||
if ( !mContainer->isVisible() || mContainer->getSize().getWidth() == 0.f )
|
||||
return;
|
||||
mUIThreads->setAutoExpandOnSingleColumn( true );
|
||||
|
||||
const Float width = mContainer->getPixelsSize().getWidth();
|
||||
mUIStack->setAutoColumnsWidth( true );
|
||||
mUIStack->setMainColumn( 1 );
|
||||
|
||||
mUIThreads->setColumnWidth( 0, width * 0.1 );
|
||||
mUIThreads->setColumnWidth( 1, eefloor( width * 0.88 ) );
|
||||
|
||||
mUIStack->setColumnWidth( 0, width * 0.05 );
|
||||
mUIStack->setColumnWidth( 1, width * 0.3 );
|
||||
mUIStack->setColumnWidth( 2, width * 0.15 );
|
||||
mUIStack->setColumnWidth( 3, eefloor( width * 0.3 ) );
|
||||
mUIStack->setColumnWidth( 4, width * 0.08 );
|
||||
mUIStack->setColumnWidth( 5, width * 0.08 );
|
||||
|
||||
mUIBreakpoints->setColumnWidth( 0, width * 0.1 );
|
||||
mUIBreakpoints->setColumnWidth( 1, eefloor( width * 0.7 ) );
|
||||
mUIBreakpoints->setColumnWidth( 2, eefloor( width * 0.1 ) );
|
||||
|
||||
mContainer->removeEventListener( event->getCallbackId() );
|
||||
} );
|
||||
mUIBreakpoints->setAutoColumnsWidth( true );
|
||||
mUIBreakpoints->setMainColumn( 1 );
|
||||
}
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
@@ -38,6 +38,7 @@ class StatusDebuggerController : public StatusBarElement {
|
||||
UITableView* mUIThreads{ nullptr };
|
||||
UITableView* mUIStack{ nullptr };
|
||||
UITableView* mUIBreakpoints{ nullptr };
|
||||
UISplitter* mUIThreadsSplitter{ nullptr };
|
||||
|
||||
void createContainer();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user