diff options
Diffstat (limited to 'win/tkWinClipboard.c')
-rw-r--r-- | win/tkWinClipboard.c | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 38037c2..76711b5 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -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,8 +90,8 @@ 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); @@ -100,9 +99,8 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData) 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)); @@ -163,11 +161,10 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData) 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; } @@ -176,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. @@ -190,27 +186,26 @@ error: */ int -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 +220,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 +233,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 +246,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 +274,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 +290,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 +299,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 +314,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 +333,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 +346,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 +359,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 +372,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 +398,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 +425,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 +438,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: + */ |