summaryrefslogtreecommitdiffstats
path: root/win/tkWinClipboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinClipboard.c')
-rw-r--r--win/tkWinClipboard.c181
1 files changed, 90 insertions, 91 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 19dcc11..6007e56 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinClipboard.c --
*
* This file contains functions for managing the clipboard.
@@ -6,28 +6,28 @@
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-2000 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkWinInt.h"
#include "tkSelect.h"
-static void UpdateClipboard _ANSI_ARGS_((HWND hwnd));
+static void UpdateClipboard(HWND hwnd);
/*
*----------------------------------------------------------------------
*
* TkSelGetSelection --
*
- * Retrieve the specified selection from another process. For
- * now, only fetching XA_STRING from CLIPBOARD is supported.
- * Eventually other types should be allowed.
- *
+ * Retrieve the specified selection from another process. For now, only
+ * fetching XA_STRING from CLIPBOARD is supported. Eventually other types
+ * should be allowed.
+ *
* Results:
- * The return value is a standard Tcl return value.
- * If an error occurs (such as no selection exists)
- * then an error message is left in the interp's result.
+ * The return value is a standard Tcl return value. If an error occurs
+ * (such as no selection exists) then an error message is left in the
+ * interp's result.
*
* Side effects:
* None.
@@ -36,18 +36,17 @@ static void UpdateClipboard _ANSI_ARGS_((HWND hwnd));
*/
int
-TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
- Tcl_Interp *interp; /* Interpreter to use for reporting
- * errors. */
- Tk_Window tkwin; /* Window on whose behalf to retrieve
- * the selection (determines display
- * from which to retrieve). */
- Atom selection; /* Selection to retrieve. */
- Atom target; /* Desired form in which selection
- * is to be returned. */
- Tk_GetSelProc *proc; /* Procedure to call to process the
- * selection, once it has been retrieved. */
- ClientData clientData; /* Arbitrary value to pass to proc. */
+TkSelGetSelection(
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ Tk_Window tkwin, /* Window on whose behalf to retrieve the
+ * selection (determines display from which to
+ * retrieve). */
+ Atom selection, /* Selection to retrieve. */
+ Atom target, /* Desired form in which selection is to be
+ * returned. */
+ Tk_GetSelProc *proc, /* Procedure to call to process the selection,
+ * once it has been retrieved. */
+ ClientData clientData) /* Arbitrary value to pass to proc. */
{
char *data, *destPtr;
Tcl_DString ds;
@@ -62,8 +61,8 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
}
/*
- * Attempt to get the data in Unicode form if available as this is
- * less work that CF_TEXT.
+ * Attempt to get the data in Unicode form if available as this is less
+ * work that CF_TEXT.
*/
result = TCL_ERROR;
@@ -91,19 +90,17 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
}
/*
- * Get the locale identifier, determine the proper code page
- * to use, and find the corresponding encoding.
+ * Get the locale identifier, determine the proper code page to
+ * use, and find the corresponding encoding.
*/
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "cp######", -1);
data = GlobalLock(handle);
-
/*
- * Even though the documentation claims that GetLocaleInfo
- * expects an LCID, on Windows 9x it really seems to expect
- * a LanguageID.
+ * Even though the documentation claims that GetLocaleInfo expects
+ * an LCID, on Windows 9x it really seems to expect a LanguageID.
*/
locale = LANGIDFROMLCID(*((int*)data));
@@ -144,7 +141,7 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
/*
* Translate CR/LF to LF.
*/
-
+
data = destPtr = Tcl_DStringValue(&ds);
while (*data) {
if (data[0] == '\r' && data[1] == '\n') {
@@ -163,12 +160,11 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
Tcl_DStringFree(&ds);
CloseClipboard();
return result;
-
-error:
+
+ error:
Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
" selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, target),
- "\" not defined", (char *) NULL);
+ Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
return TCL_ERROR;
}
@@ -177,9 +173,8 @@ error:
*
* TkSetSelectionOwner --
*
- * This function claims ownership of the specified selection.
- * If the selection is CLIPBOARD, then we empty the system
- * clipboard.
+ * This function claims ownership of the specified selection. If the
+ * selection is CLIPBOARD, then we empty the system clipboard.
*
* Results:
* None.
@@ -191,27 +186,26 @@ error:
*/
void
-XSetSelectionOwner(display, selection, owner, time)
- Display* display;
- Atom selection;
- Window owner;
- Time time;
+XSetSelectionOwner(
+ Display *display,
+ Atom selection,
+ Window owner,
+ Time time)
{
HWND hwnd = owner ? TkWinGetHWND(owner) : NULL;
Tk_Window tkwin;
/*
- * This is a gross hack because the Tk_InternAtom interface is broken.
- * It expects a Tk_Window, even though it only needs a Tk_Display.
+ * This is a gross hack because the Tk_InternAtom interface is broken. It
+ * expects a Tk_Window, even though it only needs a Tk_Display.
*/
tkwin = (Tk_Window) TkGetMainInfoList()->winPtr;
if (selection == Tk_InternAtom(tkwin, "CLIPBOARD")) {
-
/*
- * Only claim and empty the clipboard if we aren't already the
- * owner of the clipboard.
+ * Only claim and empty the clipboard if we aren't already the owner
+ * of the clipboard.
*/
if (GetClipboardOwner() != hwnd) {
@@ -225,8 +219,8 @@ XSetSelectionOwner(display, selection, owner, time)
*
* TkWinClipboardRender --
*
- * This function supplies the contents of the clipboard in
- * response to a WM_RENDERFORMAT message.
+ * This function supplies the contents of the clipboard in response to a
+ * WM_RENDERFORMAT message.
*
* Results:
* None.
@@ -238,9 +232,9 @@ XSetSelectionOwner(display, selection, owner, time)
*/
void
-TkWinClipboardRender(dispPtr, format)
- TkDisplay *dispPtr;
- UINT format;
+TkWinClipboardRender(
+ TkDisplay *dispPtr,
+ UINT format)
{
TkClipboardTarget *targetPtr;
TkClipboardBuffer *cbPtr;
@@ -251,13 +245,14 @@ TkWinClipboardRender(dispPtr, format)
for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
targetPtr = targetPtr->nextPtr) {
- if (targetPtr->type == XA_STRING)
+ if (targetPtr->type == XA_STRING) {
break;
+ }
}
/*
- * Count the number of newlines so we can add space for them in
- * the resulting string.
+ * Count the number of newlines so we can add space for them in the
+ * resulting string.
*/
length = 0;
@@ -278,7 +273,7 @@ TkWinClipboardRender(dispPtr, format)
* 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) {
@@ -294,8 +289,8 @@ TkWinClipboardRender(dispPtr, format)
*buffer = '\0';
/*
- * Depending on the platform, turn the data into Unicode or the
- * system encoding before placing it on the clipboard.
+ * Depending on the platform, turn the data into Unicode or the system
+ * encoding before placing it on the clipboard.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -303,13 +298,14 @@ TkWinClipboardRender(dispPtr, format)
Tcl_UtfToUniCharDString(rawText, -1, &ds);
ckfree(rawText);
handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
- Tcl_DStringLength(&ds)+2);
+ (unsigned) Tcl_DStringLength(&ds) + 2);
if (!handle) {
Tcl_DStringFree(&ds);
return;
}
buffer = GlobalLock(handle);
- memcpy(buffer, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds) + 2);
+ memcpy(buffer, Tcl_DStringValue(&ds),
+ (unsigned) Tcl_DStringLength(&ds) + 2);
GlobalUnlock(handle);
Tcl_DStringFree(&ds);
SetClipboardData(CF_UNICODETEXT, handle);
@@ -317,19 +313,18 @@ TkWinClipboardRender(dispPtr, format)
Tcl_UtfToExternalDString(NULL, rawText, -1, &ds);
ckfree(rawText);
handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
- Tcl_DStringLength(&ds)+1);
+ (unsigned) Tcl_DStringLength(&ds) + 1);
if (!handle) {
Tcl_DStringFree(&ds);
return;
}
buffer = GlobalLock(handle);
- memcpy(buffer, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds) + 1);
+ memcpy(buffer, Tcl_DStringValue(&ds),
+ (unsigned) Tcl_DStringLength(&ds) + 1);
GlobalUnlock(handle);
Tcl_DStringFree(&ds);
SetClipboardData(CF_TEXT, handle);
}
-
- return;
}
/*
@@ -337,8 +332,8 @@ TkWinClipboardRender(dispPtr, format)
*
* TkSelUpdateClipboard --
*
- * This function is called to force the clipboard to be updated
- * after new data is added.
+ * This function is called to force the clipboard to be updated after new
+ * data is added.
*
* Results:
* None.
@@ -350,9 +345,9 @@ TkWinClipboardRender(dispPtr, format)
*/
void
-TkSelUpdateClipboard(winPtr, targetPtr)
- TkWindow *winPtr;
- TkClipboardTarget *targetPtr;
+TkSelUpdateClipboard(
+ TkWindow *winPtr,
+ TkClipboardTarget *targetPtr)
{
HWND hwnd = TkWinGetHWND(winPtr->window);
UpdateClipboard(hwnd);
@@ -363,8 +358,8 @@ TkSelUpdateClipboard(winPtr, targetPtr)
*
* UpdateClipboard --
*
- * Take ownership of the clipboard, clear it, and indicate to the
- * system the supported formats.
+ * Take ownership of the clipboard, clear it, and indicate to the system
+ * the supported formats.
*
* Results:
* None.
@@ -376,16 +371,16 @@ TkSelUpdateClipboard(winPtr, targetPtr)
*/
static void
-UpdateClipboard(hwnd)
- HWND hwnd;
+UpdateClipboard(
+ HWND hwnd)
{
TkWinUpdatingClipboard(TRUE);
OpenClipboard(hwnd);
EmptyClipboard();
/*
- * CF_UNICODETEXT is only supported on NT, but it it is prefered
- * when possible.
+ * CF_UNICODETEXT is only supported on NT, but it it is prefered when
+ * possible.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -402,25 +397,22 @@ UpdateClipboard(hwnd)
*
* TkSelEventProc --
*
- * This procedure is invoked whenever a selection-related
- * event occurs.
+ * This procedure is invoked whenever a selection-related event occurs.
*
* Results:
* None.
*
* Side effects:
- * Lots: depends on the type of event.
+ * Lots: depends on the type of event.
*
*--------------------------------------------------------------
*/
void
-TkSelEventProc(tkwin, eventPtr)
- Tk_Window tkwin; /* Window for which event was
- * targeted. */
- register XEvent *eventPtr; /* X event: either SelectionClear,
- * SelectionRequest, or
- * SelectionNotify. */
+TkSelEventProc(
+ Tk_Window tkwin, /* Window for which event was targeted. */
+ register XEvent *eventPtr) /* X event: either SelectionClear,
+ * SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
TkSelClearSelection(tkwin, eventPtr);
@@ -432,9 +424,8 @@ TkSelEventProc(tkwin, eventPtr)
*
* TkSelPropProc --
*
- * This procedure is invoked when property-change events
- * occur on windows not known to the toolkit. This is a stub
- * function under Windows.
+ * This procedure is invoked when property-change events occur on windows
+ * not known to the toolkit. This is a stub function under Windows.
*
* Results:
* None.
@@ -446,7 +437,15 @@ TkSelEventProc(tkwin, eventPtr)
*/
void
-TkSelPropProc(eventPtr)
- register XEvent *eventPtr; /* X PropertyChange event. */
+TkSelPropProc(
+ register XEvent *eventPtr) /* X PropertyChange event. */
{
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */