- 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: "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) - 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: 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 Red Panda C++ Version 0.13.1
- enhancement: suppoort localization info in project templates - 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() void SynEdit::doDuplicateLine()
{ {
if (!mReadOnly && (mLines->count() > 0)) { if (!mReadOnly && (mLines->count() > 0)) {
@ -2823,7 +2829,11 @@ void SynEdit::doAddChar(QChar AChar)
void SynEdit::doCutToClipboard() void SynEdit::doCutToClipboard()
{ {
if (mReadOnly || !selAvail()) if (mReadOnly)
return;
if (!selAvail())
doSelecteLine();
if (!selAvail())
return; return;
mUndoList->BeginBlock(); mUndoList->BeginBlock();
auto action = finally([this] { auto action = finally([this] {
@ -2836,7 +2846,10 @@ void SynEdit::doCutToClipboard()
void SynEdit::doCopyToClipboard() void SynEdit::doCopyToClipboard()
{ {
if (!selAvail()) if (!selAvail())
doSelecteLine();
if (!selAvail()) {
return; return;
}
bool ChangeTrim = (mActiveSelectionMode == SynSelectionMode::smColumn) && bool ChangeTrim = (mActiveSelectionMode == SynSelectionMode::smColumn) &&
mOptions.testFlag(eoTrimTrailingSpaces); mOptions.testFlag(eoTrimTrailingSpaces);
QString sText; QString sText;
@ -5539,12 +5552,11 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
} }
break; break;
case SynEditorCommand::ecCut: case SynEditorCommand::ecCut:
if (!mReadOnly && selAvail()) if (!mReadOnly)
doCutToClipboard(); doCutToClipboard();
break; break;
case SynEditorCommand::ecCopy: case SynEditorCommand::ecCopy:
if (selAvail()) doCopyToClipboard();
doCopyToClipboard();
break; break;
case SynEditorCommand::ecPaste: case SynEditorCommand::ecPaste:
if (!mReadOnly) if (!mReadOnly)

View File

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