diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-02-22 13:56:32 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-02-22 13:56:32 (GMT) |
commit | dde89e53698859ca30c7ef441d2b64350d2a8187 (patch) | |
tree | d27aec929ff20b2ab6ba34faa14bd56439bf1d33 /unix | |
parent | 18bcf9971777b9bf6d2eacd064c42f0f7e58ae47 (diff) | |
download | tk-dde89e53698859ca30c7ef441d2b64350d2a8187.zip tk-dde89e53698859ca30c7ef441d2b64350d2a8187.tar.gz tk-dde89e53698859ca30c7ef441d2b64350d2a8187.tar.bz2 |
Less of that K&R or wrongly indented function header style!
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tkAppInit.c | 77 | ||||
-rw-r--r-- | unix/tkUnixFont.c | 99 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 33 | ||||
-rw-r--r-- | unix/tkUnixSelect.c | 31 |
4 files changed, 126 insertions, 114 deletions
diff --git a/unix/tkAppInit.c b/unix/tkAppInit.c index 3a215fe..526a3e8 100644 --- a/unix/tkAppInit.c +++ b/unix/tkAppInit.c @@ -1,16 +1,16 @@ -/* +/* * tkAppInit.c -- * - * Provides a default version of the Tcl_AppInit procedure for - * use in wish and similar Tk-based applications. + * Provides a default version of the Tcl_AppInit procedure for use in + * wish and similar Tk-based applications. * * Copyright (c) 1993 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * - * 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: tkAppInit.c,v 1.7 2002/06/21 20:24:29 dgp Exp $ + * RCS: @(#) $Id: tkAppInit.c,v 1.8 2007/02/22 13:56:33 dkf Exp $ */ #include "tk.h" @@ -28,8 +28,8 @@ extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); * This is the main program for the application. * * Results: - * None: Tk_Main never returns here, so this procedure never - * returns either. + * None: Tk_Main never returns here, so this procedure never returns + * either. * * Side effects: * Whatever the application does. @@ -38,28 +38,28 @@ extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); */ int -main(argc, argv) - int argc; /* Number of command-line arguments. */ - char **argv; /* Values of command-line arguments. */ +main( + int argc, /* Number of command-line arguments. */ + char **argv) /* Values of command-line arguments. */ { /* - * The following #if block allows you to change the AppInit - * function by using a #define of TCL_LOCAL_APPINIT instead - * of rewriting this entire file. The #if checks for that - * #define and uses Tcl_AppInit if it doesn't exist. + * The following #if block allows you to change the AppInit function by + * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire + * file. The #if checks for that #define and uses Tcl_AppInit if it + * doesn't exist. */ - + #ifndef TK_LOCAL_APPINIT -#define TK_LOCAL_APPINIT Tcl_AppInit +#define TK_LOCAL_APPINIT Tcl_AppInit #endif extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); - + /* * The following #if block allows you to change how Tcl finds the startup * script, prime the library or encoding paths, fiddle with the argv, * etc., without needing to rewrite Tk_Main() */ - + #ifdef TK_LOCAL_MAIN_HOOK extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); TK_LOCAL_MAIN_HOOK(&argc, &argv); @@ -74,13 +74,13 @@ main(argc, argv) * * Tcl_AppInit -- * - * This procedure performs application-specific initialization. - * Most applications, especially those that incorporate additional - * packages, will have their own version of this procedure. + * This procedure performs application-specific initialization. Most + * applications, especially those that incorporate additional packages, + * will have their own version of this procedure. * * Results: - * Returns a standard Tcl completion code, and leaves an error - * message in the interp's result if an error occurs. + * Returns a standard Tcl completion code, and leaves an error message in + * the interp's result if an error occurs. * * Side effects: * Depends on the startup script. @@ -89,8 +89,8 @@ main(argc, argv) */ int -Tcl_AppInit(interp) - Tcl_Interp *interp; /* Interpreter for application. */ +Tcl_AppInit( + Tcl_Interp *interp) /* Interpreter for application. */ { if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; @@ -107,10 +107,9 @@ Tcl_AppInit(interp) (Tcl_PackageInitProc *) NULL); #endif /* TK_TEST */ - /* - * Call the init procedures for included packages. Each call should - * look like this: + * Call the init procedures for included packages. Each call should look + * like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; @@ -120,17 +119,25 @@ Tcl_AppInit(interp) */ /* - * Call Tcl_CreateCommand for application-specific commands, if - * they weren't already created by the init procedures called above. + * Call Tcl_CreateCommand for application-specific commands, if they + * weren't already created by the init procedures called above. */ /* - * Specify a user-specific startup file to invoke if the application - * is run interactively. Typically the startup file is "~/.apprc" - * where "app" is the name of the application. If this line is deleted - * then no user-specific startup file will be run under any conditions. + * Specify a user-specific startup file to invoke if the application is + * run interactively. Typically the startup file is "~/.apprc" where "app" + * is the name of the application. If this line is deleted then no user- + * -specific startup file will be run under any conditions. */ Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); return TCL_OK; } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 0ab8fb5..2b99e71 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixFont.c,v 1.30 2006/12/01 20:14:23 kennykb Exp $ + * RCS: @(#) $Id: tkUnixFont.c,v 1.31 2007/02/22 13:56:33 dkf Exp $ */ #include "tkUnixInt.h" @@ -951,7 +951,7 @@ TkpGetFontAttrsForChar( Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ Tcl_UniChar c, /* Character of interest */ - TkFontAttributes* faPtr) /* Output: Font attributes */ + TkFontAttributes *faPtr) /* Output: Font attributes */ { FontAttributes atts; UnixFont *fontPtr = (UnixFont *) tkfont; @@ -1204,32 +1204,31 @@ Tk_MeasureChars( */ int -TkpMeasureCharsInContext(tkfont, source, numBytes, rangeStart, rangeLength, - maxLength, flags, lengthPtr) - Tk_Font tkfont; /* Font in which characters will be drawn. */ - CONST char * source; /* UTF-8 string to be displayed. Need not be - * '\0' terminated. */ - int numBytes; /* Maximum number of bytes to consider from - * source string in all. */ - int rangeStart; /* Index of first byte to measure. */ - int rangeLength; /* Length of range to measure in bytes. */ - int maxLength; /* If >= 0, maxLength specifies the longest - * permissible line length; don't consider any - * character that would cross this x-position. - * If < 0, then line length is unbounded and the - * flags argument is ignored. */ - int flags; /* Various flag bits OR-ed together: - * TK_PARTIAL_OK means include the last char - * which only partially fit on this line. - * TK_WHOLE_WORDS means stop on a word boundary, - * if possible. TK_AT_LEAST_ONE means return at - * least one character even if no characters fit. - * TK_ISOLATE_END means that the last character - * should not be considered in context with the - * rest of the string (used for breaking - * lines). */ - int * lengthPtr; /* Filled with x-location just after the - * terminating character. */ +TkpMeasureCharsInContext( + Tk_Font tkfont, /* Font in which characters will be drawn. */ + CONST char *source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. */ + int numBytes, /* Maximum number of bytes to consider from + * source string in all. */ + int rangeStart, /* Index of first byte to measure. */ + int rangeLength, /* Length of range to measure in bytes. */ + int maxLength, /* If >= 0, maxLength specifies the longest + * permissible line length; don't consider any + * character that would cross this x-position. + * If < 0, then line length is unbounded and + * the flags argument is ignored. */ + int flags, /* Various flag bits OR-ed together: + * TK_PARTIAL_OK means include the last char + * which only partially fit on this line. + * TK_WHOLE_WORDS means stop on a word + * boundary, if possible. TK_AT_LEAST_ONE + * means return at least one character even if + * no characters fit. TK_ISOLATE_END means + * that the last character should not be + * considered in context with the rest of the + * string (used for breaking lines). */ + int *lengthPtr) /* Filled with x-location just after the + * terminating character. */ { (void) numBytes; /*unused*/ return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength, @@ -1393,30 +1392,30 @@ Tk_DrawChars( */ void -TkpDrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, - rangeStart, rangeLength, x, y) - Display * display; /* Display on which to draw. */ - Drawable drawable; /* Window or pixmap in which to draw. */ - GC gc; /* Graphics context for drawing characters. */ - Tk_Font tkfont; /* Font in which characters will be drawn; must - * be the same as font used in GC. */ - CONST char * source; /* UTF-8 string to be displayed. Need not be - * '\0' terminated. All Tk meta-characters - * (tabs, control characters, and newlines) - * should be stripped out of the string that is - * passed to this function. If they are not - * stripped out, they will be displayed as - * regular printing characters. */ - int numBytes; /* Number of bytes in string. */ - int rangeStart; /* Index of first byte to draw. */ - int rangeLength; /* Length of range to draw in bytes. */ - int x; int y; /* Coordinates at which to place origin of the - * whole (not just the range) string when - * drawing. */ +TkpDrawCharsInContext( + Display *display, /* Display on which to draw. */ + Drawable drawable, /* Window or pixmap in which to draw. */ + GC gc, /* Graphics context for drawing characters. */ + Tk_Font tkfont, /* Font in which characters will be drawn; + * must be the same as font used in GC. */ + CONST char *source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. All Tk meta-characters + * (tabs, control characters, and newlines) + * should be stripped out of the string that + * is passed to this function. If they are not + * stripped out, they will be displayed as + * regular printing characters. */ + int numBytes, /* Number of bytes in string. */ + int rangeStart; /* Index of first byte to draw. */ + int rangeLength; /* Length of range to draw in bytes. */ + int x, int y) /* Coordinates at which to place origin of the + * whole (not just the range) string when + * drawing. */ { (void) numBytes; /*unused*/ - Tk_DrawChars(display, drawable, gc, tkfont, - source + rangeStart, rangeLength, x, y); + + Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, + rangeLength, x, y); } /* diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 285ac8e..4435564 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixRFont.c,v 1.14 2006/12/01 20:14:23 kennykb Exp $ + * RCS: @(#) $Id: tkUnixRFont.c,v 1.15 2007/02/22 13:56:34 dkf Exp $ */ #include "tkUnixInt.h" @@ -491,33 +491,33 @@ TkpGetFontAttrsForChar( Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ Tcl_UniChar c, /* Character of interest */ - TkFontAttributes* faPtr) /* Output: Font attributes */ + TkFontAttributes *faPtr) /* Output: Font attributes */ { - UnixFtFont *fontPtr = (UnixFtFont*) tkfont; + UnixFtFont *fontPtr = (UnixFtFont *) tkfont; /* Structure describing the logical font */ FcChar32 ucs4 = (FcChar32) c; /* UCS-4 character to map */ XftFont *xftFontPtr = GetFont(fontPtr, ucs4); /* Actual font used to render the character */ - const char* family; /* Font family name */ + const char *family; /* Font family name */ double size; /* Font size */ int weight; /* Font weight */ int slant; /* Font slant */ - + if (XftPatternGetString(xftFontPtr->pattern, XFT_FAMILY, 0, - &family) != XftResultMatch) { + &family) != XftResultMatch) { family = "Unknown"; } if (XftPatternGetDouble(xftFontPtr->pattern, XFT_SIZE, 0, - &size) != XftResultMatch) { + &size) != XftResultMatch) { size = 12.0; } if (XftPatternGetInteger(xftFontPtr->pattern, XFT_WEIGHT, 0, - &weight) != XftResultMatch) { + &weight) != XftResultMatch) { weight = XFT_WEIGHT_MEDIUM; } if (XftPatternGetInteger(xftFontPtr->pattern, XFT_SLANT, 0, - &slant) != XftResultMatch) { + &slant) != XftResultMatch) { slant = XFT_SLANT_ROMAN; } faPtr->family = Tk_GetUid(family); @@ -628,11 +628,18 @@ Tk_MeasureChars( } int -TkpMeasureCharsInContext(Tk_Font tkfont, CONST char * source, int numBytes, - int rangeStart, int rangeLength, int maxLength, - int flags, int * lengthPtr) +TkpMeasureCharsInContext( + Tk_Font tkfont, + CONST char *source, + int numBytes, + int rangeStart, + int rangeLength, + int maxLength, + int flags, + int *lengthPtr) { (void) numBytes; /*unused*/ + return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength, maxLength, flags, lengthPtr); } @@ -657,7 +664,7 @@ Tk_DrawChars( int x, int y) /* Coordinates at which to place origin of * string when drawing. */ { - const int maxCoord = 0x7FFF; /* Xft coordinates are 16 bit values */ + const int maxCoord = 0x7FFF;/* Xft coordinates are 16 bit values */ UnixFtFont *fontPtr = (UnixFtFont *) tkfont; XGCValues values; XColor xcolor; diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c index 9cef53b..ca54913 100644 --- a/unix/tkUnixSelect.c +++ b/unix/tkUnixSelect.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixSelect.c,v 1.18 2005/11/14 15:55:02 dkf Exp $ + * RCS: @(#) $Id: tkUnixSelect.c,v 1.19 2007/02/22 13:56:34 dkf Exp $ */ #include "tkInt.h" @@ -232,8 +232,8 @@ TkSelGetSelection( */ void -TkSelPropProc(eventPtr) - register XEvent *eventPtr; /* X PropertyChange event. */ +TkSelPropProc( + register XEvent *eventPtr) /* X PropertyChange event. */ { register IncrInfo *incrPtr; register TkSelHandler *selPtr; @@ -311,6 +311,7 @@ TkSelPropProc(eventPtr) length = 0; } else { TkSelInProgress ip; + ip.selPtr = selPtr; ip.nextPtr = TkSelGetInProgress(); TkSelSetInProgress(&ip); @@ -400,9 +401,8 @@ TkSelPropProc(eventPtr) */ while (1) { - result = Tcl_UtfToExternal(NULL, encoding, - src, srcLen, encodingCvtFlags, - &incrPtr->converts[i].state, + result = Tcl_UtfToExternal(NULL, encoding, src, srcLen, + encodingCvtFlags, &incrPtr->converts[i].state, dst, dstLen, &srcRead, &dstWrote, NULL); soFar = dst + dstWrote - Tcl_DStringValue(&ds); encodingCvtFlags &= ~TCL_ENCODING_START; @@ -450,8 +450,7 @@ TkSelPropProc(eventPtr) */ char *propPtr = (char *) SelCvtToX((char *) buffer, - formatType, (Tk_Window) incrPtr->winPtr, - &numItems); + formatType, (Tk_Window) incrPtr->winPtr, &numItems); if (propPtr == NULL) { numItems = 0; @@ -576,7 +575,7 @@ TkSelEventProc( } if (bytesAfter != 0) { Tcl_SetResult(retrPtr->interp, "selection property too large", - TCL_STATIC); + TCL_STATIC); retrPtr->result = TCL_ERROR; XFree(propInfo); return; @@ -824,8 +823,9 @@ ConvertSelection( for (infoPtr = winPtr->dispPtr->selectionInfoPtr; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { - if (infoPtr->selection == eventPtr->selection) + if (infoPtr->selection == eventPtr->selection) { break; + } } if (infoPtr == NULL) { goto refuse; @@ -877,8 +877,8 @@ ConvertSelection( * below). */ - incr.converts = (ConvertInfo *) ckalloc((unsigned) - (incr.numConversions*sizeof(ConvertInfo))); + incr.converts = (ConvertInfo *) + ckalloc((unsigned) incr.numConversions * sizeof(ConvertInfo)); incr.numIncrs = 0; for (i = 0; i < incr.numConversions; i++) { Atom target, property, type; @@ -961,9 +961,8 @@ ConvertSelection( * allows us to pass our utf-8 information untouched. */ - XChangeProperty(reply.display, reply.requestor, - property, type, 8, PropModeReplace, - (unsigned char *) buffer, numItems); + XChangeProperty(reply.display, reply.requestor, property, type, 8, + PropModeReplace, (unsigned char *) buffer, numItems); } else if ((type == XA_STRING) || (type == winPtr->dispPtr->compoundTextAtom)) { Tcl_DString ds; @@ -980,7 +979,7 @@ ConvertSelection( } else { encoding = Tcl_GetEncoding(NULL, "iso2022"); } - Tcl_UtfToExternalDString(encoding, (char*)buffer, -1, &ds); + Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds); XChangeProperty(reply.display, reply.requestor, property, type, 8, PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); |