From f98486f81600c792bfb248f8f8eb87058f2d1040 Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 14 Dec 2015 10:00:01 +0000 Subject: Support to paste file list (e.g. support CF_HDROPtype) Ticket [9fcc519a7c] --- win/tkWinClipboard.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) mode change 100644 => 100755 win/tkWinClipboard.c diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c old mode 100644 new mode 100755 index 2501688..a616af5 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -12,6 +12,7 @@ #include "tkWinInt.h" #include "tkSelect.h" +#include /* 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++; } } -- cgit v0.12 From 11483b44ac56938fe3548e59216eca6886180a0b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Dec 2015 10:32:48 +0000 Subject: minor formatting --- win/tkWinClipboard.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index a616af5..200883f 100755 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -135,7 +135,7 @@ TkSelGetSelection( } } else if (IsClipboardFormatAvailable(CF_HDROP)) { DROPFILES *drop; - + handle = GetClipboardData(CF_HDROP); if (!handle) { CloseClipboard(); @@ -147,7 +147,7 @@ TkSelGetSelection( WCHAR *fname = (WCHAR *) ((char *) drop + drop->pFiles); Tcl_DString dsTmp; int count = 0, len; - + while (*fname != 0) { if (count) { Tcl_DStringAppend(&ds, "\n", 1); @@ -179,7 +179,8 @@ TkSelGetSelection( data++; } else if (noBackslash && data[0] == '\\') { data++; - *destPtr++ = '/'; } else { + *destPtr++ = '/'; + } else { *destPtr++ = *data++; } } -- cgit v0.12