fix #294 - fix: Ctrl+Return insert linebreak shouldn't scroll unnecessarilly.
- enhancement: Move caret to line begin would scroll to the begin if possible.
This commit is contained in:
parent
0426bfe1b0
commit
d32e4e642d
2
NEWS.md
2
NEWS.md
|
@ -63,6 +63,8 @@ Red Panda C++ Version 2.27
|
|||
- enhancement: Show type completion info after 'const' and 'volatile'
|
||||
- fix: Caret unseen when move to a long line end by press END.
|
||||
- fix: No icons for inherited class private members.
|
||||
- fix: Ctrl+Return insert linebreak shouldn't scroll unnecessarilly.
|
||||
- enhancement: Move caret to line begin would scroll to the begin if possible.
|
||||
|
||||
Red Panda C++ Version 2.26
|
||||
- enhancement: Code suggestion for embedded std::vectors.
|
||||
|
|
|
@ -3061,9 +3061,14 @@ void QSynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle)
|
|||
});
|
||||
// Make sure X is visible
|
||||
int visibleX = displayX();
|
||||
if (visibleX < leftPos())
|
||||
setLeftPos(visibleX);
|
||||
else if (visibleX > viewWidth() + leftPos() && viewWidth()>0)
|
||||
if (visibleX < leftPos()) {
|
||||
if (viewWidth() / 3 >visibleX)
|
||||
setLeftPos(0);
|
||||
else if (viewWidth() > tabWidth() + mCharWidth)
|
||||
setLeftPos(std::max(0,visibleX - tabWidth()));
|
||||
else
|
||||
setLeftPos(visibleX);
|
||||
} else if (visibleX > viewWidth() + leftPos() && viewWidth()>0)
|
||||
if (viewWidth() >= 3*mCharWidth )
|
||||
setLeftPos(visibleX - viewWidth() + 3*mCharWidth);
|
||||
else
|
||||
|
@ -3100,9 +3105,9 @@ void QSynEdit::setInternalDisplayXY(const DisplayCoord &aPos)
|
|||
decPaintLock();
|
||||
}
|
||||
|
||||
void QSynEdit::internalSetCaretXY(const BufferCoord &Value)
|
||||
void QSynEdit::internalSetCaretXY(const BufferCoord &Value, bool ensureCaretVisible)
|
||||
{
|
||||
setCaretXYEx(true, Value);
|
||||
setCaretXYEx(ensureCaretVisible, Value);
|
||||
}
|
||||
|
||||
void QSynEdit::internalSetCaretX(int Value)
|
||||
|
@ -4871,7 +4876,7 @@ void QSynEdit::moveCaretVert(int deltaY, bool isSelection)
|
|||
mLastCaretColumn = SaveLastCaretX;
|
||||
}
|
||||
|
||||
void QSynEdit::moveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection)
|
||||
void QSynEdit::moveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection, bool ensureCaretVisible)
|
||||
{
|
||||
if (mOptions.testFlag(EditorOption::eoGroupUndo)) {
|
||||
mUndoList->addGroupBreak();
|
||||
|
@ -4884,7 +4889,7 @@ void QSynEdit::moveCaretAndSelection(const BufferCoord &ptBefore, const BufferCo
|
|||
setBlockEnd(ptAfter);
|
||||
} else
|
||||
setBlockBegin(ptAfter);
|
||||
internalSetCaretXY(ptAfter);
|
||||
internalSetCaretXY(ptAfter,ensureCaretVisible);
|
||||
decPaintLock();
|
||||
}
|
||||
|
||||
|
@ -4912,7 +4917,7 @@ void QSynEdit::moveCaretToLineStart(bool isSelection)
|
|||
moveCaretAndSelection(caretXY(), BufferCoord{newX, mCaretY}, isSelection);
|
||||
}
|
||||
|
||||
void QSynEdit::moveCaretToLineEnd(bool isSelection)
|
||||
void QSynEdit::moveCaretToLineEnd(bool isSelection, bool ensureCaretVisible)
|
||||
{
|
||||
int vNewX;
|
||||
if (mOptions.testFlag(EditorOption::eoEnhanceEndKey)) {
|
||||
|
@ -4930,7 +4935,7 @@ void QSynEdit::moveCaretToLineEnd(bool isSelection)
|
|||
} else
|
||||
vNewX = displayLineText().length() + 1;
|
||||
|
||||
moveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection);
|
||||
moveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection, ensureCaretVisible);
|
||||
}
|
||||
|
||||
void QSynEdit::doGotoBlockStart(bool isSelection)
|
||||
|
@ -5765,7 +5770,7 @@ void QSynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
|
|||
beginEditing();
|
||||
addCaretToUndo();
|
||||
addSelectionToUndo();
|
||||
moveCaretToLineEnd(false);
|
||||
moveCaretToLineEnd(false, false);
|
||||
insertLine(true);
|
||||
endEditing();
|
||||
break;
|
||||
|
|
|
@ -529,7 +529,7 @@ private:
|
|||
void ensureCursorPosVisibleEx(bool ForceToMiddle);
|
||||
void scrollWindow(int dx,int dy);
|
||||
void setInternalDisplayXY(const DisplayCoord& aPos);
|
||||
void internalSetCaretXY(const BufferCoord& Value);
|
||||
void internalSetCaretXY(const BufferCoord& Value, bool ensureCaretVisible = true);
|
||||
void internalSetCaretX(int Value);
|
||||
void internalSetCaretY(int Value);
|
||||
void setStatusChanged(StatusChanges changes);
|
||||
|
@ -574,9 +574,9 @@ private:
|
|||
void moveCaretHorz(int deltaX, bool isSelection);
|
||||
void moveCaretVert(int deltaY, bool isSelection);
|
||||
void moveCaretAndSelection(const BufferCoord& ptBefore, const BufferCoord& ptAfter,
|
||||
bool isSelection);
|
||||
bool isSelection, bool ensureCaretVisible = true);
|
||||
void moveCaretToLineStart(bool isSelection);
|
||||
void moveCaretToLineEnd(bool isSelection);
|
||||
void moveCaretToLineEnd(bool isSelection, bool ensureCaretVisible = true);
|
||||
void doGotoBlockStart(bool isSelection);
|
||||
void doGotoBlockEnd(bool isSelection);
|
||||
void doGotoEditorStart(bool isSelection);
|
||||
|
|
Loading…
Reference in New Issue