From 1ce0ec3d323d1736ce89666335610b60846f664f Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 28 Jul 2022 21:19:54 +0800 Subject: [PATCH] - enhancement: disable column mode in readonly editors --- NEWS.md | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 25759888..8caabc6b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ Red Panda C++ Version 1.1.6 - enhancement: don't show cpp defines when editing c files - enhancement: choose default language when first run - fix: Drag&Drop no correctly disabled for readonly editors + - enhancement: disable column mode in readonly editors Red Panda C++ Version 1.1.5 diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index c7779592..5f66fd89 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -4958,7 +4958,7 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection) incPaintLock(); if (mOptions.testFlag(eoAltSetsColumnMode) && (mActiveSelectionMode != SynSelectionMode::Line)) { - if (qApp->keyboardModifiers().testFlag(Qt::AltModifier)) { + if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) { setActiveSelectionMode(SynSelectionMode::Column); } else setActiveSelectionMode(selectionMode()); @@ -5001,7 +5001,7 @@ void SynEdit::moveCaretVert(int DY, bool isSelection) incPaintLock(); if (mOptions.testFlag(eoAltSetsColumnMode) && (mActiveSelectionMode != SynSelectionMode::Line)) { - if (qApp->keyboardModifiers().testFlag(Qt::AltModifier)) + if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) setActiveSelectionMode(SynSelectionMode::Column); else setActiveSelectionMode(selectionMode()); @@ -6285,9 +6285,8 @@ void SynEdit::mousePressEvent(QMouseEvent *event) //code from above and SetBlockEnd will take care of proper invalidation setBlockEnd(caretXY()); } else if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line) - && !mReadOnly) { - if (event->modifiers() == Qt::AltModifier) + (mActiveSelectionMode != SynSelectionMode::Line)) { + if (event->modifiers() == Qt::AltModifier && !mReadOnly) setActiveSelectionMode(SynSelectionMode::Column); else setActiveSelectionMode(selectionMode()); @@ -6348,9 +6347,8 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) } } else if (buttons == Qt::LeftButton) { if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line) - && !mReadOnly) { - if (event->modifiers() == Qt::AltModifier) + (mActiveSelectionMode != SynSelectionMode::Line) ) { + if (event->modifiers() == Qt::AltModifier && !mReadOnly) setActiveSelectionMode(SynSelectionMode::Column); else setActiveSelectionMode(selectionMode());