- enhancement: If no selection, Ctrl+C (Copy) auto selects the current line and put the cursor to the beginning.

This commit is contained in:
Roy Qu 2023-03-09 11:19:57 +08:00
parent cf7296af8c
commit 3a0d3f684a
5 changed files with 18 additions and 15 deletions

View File

@ -16,6 +16,7 @@ Red Panda C++ Version 2.17
- fix: Cpu info window is auto openned, when debug using gdb-server.
- enhancement: Shift+Up in the first line will expand selection to the beginning of the line.
- enhancement: Shift+Down in the last line will expand selection to the end of the line.
- enhancement: If no selection, Ctrl+C (Copy) auto selects the current line and put the cursor to the beginning.
Red Panda C++ Version 2.16

View File

@ -1455,6 +1455,7 @@ void Editor::copyToClipboard()
return;
}
}
switch(pSettings->editor().copyWithFormatAs()) {
case 1: //HTML
copyAsHTML();
@ -1485,8 +1486,9 @@ void Editor::cutToClipboard()
void Editor::copyAsHTML()
{
if (!selAvail())
return;
if (!selAvail()) {
doSelectLine();
}
QSynedit::HTMLExporter exporter(tabWidth(), pCharsetInfoManager->getDefaultSystemEncoding());
exporter.setTitle(QFileInfo(mFilename).fileName());

View File

@ -606,7 +606,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionConvert_to_UTF_8->setEnabled(e->encodingOption()!=ENCODING_UTF8 && e->fileEncoding()!=ENCODING_UTF8);
ui->actionConvert_to_UTF_8_BOM->setEnabled(e->encodingOption()!=ENCODING_UTF8_BOM && e->fileEncoding()!=ENCODING_UTF8_BOM);
ui->actionCopy->setEnabled(e->selAvail());
ui->actionCopy->setEnabled(true);
ui->actionCut->setEnabled(true);
ui->actionFoldAll->setEnabled(e->document()->count()>0);
ui->actionIndent->setEnabled(!e->readOnly());

View File

@ -2189,13 +2189,15 @@ void QSynEdit::doDeleteLine()
}
}
void QSynEdit::doSelecteLine()
void QSynEdit::doSelectLine()
{
setBlockBegin(BufferCoord{1,mCaretY});
BufferCoord ptBegin=BufferCoord{1,mCaretY};
BufferCoord ptEnd;
if (mCaretY==mDocument->count())
setBlockEnd(BufferCoord{lineText().length()+1,mCaretY});
ptEnd = BufferCoord{lineText().length()+1,mCaretY};
else
setBlockEnd(BufferCoord{1,mCaretY+1});
ptEnd = BufferCoord{1,mCaretY+1};
setCaretAndSelection(ptBegin,ptBegin,ptEnd);
}
void QSynEdit::doDuplicateLine()
@ -2954,7 +2956,7 @@ void QSynEdit::doCutToClipboard()
addCaretToUndo();
addSelectionToUndo();
if (!selAvail()) {
doSelecteLine();
doSelectLine();
}
internalDoCopyToClipboard(selText());
setSelectedTextEmpty();
@ -2966,14 +2968,10 @@ void QSynEdit::doCopyToClipboard()
{
bool selected=selAvail();
if (!selected)
doSelecteLine();
doSelectLine();
QString sText;
sText = selText();
internalDoCopyToClipboard(sText);
if (!selected) {
setBlockBegin(caretXY());
setBlockEnd(caretXY());
}
}
void QSynEdit::internalDoCopyToClipboard(const QString &s)

View File

@ -468,6 +468,8 @@ protected:
virtual void onEndFirstPaintLock();
virtual void onBeginFirstPaintLock();
protected:
void doSelectLine();
private:
void beginEditingWithoutUndo();
void endEditingWithoutUndo();
@ -588,7 +590,7 @@ private:
void doDeleteToWordEnd();
void doDeleteFromBOL();
void doDeleteLine();
void doSelecteLine();
void doDuplicateLine();
void doMoveSelUp();
void doMoveSelDown();