diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2015-12-14 10:00:01 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2015-12-14 10:00:01 (GMT) |
commit | f98486f81600c792bfb248f8f8eb87058f2d1040 (patch) | |
tree | 9ee0c18fad59bf70b72c827a8a4145d476dc9463 | |
parent | 3f1055f6005a1124d104b5c8c94e3f83e3604723 (diff) | |
download | tk-f98486f81600c792bfb248f8f8eb87058f2d1040.zip tk-f98486f81600c792bfb248f8f8eb87058f2d1040.tar.gz tk-f98486f81600c792bfb248f8f8eb87058f2d1040.tar.bz2 |
Support to paste file list (e.g. support CF_HDROPtype) Ticket [9fcc519a7c]
-rwxr-xr-x[-rw-r--r--] | win/tkWinClipboard.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 2501688..a616af5 100644..100755 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -12,6 +12,7 @@ #include "tkWinInt.h" #include "tkSelect.h" +#include <shlobj.h> /* for DROPFILES */ static void UpdateClipboard(HWND hwnd); @@ -52,7 +53,7 @@ TkSelGetSelection( Tcl_DString ds; HGLOBAL handle; Tcl_Encoding encoding; - int result, locale; + int result, locale, noBackslash = 0; if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD")) || (target != XA_STRING) @@ -132,7 +133,37 @@ TkSelGetSelection( if (encoding) { Tcl_FreeEncoding(encoding); } - + } else if (IsClipboardFormatAvailable(CF_HDROP)) { + DROPFILES *drop; + + handle = GetClipboardData(CF_HDROP); + if (!handle) { + CloseClipboard(); + goto error; + } + Tcl_DStringInit(&ds); + drop = (DROPFILES *) GlobalLock(handle); + if (drop->fWide) { + WCHAR *fname = (WCHAR *) ((char *) drop + drop->pFiles); + Tcl_DString dsTmp; + int count = 0, len; + + while (*fname != 0) { + if (count) { + Tcl_DStringAppend(&ds, "\n", 1); + } + len = Tcl_UniCharLen((Tcl_UniChar *) fname); + Tcl_DStringInit(&dsTmp); + Tcl_UniCharToUtfDString((Tcl_UniChar *) fname, len, &dsTmp); + Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsTmp), + Tcl_DStringLength(&dsTmp)); + Tcl_DStringFree(&dsTmp); + fname += len + 1; + count++; + } + noBackslash = (count > 0); + } + GlobalUnlock(handle); } else { CloseClipboard(); goto error; @@ -146,7 +177,9 @@ TkSelGetSelection( while (*data) { if (data[0] == '\r' && data[1] == '\n') { data++; - } else { + } else if (noBackslash && data[0] == '\\') { + data++; + *destPtr++ = '/'; } else { *destPtr++ = *data++; } } |