diff --git a/NEWS.md b/NEWS.md index cf95c337..a3fc48ab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -79,7 +79,9 @@ Red Panda C++ Version 2.27 - fix: Function name not correctly found if it and the '(' is not in one line; - fix: Register names in the cpu info are not in correct order. - enhancement: Auto type induction for new / temp class object. - - Enhancement: Vertically scroll by pixel. + - enhancement: Vertically scroll by pixel. + - enhancement: Display (gdb) prompt in debug console after it's cleared. + - fix: Output of "disas" is not shown in debug console. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/debugger/gdbmidebugger.cpp b/RedPandaIDE/debugger/gdbmidebugger.cpp index b1b01a54..2be3ce86 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.cpp +++ b/RedPandaIDE/debugger/gdbmidebugger.cpp @@ -841,7 +841,7 @@ void GDBMIDebuggerClient::processResultRecord(const QByteArray &line) QByteArray result = line.mid(pos+1); processResult(result); } else if (mCurrentCmd && !(mCurrentCmd->command.startsWith('-'))) { - if (mCurrentCmd->command == "disas") { + if (mCurrentCmd->command == "disas" && mCurrentCmd->source != DebugCommandSource::Console) { QStringList disOutput = mConsoleOutput; if (disOutput.length()>=3) { disOutput.pop_back(); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 25f38d0c..0bec8826 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -2653,7 +2653,7 @@ void MainWindow::prepareDebugger() // Clear logs ui->debugConsole->clear(); if (pSettings->debugger().enableDebugConsole()) { - ui->debugConsole->addLine("(gdb) "); + ui->debugConsole->addLine("(gdb)"); } ui->txtEvalOutput->clear(); @@ -4765,6 +4765,9 @@ void MainWindow::onDebugConsoleCopy() void MainWindow::onDebugConsoleClear() { ui->debugConsole->clear(); + if (pSettings->debugger().enableDebugConsole()) { + ui->debugConsole->addLine("(gdb)"); + } } void MainWindow::onFilesViewOpenInExplorer() diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index e95513c6..b3d35495 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -158,6 +158,8 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent), this, &QSynEdit::onScrolled); connect(verticalScrollBar(),&QScrollBar::valueChanged, this, &QSynEdit::onScrolled); + connect(verticalScrollBar(), &QAbstractSlider::sliderReleased, + this, qOverload<>(&QSynEdit::ensureLineAlignedWithTop)); //enable input method setAttribute(Qt::WA_InputMethodEnabled); @@ -2877,6 +2879,31 @@ SyntaxState QSynEdit::calcSyntaxStateAtLine(int line, const QString &newLineText return syntaxer()->getState(); } +int QSynEdit::calcLineAlignedTopPos(int currentValue, bool passFirstLine) +{ + int offset = currentValue % mTextHeight; + if (offset!=0) { + if (passFirstLine) + currentValue += (mTextHeight - offset); + else + currentValue -= offset; + } + return currentValue; +} + +void QSynEdit::ensureLineAlignedWithTop(void) +{ + int value = mTopPos; + int offset = value % mTextHeight; + if (offset!=0) { + if (offset < mTextHeight / 3) + value -= offset; + else + value += (mTextHeight - offset); + } + setTopPos(value); +} + int QSynEdit::clientWidth() const { return viewport()->size().width(); @@ -2952,12 +2979,9 @@ void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle) setTopPos( (vCaretRow - (mLinesInWindow - 1) / 2-1) * mTextHeight); } else { if ((vCaretRow-1) * mTextHeight < mTopPos) - setTopPos( (vCaretRow - 1) * mTextHeight); + setTopPos((vCaretRow - 1) * mTextHeight); else if (vCaretRow * mTextHeight > mTopPos + clientHeight() ) { - int value = vCaretRow * mTextHeight - clientHeight(); - int offset = value % mTextHeight; - if (offset!=0) - value += (mTextHeight - offset); + int value = calcLineAlignedTopPos(vCaretRow * mTextHeight - clientHeight(), true); setTopPos(value); } else setTopPos(mTopPos); @@ -6029,7 +6053,6 @@ void QSynEdit::mousePressEvent(QMouseEvent *event) bool bStartDrag = false; mMouseMoved = false; mMouseOrigin = event->pos(); - mMouseScrollOldTop = topPos(); Qt::MouseButton button = event->button(); int X=event->pos().x(); int Y=event->pos().y(); @@ -6108,11 +6131,7 @@ void QSynEdit::mouseReleaseEvent(QMouseEvent *event) mStateFlags.setFlag(StateFlag::sfWaitForDragging, false); } mStateFlags.setFlag(StateFlag::sfDblClicked,false); - if (mTopPos != mMouseScrollOldTop) { - int offset=mTopPos % mTextHeight; - if (offset != 0) - setTopPos(mTopPos - offset); - } + ensureLineAlignedWithTop(); ensureCaretVisible(); if (oldCaret!=caretXY()) { if (mOptions.testFlag(EditorOption::eoGroupUndo)) @@ -6304,14 +6323,8 @@ void QSynEdit::dropEvent(QDropEvent *event) && coord>=mDragSelBeginSave && coord<=mDragSelEndSave) ) { mDocument->deleteAt(mDocument->count()-1); - int topPos = mTopPos; - if (topPos!=mMouseScrollOldTop) { - int offset = topPos % mTextHeight; - if (offset!=0) - topPos -= offset; - setTopPos(topPos); - ensureCaretVisible(); - } + ensureLineAlignedWithTop(); + ensureCaretVisible(); //do nothing if drag onto itself event->acceptProposedAction(); mDropped = true; @@ -6388,11 +6401,7 @@ void QSynEdit::dropEvent(QDropEvent *event) endEditing(); event->acceptProposedAction(); mDropped = true; - if (topPos!=mMouseScrollOldTop) { - int offset = topPos % mTextHeight; - if (offset!=0) - topPos -= offset; - } + topPos = calcLineAlignedTopPos(topPos, false); setTopPos(topPos); setLeftPos(leftPos); internalSetCaretXY(coord); diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index 6f818492..e939dcc6 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -501,6 +501,8 @@ protected: void decPaintLock(); SyntaxState calcSyntaxStateAtLine(int line, const QString &newLineText); private: + int calcLineAlignedTopPos(int currentValue, bool passFirstLine); + void ensureLineAlignedWithTop(void); BufferCoord ensureBufferCoordValid(const BufferCoord& coord); void beginEditingWithoutUndo(); void endEditingWithoutUndo(); @@ -683,7 +685,6 @@ private: QFont mFontDummy; bool mMouseMoved; QPoint mMouseOrigin; - int mMouseScrollOldTop; bool mInserting; PDocument mDocument;