tweak caret movement
This commit is contained in:
parent
4f637481e4
commit
31aee0cfcc
|
@ -2981,10 +2981,10 @@ void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle)
|
||||||
if (vCaretRow < yposToRow(0) || vCaretRow>(yposToRow(0) + (mLinesInWindow - 2)))
|
if (vCaretRow < yposToRow(0) || vCaretRow>(yposToRow(0) + (mLinesInWindow - 2)))
|
||||||
setTopPos( (vCaretRow - (mLinesInWindow - 1) / 2-1) * mTextHeight);
|
setTopPos( (vCaretRow - (mLinesInWindow - 1) / 2-1) * mTextHeight);
|
||||||
} else {
|
} else {
|
||||||
if (vCaretRow < yposToRow(0))
|
if ((vCaretRow-1) * mTextHeight < mTopPos)
|
||||||
setTopPos( (vCaretRow - 1) * mTextHeight);
|
setTopPos( (vCaretRow - 1) * mTextHeight);
|
||||||
else if (vCaretRow > yposToRow(0) + (mLinesInWindow - 2) && mLinesInWindow > 2) {
|
else if (vCaretRow * mTextHeight > mTopPos + clientHeight() ) {
|
||||||
setTopPos( (vCaretRow - (mLinesInWindow - 2) -1) * mTextHeight);
|
setTopPos( vCaretRow * mTextHeight - clientHeight());
|
||||||
} else
|
} else
|
||||||
setTopPos(mTopPos);
|
setTopPos(mTopPos);
|
||||||
}
|
}
|
||||||
|
@ -5605,7 +5605,12 @@ void QSynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
|
||||||
if (command == EditCommand::PageUp || command == EditCommand::SelPageUp) {
|
if (command == EditCommand::PageUp || command == EditCommand::SelPageUp) {
|
||||||
counter = -counter;
|
counter = -counter;
|
||||||
}
|
}
|
||||||
|
int gap = (lineToRow(caretY())-1) * mTextHeight - topPos();
|
||||||
|
incPaintLock();
|
||||||
|
ensureCaretVisible();
|
||||||
moveCaretVert(counter, command == EditCommand::SelPageUp || command == EditCommand::SelPageDown);
|
moveCaretVert(counter, command == EditCommand::SelPageUp || command == EditCommand::SelPageDown);
|
||||||
|
setTopPos((lineToRow(caretY())-1) * mTextHeight - gap);
|
||||||
|
decPaintLock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EditCommand::PageTop:
|
case EditCommand::PageTop:
|
||||||
|
|
Loading…
Reference in New Issue