- enhancement: alt+shift+arrow do column selection

- fix: input may cause error, if selection in column mode and begin/end at the same column
  - enhancement: draw selection line if selection in column mode and begin/end at the same column
This commit is contained in:
Roy Qu 2022-03-25 12:59:53 +08:00
parent c979ef1505
commit 8b224010e0
4 changed files with 15 additions and 4 deletions

View File

@ -18,7 +18,9 @@ Red Panda C++ Version 1.0.1
- enhancement: switch capslock won't cancel code completion - enhancement: switch capslock won't cancel code completion
- enhancement: double click on item in code completion list will use it to complete - enhancement: double click on item in code completion list will use it to complete
- fix: goto declaration by ctrl+click will incorrectly select contents - fix: goto declaration by ctrl+click will incorrectly select contents
- enhacement: alt+shift+arrow do column selection - enhancement: alt+shift+arrow do column selection
- fix: input may cause error, if selection in column mode and begin/end at the same column
- enhancement: draw selection line if selection in column mode and begin/end at the same column
Red Panda C++ Version 1.0.0 Red Panda C++ Version 1.0.0
- fix: calculation for code snippets's tab stop positions is not correct - fix: calculation for code snippets's tab stop positions is not correct

View File

@ -701,6 +701,9 @@ void Editor::keyPressEvent(QKeyEvent *event)
if (t.isEmpty()) if (t.isEmpty())
return; return;
if (activeSelectionMode()==SynSelectionMode::smColumn)
return;
QChar ch = t[0]; QChar ch = t[0];
if (isIdentChar(ch)) { if (isIdentChar(ch)) {
mLastIdCharPressed++; mLastIdCharPressed++;

View File

@ -1037,6 +1037,11 @@ bool SynEdit::selAvail() const
((mBlockBegin.Line != mBlockEnd.Line) && (mActiveSelectionMode != SynSelectionMode::smColumn)); ((mBlockBegin.Line != mBlockEnd.Line) && (mActiveSelectionMode != SynSelectionMode::smColumn));
} }
bool SynEdit::colSelAvail() const
{
return (mActiveSelectionMode == SynSelectionMode::smColumn && mBlockBegin.Line!=mBlockEnd.Line);
}
QString SynEdit::wordAtCursor() QString SynEdit::wordAtCursor()
{ {
return wordAtRowCol(caretXY()); return wordAtRowCol(caretXY());
@ -2917,7 +2922,7 @@ void SynEdit::doPasteFromClipboard()
blockEnd(), blockEnd(),
selText(), selText(),
mActiveSelectionMode); mActiveSelectionMode);
} else } else if (!colSelAvail())
setActiveSelectionMode(selectionMode()); setActiveSelectionMode(selectionMode());
BufferCoord vStartOfBlock = blockBegin(); BufferCoord vStartOfBlock = blockBegin();
BufferCoord vEndOfBlock = blockEnd(); BufferCoord vEndOfBlock = blockEnd();
@ -4786,7 +4791,7 @@ void SynEdit::moveCaretVert(int DY, bool isSelection)
if (qApp->keyboardModifiers().testFlag(Qt::AltModifier)) if (qApp->keyboardModifiers().testFlag(Qt::AltModifier))
setActiveSelectionMode(SynSelectionMode::smColumn); setActiveSelectionMode(SynSelectionMode::smColumn);
else else
setSelectionMode(selectionMode()); setActiveSelectionMode(selectionMode());
} }
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection); moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
decPaintLock(); decPaintLock();
@ -4914,7 +4919,7 @@ void SynEdit::doSetSelText(const QString &Value)
mUndoList->AddChange( mUndoList->AddChange(
SynChangeReason::crDelete, mBlockBegin, mBlockEnd, SynChangeReason::crDelete, mBlockBegin, mBlockEnd,
selText(), mActiveSelectionMode); selText(), mActiveSelectionMode);
} else } else if (!colSelAvail())
setActiveSelectionMode(selectionMode()); setActiveSelectionMode(selectionMode());
BufferCoord StartOfBlock = blockBegin(); BufferCoord StartOfBlock = blockBegin();
BufferCoord EndOfBlock = blockEnd(); BufferCoord EndOfBlock = blockEnd();

View File

@ -208,6 +208,7 @@ public:
void lockPainter(); void lockPainter();
void unlockPainter(); void unlockPainter();
bool selAvail() const; bool selAvail() const;
bool colSelAvail() const;
QString wordAtCursor(); QString wordAtCursor();
QString wordAtRowCol(const BufferCoord& XY); QString wordAtRowCol(const BufferCoord& XY);