diff options
author | Justin Dailey <unknown> | 2020-04-10 08:16:50 +1000 |
---|---|---|
committer | Justin Dailey <unknown> | 2020-04-10 08:16:50 +1000 |
commit | fc79966496fc5efd7f5bb0ea4b5aa394abe1e363 (patch) | |
tree | 8786205c525a8b70876e4b5e4a89e09fe3548432 | |
parent | bccddaa3cb64acce1af28e972b898be2b2e60001 (diff) | |
download | scintilla-mirror-fc79966496fc5efd7f5bb0ea4b5aa394abe1e363.tar.gz |
Bug [#2167]. Add line copy format on clipboard, compatible with Visual Studio.
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | qt/ScintillaEditBase/ScintillaQt.cpp | 34 |
2 files changed, 37 insertions, 1 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 49a0ca0e0..0f0dac916 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -599,6 +599,10 @@ GCS_RESULTSTR set. </li> <li> + With Qt on Win32 add support for line copy format on clipboard, compatible with Visual Studio. + <a href="https://sourceforge.net/p/scintilla/bugs/2167/">Bug #2167</a>. + </li> + <li> On GTK with Wayland fix display of windowed IME. <a href="https://sourceforge.net/p/scintilla/bugs/2149/">Bug #2149</a>. </li> diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp index 9a2545a38..4236c7f86 100644 --- a/qt/ScintillaEditBase/ScintillaQt.cpp +++ b/qt/ScintillaEditBase/ScintillaQt.cpp @@ -61,6 +61,8 @@ void ScintillaQt::execCommand(QAction *action) #if defined(Q_OS_WIN) static const QString sMSDEVColumnSelect("MSDEVColumnSelect"); static const QString sWrappedMSDEVColumnSelect("application/x-qt-windows-mime;value=\"MSDEVColumnSelect\""); +static const QString sVSEditorLineCutCopy("VisualStudioEditorOperationsLineCutCopyClipboardTag"); +static const QString sWrappedVSEditorLineCutCopy("application/x-qt-windows-mime;value=\"VisualStudioEditorOperationsLineCutCopyClipboardTag\""); #elif defined(Q_OS_MAC) static const QString sScintillaRecPboardType("com.scintilla.utf16-plain-text.rectangular"); static const QString sScintillaRecMimeType("text/x-scintilla.utf16-plain-text.rectangular"); @@ -189,6 +191,14 @@ static void AddRectangularToMime(QMimeData *mimeData, QString su) #endif } +static void AddLineCutCopyToMime(QMimeData *mimeData) +{ +#if defined(Q_OS_WIN) + // Add an empty marker + mimeData->setData(sVSEditorLineCutCopy, QByteArray()); +#endif +} + static bool IsRectangularInMime(const QMimeData *mimeData) { QStringList formats = mimeData->formats(); @@ -213,6 +223,23 @@ static bool IsRectangularInMime(const QMimeData *mimeData) return false; } +static bool IsLineCutCopyInMime(const QMimeData *mimeData) +{ + QStringList formats = mimeData->formats(); + for (int i = 0; i < formats.size(); ++i) { +#if defined(Q_OS_WIN) + // Visual Studio Line Cut/Copy markers + // If line cut/copy made by this application, see base name. + if (formats[i] == sVSEditorLineCutCopy) + return true; + // Otherwise see wrapped name. + if (formats[i] == sWrappedVSEditorLineCutCopy) + return true; +#endif + } + return false; +} + bool ScintillaQt::ValidCodePage(int codePage) const { return codePage == 0 @@ -302,6 +329,10 @@ void ScintillaQt::CopyToModeClipboard(const SelectionText &selectedText, QClipbo AddRectangularToMime(mimeData, su); } + if (selectedText.lineCopy) { + AddLineCutCopyToMime(mimeData); + } + // Allow client code to add additional data (e.g rich text). emit aboutToCopy(mimeData); @@ -327,6 +358,7 @@ void ScintillaQt::PasteFromMode(QClipboard::Mode clipboardMode_) QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(clipboardMode_); bool isRectangular = IsRectangularInMime(mimeData); + bool isLine = SelectionEmpty() && IsLineCutCopyInMime(mimeData); QString text = clipboard->text(clipboardMode_); QByteArray utext = BytesForDocument(text); std::string dest(utext.constData(), utext.length()); @@ -336,7 +368,7 @@ void ScintillaQt::PasteFromMode(QClipboard::Mode clipboardMode_) UndoGroup ug(pdoc); ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); InsertPasteShape(selText.Data(), selText.Length(), - selText.rectangular ? pasteRectangular : pasteStream); + isRectangular ? pasteRectangular : (isLine ? pasteLine : pasteStream)); EnsureCaretVisible(); } |