fix: vertical selection speed

This commit is contained in:
Roy Qu 2024-03-22 22:43:21 +08:00
parent 7c29f4a964
commit 51a05e1bc6
4 changed files with 7 additions and 17 deletions

View File

@ -1461,7 +1461,7 @@ void Settings::Editor::doLoad()
mScrollPastEol = boolValue("scroll_past_eol", false); mScrollPastEol = boolValue("scroll_past_eol", false);
mHalfPageScroll = boolValue("half_page_scroll",false); mHalfPageScroll = boolValue("half_page_scroll",false);
mMouseWheelScrollSpeed = intValue("mouse_wheel_scroll_speed", 3); mMouseWheelScrollSpeed = intValue("mouse_wheel_scroll_speed", 3);
mMouseSelectionScrollSpeed = intValue("mouse_selection_scroll_speed",1); mMouseSelectionScrollSpeed = intValue("mouse_selection_scroll_speed",10);
//right edge //right edge

View File

@ -436,7 +436,7 @@
<number>1</number> <number>1</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>100</number> <number>999</number>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -1771,11 +1771,7 @@ void QSynEdit::doMouseScroll(bool isDragging, int scrollX, int scrollY)
} }
if (scrollY != 0) { if (scrollY != 0) {
int y; int y;
//qDebug()<<mScrollDeltaY; setTopPos(mTopPos + scrollY * mMouseSelectionScrollSpeed);
if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier))
setTopPos(mTopPos + scrollY * mLinesInWindow * mTextHeight);
else
setTopPos(mTopPos + scrollY * mMouseSelectionScrollSpeed * mTextHeight);
y = yposToRow(0); y = yposToRow(0);
if (scrollY > 0) // scrolling down? if (scrollY > 0) // scrolling down?
y+=mLinesInWindow - 1; y+=mLinesInWindow - 1;
@ -2537,7 +2533,7 @@ void QSynEdit::computeCaret()
DisplayCoord vCaretNearestPos = pixelsToNearestGlyphPos(x, y); DisplayCoord vCaretNearestPos = pixelsToNearestGlyphPos(x, y);
vCaretNearestPos.row = minMax(vCaretNearestPos.row, 1, displayLineCount()); vCaretNearestPos.row = minMax(vCaretNearestPos.row, 1, displayLineCount());
setInternalDisplayXY(vCaretNearestPos); setInternalDisplayXY(vCaretNearestPos, false);
} }
void QSynEdit::computeScroll(bool isDragging) void QSynEdit::computeScroll(bool isDragging)
@ -2954,17 +2950,11 @@ void QSynEdit::decPaintLock()
Q_ASSERT(mPaintLock > 0); Q_ASSERT(mPaintLock > 0);
mPaintLock--; mPaintLock--;
if (mPaintLock == 0 ) { if (mPaintLock == 0 ) {
bool scrollbarUpdated = false;
if (mStateFlags.testFlag(StateFlag::sfHScrollbarChanged)) { if (mStateFlags.testFlag(StateFlag::sfHScrollbarChanged)) {
updateHScrollbar(); updateHScrollbar();
scrollbarUpdated = true;
} }
if (mStateFlags.testFlag(StateFlag::sfVScrollbarChanged)) { if (mStateFlags.testFlag(StateFlag::sfVScrollbarChanged)) {
updateVScrollbar(); updateVScrollbar();
scrollbarUpdated = true;
}
if (scrollbarUpdated) {
ensureCursorPosVisible();
} }
if (mStateFlags.testFlag(StateFlag::sfCaretChanged)) if (mStateFlags.testFlag(StateFlag::sfCaretChanged))
updateCaret(); updateCaret();
@ -3079,10 +3069,10 @@ void QSynEdit::scrollWindow(int dx, int dy)
verticalScrollBar()->setValue(ny); verticalScrollBar()->setValue(ny);
} }
void QSynEdit::setInternalDisplayXY(const DisplayCoord &aPos) void QSynEdit::setInternalDisplayXY(const DisplayCoord &aPos, bool ensureCaretVisible)
{ {
incPaintLock(); incPaintLock();
internalSetCaretXY(displayToBufferPos(aPos)); internalSetCaretXY(displayToBufferPos(aPos), ensureCaretVisible);
decPaintLock(); decPaintLock();
} }

View File

@ -528,7 +528,7 @@ private:
void ensureCursorPosVisible(); void ensureCursorPosVisible();
void ensureCursorPosVisibleEx(bool ForceToMiddle); void ensureCursorPosVisibleEx(bool ForceToMiddle);
void scrollWindow(int dx,int dy); void scrollWindow(int dx,int dy);
void setInternalDisplayXY(const DisplayCoord& aPos); void setInternalDisplayXY(const DisplayCoord& aPos, bool ensureCaretVisible = true);
void internalSetCaretXY(const BufferCoord& Value, bool ensureCaretVisible = true); void internalSetCaretXY(const BufferCoord& Value, bool ensureCaretVisible = true);
void internalSetCaretX(int Value); void internalSetCaretX(int Value);
void internalSetCaretY(int Value); void internalSetCaretY(int Value);