aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-01-09 14:21:37 +1100
committerNeil <nyamatongwe@gmail.com>2020-01-09 14:21:37 +1100
commitefc60deb7937c6763985ba33d34fe65830778eed (patch)
tree965b5ddfcf293807458906b88a7aa71d26c31d78
parentacb7c70264348bc80c151bfc76c7b107e8db99ab (diff)
downloadscintilla-mirror-efc60deb7937c6763985ba33d34fe65830778eed.tar.gz
Backport: Remove support for CF_TEXT clipboard format. CF_UNICODETEXT is now used in all
cases. Windows automatically provides CF_UNICODETEXT when CF_TEXT on clipboard. This does not change drag-and-drop as that depends on CF_TEXT such as when dragging from DBCS. Backport of changeset 7946:4dad3058a477.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--win32/ScintillaWin.cxx46
2 files changed, 5 insertions, 45 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index d15381d79..bbc9c826d 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -579,6 +579,10 @@
Don't clear clipboard before copying text with Qt.
<a href="https://sourceforge.net/p/scintilla/bugs/2147/">Bug #2147</a>.
</li>
+ <li>
+ On Win32, remove support for CF_TEXT clipboard format as Windows will convert to
+ CF_UNICODETEXT.
+ </li>
</ul>
<h3>
<a href="https://sourceforge.net/projects/scintilla/files/scintilla/3.11.2/scintilla3112.zip/download">Release 3.11.2</a>
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index dbb83d9f6..dc31987fb 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -2204,11 +2204,7 @@ void ScintillaWin::CopyAllowLine() {
bool ScintillaWin::CanPaste() {
if (!Editor::CanPaste())
return false;
- if (::IsClipboardFormatAvailable(CF_TEXT))
- return true;
- if (IsUnicodeMode())
- return ::IsClipboardFormatAvailable(CF_UNICODETEXT) != 0;
- return false;
+ return ::IsClipboardFormatAvailable(CF_UNICODETEXT) != FALSE;
}
namespace {
@@ -2323,38 +2319,6 @@ void ScintillaWin::Paste() {
InsertPasteShape(&putf[0], len, pasteShape);
}
memUSelection.Unlock();
- } else {
- // CF_UNICODETEXT not available, paste ANSI text
- GlobalMemory memSelection(::GetClipboardData(CF_TEXT));
- if (memSelection) {
- const char *ptr = static_cast<const char *>(memSelection.ptr);
- if (ptr) {
- const size_t bytes = memSelection.Size();
- size_t len = bytes;
- for (size_t i = 0; i < bytes; i++) {
- if ((len == bytes) && (0 == ptr[i]))
- len = i;
- }
-
- // In Unicode mode, convert clipboard text to UTF-8
- if (IsUnicodeMode()) {
- std::vector<wchar_t> uptr(len+1);
-
- const int ilen = static_cast<int>(len);
- const size_t ulen = ::MultiByteToWideChar(CP_ACP, 0,
- ptr, ilen, &uptr[0], ilen +1);
-
- const size_t mlen = UTF8Length(&uptr[0], ulen);
- std::vector<char> putf(mlen+1);
- UTF8FromUTF16(&uptr[0], ulen, &putf[0], mlen);
-
- InsertPasteShape(&putf[0], mlen, pasteShape);
- } else {
- InsertPasteShape(ptr, len, pasteShape);
- }
- }
- memSelection.Unlock();
- }
}
::CloseClipboard();
Redraw();
@@ -2867,14 +2831,6 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
if (uniText) {
uniText.SetClip(CF_UNICODETEXT);
- } else {
- // There was a failure - try to copy at least ANSI text
- GlobalMemory ansiText;
- ansiText.Allocate(selectedText.LengthWithTerminator());
- if (ansiText) {
- memcpy(ansiText.ptr, selectedText.Data(), selectedText.LengthWithTerminator());
- ansiText.SetClip(CF_TEXT);
- }
}
if (selectedText.rectangular) {