diff options
Diffstat (limited to 'generic/tkTextTag.c')
-rw-r--r-- | generic/tkTextTag.c | 136 |
1 files changed, 14 insertions, 122 deletions
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 00723ab..c126fcc 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextTag.c,v 1.4 1999/12/14 06:52:33 hobbs Exp $ + * RCS: @(#) $Id: tkTextTag.c,v 1.5 2000/01/06 02:18:59 hobbs Exp $ */ #include "default.h" @@ -19,32 +19,6 @@ #include "tkInt.h" #include "tkText.h" -/* - * Information used for parsing tag configuration information: - */ - -static Tk_CustomOption stateOption = { - (Tk_OptionParseProc *) TkStateParseProc, - TkStatePrintProc, (ClientData) 2 -}; - -/* The "-elide" is only provided for compatibility with TkMan 2.0, - * but might be removed in the future. The option "-state" provides - * the same functionality and is preferred. - */ - -static int ElideParseProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tk_Window tkwin, - CONST char *value, char *widgRec, int offset)); -static char * ElidePrintProc _ANSI_ARGS_((ClientData clientData, - Tk_Window tkwin, char *widgRec, int offset, - Tcl_FreeProc **freeProcPtr)); - -static Tk_CustomOption elideOption = { - (Tk_OptionParseProc *) ElideParseProc, - ElidePrintProc, (ClientData) 0 -}; - static Tk_ConfigSpec tagConfigSpecs[] = { {TK_CONFIG_BORDER, "-background", (char *) NULL, (char *) NULL, (char *) NULL, Tk_Offset(TkTextTag, border), TK_CONFIG_NULL_OK}, @@ -52,10 +26,10 @@ static Tk_ConfigSpec tagConfigSpecs[] = { (char *) NULL, Tk_Offset(TkTextTag, bgStipple), TK_CONFIG_NULL_OK}, {TK_CONFIG_STRING, "-borderwidth", (char *) NULL, (char *) NULL, "0", Tk_Offset(TkTextTag, bdString), - TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-elide", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(TkTextTag, state), - TK_CONFIG_NULL_OK, &elideOption}, + TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK}, + {TK_CONFIG_STRING, "-elide", (char *) NULL, (char *) NULL, + "0", Tk_Offset(TkTextTag, elideString), + TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK}, {TK_CONFIG_BITMAP, "-fgstipple", (char *) NULL, (char *) NULL, (char *) NULL, Tk_Offset(TkTextTag, fgStipple), TK_CONFIG_NULL_OK}, {TK_CONFIG_FONT, "-font", (char *) NULL, (char *) NULL, @@ -83,9 +57,6 @@ static Tk_ConfigSpec tagConfigSpecs[] = { (char *) NULL, Tk_Offset(TkTextTag, spacing2String), TK_CONFIG_NULL_OK}, {TK_CONFIG_STRING, "-spacing3", (char *) NULL, (char *) NULL, (char *) NULL, Tk_Offset(TkTextTag, spacing3String), TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-state", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(TkTextTag, state), - TK_CONFIG_NULL_OK, &stateOption}, {TK_CONFIG_STRING, "-tabs", (char *) NULL, (char *) NULL, (char *) NULL, Tk_Offset(TkTextTag, tabString), TK_CONFIG_NULL_OK}, {TK_CONFIG_STRING, "-underline", (char *) NULL, (char *) NULL, @@ -419,6 +390,12 @@ TkTextTagCmd(textPtr, interp, argc, argv) return TCL_ERROR; } } + if (tagPtr->elideString != NULL) { + if (Tcl_GetBoolean(interp, tagPtr->elideString, + &tagPtr->elide) != TCL_OK) { + return TCL_ERROR; + } + } /* * If the "sel" tag was changed, be sure to mirror information @@ -451,7 +428,7 @@ TkTextTagCmd(textPtr, interp, argc, argv) || (tagPtr->spacing3String != NULL) || (tagPtr->tabString != NULL) || (tagPtr->underlineString != NULL) - || (tagPtr->state != TK_STATE_NULL) + || (tagPtr->elideString != NULL) || (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { tagPtr->affectsDisplay = 1; } @@ -844,7 +821,8 @@ TkTextCreateTag(textPtr, tagName) tagPtr->tabArrayPtr = NULL; tagPtr->underlineString = NULL; tagPtr->underline = 0; - tagPtr->state = TK_STATE_NULL; + tagPtr->elideString = NULL; + tagPtr->elide = 0; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; tagPtr->affectsDisplay = 0; textPtr->numTags++; @@ -1408,89 +1386,3 @@ TkTextPickCurrent(textPtr, eventPtr) ckfree((char *) copyArrayPtr); } } - -/* - *-------------------------------------------------------------- - * - * ElideParseProc -- - * - * This procedure is invoked during option processing to handle - * the "-elide" option. This option is an obsolete equivalent - * of the "-state" option. It is only added for compatibility - * with TkMan 2.0, but will be removed in the future. - * - * Results: - * A standard Tcl return value. - * - * Side effects: - * The state for a given item gets replaced by the state - * indicated in the value argument. - * - *-------------------------------------------------------------- - */ - -static int -ElideParseProc(clientData, interp, tkwin, value, widgRec, offset) - ClientData clientData; /* some flags.*/ - Tcl_Interp *interp; /* Used for reporting errors. */ - Tk_Window tkwin; /* Window containing canvas widget. */ - CONST char *value; /* Value of option. */ - char *widgRec; /* Pointer to record for item. */ - int offset; /* Offset into item. */ -{ - int b; - register Tk_State *statePtr = (Tk_State *) (widgRec + offset); - - if(value == NULL || *value == 0) { - *statePtr = TK_STATE_NULL; - return TCL_OK; - } - if (Tcl_GetBoolean(interp, (char *) value, &b) != TCL_OK) { - *statePtr = TK_STATE_NULL; - return TCL_ERROR; - } - *statePtr = b?TK_STATE_HIDDEN:TK_STATE_NORMAL; - return TCL_OK; -} -/* - *-------------------------------------------------------------- - * - * ElidePrintProc -- - * - * This procedure is invoked by the Tk configuration code - * to produce a printable string for the "-elide" - * configuration option. - * - * Results: - * The return value is a string describing the state for - * the item referred to by "widgRec". In addition, *freeProcPtr - * is filled in with the address of a procedure to call to free - * the result string when it's no longer needed (or NULL to - * indicate that the string doesn't need to be freed). - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -static char * -ElidePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) - ClientData clientData; /* Ignored. */ - Tk_Window tkwin; /* Window containing text widget. */ - char *widgRec; /* Pointer to record for item. */ - int offset; /* Offset into item. */ - Tcl_FreeProc **freeProcPtr; /* Pointer to variable to fill in with - * information about how to reclaim - * storage for return string. */ -{ - register Tk_State *statePtr = (Tk_State *) (widgRec + offset); - - if (*statePtr==TK_STATE_HIDDEN) { - return "1"; - } else if (*statePtr==TK_STATE_NULL) { - return ""; - } else { - return "0"; - } -} |