diff options
author | dkf <dkf@noemail.net> | 2005-12-02 00:19:03 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2005-12-02 00:19:03 (GMT) |
commit | e47885308810066654079e599a1e29fe8ec8b637 (patch) | |
tree | 52d269b4d68227dbd097997cd3eb23056cdf78fe /win/tkWinClipboard.c | |
parent | 413d970d950ddbe5b553eeb644dbc55738bd7a2d (diff) | |
download | tk-e47885308810066654079e599a1e29fe8ec8b637.zip tk-e47885308810066654079e599a1e29fe8ec8b637.tar.gz tk-e47885308810066654079e599a1e29fe8ec8b637.tar.bz2 |
ANSIfication
FossilOrigin-Name: 1be88f1039a57d37b1f4567340d02ca39ddb3575
Diffstat (limited to 'win/tkWinClipboard.c')
-rw-r--r-- | win/tkWinClipboard.c | 171 |
1 files changed, 84 insertions, 87 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index b08147a..bb91f4d 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -1,4 +1,4 @@ -/* +/* * tkWinClipboard.c -- * * This file contains functions for managing the clipboard. @@ -6,30 +6,30 @@ * 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. * - * RCS: @(#) $Id: tkWinClipboard.c,v 1.7 2000/04/12 18:51:11 hobbs Exp $ + * RCS: @(#) $Id: tkWinClipboard.c,v 1.8 2005/12/02 00:19:04 dkf Exp $ */ #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. @@ -38,18 +38,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; @@ -64,8 +63,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; @@ -93,19 +92,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)); @@ -146,7 +143,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') { @@ -165,12 +162,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; } @@ -179,9 +175,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. @@ -193,27 +188,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) { @@ -227,8 +221,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. @@ -240,9 +234,9 @@ XSetSelectionOwner(display, selection, owner, time) */ void -TkWinClipboardRender(dispPtr, format) - TkDisplay *dispPtr; - UINT format; +TkWinClipboardRender( + TkDisplay *dispPtr, + UINT format) { TkClipboardTarget *targetPtr; TkClipboardBuffer *cbPtr; @@ -253,13 +247,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; @@ -296,8 +291,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) { @@ -330,8 +325,6 @@ TkWinClipboardRender(dispPtr, format) Tcl_DStringFree(&ds); SetClipboardData(CF_TEXT, handle); } - - return; } /* @@ -339,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. @@ -352,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); @@ -365,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. @@ -378,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) { @@ -404,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); @@ -434,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. @@ -448,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: + */ |