tweak displays
This commit is contained in:
parent
8a5102172e
commit
d63aa1a58f
|
@ -9769,7 +9769,6 @@ void MainWindow::on_actionGo_to_Line_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionNew_Template_triggered()
|
void MainWindow::on_actionNew_Template_triggered()
|
||||||
{
|
{
|
||||||
if (!mProject)
|
if (!mProject)
|
||||||
|
|
|
@ -227,55 +227,7 @@ void QSynEdit::setCaretXY(const BufferCoord &value)
|
||||||
{
|
{
|
||||||
setBlockBegin(value);
|
setBlockBegin(value);
|
||||||
setBlockEnd(value);
|
setBlockEnd(value);
|
||||||
setCaretXYEx(true,value);
|
internalSetCaretXY(value, true);
|
||||||
}
|
|
||||||
|
|
||||||
void QSynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value)
|
|
||||||
{
|
|
||||||
value = ensureBufferCoordValid(value);
|
|
||||||
// if ((value.Char > nMaxX) && (! (mOptions.testFlag(SynEditorOption::eoScrollPastEol)) ) )
|
|
||||||
// value.Char = nMaxX;
|
|
||||||
// if (value.Char < 1)
|
|
||||||
// value.Char = 1;
|
|
||||||
if ((value.ch != mCaretX) || (value.line != mCaretY)) {
|
|
||||||
incPaintLock();
|
|
||||||
auto action = finally([this]{
|
|
||||||
decPaintLock();
|
|
||||||
});
|
|
||||||
// simply include the flags, fPaintLock is > 0
|
|
||||||
if (mCaretX != value.ch) {
|
|
||||||
mCaretX = value.ch;
|
|
||||||
mStatusChanges.setFlag(StatusChange::scCaretX);
|
|
||||||
mStateFlags.setFlag(StateFlag::sfHScrollbarChanged);
|
|
||||||
invalidateLine(mCaretY);
|
|
||||||
}
|
|
||||||
if (mCaretY != value.line) {
|
|
||||||
int oldCaretY = mCaretY;
|
|
||||||
mCaretY = value.line;
|
|
||||||
invalidateLine(mCaretY);
|
|
||||||
invalidateGutterLine(mCaretY);
|
|
||||||
invalidateLine(oldCaretY);
|
|
||||||
invalidateGutterLine(oldCaretY);
|
|
||||||
mStatusChanges.setFlag(StatusChange::scCaretY);
|
|
||||||
mStateFlags.setFlag(StateFlag::sfVScrollbarChanged);
|
|
||||||
}
|
|
||||||
// Call UpdateLastCaretX before DecPaintLock because the event handler it
|
|
||||||
// calls could raise an exception, and we don't want fLastCaretX to be
|
|
||||||
// left in an undefined state if that happens.
|
|
||||||
updateLastCaretX();
|
|
||||||
if (CallEnsureCursorPosVisible)
|
|
||||||
ensureCursorPosVisible();
|
|
||||||
} else {
|
|
||||||
// Also call UpdateLastCaretX if the caret didn't move. Apps don't know
|
|
||||||
// anything about fLastCaretX and they shouldn't need to. So, to avoid any
|
|
||||||
// unwanted surprises, always update fLastCaretX whenever CaretXY is
|
|
||||||
// assigned to.
|
|
||||||
// Note to SynEdit developers: If this is undesirable in some obscure
|
|
||||||
// case, just save the value of fLastCaretX before assigning to CaretXY and
|
|
||||||
// restore it afterward as appropriate.
|
|
||||||
updateLastCaretX();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::setCaretXYCentered(const BufferCoord &value)
|
void QSynEdit::setCaretXYCentered(const BufferCoord &value)
|
||||||
|
@ -284,14 +236,10 @@ void QSynEdit::setCaretXYCentered(const BufferCoord &value)
|
||||||
auto action = finally([this] {
|
auto action = finally([this] {
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
});
|
});
|
||||||
mStatusChanges.setFlag(StatusChange::scSelection);
|
setBlockBegin(value);
|
||||||
setCaretXYEx(false,value);
|
setBlockEnd(value);
|
||||||
if (selAvail())
|
internalSetCaretXY(value, false);
|
||||||
invalidateSelection();
|
ensureCaretVisibleEx(true); // but here after block has been set
|
||||||
mBlockBegin.ch = mCaretX;
|
|
||||||
mBlockBegin.line = mCaretY;
|
|
||||||
mBlockEnd = mBlockBegin;
|
|
||||||
ensureCursorPosVisibleEx(true); // but here after block has been set
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::uncollapseAroundLine(int line)
|
void QSynEdit::uncollapseAroundLine(int line)
|
||||||
|
@ -1839,7 +1787,7 @@ void QSynEdit::doDeleteLastChar()
|
||||||
if (mReadOnly)
|
if (mReadOnly)
|
||||||
return ;
|
return ;
|
||||||
auto action = finally([this]{
|
auto action = finally([this]{
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mActiveSelectionMode==SelectionMode::Column) {
|
if (mActiveSelectionMode==SelectionMode::Column) {
|
||||||
|
@ -1908,7 +1856,7 @@ void QSynEdit::doDeleteCurrentChar()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto action = finally([this]{
|
auto action = finally([this]{
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mActiveSelectionMode==SelectionMode::Column) {
|
if (mActiveSelectionMode==SelectionMode::Column) {
|
||||||
|
@ -2345,7 +2293,7 @@ void QSynEdit::insertLine(bool moveCaret)
|
||||||
doLinesInserted(mCaretY - InsDelta, nLinesInserted);
|
doLinesInserted(mCaretY - InsDelta, nLinesInserted);
|
||||||
setBlockBegin(caretXY());
|
setBlockBegin(caretXY());
|
||||||
setBlockEnd(caretXY());
|
setBlockEnd(caretXY());
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
updateLastCaretX();
|
updateLastCaretX();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2374,7 +2322,7 @@ void QSynEdit::doTabKey()
|
||||||
}
|
}
|
||||||
setSelTextPrimitive(QStringList(Spaces));
|
setSelTextPrimitive(QStringList(Spaces));
|
||||||
endEditing();
|
endEditing();
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::doShiftTabKey()
|
void QSynEdit::doShiftTabKey()
|
||||||
|
@ -2533,7 +2481,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, false);
|
setCaretDisplayXY(vCaretNearestPos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::computeScroll(bool isDragging)
|
void QSynEdit::computeScroll(bool isDragging)
|
||||||
|
@ -3019,12 +2967,12 @@ void QSynEdit::updateLastCaretX()
|
||||||
mLastCaretColumn = displayX();
|
mLastCaretColumn = displayX();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::ensureCursorPosVisible()
|
void QSynEdit::ensureCaretVisible()
|
||||||
{
|
{
|
||||||
ensureCursorPosVisibleEx(false);
|
ensureCaretVisibleEx(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle)
|
void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle)
|
||||||
{
|
{
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
auto action = finally([this]{
|
auto action = finally([this]{
|
||||||
|
@ -3069,26 +3017,64 @@ void QSynEdit::scrollWindow(int dx, int dy)
|
||||||
verticalScrollBar()->setValue(ny);
|
verticalScrollBar()->setValue(ny);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::setInternalDisplayXY(const DisplayCoord &aPos, bool ensureCaretVisible)
|
void QSynEdit::setCaretDisplayXY(const DisplayCoord &aPos, bool ensureCaretVisible)
|
||||||
{
|
{
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
internalSetCaretXY(displayToBufferPos(aPos), ensureCaretVisible);
|
internalSetCaretXY(displayToBufferPos(aPos), ensureCaretVisible);
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::internalSetCaretXY(const BufferCoord &Value, bool ensureCaretVisible)
|
void QSynEdit::internalSetCaretXY(BufferCoord value, bool ensureVisible)
|
||||||
{
|
{
|
||||||
setCaretXYEx(ensureCaretVisible, Value);
|
value = ensureBufferCoordValid(value);
|
||||||
|
if ((value.ch != mCaretX) || (value.line != mCaretY)) {
|
||||||
|
incPaintLock();
|
||||||
|
auto action = finally([this]{
|
||||||
|
decPaintLock();
|
||||||
|
});
|
||||||
|
// simply include the flags, fPaintLock is > 0
|
||||||
|
if (mCaretX != value.ch) {
|
||||||
|
mCaretX = value.ch;
|
||||||
|
mStatusChanges.setFlag(StatusChange::scCaretX);
|
||||||
|
mStateFlags.setFlag(StateFlag::sfHScrollbarChanged);
|
||||||
|
invalidateLine(mCaretY);
|
||||||
|
}
|
||||||
|
if (mCaretY != value.line) {
|
||||||
|
int oldCaretY = mCaretY;
|
||||||
|
mCaretY = value.line;
|
||||||
|
invalidateLine(mCaretY);
|
||||||
|
invalidateGutterLine(mCaretY);
|
||||||
|
invalidateLine(oldCaretY);
|
||||||
|
invalidateGutterLine(oldCaretY);
|
||||||
|
mStatusChanges.setFlag(StatusChange::scCaretY);
|
||||||
|
mStateFlags.setFlag(StateFlag::sfVScrollbarChanged);
|
||||||
|
}
|
||||||
|
// Call UpdateLastCaretX before DecPaintLock because the event handler it
|
||||||
|
// calls could raise an exception, and we don't want fLastCaretX to be
|
||||||
|
// left in an undefined state if that happens.
|
||||||
|
updateLastCaretX();
|
||||||
|
if (ensureVisible)
|
||||||
|
ensureCaretVisible();
|
||||||
|
} else {
|
||||||
|
// Also call UpdateLastCaretX if the caret didn't move. Apps don't know
|
||||||
|
// anything about fLastCaretX and they shouldn't need to. So, to avoid any
|
||||||
|
// unwanted surprises, always update fLastCaretX whenever CaretXY is
|
||||||
|
// assigned to.
|
||||||
|
// Note to SynEdit developers: If this is undesirable in some obscure
|
||||||
|
// case, just save the value of fLastCaretX before assigning to CaretXY and
|
||||||
|
// restore it afterward as appropriate.
|
||||||
|
updateLastCaretX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::internalSetCaretX(int Value)
|
void QSynEdit::internalSetCaretX(int value)
|
||||||
{
|
{
|
||||||
internalSetCaretXY(BufferCoord{Value, mCaretY});
|
internalSetCaretXY(BufferCoord{value, mCaretY});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::internalSetCaretY(int Value)
|
void QSynEdit::internalSetCaretY(int value)
|
||||||
{
|
{
|
||||||
internalSetCaretXY(BufferCoord{mCaretX,Value});
|
internalSetCaretXY(BufferCoord{mCaretX,value});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::setStatusChanged(StatusChanges changes)
|
void QSynEdit::setStatusChanged(StatusChanges changes)
|
||||||
|
@ -4224,7 +4210,7 @@ void QSynEdit::doUndoItem()
|
||||||
item->changeNumber());
|
item->changeNumber());
|
||||||
internalSetCaretXY(item->changeStartPos());
|
internalSetCaretXY(item->changeStartPos());
|
||||||
setBlockBegin(caretXY());
|
setBlockBegin(caretXY());
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChangeReason::ReplaceLine:
|
case ChangeReason::ReplaceLine:
|
||||||
|
@ -4289,7 +4275,7 @@ void QSynEdit::doUndoItem()
|
||||||
item->changeSelMode(),
|
item->changeSelMode(),
|
||||||
item->changeNumber());
|
item->changeNumber());
|
||||||
setBlockBegin(caretXY());
|
setBlockBegin(caretXY());
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChangeReason::LineBreak:{
|
case ChangeReason::LineBreak:{
|
||||||
|
@ -4778,7 +4764,7 @@ void QSynEdit::moveCaretHorz(int deltaX, bool isSelection)
|
||||||
}
|
}
|
||||||
// set caret and block begin / end
|
// set caret and block begin / end
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
|
ensureCaretVisible();
|
||||||
moveCaretAndSelection(mBlockBegin, ptDst, isSelection);
|
moveCaretAndSelection(mBlockBegin, ptDst, isSelection);
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
}
|
}
|
||||||
|
@ -4838,6 +4824,7 @@ void QSynEdit::moveCaretVert(int deltaY, bool isSelection)
|
||||||
|
|
||||||
// set caret and block begin / end
|
// set caret and block begin / end
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
|
ensureCaretVisible();
|
||||||
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
|
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
|
|
||||||
|
@ -5160,8 +5147,8 @@ int QSynEdit::searchReplace(const QString &sSearch, const QString &sReplace, Sea
|
||||||
setBlockBegin(ptCurrent);
|
setBlockBegin(ptCurrent);
|
||||||
|
|
||||||
//Be sure to use the Ex version of CursorPos so that it appears in the middle if necessary
|
//Be sure to use the Ex version of CursorPos so that it appears in the middle if necessary
|
||||||
setCaretXYEx(false, BufferCoord{ptCurrent.ch, ptCurrent.line});
|
internalSetCaretXY(BufferCoord{ptCurrent.ch, ptCurrent.line}, false);
|
||||||
ensureCursorPosVisibleEx(true);
|
ensureCaretVisibleEx(true);
|
||||||
ptCurrent.ch += nSearchLen;
|
ptCurrent.ch += nSearchLen;
|
||||||
setBlockEnd(ptCurrent);
|
setBlockEnd(ptCurrent);
|
||||||
|
|
||||||
|
@ -5350,7 +5337,7 @@ void QSynEdit::doInsertText(const BufferCoord& pos,
|
||||||
doLinesInserted(pos.line+1, insertedLines);
|
doLinesInserted(pos.line+1, insertedLines);
|
||||||
internalSetCaretXY(newPos);
|
internalSetCaretXY(newPos);
|
||||||
setBlockBegin(newPos);
|
setBlockBegin(newPos);
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
break;
|
break;
|
||||||
case SelectionMode::Column:{
|
case SelectionMode::Column:{
|
||||||
BufferCoord bb=blockBegin();
|
BufferCoord bb=blockBegin();
|
||||||
|
@ -5365,7 +5352,7 @@ void QSynEdit::doInsertText(const BufferCoord& pos,
|
||||||
internalSetCaretXY(bb);
|
internalSetCaretXY(bb);
|
||||||
setBlockBegin(bb);
|
setBlockBegin(bb);
|
||||||
setBlockEnd(be);
|
setBlockEnd(be);
|
||||||
ensureCursorPosVisible();
|
ensureCaretVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -6262,10 +6249,12 @@ void QSynEdit::wheelEvent(QWheelEvent *event)
|
||||||
int oldValue = value;
|
int oldValue = value;
|
||||||
while (mWheelAccumulatedDeltaY>=120) {
|
while (mWheelAccumulatedDeltaY>=120) {
|
||||||
mWheelAccumulatedDeltaY-=120;
|
mWheelAccumulatedDeltaY-=120;
|
||||||
|
value = (value / mTextHeight) * mTextHeight;
|
||||||
value += sign*mMouseWheelScrollSpeed*mTextHeight;
|
value += sign*mMouseWheelScrollSpeed*mTextHeight;
|
||||||
}
|
}
|
||||||
while (mWheelAccumulatedDeltaY<=-120) {
|
while (mWheelAccumulatedDeltaY<=-120) {
|
||||||
mWheelAccumulatedDeltaY+=120;
|
mWheelAccumulatedDeltaY+=120;
|
||||||
|
value = (value / mTextHeight) * mTextHeight;
|
||||||
value -= sign*mMouseWheelScrollSpeed*mTextHeight;
|
value -= sign*mMouseWheelScrollSpeed*mTextHeight;
|
||||||
}
|
}
|
||||||
if (value != oldValue)
|
if (value != oldValue)
|
||||||
|
|
|
@ -241,7 +241,6 @@ public:
|
||||||
void setCaretX(int value);
|
void setCaretX(int value);
|
||||||
void setCaretY(int value);
|
void setCaretY(int value);
|
||||||
void setCaretXY(const BufferCoord& value);
|
void setCaretXY(const BufferCoord& value);
|
||||||
void setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value);
|
|
||||||
void setCaretXYCentered(const BufferCoord& value);
|
void setCaretXYCentered(const BufferCoord& value);
|
||||||
void setCaretAndSelection(const BufferCoord& ptCaret,
|
void setCaretAndSelection(const BufferCoord& ptCaret,
|
||||||
const BufferCoord& ptSelBegin,
|
const BufferCoord& ptSelBegin,
|
||||||
|
@ -525,13 +524,13 @@ private:
|
||||||
void doSetSelText(const QString& value);
|
void doSetSelText(const QString& value);
|
||||||
|
|
||||||
void updateLastCaretX();
|
void updateLastCaretX();
|
||||||
void ensureCursorPosVisible();
|
void ensureCaretVisible();
|
||||||
void ensureCursorPosVisibleEx(bool ForceToMiddle);
|
void ensureCaretVisibleEx(bool ForceToMiddle);
|
||||||
void scrollWindow(int dx,int dy);
|
void scrollWindow(int dx,int dy);
|
||||||
void setInternalDisplayXY(const DisplayCoord& aPos, bool ensureCaretVisible = true);
|
void setCaretDisplayXY(const DisplayCoord& aPos, bool ensureCaretVisible = true);
|
||||||
void internalSetCaretXY(const BufferCoord& Value, bool ensureCaretVisible = true);
|
void internalSetCaretXY(BufferCoord value, bool ensureVisible = true);
|
||||||
void internalSetCaretX(int Value);
|
void internalSetCaretX(int value);
|
||||||
void internalSetCaretY(int Value);
|
void internalSetCaretY(int value);
|
||||||
void setStatusChanged(StatusChanges changes);
|
void setStatusChanged(StatusChanges changes);
|
||||||
void doOnStatusChange(StatusChanges changes);
|
void doOnStatusChange(StatusChanges changes);
|
||||||
void updateHScrollbar();
|
void updateHScrollbar();
|
||||||
|
|
Loading…
Reference in New Issue