diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 3afb8823..df594a2c 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -781,17 +781,6 @@ void Editor::keyPressEvent(QKeyEvent *event) insertString.append(QString(" * @return ")+USER_CODE_IN_INSERT_POS); } insertString.append(" */"); - // } else if (caretY()==1) { /* file header */ - // insertString.append(QString(" * @file %1%2") - // .arg(USER_CODE_IN_REPL_POS_BEGIN) - // .arg(USER_CODE_IN_REPL_POS_END)); - // insertString.append(QString(" * @brief: ")+ USER_CODE_IN_INSERT_POS); - // insertString.append(QString(" * @version: ")+ USER_CODE_IN_INSERT_POS); - // insertString.append(QString(" * @copyright: ")+ USER_CODE_IN_INSERT_POS); - // insertString.append(QString(" * @author: ")+ USER_CODE_IN_INSERT_POS); - // insertString.append(" * @date: "); - // insertString.append(" * "); - // insertString.append(" **/"); } else { insertString.append(QString(" * ")+USER_CODE_IN_INSERT_POS); insertString.append(" */"); diff --git a/libs/qsynedit/qsynedit/painter.cpp b/libs/qsynedit/qsynedit/painter.cpp index a2b7f1b1..c2b7d4b8 100644 --- a/libs/qsynedit/qsynedit/painter.cpp +++ b/libs/qsynedit/qsynedit/painter.cpp @@ -520,6 +520,9 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList) pen.setWidth(penWidth); mPainter->setPen(pen); mPainter->setBrush(Qt::NoBrush); + int lineHeight = rc.height(); + int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent(); + int linePadding = (lineHeight - fontHeight) / 2; switch(p->type) { case EditingAreaType::eatRectangleBorder: rc.setTop(rc.top()+penWidth/2); @@ -527,17 +530,14 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList) rc.setBottom(rc.bottom()-penWidth/2); mPainter->drawRect(rc); break; - case EditingAreaType::eatUnderLine: { - int lineHeight = rc.height(); - int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent(); - int linePadding = (lineHeight - fontHeight) / 2; + case EditingAreaType::eatUnderLine: mPainter->drawLine(rc.left(),rc.bottom()-linePadding-pen.width(),rc.right(),rc.bottom()-linePadding-pen.width()); - } break; case EditingAreaType::eatWaveUnderLine: { - int lineHeight = rc.height(); - int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent(); - int linePadding = (lineHeight - fontHeight) / 2; + if (linePadding>mPainter->fontMetrics().descent()) + linePadding -= mPainter->fontMetrics().descent(); + else + linePadding = 0; int maxOffset = std::min(3*penWidth, mPainter->fontMetrics().descent()); maxOffset = std::max(3, maxOffset); int offset = maxOffset; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index ffc2d626..f2f4668f 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -6069,6 +6069,7 @@ 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(); @@ -6143,6 +6144,13 @@ void QSynEdit::mouseReleaseEvent(QMouseEvent *event) mStateFlags.setFlag(StateFlag::sfWaitForDragging, false); } mStateFlags.setFlag(StateFlag::sfDblClicked,false); + if (mMouseScrollOldTop > topPos()) { + if (topPos() % mTextHeight !=0) + setTopPos(topPos()/mTextHeight * mTextHeight); + } else if (mMouseScrollOldTop < topPos()) { + if (topPos() % mTextHeight !=0) + setTopPos( (topPos()/mTextHeight + 1) * mTextHeight); + } if (oldCaret!=caretXY()) { if (mOptions.testFlag(EditorOption::eoGroupUndo)) mUndoList->addGroupBreak(); diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index de97bc86..2ce358f7 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -689,6 +689,7 @@ private: QFont mFontForNonAscii; bool mMouseMoved; QPoint mMouseOrigin; + int mMouseScrollOldTop; bool mInserting; bool mPainting;