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
commit6a3def7b51ade909d6902346279a42a6bd52304a (patch)
treeadb0421ea88d361ffd0ceb9180cfbffc5cf58a06
parent4802759822f464acdd106a81ea3729e58b1f23bb (diff)
downloadscintilla-mirror-6a3def7b51ade909d6902346279a42a6bd52304a.tar.gz
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.
-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 10b4b7f1c..f1fa9c3b9 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -592,6 +592,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://www.scintilla.org/scite423.zip">Release 4.2.3</a>
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 99a54c1aa..6847d4a83 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -2206,11 +2206,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 {
@@ -2324,38 +2320,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 size_t ulen = WideCharFromMultiByte(CP_ACP,
- std::string_view(ptr, len), &uptr[0], len + 1);
-
- const std::wstring_view wsv(&uptr[0], ulen);
- const size_t mlen = UTF8Length(wsv);
- std::vector<char> putf(mlen+1);
- UTF8FromUTF16(wsv, &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) {