diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2015-12-14 15:14:01 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2015-12-14 15:14:01 (GMT) |
commit | 66ba0bfddcbc40934af2383e187fc55d981902f4 (patch) | |
tree | b5e89b9ec51bfdbad14582aa57e782c92b985f76 | |
parent | 63f1bed7bb0c9cdd0a7171121ae98f5c8c33224e (diff) | |
parent | 11483b44ac56938fe3548e59216eca6886180a0b (diff) | |
download | tk-66ba0bfddcbc40934af2383e187fc55d981902f4.zip tk-66ba0bfddcbc40934af2383e187fc55d981902f4.tar.gz tk-66ba0bfddcbc40934af2383e187fc55d981902f4.tar.bz2 |
Support to paste file list (e.g. support CF_HDROPtype) Ticket [9fcc519a7c]
-rw-r--r-- | win/tkWinClipboard.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 2501688..200883f 100644 --- 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,6 +177,9 @@ TkSelGetSelection( while (*data) { if (data[0] == '\r' && data[1] == '\n') { data++; + } else if (noBackslash && data[0] == '\\') { + data++; + *destPtr++ = '/'; } else { *destPtr++ = *data++; } |