diff --git a/NEWS.md b/NEWS.md index 353b34de..30c59957 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 4645256f..4292c83f 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -184,7 +184,7 @@ Editor::Editor(QWidget *parent, const QString& filename, setCaretPosition(1,1); mCanAutoSave = true; } - } + } if (!isNew && parentPageControl) { resetBookmarks(); resetBreakpoints(); @@ -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()); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 593cd00b..a9db4cd3 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -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()); diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index cbbd80ff..bfc580b0 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -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) diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index 01679d29..6fc4dc61 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -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();