From 7ad6a6415029803737f6447206907acd62eb511e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 8 Jul 2023 19:47:48 +0800 Subject: [PATCH] - fix: "Toggle breakpoint " in the editor gutter's context menu doesn't work. - fix: Click editor's gutter won't toggle breakpoint in KDE debian 12 --- NEWS.md | 2 ++ RedPandaIDE/editor.h | 1 - libs/qsynedit/qsynedit/qsynedit.cpp | 17 ++++++++++++----- libs/qsynedit/qsynedit/qsynedit.h | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index b0fc0ede..eb1d8494 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,6 +35,8 @@ Red Panda C++ Version 2.23 - enhancement: Correctly reformat C++ three-way comparision operator "<=>" - enhancement: Auto insert spaces between #include and <> when reformat - enhancement: Auto insert spaces between #include and "" when reformat + - fix: Click editor's gutter won't toggle breakpoint in KDE debian 12 + - fix: "Toggle breakpoint " in the editor gutter's context menu doesn't work. Red Panda C++ Version 2.22 diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 60baa4bc..f572b45f 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -31,7 +31,6 @@ #define USER_CODE_IN_REPL_POS_BEGIN "%REPL_BEGIN%" #define USER_CODE_IN_REPL_POS_END "%REPL_END%" - class Project; struct TabStop { int x; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 22bb41b2..85fff9aa 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -69,6 +69,7 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent), mDocument = std::make_shared(mFontDummy, mFontDummy, this); //fPlugins := TList.Create; mMouseMoved = false; + mMouseOrigin = QPoint(0,0); mUndoing = false; mDocument->connect(mDocument.get(), &Document::changed, this, &QSynEdit::onLinesChanged); mDocument->connect(mDocument.get(), &Document::changing, this, &QSynEdit::onLinesChanging); @@ -656,10 +657,13 @@ bool QSynEdit::pointToCharLine(const QPoint &point, BufferCoord &coord) bool QSynEdit::pointToLine(const QPoint &point, int &line) { - BufferCoord coord; - bool result = pointToCharLine(point,coord); - if (result) - line=coord.line; + if ((point.y() < clientTop()) + || (point.y() > clientTop()+clientHeight())) { + return false; + } + line = rowToLine( + std::max(1, mTopLine + (point.y() / mTextHeight)) + ); return true; } @@ -6143,6 +6147,7 @@ void QSynEdit::mousePressEvent(QMouseEvent *event) bool bWasSel = false; bool bStartDrag = false; mMouseMoved = false; + mMouseOrigin = event->pos(); Qt::MouseButton button = event->button(); int X=event->pos().x(); int Y=event->pos().y(); @@ -6227,7 +6232,9 @@ void QSynEdit::mouseReleaseEvent(QMouseEvent *event) void QSynEdit::mouseMoveEvent(QMouseEvent *event) { QAbstractScrollArea::mouseMoveEvent(event); - mMouseMoved = true; + if ( (std::abs(event->pos().y()-mMouseOrigin.y()) > 2) + || (std::abs(event->pos().x()-mMouseOrigin.x()) > 2) ) + mMouseMoved = true; Qt::MouseButtons buttons = event->buttons(); if (mStateFlags.testFlag(StateFlag::sfWaitForDragging) && !mReadOnly) { diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index 1fdb422c..0f1c6c78 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -656,6 +656,7 @@ private: QFont mFontDummy; QFont mFontForNonAscii; bool mMouseMoved; + QPoint mMouseOrigin; bool mInserting; bool mPainting;