- 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. - 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+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: 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 Red Panda C++ Version 2.16

View File

@ -184,7 +184,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
setCaretPosition(1,1); setCaretPosition(1,1);
mCanAutoSave = true; mCanAutoSave = true;
} }
} }
if (!isNew && parentPageControl) { if (!isNew && parentPageControl) {
resetBookmarks(); resetBookmarks();
resetBreakpoints(); resetBreakpoints();
@ -1455,6 +1455,7 @@ void Editor::copyToClipboard()
return; return;
} }
} }
switch(pSettings->editor().copyWithFormatAs()) { switch(pSettings->editor().copyWithFormatAs()) {
case 1: //HTML case 1: //HTML
copyAsHTML(); copyAsHTML();
@ -1485,8 +1486,9 @@ void Editor::cutToClipboard()
void Editor::copyAsHTML() void Editor::copyAsHTML()
{ {
if (!selAvail()) if (!selAvail()) {
return; doSelectLine();
}
QSynedit::HTMLExporter exporter(tabWidth(), pCharsetInfoManager->getDefaultSystemEncoding()); QSynedit::HTMLExporter exporter(tabWidth(), pCharsetInfoManager->getDefaultSystemEncoding());
exporter.setTitle(QFileInfo(mFilename).fileName()); 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->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->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->actionCut->setEnabled(true);
ui->actionFoldAll->setEnabled(e->document()->count()>0); ui->actionFoldAll->setEnabled(e->document()->count()>0);
ui->actionIndent->setEnabled(!e->readOnly()); 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()) if (mCaretY==mDocument->count())
setBlockEnd(BufferCoord{lineText().length()+1,mCaretY}); ptEnd = BufferCoord{lineText().length()+1,mCaretY};
else else
setBlockEnd(BufferCoord{1,mCaretY+1}); ptEnd = BufferCoord{1,mCaretY+1};
setCaretAndSelection(ptBegin,ptBegin,ptEnd);
} }
void QSynEdit::doDuplicateLine() void QSynEdit::doDuplicateLine()
@ -2954,7 +2956,7 @@ void QSynEdit::doCutToClipboard()
addCaretToUndo(); addCaretToUndo();
addSelectionToUndo(); addSelectionToUndo();
if (!selAvail()) { if (!selAvail()) {
doSelecteLine(); doSelectLine();
} }
internalDoCopyToClipboard(selText()); internalDoCopyToClipboard(selText());
setSelectedTextEmpty(); setSelectedTextEmpty();
@ -2966,14 +2968,10 @@ void QSynEdit::doCopyToClipboard()
{ {
bool selected=selAvail(); bool selected=selAvail();
if (!selected) if (!selected)
doSelecteLine(); doSelectLine();
QString sText; QString sText;
sText = selText(); sText = selText();
internalDoCopyToClipboard(sText); internalDoCopyToClipboard(sText);
if (!selected) {
setBlockBegin(caretXY());
setBlockEnd(caretXY());
}
} }
void QSynEdit::internalDoCopyToClipboard(const QString &s) void QSynEdit::internalDoCopyToClipboard(const QString &s)

View File

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