From 7d96a8905e2fbd260f10fdc313bf806abdb23e2c Mon Sep 17 00:00:00 2001 From: QuangNguyenMinh123 <100016403+QuangNguyenMinh123@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:44:38 +0700 Subject: [PATCH] Erase color of level 0 bt line when target is running --- src/SeerEditorManagerWidget.cpp | 19 +++++++++++++++++-- src/SeerEditorManagerWidget.h | 1 + src/SeerEditorWidgetSource.h | 1 + src/SeerEditorWidgetSourceAreas.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/SeerEditorManagerWidget.cpp b/src/SeerEditorManagerWidget.cpp index 4ae681b..ba1d62e 100644 --- a/src/SeerEditorManagerWidget.cpp +++ b/src/SeerEditorManagerWidget.cpp @@ -631,7 +631,7 @@ void SeerEditorManagerWidget::handleText (const QString& text) { // Parse through the frame list and set the current lines that are in the frame list. QStringList frame_list = Seer::parse(newtext, "frame=", '{', '}', false); - + _lastFrameList = frame_list; SeerEditorManagerEntries::iterator i_later=endEntry(); int lineToPrintLater = -1; for ( const auto& frame_text : frame_list ) { @@ -732,7 +732,22 @@ void SeerEditorManagerWidget::handleText (const QString& text) { static_cast(w)->sourceArea()->handleText(text); } - }else{ + }else if (text.startsWith("*running")) { + // target / program is running, should erase 'yellow' color is for the current line + // _lastFrameList is invoked to erase previously "colored" line + for ( const auto& frame_text : _lastFrameList ) { + QString fullname_text = Seer::parseFirst(frame_text, "fullname=", '"', '"', false); + QString line_text = Seer::parseFirst(frame_text, "line=", '"', '"', false); + + SeerEditorManagerEntries::iterator i = findEntry(fullname_text); + SeerEditorManagerEntries::iterator e = endEntry(); + + if (i != e) { + i->widget->sourceArea()->eraseColorCurrentLine(line_text.toInt()); + } + } + } + else{ // Ignore others. return; } diff --git a/src/SeerEditorManagerWidget.h b/src/SeerEditorManagerWidget.h index 32bc06a..92bebd4 100644 --- a/src/SeerEditorManagerWidget.h +++ b/src/SeerEditorManagerWidget.h @@ -155,5 +155,6 @@ class SeerEditorManagerWidget : public QWidget, protected Ui::SeerEditorManagerW bool _showOpcodeColumn; bool _showSourceLines; bool _notifyAssemblyTabShown; + QStringList _lastFrameList; // variable for saving previous backtrace }; diff --git a/src/SeerEditorWidgetSource.h b/src/SeerEditorWidgetSource.h index 00aaf1f..3c695a6 100644 --- a/src/SeerEditorWidgetSource.h +++ b/src/SeerEditorWidgetSource.h @@ -97,6 +97,7 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit { void setExternalEditorCommand (const QString& externalEditorCommand); const QString& externalEditorCommand (); + void eraseColorCurrentLine (int lineno); signals: void insertBreakpoint (QString breakpoint); void insertPrintpoint (QString type, QString function, QString channel, QString parameters); diff --git a/src/SeerEditorWidgetSourceAreas.cpp b/src/SeerEditorWidgetSourceAreas.cpp index 936290f..795b3ca 100644 --- a/src/SeerEditorWidgetSourceAreas.cpp +++ b/src/SeerEditorWidgetSourceAreas.cpp @@ -1669,6 +1669,32 @@ const QString& SeerEditorWidgetSourceArea::externalEditorCommand () { return _externalEditorCommand; } +void SeerEditorWidgetSourceArea::eraseColorCurrentLine (int lineno) { + + // Erase color of this line + QTextCharFormat lineFormat; + lineFormat = highlighterSettings().get("Text"); + + // Create a selection at the cursor. + QTextBlock block = document()->findBlockByLineNumber(lineno-1); + QTextCursor cursor = textCursor(); + + cursor.setPosition(block.position()); + + QTextEdit::ExtraSelection selection; + selection.format.setForeground(lineFormat.foreground()); + selection.format.setBackground(lineFormat.background()); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = cursor; + selection.cursor.clearSelection(); + + // Add it to the extra selection list. + _currentLinesExtraSelections.append(selection); + + // Refresh all the extra selections. + refreshExtraSelections(); +} + void SeerEditorWidgetSourceArea::handleText (const QString& text) { if (text.startsWith("*stopped")) {