From 8b224010e01e92f2cf718842182169e82541080c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 25 Mar 2022 12:59:53 +0800 Subject: [PATCH] - 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 --- NEWS.md | 4 +++- RedPandaIDE/editor.cpp | 3 +++ RedPandaIDE/qsynedit/SynEdit.cpp | 11 ++++++++--- RedPandaIDE/qsynedit/SynEdit.h | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 62978d8b..9ab9bfd9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,7 +18,9 @@ Red Panda C++ Version 1.0.1 - enhancement: switch capslock won't cancel code completion - enhancement: double click on item in code completion list will use it to complete - 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 - fix: calculation for code snippets's tab stop positions is not correct diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 770e07c0..b1c337c7 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -701,6 +701,9 @@ void Editor::keyPressEvent(QKeyEvent *event) if (t.isEmpty()) return; + if (activeSelectionMode()==SynSelectionMode::smColumn) + return; + QChar ch = t[0]; if (isIdentChar(ch)) { mLastIdCharPressed++; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 8293007f..b1ed4024 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -1037,6 +1037,11 @@ bool SynEdit::selAvail() const ((mBlockBegin.Line != mBlockEnd.Line) && (mActiveSelectionMode != SynSelectionMode::smColumn)); } +bool SynEdit::colSelAvail() const +{ + return (mActiveSelectionMode == SynSelectionMode::smColumn && mBlockBegin.Line!=mBlockEnd.Line); +} + QString SynEdit::wordAtCursor() { return wordAtRowCol(caretXY()); @@ -2917,7 +2922,7 @@ void SynEdit::doPasteFromClipboard() blockEnd(), selText(), mActiveSelectionMode); - } else + } else if (!colSelAvail()) setActiveSelectionMode(selectionMode()); BufferCoord vStartOfBlock = blockBegin(); BufferCoord vEndOfBlock = blockEnd(); @@ -4786,7 +4791,7 @@ void SynEdit::moveCaretVert(int DY, bool isSelection) if (qApp->keyboardModifiers().testFlag(Qt::AltModifier)) setActiveSelectionMode(SynSelectionMode::smColumn); else - setSelectionMode(selectionMode()); + setActiveSelectionMode(selectionMode()); } moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection); decPaintLock(); @@ -4914,7 +4919,7 @@ void SynEdit::doSetSelText(const QString &Value) mUndoList->AddChange( SynChangeReason::crDelete, mBlockBegin, mBlockEnd, selText(), mActiveSelectionMode); - } else + } else if (!colSelAvail()) setActiveSelectionMode(selectionMode()); BufferCoord StartOfBlock = blockBegin(); BufferCoord EndOfBlock = blockEnd(); diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index e7cfb2ff..7efd6d25 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -208,6 +208,7 @@ public: void lockPainter(); void unlockPainter(); bool selAvail() const; + bool colSelAvail() const; QString wordAtCursor(); QString wordAtRowCol(const BufferCoord& XY);