diff --git a/NEWS.md b/NEWS.md index ffdee866..f211df67 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ Red Panda C++ Version 0.13.2 - fix: "delete and exit" button in the environtment / page option page doesn't work correctly - fix: crash when closing the options dialog under Ubuntu 20.04 LTS ( no memory leak now) - enhancement: can add non-code file in templates + - enhancement: if there's no selection when copy/cut, select currect line by default Red Panda C++ Version 0.13.1 - enhancement: suppoort localization info in project templates diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 76e7df5b..d7da9530 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -2054,6 +2054,12 @@ void SynEdit::doDeleteLine() } } +void SynEdit::doSelecteLine() +{ + setBlockBegin(BufferCoord{1,mCaretY}); + setBlockEnd(BufferCoord{lineText().length()+1,mCaretY}); +} + void SynEdit::doDuplicateLine() { if (!mReadOnly && (mLines->count() > 0)) { @@ -2823,7 +2829,11 @@ void SynEdit::doAddChar(QChar AChar) void SynEdit::doCutToClipboard() { - if (mReadOnly || !selAvail()) + if (mReadOnly) + return; + if (!selAvail()) + doSelecteLine(); + if (!selAvail()) return; mUndoList->BeginBlock(); auto action = finally([this] { @@ -2836,7 +2846,10 @@ void SynEdit::doCutToClipboard() void SynEdit::doCopyToClipboard() { if (!selAvail()) + doSelecteLine(); + if (!selAvail()) { return; + } bool ChangeTrim = (mActiveSelectionMode == SynSelectionMode::smColumn) && mOptions.testFlag(eoTrimTrailingSpaces); QString sText; @@ -5539,12 +5552,11 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) } break; case SynEditorCommand::ecCut: - if (!mReadOnly && selAvail()) + if (!mReadOnly) doCutToClipboard(); break; case SynEditorCommand::ecCopy: - if (selAvail()) - doCopyToClipboard(); + doCopyToClipboard(); break; case SynEditorCommand::ecPaste: if (!mReadOnly) diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index d4689b0d..ea5cee8c 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -555,6 +555,7 @@ private: void doDeleteLastWord(); void doDeleteFromBOL(); void doDeleteLine(); + void doSelecteLine(); void doDuplicateLine(); void doMoveSelUp(); void doMoveSelDown();