diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index ff9fa0b7..a02e6708 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -33,8 +33,9 @@ void Debugger::start() tr("Can''t find debugger in : \"%1\"").arg(debuggerPath)); return; } - mReader = std::make_shared(); + mReader = new DebugReader(this); mReader->setDebuggerPath(debuggerPath); + connect(mReader, &QThread::finished,this,&Debugger::stop); mReader->start(); @@ -52,7 +53,7 @@ void Debugger::start() //Reader.Resume; //Reader.OnInvalidateAllVars := OnInvalidateAllVars; -//MainForm.UpdateAppTitle; + pMainWindow->updateAppTitle(); //Application.HintHidePause := 5000; } @@ -61,27 +62,22 @@ void Debugger::stop() { if (mExecuting) { mExecuting = false; - if WatchVarList.Count = 0 then // nothing worth showing, restore view - MainForm.LeftPageControl.ActivePageIndex := LeftPageIndexBackup; - // Close CPU window - if Assigned(CPUForm) then - CPUForm.Close; + //stop debugger + mReader->stopDebug(); + mReader->deleteLater(); + mReader=nullptr; +// if WatchVarList.Count = 0 then // nothing worth showing, restore view +// MainForm.LeftPageControl.ActivePageIndex := LeftPageIndexBackup; - // stop gdb - TerminateProcess(fProcessID, 0); - - Reader.Terminate; - Reader := nil; +// // Close CPU window +// if Assigned(CPUForm) then +// CPUForm.Close; // Free resources - CloseHandle(fProcessID); - CloseHandle(fOutputRead); - CloseHandle(fInputWrite); + pMainWindow->removeActiveBreakpoints(); - MainForm.RemoveActiveBreakpoints; - - MainForm.UpdateAppTitle; + pMainWindow->updateAppTitle(); MainForm.OnBacktraceReady; diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 77f2638e..a17d0df0 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -126,7 +126,6 @@ public: explicit Debugger(QObject *parent = nullptr); // Play/pause void start(); - void stop(); void sendCommand(const QString& command, const QString& params, bool updateWatch = true, bool showInConsole = false, @@ -147,7 +146,8 @@ public: BacktraceModel* backtraceModel(); BreakpointModel* breakpointModel(); - +public slots: + void stop(); signals: private: @@ -162,7 +162,7 @@ private: BreakpointModel* mBreakpointModel; bool mUseUTF8; BacktraceModel* mBacktraceModel; - PDebugReader mReader; + DebugReader* mReader; }; class DebugReader : public QThread diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 89d552e6..71eb1714 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -57,8 +57,9 @@ Editor::Editor(QWidget *parent, const QString& filename, mInProject(inProject), mIsNew(isNew), mSyntaxErrorColor(QColorConstants::Red), - mSyntaxWaringColor("orange"), - mLineCount(0) + mSyntaxWarningColor("orange"), + mLineCount(0), + mActiveBreakpointLine(-1) { if (mFilename.isEmpty()) { newfileCount++; @@ -373,7 +374,9 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y) return; } - if (hasBreakpoint(aLine)) { + if (mActiveBreakpointLine == aLine) { + painter.drawPixmap(X,Y,*(pIconsManager->activeBreakpoint())); + } else if (hasBreakpoint(aLine)) { painter.drawPixmap(X,Y,*(pIconsManager->breakpoint())); } // if fActiveLine = Line then begin // prefer active line over breakpoints @@ -432,7 +435,7 @@ void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList) if (issue->issueType == CompileIssueType::Error) { p->color = mSyntaxErrorColor; } else { - p->color = mSyntaxWaringColor; + p->color = mSyntaxWarningColor; } p->type = SynEditingAreaType::eatWaveUnderLine; areaList.append(p); @@ -442,7 +445,20 @@ void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList) bool Editor::onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgroundColor) { - + if (Line == mActiveBreakpointLine) { + foreground = mActiveBreakpointForegroundColor; + backgroundColor = mActiveBreakpointBackgroundColor; + } else if (hasBreakpoint(Line)) { + foreground = mBreakpointForegroundColor; + backgroundColor = mBreakpointBackgroundColor; + } +// end else if Line = fErrorLine then begin +// StrToThemeColor(tc, devEditor.Syntax.Values[cErr]); +// BG := tc.Background; +// FG := tc.Foreground; +// if (BG <> clNone) or (FG<>clNone) then +// Special := TRUE; +// end; } void Editor::copyToClipboard() @@ -1196,6 +1212,16 @@ bool Editor::hasBreakpoint(int line) return mBreakpointLines.contains(line); } +void Editor::removeBreakpointFocus() +{ + if (mActiveBreakpointLine!=-1) { + int oldLine = mActiveBreakpointLine; + mActiveBreakpointLine = -1; + invalidateGutterLine(oldLine); + invalidateLine(oldLine); + } +} + void Editor::applySettings() { SynEditorOptions options = eoAltSetsColumnMode | @@ -1272,6 +1298,24 @@ void Editor::applyColorScheme(const QString& schemeName) if (item) { codeFolding().indentGuidesColor = item->foreground(); } + item = pColorManager->getItem(schemeName,COLOR_SCHEME_ERROR); + if (item) { + this->mSyntaxErrorColor = item->foreground(); + } + item = pColorManager->getItem(schemeName,COLOR_SCHEME_WARNING); + if (item) { + this->mSyntaxWarningColor = item->foreground(); + } + item = pColorManager->getItem(schemeName,COLOR_SCHEME_ACTIVE_BREAKPOINT); + if (item) { + this->mActiveBreakpointForegroundColor = item->foreground(); + this->mActiveBreakpointBackgroundColor = item->background(); + } + item = pColorManager->getItem(schemeName,COLOR_SCHEME_BREAKPOINT); + if (item) { + this->mBreakpointForegroundColor = item->foreground(); + this->mBreakpointBackgroundColor = item->foreground(); + } this->invalidate(); } diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index b5745205..3ea9df65 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -111,6 +111,7 @@ public: int gutterClickedLine() const; void toggleBreakpoint(int line); bool hasBreakpoint(int line); + void removeBreakpointFocus(); signals: @@ -147,11 +148,16 @@ private: bool mIsNew; QMap mSyntaxIssues; QColor mSyntaxErrorColor; - QColor mSyntaxWaringColor; + QColor mSyntaxWarningColor; + QColor mActiveBreakpointForegroundColor; + QColor mActiveBreakpointBackgroundColor; + QColor mBreakpointForegroundColor; + QColor mBreakpointBackgroundColor; int mSyntaxErrorLine; int mLineCount; int mGutterClickedLine; QSet mBreakpointLines; + int mActiveBreakpointLine; // QWidget interface protected: diff --git a/RedPandaIDE/editorlist.cpp b/RedPandaIDE/editorlist.cpp index 5495ede0..24a45e7e 100644 --- a/RedPandaIDE/editorlist.cpp +++ b/RedPandaIDE/editorlist.cpp @@ -146,6 +146,23 @@ bool EditorList::isFileOpened(const QString &name) return false; } +int EditorList::pageCount() +{ + return mLeftPageWidget->count()+mRightPageWidget->count(); +} + +Editor *EditorList::operator[](int index) +{ + if (index>=0 && indexcount()) { + return static_cast(mLeftPageWidget->widget(index)); + } + index -= mLeftPageWidget->count(); + if (index>=0 && indexcount()) { + return static_cast(mRightPageWidget->widget(index)); + } + return nullptr; +} + bool EditorList::closeAll(bool force) { beginUpdate(); auto end = finally([this] { diff --git a/RedPandaIDE/editorlist.h b/RedPandaIDE/editorlist.h index 75ff2708..df2c9e4a 100644 --- a/RedPandaIDE/editorlist.h +++ b/RedPandaIDE/editorlist.h @@ -41,6 +41,9 @@ public: void applySettings(); void applyColorSchemes(const QString& name); bool isFileOpened(const QString& name); + int pageCount(); + + Editor* operator[](int index); private: QTabWidget* getNewEditorPageControl() const; diff --git a/RedPandaIDE/iconsmanager.cpp b/RedPandaIDE/iconsmanager.cpp index 91158bae..3b644512 100644 --- a/RedPandaIDE/iconsmanager.cpp +++ b/RedPandaIDE/iconsmanager.cpp @@ -7,7 +7,7 @@ IconsManager::IconsManager(QObject *parent) : QObject(parent) mSyntaxError = std::make_shared(":/icons/images/editor/syntaxerror.png"); mSyntaxWarning = std::make_shared(":/icons/images/editor/syntaxwarning.png"); mBreakpoint = std::make_shared(":/icons/images/editor/breakpoint.png"); - mCurrentLine = std::make_shared(":/icons/images/editor/currentline.png"); + mActiveBreakpoint = std::make_shared(":/icons/images/editor/currentline.png"); } PIcon IconsManager::syntaxError() const @@ -25,7 +25,7 @@ PIcon IconsManager::breakpoint() const return mBreakpoint; } -PIcon IconsManager::currentLine() const +PIcon IconsManager::activeBreakpoint() const { - return mCurrentLine; + return mActiveBreakpoint; } diff --git a/RedPandaIDE/iconsmanager.h b/RedPandaIDE/iconsmanager.h index 525f0277..ed4623fb 100644 --- a/RedPandaIDE/iconsmanager.h +++ b/RedPandaIDE/iconsmanager.h @@ -18,14 +18,14 @@ public: PIcon breakpoint() const; - PIcon currentLine() const; + PIcon activeBreakpoint() const; signals: private: PIcon mSyntaxError; PIcon mSyntaxWarning; PIcon mBreakpoint; - PIcon mCurrentLine; + PIcon mActiveBreakpoint; }; extern IconsManager* pIconsManager; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 43ab161e..dced5466 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -207,6 +207,60 @@ void MainWindow::applySettings() this->setFont(font); } +void MainWindow::removeActiveBreakpoints() +{ + for (int i=0;ipageCount();i++) { + Editor* e= (*mEditorList)[i]; + e->removeBreakpointFocus(); + } +} + +void MainWindow::updateAppTitle() +{ +appName := Lang[ID_DEVCPP]; +e := fEditorList.GetEditor; +if Assigned(e) and not e.InProject then begin + if e.Text.Modified then + str := e.FileName + ' [*]' + else + str := e.FileName; + if fDebugger.Executing then begin + Caption := Format('%s - [Debugging] - %s %s', [str, appName, DEVCPP_VERSION]); + Application.Title := Format('%s - [Debugging] - %s', [ExtractFileName(e.FileName), appName]); + end else if devExecutor.Running then begin + Caption := Format('%s - [Executing] - %s %s', [str, appName, DEVCPP_VERSION]); + Application.Title := Format('%s - [Executing] - %s', [ExtractFileName(e.FileName), appName]); + end else if fCompiler.Compiling then begin + Caption := Format('%s - [Compiling] - %s %s', [str, appName, DEVCPP_VERSION]); + Application.Title := Format('%s - [Compiling] - %s', [ExtractFileName(e.FileName), appName]); + end else begin + Caption := Format('%s - %s %s', [str, appName, DEVCPP_VERSION]); + Application.Title := Format('%s - %s', [ExtractFileName(e.FileName), appName]); + end; +end else if Assigned(fProject) then begin + if fDebugger.Executing then begin + Caption := Format('%s - [%s] - [Debugging] - %s %s', + [fProject.Name, ExtractFilename(fProject.Filename), appName, DEVCPP_VERSION]); + Application.Title := Format('%s - [Debugging] - %s', [fProject.Name, appName]); + end else if devExecutor.Running then begin + Caption := Format('%s - [%s] - [Executing] - %s %s', + [fProject.Name, ExtractFilename(fProject.Filename), appName, DEVCPP_VERSION]); + Application.Title := Format('%s - [Executing] - %s', [fProject.Name, appName]); + end else if fCompiler.Compiling then begin + Caption := Format('%s - [%s] - [Compiling] - %s %s', + [fProject.Name, ExtractFilename(fProject.Filename), appName, DEVCPP_VERSION]); + Application.Title := Format('%s - [Compiling] - %s', [fProject.Name, appName]); + end else begin + Caption := Format('%s - [%s] - %s %s', + [fProject.Name, ExtractFilename(fProject.Filename), appName, DEVCPP_VERSION]); + Application.Title := Format('%s - %s', [fProject.Name, appName]); + end; +end else begin + Caption := Format('%s %s', [appName, DEVCPP_VERSION]); + Application.Title := Format('%s', [DEVCPP]); +end; +} + void MainWindow::updateStatusbarForLineCol() { Editor* e = mEditorList->getEditor(); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 490e5402..4d09ce55 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -58,6 +58,9 @@ public: void applySettings(); + void removeActiveBreakpoints(); + void updateAppTitle(); + protected: void openFiles(const QStringList& files); void openFile(const QString& filename);