- enhancement: if there's no selection when copy/cut, select currect line by default

This commit is contained in:
Roy Qu 2022-01-10 18:37:00 +08:00
parent 5eec4ea504
commit 0e0f954bec
3 changed files with 18 additions and 4 deletions

View File

@ -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

View File

@ -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,11 +5552,10 @@ 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();
break;
case SynEditorCommand::ecPaste:

View File

@ -555,6 +555,7 @@ private:
void doDeleteLastWord();
void doDeleteFromBOL();
void doDeleteLine();
void doSelecteLine();
void doDuplicateLine();
void doMoveSelUp();
void doMoveSelDown();