From 3213b080b096a2603f686f8bf239d886ee2fdace Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 2 Feb 2022 15:26:18 +0000 Subject: Get rid of underlineObj/overstrikgObj/elideObj int text tags --- generic/tkText.h | 15 +++++++++------ generic/tkTextBTree.c | 2 +- generic/tkTextTag.c | 35 ++++++++++++----------------------- tests/textTag.test | 8 ++++---- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/generic/tkText.h b/generic/tkText.h index c392e30..2227fd1 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -358,8 +358,9 @@ typedef struct TkTextTag { * baseline of line. Used for superscripts and * subscripts. Only valid if offsetString is * non-NULL. */ - Tcl_Obj *overstrikeObj; /* -overstrike option string (malloc-ed). NULL - * means option not specified. */ +#if TCL_MAJOR_VERSION < 9 + char *overstrikeString; /* (not used any more) */ +#endif int overstrike; /* > 0 means draw horizontal line through * middle of text. -1 means not specified. */ XColor *overstrikeColor; /* Color for the overstrike. NULL means same @@ -396,8 +397,9 @@ typedef struct TkTextTag { * NULL. Corresponds to tabString. */ int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR * or TK_TEXT_TABSTYLE_NULL (if not specified). */ - Tcl_Obj *underlineObj; /* -underline option. NULL - * means option not specified. */ +#if TCL_MAJOR_VERSION < 9 + char *underlineString; /* (not used any more) */ +#endif int underline; /* > 0 means draw underline underneath * text. -1 means not specified. */ XColor *underlineColor; /* Color for the underline. NULL means same @@ -407,8 +409,9 @@ typedef struct TkTextTag { * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or * TEXT_WRAPMODE_NULL to use wrapmode for * whole widget. */ - Tcl_Obj *elideObj; /* -elide option. NULL - * means option not specified. */ +#if TCL_MAJOR_VERSION < 9 + char *elideString; /* (not used any more) */ +#endif int elide; /* > 0 means that data under this tag * should not be displayed. -1 means not specified. */ int affectsDisplay; /* Non-zero means that this tag affects the diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index b03b045..e609126 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -3616,7 +3616,7 @@ TkTextIsElided( summaryPtr = summaryPtr->nextPtr) { if (summaryPtr->toggleCount & 1) { tagPtr = summaryPtr->tagPtr; - if (tagPtr->elideObj != NULL) { + if (tagPtr->elide >= 0) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; infoPtr->tagCnts[tagPtr->priority] += summaryPtr->toggleCount; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 5116254..377a00f 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -25,7 +25,7 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BOOLEAN, "-elide", NULL, NULL, - NULL, offsetof(TkTextTag, elideObj), offsetof(TkTextTag, elide), + NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elide), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BITMAP, "-fgstipple", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0}, @@ -44,7 +44,7 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_STRING, "-offset", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-overstrike", NULL, NULL, - NULL, offsetof(TkTextTag, overstrikeObj), offsetof(TkTextTag, overstrike), + NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrike), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor), @@ -71,7 +71,7 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tabStyle), TK_OPTION_NULL_OK, tkTextTabStyleStrings, 0}, {TK_OPTION_BOOLEAN, "-underline", NULL, NULL, - NULL, offsetof(TkTextTag, underlineObj), offsetof(TkTextTag, underline), + NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underline), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-underlinefg", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineColor), @@ -397,12 +397,6 @@ TkTextTagCmd( return TCL_ERROR; } } - if (tagPtr->overstrikeObj != NULL) { - if (Tcl_GetBoolean(interp, Tcl_GetString(tagPtr->overstrikeObj), - &tagPtr->overstrike) != TCL_OK) { - return TCL_ERROR; - } - } if (tagPtr->rMarginString != NULL) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->rMarginString, &tagPtr->rMargin) != TCL_OK) { @@ -447,18 +441,7 @@ TkTextTagCmd( return TCL_ERROR; } } - if (tagPtr->underlineObj != NULL) { - if (Tcl_GetBoolean(interp, Tcl_GetString(tagPtr->underlineObj), - &tagPtr->underline) != TCL_OK) { - return TCL_ERROR; - } - } if (tagPtr->elide >= 0) { - if (Tcl_GetBoolean(interp, Tcl_GetString(tagPtr->elideObj), - &tagPtr->elide) != TCL_OK) { - return TCL_ERROR; - } - /* * Indices are potentially obsolete after changing -elide, * especially those computed with "display" or "any" @@ -1024,7 +1007,9 @@ TkTextCreateTag( tagPtr->lMarginColor = NULL; tagPtr->offsetString = NULL; tagPtr->offset = 0; - tagPtr->overstrikeObj = NULL; +#if TCL_MAJOR_VERSION < 9 + tagPtr->overstrikeString = NULL; +#endif tagPtr->overstrike = -1; tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; @@ -1041,10 +1026,14 @@ TkTextCreateTag( tagPtr->tabStringPtr = NULL; tagPtr->tabArrayPtr = NULL; tagPtr->tabStyle = TK_TEXT_TABSTYLE_NULL; - tagPtr->underlineObj = NULL; +#if TCL_MAJOR_VERSION < 9 + tagPtr->underlineString = NULL; +#endif tagPtr->underline = -1; tagPtr->underlineColor = NULL; - tagPtr->elideObj = NULL; +#if TCL_MAJOR_VERSION < 9 + tagPtr->elideString = NULL; +#endif tagPtr->elide = -1; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; tagPtr->affectsDisplay = 0; diff --git a/tests/textTag.test b/tests/textTag.test index 2e776d7..e22167d 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -175,7 +175,7 @@ test textTag-1.20 {tag configuration options} -body { .t tag cget x -overstrike } -cleanup { .t tag configure x -overstrike [lindex [.t tag configure x -overstrike] 3] -} -result {on} +} -result 1 test textTag-1.21 {configuration options} -body { .t tag configure x -overstrike stupid } -cleanup { @@ -296,7 +296,7 @@ test textTag-1.34 {tag configuration options} -body { .t tag cget x -underline } -cleanup { .t tag configure x -underline [lindex [.t tag configure x -underline] 3] -} -result {no} +} -result 0 test textTag-1.35 {configuration options} -body { .t tag configure x -underline stupid } -cleanup { @@ -506,7 +506,7 @@ test textTag-5.4 {TkTextTagCmd - "configure" option} -body { .t tag configure x -underline } -cleanup { .t tag delete x -} -result {-underline {} {} {} yes} +} -result {-underline {} {} {} 1} test textTag-5.4a {TkTextTagCmd - "configure" option} -body { .t tag delete x .t tag configure x -underlinefg lightgreen @@ -520,7 +520,7 @@ test textTag-5.5 {TkTextTagCmd - "configure" option} -body { .t tag cget x -overstrike } -cleanup { .t tag delete x -} -result {on} +} -result 1 test textTag-5.5a {TkTextTagCmd - "configure" option} -body { .t tag delete x .t tag configure x -overstrikefg lightgreen -- cgit v0.12