summaryrefslogtreecommitdiffstats
path: root/win/tkWinClipboard.c
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2015-12-14 10:00:01 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2015-12-14 10:00:01 (GMT)
commitf59dbeeff6ce7a7d39febca41fd2a363e3bc00ac (patch)
tree9ee0c18fad59bf70b72c827a8a4145d476dc9463 /win/tkWinClipboard.c
parent187c36aaddddaeb8deb89f30056a02b5f76bbba6 (diff)
downloadtk-f59dbeeff6ce7a7d39febca41fd2a363e3bc00ac.zip
tk-f59dbeeff6ce7a7d39febca41fd2a363e3bc00ac.tar.gz
tk-f59dbeeff6ce7a7d39febca41fd2a363e3bc00ac.tar.bz2
Support to paste file list (e.g. support CF_HDROPtype) Ticket [9fcc519a7c]
Diffstat (limited to 'win/tkWinClipboard.c')
-rwxr-xr-x[-rw-r--r--]win/tkWinClipboard.c39
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++;
}
}