summaryrefslogtreecommitdiffstats
path: root/win/tkWinClipboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinClipboard.c')
-rw-r--r--win/tkWinClipboard.c57
1 files changed, 11 insertions, 46 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 200883f..76711b5 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -12,7 +12,6 @@
#include "tkWinInt.h"
#include "tkSelect.h"
-#include <shlobj.h> /* for DROPFILES */
static void UpdateClipboard(HWND hwnd);
@@ -53,7 +52,7 @@ TkSelGetSelection(
Tcl_DString ds;
HGLOBAL handle;
Tcl_Encoding encoding;
- int result, locale, noBackslash = 0;
+ int result, locale;
if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD"))
|| (target != XA_STRING)
@@ -105,7 +104,7 @@ TkSelGetSelection(
*/
locale = LANGIDFROMLCID(*((int*)data));
- GetLocaleInfoA(locale, LOCALE_IDEFAULTANSICODEPAGE,
+ GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE,
Tcl_DStringValue(&ds)+2, Tcl_DStringLength(&ds)-2);
GlobalUnlock(handle);
@@ -133,37 +132,7 @@ 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;
@@ -177,9 +146,6 @@ TkSelGetSelection(
while (*data) {
if (data[0] == '\r' && data[1] == '\n') {
data++;
- } else if (noBackslash && data[0] == '\\') {
- data++;
- *destPtr++ = '/';
} else {
*destPtr++ = *data++;
}
@@ -190,16 +156,15 @@ TkSelGetSelection(
* Pass the data off to the selection procedure.
*/
- result = proc(clientData, interp, Tcl_DStringValue(&ds));
+ result = (*proc)(clientData, interp, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
CloseClipboard();
return result;
error:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "%s selection doesn't exist or form \"%s\" not defined",
- Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target)));
- Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
+ Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
+ " selection doesn't exist or form \"",
+ Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
return TCL_ERROR;
}
@@ -309,7 +274,7 @@ TkWinClipboardRender(
* Copy the data and change EOL characters.
*/
- buffer = rawText = ckalloc(length + 1);
+ buffer = rawText = ckalloc((unsigned)length + 1);
if (targetPtr != NULL) {
for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
cbPtr = cbPtr->nextPtr) {
@@ -329,7 +294,7 @@ TkWinClipboardRender(
* encoding before placing it on the clipboard.
*/
-#ifdef UNICODE
+ if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
Tcl_DStringInit(&ds);
Tcl_UtfToUniCharDString(rawText, -1, &ds);
ckfree(rawText);
@@ -345,7 +310,7 @@ TkWinClipboardRender(
GlobalUnlock(handle);
Tcl_DStringFree(&ds);
SetClipboardData(CF_UNICODETEXT, handle);
-#else
+ } else {
Tcl_UtfToExternalDString(NULL, rawText, -1, &ds);
ckfree(rawText);
handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
@@ -360,7 +325,7 @@ TkWinClipboardRender(
GlobalUnlock(handle);
Tcl_DStringFree(&ds);
SetClipboardData(CF_TEXT, handle);
-#endif
+ }
}
/*
@@ -419,7 +384,7 @@ UpdateClipboard(
* possible.
*/
- if (TkWinGetPlatformId() != VER_PLATFORM_WIN32_WINDOWS) {
+ if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
SetClipboardData(CF_UNICODETEXT, NULL);
} else {
SetClipboardData(CF_TEXT, NULL);