From b258e6b408ef99ed31fdde484f21548851eca156 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:23:23 +0000 Subject: -selectbackground tag configuration option: implementation --- generic/tkText.c | 7 ++++++- generic/tkText.h | 2 ++ generic/tkTextDisp.c | 13 +++++++++++++ generic/tkTextTag.c | 10 +++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 3079417..1b420d6 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2253,7 +2253,11 @@ ConfigureText( * replaced in the widget record. */ - textPtr->selTagPtr->border = textPtr->selBorder; + if (textPtr->selTagPtr->selBorder == NULL) { + textPtr->selTagPtr->border = textPtr->selBorder; + } else { + textPtr->selTagPtr->selBorder = textPtr->selBorder; + } if (textPtr->selTagPtr->borderWidthPtr != textPtr->selBorderWidthPtr) { textPtr->selTagPtr->borderWidthPtr = textPtr->selBorderWidthPtr; textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; @@ -2277,6 +2281,7 @@ ConfigureText( textPtr->selTagPtr->affectsDisplayGeometry = 1; } if ((textPtr->selTagPtr->border != NULL) + || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) diff --git a/generic/tkText.h b/generic/tkText.h index fc92644..5cd009f 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -362,6 +362,8 @@ typedef struct TkTextTag { * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ + Tk_3DBorder selBorder; /* Used for drawing background for selected text. + * NULL means no value specified here. */ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 7969091..1bd5905 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -748,6 +748,7 @@ GetStyle( TextStyle *stylePtr; Tcl_HashEntry *hPtr; int numTags, isNew, i; + int isSelected; XGCValues gcValues; unsigned long mask; /* @@ -786,6 +787,14 @@ GetStyle( styleValues.tabStyle = textPtr->tabStyle; styleValues.wrapMode = textPtr->wrapMode; styleValues.elide = 0; + isSelected = 0; + + for (i = 0 ; i < numTags; i++) { + if (textPtr->selTagPtr == tagPtrs[i]) { + isSelected = 1; + break; + } + } for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; @@ -811,6 +820,10 @@ GetStyle( border = textPtr->inactiveSelBorder; } + if ((tagPtr->selBorder != NULL) && (isSelected)) { + border = tagPtr->selBorder; + } + if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 3363d25..a857cf9 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -70,6 +70,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, + {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-spacing2", NULL, NULL, @@ -484,7 +486,11 @@ TkTextTagCmd( */ if (tagPtr == textPtr->selTagPtr) { - textPtr->selBorder = tagPtr->border; + if (tagPtr->selBorder == NULL) { + textPtr->selBorder = tagPtr->border; + } else { + textPtr->selBorder = tagPtr->selBorder; + } textPtr->selBorderWidth = tagPtr->borderWidth; textPtr->selBorderWidthPtr = tagPtr->borderWidthPtr; textPtr->selFgColorPtr = tagPtr->fgColor; @@ -509,6 +515,7 @@ TkTextTagCmd( tagPtr->affectsDisplayGeometry = 1; } if ((tagPtr->border != NULL) + || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) || (tagPtr->fgColor != NULL) @@ -1017,6 +1024,7 @@ TkTextCreateTag( tagPtr->overstrike = 0; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; + tagPtr->selBorder = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; -- cgit v0.12 From b3b68ebfe18ad11c210bc80ec440c49d7b6dad8d Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:24:38 +0000 Subject: -selectbackground tag configuration option: documentation --- doc/text.n | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/text.n b/doc/text.n index ac7803c..41d6a6f 100644 --- a/doc/text.n +++ b/doc/text.n @@ -517,6 +517,13 @@ option is only used when wrapping is enabled. If a text line wraps, the right margin for each line on the display is determined by the first non-elided character of that display line. .TP +\fB\-selectbackground \fIcolor\fR +\fIcolor\fR specifies the background color to use when displaying selected +items. It may have any of the forms accepted by \fBTk_GetColor\fR. If +\fIcolor\fR has not been specified, or if it is specified as an empty +string, then the color specified by the fB\-background\fR tag option is +used. +.TP \fB\-spacing1 \fIpixels\fR . \fIPixels\fR specifies how much additional space should be left above each -- cgit v0.12 From f47ea89bb9b84548e135f0a72a033b20f0fe9f2a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:27:11 +0000 Subject: -selectbackground tag configuration option: tests --- tests/textTag.test | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/textTag.test b/tests/textTag.test index fed073a..a7935da 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -228,6 +228,17 @@ test textTag-1.25 {configuration options} -constraints { } -cleanup { .t tag configure x -rmargin [lindex [.t tag configure x -rmargin] 3] } -returnCodes error -result {bad screen distance "bad"} +test textTag-1.25a {tag configuration options} -body { + .t tag configure x -selectbackground #012345 + .t tag cget x -selectbackground +} -cleanup { + .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] +} -result {#012345} +test textTag-1.25b {configuration options} -body { + .t tag configure x -selectbackground non-existent +} -cleanup { + .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] +} -returnCodes error -result {unknown color name "non-existent"} test textTag-1.26 {tag configuration options} -constraints { haveCourier12 } -body { @@ -713,7 +724,29 @@ test textTag-5.22 {TkTextTagCmd - "configure" option} -constraints { .t tag configure sel -borderwidth {} .t cget -selectborderwidth } -result {} - +test textTag-5.23 {TkTextTagCmd - "configure" option} -body { + set x {} + # when [.t tag cget sel -selectbackground] == "", mirroring happens between + # the text widget option -selectbackground + # and the tag option -background + .t tag configure sel -selectbackground {} + .t configure -selectbackground black + .t tag configure sel -background yellow + lappend x [.t cget -selectbackground] + .t tag configure sel -background orange + .t configure -selectbackground blue + lappend x [.t tag cget sel -background] + # when [.t tag cget sel -selectbackground] != "", mirroring happens between + # the text widget option -selectbackground + # and the tag option -selectbackground + .t tag configure sel -selectbackground green + .t configure -selectbackground red + lappend x [.t tag cget sel -selectbackground] + .t configure -selectbackground black + .t tag configure sel -selectbackground white + lappend x [.t cget -selectbackground] + return $x +} -result {yellow blue red white} test textTag-6.1 {TkTextTagCmd - "delete" option} -constraints { haveCourier12 -- cgit v0.12 From 0e661eb452692fff53250ae95abde079888f3a27 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:29:22 +0000 Subject: -selectforeground tag configuration option: implementation --- generic/tkText.c | 7 ++++++- generic/tkText.h | 2 ++ generic/tkTextDisp.c | 10 ++++++++-- generic/tkTextTag.c | 10 +++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 1b420d6..464d4d9 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2262,7 +2262,11 @@ ConfigureText( textPtr->selTagPtr->borderWidthPtr = textPtr->selBorderWidthPtr; textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; } - textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; + if (textPtr->selTagPtr->selFgColor == NULL) { + textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; + } else { + textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr; + } textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; if ((textPtr->selTagPtr->elideString != NULL) @@ -2285,6 +2289,7 @@ ConfigureText( || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) + || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->underlineString != NULL)) { diff --git a/generic/tkText.h b/generic/tkText.h index 5cd009f..3056ab8 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -364,6 +364,8 @@ typedef struct TkTextTag { * valid if rMarginString is non-NULL. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ + XColor *selFgColor; /* Foreground color for selected text. NULL means + * no value specified here. */ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1bd5905..e8f8d79 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -798,9 +798,11 @@ GetStyle( for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; + XColor *fgColor; tagPtr = tagPtrs[i]; border = tagPtr->border; + fgColor = tagPtr->fgColor; /* * If this is the selection tag, and inactiveSelBorder is NULL (the @@ -824,6 +826,10 @@ GetStyle( border = tagPtr->selBorder; } + if ((tagPtr->selFgColor != None) && (isSelected)) { + fgColor = tagPtr->selFgColor; + } + if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; @@ -847,8 +853,8 @@ GetStyle( styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } - if ((tagPtr->fgColor != None) && (tagPtr->priority > fgPrio)) { - styleValues.fgColor = tagPtr->fgColor; + if ((fgColor != None) && (tagPtr->priority > fgPrio)) { + styleValues.fgColor = fgColor; fgPrio = tagPtr->priority; } if ((tagPtr->tkfont != None) && (tagPtr->priority > fontPrio)) { diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a857cf9..97356ed 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -72,6 +72,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-spacing2", NULL, NULL, @@ -493,7 +495,11 @@ TkTextTagCmd( } textPtr->selBorderWidth = tagPtr->borderWidth; textPtr->selBorderWidthPtr = tagPtr->borderWidthPtr; - textPtr->selFgColorPtr = tagPtr->fgColor; + if (tagPtr->selFgColor == NULL) { + textPtr->selFgColorPtr = tagPtr->fgColor; + } else { + textPtr->selFgColorPtr = tagPtr->selFgColor; + } } tagPtr->affectsDisplay = 0; @@ -519,6 +525,7 @@ TkTextTagCmd( || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) || (tagPtr->fgColor != NULL) + || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) || (tagPtr->overstrikeString != NULL) || (tagPtr->underlineString != NULL)) { @@ -1025,6 +1032,7 @@ TkTextCreateTag( tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->selBorder = NULL; + tagPtr->selFgColor = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; -- cgit v0.12 From 8ffa9516ef4ea4b1d2bded2bc05999322889a15a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:29:50 +0000 Subject: -selectforeground tag configuration option: documentation --- doc/text.n | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/text.n b/doc/text.n index 41d6a6f..61808ce 100644 --- a/doc/text.n +++ b/doc/text.n @@ -524,6 +524,13 @@ items. It may have any of the forms accepted by \fBTk_GetColor\fR. If string, then the color specified by the fB\-background\fR tag option is used. .TP +\fB\-selectforeground \fIcolor\fR +\fIcolor\fR specifies the foreground color to use when displaying selected +items. It may have any of the forms accepted by \fBTk_GetColor\fR. If +\fIcolor\fR has not been specified, or if it is specified as an empty +string, then the color specified by the fB\-foreground\fR tag option is +used. +.TP \fB\-spacing1 \fIpixels\fR . \fIPixels\fR specifies how much additional space should be left above each -- cgit v0.12 From 91073e4b5a77eb86aadddb05d9666a89f9b81907 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:30:11 +0000 Subject: -selectforeground tag configuration option: tests --- tests/textTag.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/textTag.test b/tests/textTag.test index a7935da..8b5ac74 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -239,6 +239,17 @@ test textTag-1.25b {configuration options} -body { } -cleanup { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} +test textTag-1.25c {tag configuration options} -body { + .t tag configure x -selectforeground #012345 + .t tag cget x -selectforeground +} -cleanup { + .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] +} -result {#012345} +test textTag-1.25d {configuration options} -body { + .t tag configure x -selectforeground non-existent +} -cleanup { + .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] +} -returnCodes error -result {unknown color name "non-existent"} test textTag-1.26 {tag configuration options} -constraints { haveCourier12 } -body { @@ -747,6 +758,29 @@ test textTag-5.23 {TkTextTagCmd - "configure" option} -body { lappend x [.t cget -selectbackground] return $x } -result {yellow blue red white} +test textTag-5.24 {TkTextTagCmd - "configure" option} -body { + set x {} + # when [.t tag cget sel -selectforeground] == "", mirroring happens between + # the text widget option -selectforeground + # and the tag option -foreground + .t tag configure sel -selectforeground {} + .t configure -selectforeground black + .t tag configure sel -foreground yellow + lappend x [.t cget -selectforeground] + .t tag configure sel -foreground orange + .t configure -selectforeground blue + lappend x [.t tag cget sel -foreground] + # when [.t tag cget sel -selectforeground] != "", mirroring happens between + # the text widget option -selectforeground + # and the tag option -selectforeground + .t tag configure sel -selectforeground green + .t configure -selectforeground red + lappend x [.t tag cget sel -selectforeground] + .t configure -selectforeground black + .t tag configure sel -selectforeground white + lappend x [.t cget -selectforeground] + return $x +} -result {yellow blue red white} test textTag-6.1 {TkTextTagCmd - "delete" option} -constraints { haveCourier12 -- cgit v0.12 From 5d588d31457d24ca04b54f6f1c92647e6a3d2b50 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:32:10 +0000 Subject: -selectbgstipple tag configuration option: implementation --- generic/tkText.c | 1 + generic/tkText.h | 2 ++ generic/tkTextDisp.c | 10 ++++++++-- generic/tkTextTag.c | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 464d4d9..7a2a6d5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2288,6 +2288,7 @@ ConfigureText( || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) + || (textPtr->selTagPtr->selBgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) diff --git a/generic/tkText.h b/generic/tkText.h index 3056ab8..c8a71b3 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -364,6 +364,8 @@ typedef struct TkTextTag { * valid if rMarginString is non-NULL. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ + Pixmap selBgStipple; /* Stipple bitmap for background of selected text. + * None means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e8f8d79..0ccd3c2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -798,10 +798,12 @@ GetStyle( for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; + Pixmap bgStipple; XColor *fgColor; tagPtr = tagPtrs[i]; border = tagPtr->border; + bgStipple = tagPtr->bgStipple; fgColor = tagPtr->fgColor; /* @@ -826,6 +828,10 @@ GetStyle( border = tagPtr->selBorder; } + if ((tagPtr->selBgStipple != None) && (isSelected)) { + bgStipple = tagPtr->selBgStipple; + } + if ((tagPtr->selFgColor != None) && (isSelected)) { fgColor = tagPtr->selFgColor; } @@ -848,9 +854,9 @@ GetStyle( styleValues.relief = tagPtr->relief; reliefPrio = tagPtr->priority; } - if ((tagPtr->bgStipple != None) + if ((bgStipple != None) && (tagPtr->priority > bgStipplePrio)) { - styleValues.bgStipple = tagPtr->bgStipple; + styleValues.bgStipple = bgStipple; bgStipplePrio = tagPtr->priority; } if ((fgColor != None) && (tagPtr->priority > fgPrio)) { diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 97356ed..86a6e77 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -72,6 +72,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, @@ -524,6 +526,7 @@ TkTextTagCmd( || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) + || (tagPtr->selBgStipple != None) || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) @@ -1032,6 +1035,7 @@ TkTextCreateTag( tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->selBorder = NULL; + tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; -- cgit v0.12 From 28fda9f36ca5e2e5cb00e56da38cd13e8391f44d Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:32:41 +0000 Subject: -selectbgstipple tag configuration option: documentation --- doc/text.n | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/text.n b/doc/text.n index 61808ce..a8f25c9 100644 --- a/doc/text.n +++ b/doc/text.n @@ -524,6 +524,14 @@ items. It may have any of the forms accepted by \fBTk_GetColor\fR. If string, then the color specified by the fB\-background\fR tag option is used. .TP +\fB\-selectbgstipple \fIbitmap\fR +. +\fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the +selected background. It may have any of the forms accepted by +\fBTk_GetBitmap\fR. If \fIbitmap\fR has not been specified, or if it is +specified as an empty string, then the \fIbitmap\fR specified by +'''-bgstipple''' will be used for the background. +.TP \fB\-selectforeground \fIcolor\fR \fIcolor\fR specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If -- cgit v0.12 From fe236b4cfe544d14e84df23e27d07f7efba752d5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:33:07 +0000 Subject: -selectbgstipple tag configuration option: tests --- tests/textTag.test | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/textTag.test b/tests/textTag.test index 8b5ac74..63081f3 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -240,12 +240,23 @@ test textTag-1.25b {configuration options} -body { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} test textTag-1.25c {tag configuration options} -body { + .t tag configure x -selectbgstipple gray50 + .t tag cget x -selectbgstipple +} -cleanup { + .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] +} -result {gray50} +test textTag-1.25d {configuration options} -body { + .t tag configure x -selectbgstipple badStipple +} -cleanup { + .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] +} -returnCodes error -result {bitmap "badStipple" not defined} +test textTag-1.25e {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25d {configuration options} -body { +test textTag-1.25f {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] -- cgit v0.12 From da061a037670e4bc29f960a349403aac50cd915c Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:36:19 +0000 Subject: -selectfgstipple tag configuration option: implementation --- generic/tkText.c | 1 + generic/tkText.h | 3 +++ generic/tkTextDisp.c | 10 ++++++++-- generic/tkTextTag.c | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 7a2a6d5..ccc9691 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2292,6 +2292,7 @@ ConfigureText( || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) + || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->underlineString != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; diff --git a/generic/tkText.h b/generic/tkText.h index c8a71b3..1a7d986 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -368,6 +368,9 @@ typedef struct TkTextTag { * None means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ + Pixmap selFgStipple; /* Stipple bitmap for text and other + * foreground stuff when selected. None means + * no value specified here.*/ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 0ccd3c2..d0c1483 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -800,11 +800,13 @@ GetStyle( Tk_3DBorder border; Pixmap bgStipple; XColor *fgColor; + Pixmap fgStipple; tagPtr = tagPtrs[i]; border = tagPtr->border; bgStipple = tagPtr->bgStipple; fgColor = tagPtr->fgColor; + fgStipple = tagPtr->fgStipple; /* * If this is the selection tag, and inactiveSelBorder is NULL (the @@ -836,6 +838,10 @@ GetStyle( fgColor = tagPtr->selFgColor; } + if ((tagPtr->selFgStipple != None) && (isSelected)) { + bgStipple = tagPtr->selFgStipple; + } + if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; @@ -867,9 +873,9 @@ GetStyle( styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } - if ((tagPtr->fgStipple != None) + if ((fgStipple != None) && (tagPtr->priority > fgStipplePrio)) { - styleValues.fgStipple = tagPtr->fgStipple; + styleValues.fgStipple = fgStipple; fgStipplePrio = tagPtr->priority; } if ((tagPtr->justifyString != NULL) diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 86a6e77..bb512e4 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -74,6 +74,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_BITMAP, "-selectfgstipple", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selFgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, @@ -530,6 +532,7 @@ TkTextTagCmd( || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) + || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) || (tagPtr->underlineString != NULL)) { tagPtr->affectsDisplay = 1; @@ -1037,6 +1040,7 @@ TkTextCreateTag( tagPtr->selBorder = NULL; tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; + tagPtr->selFgStipple = None; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; -- cgit v0.12 From 196fc0f4ea980dfeed790a1c2f5e4cae7077c0b4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:36:41 +0000 Subject: -selectfgstipple tag configuration option: documentation (+ polished doc of the previously developed new tag options) --- doc/text.n | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/text.n b/doc/text.n index a8f25c9..0216e5c 100644 --- a/doc/text.n +++ b/doc/text.n @@ -518,10 +518,10 @@ margin for each line on the display is determined by the first non-elided character of that display line. .TP \fB\-selectbackground \fIcolor\fR -\fIcolor\fR specifies the background color to use when displaying selected +\fIColor\fR specifies the background color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not been specified, or if it is specified as an empty -string, then the color specified by the fB\-background\fR tag option is +string, then the color specified by the \fB\-background\fR tag option is used. .TP \fB\-selectbgstipple \fIbitmap\fR @@ -529,14 +529,22 @@ used. \fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the selected background. It may have any of the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been specified, or if it is -specified as an empty string, then the \fIbitmap\fR specified by -'''-bgstipple''' will be used for the background. +specified as an empty string, then the bitmap specified by +\fB\-bgstipple\fR will be used for the background. +.TP +\fB\-selectfgstipple \fIbitmap\fR +. +\fIBitmap\fR specifies a bitmap that is used as a stipple pattern when drawing +selected text and other foreground information such as underlines. It may have any of +the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been +specified, or if it is specified as an empty string, then the bitmap specified by +\fB\-fgstipple\fR will be used. .TP \fB\-selectforeground \fIcolor\fR -\fIcolor\fR specifies the foreground color to use when displaying selected +\fIColor\fR specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not been specified, or if it is specified as an empty -string, then the color specified by the fB\-foreground\fR tag option is +string, then the color specified by the \fB\-foreground\fR tag option is used. .TP \fB\-spacing1 \fIpixels\fR -- cgit v0.12 From e108f0116e3154bacd641f8f85529512a2b9046f Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:37:33 +0000 Subject: -selectfgstipple tag configuration option: tests --- tests/textTag.test | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/textTag.test b/tests/textTag.test index 63081f3..ede86fd 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -251,12 +251,23 @@ test textTag-1.25d {configuration options} -body { .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] } -returnCodes error -result {bitmap "badStipple" not defined} test textTag-1.25e {tag configuration options} -body { + .t tag configure x -selectfgstipple gray50 + .t tag cget x -selectfgstipple +} -cleanup { + .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] +} -result {gray50} +test textTag-1.25f {configuration options} -body { + .t tag configure x -selectfgstipple badStipple +} -cleanup { + .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] +} -returnCodes error -result {bitmap "badStipple" not defined} +test textTag-1.25g {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25f {configuration options} -body { +test textTag-1.25h {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] -- cgit v0.12 From 62609c21da13af24e1df10132bdb5effc1d3ea7a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:40:51 +0000 Subject: -underlinefg tag configuration option: implementation --- generic/tkText.c | 3 ++- generic/tkText.h | 4 +++- generic/tkTextDisp.c | 19 +++++++++++++++++-- generic/tkTextTag.c | 6 +++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index ccc9691..7010601 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2294,7 +2294,8 @@ ConfigureText( || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) - || (textPtr->selTagPtr->underlineString != NULL)) { + || (textPtr->selTagPtr->underlineString != NULL) + || (textPtr->selTagPtr->underlineColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 1a7d986..815841c 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -398,7 +398,9 @@ typedef struct TkTextTag { int underline; /* Non-zero means draw underline underneath * text. Only valid if underlineString is * non-NULL. */ - TkWrapMode wrapMode; /* How to handle wrap-around for this tag. + XColor *underlineColor; /* Color for the underline. NULL means same + * color as foreground. */ + TkWrapMode wrapMode; /* How to hsandle wrap-around for this tag. * Must be TEXT_WRAPMODE_CHAR, * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or * TEXT_WRAPMODE_NULL to use wrapmode for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d0c1483..f246818 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -149,6 +149,8 @@ typedef struct StyleValues { int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ int underline; /* Non-zero means draw underline underneath * text. */ + XColor *underlineColor; /* Foreground color for underline underneath + * text. */ int elide; /* Zero means draw text, otherwise not. */ TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * One of TEXT_WRAPMODE_CHAR, @@ -166,6 +168,7 @@ typedef struct TextStyle { * referenced in Chunks. */ GC bgGC; /* Graphics context for background. None means * use widget background. */ + GC ulGC; /* Graphics context for underline. */ GC fgGC; /* Graphics context for foreground. */ StyleValues *sValuePtr; /* Raw information from which GCs were * derived. */ @@ -778,6 +781,7 @@ GetStyle( memset(&styleValues, 0, sizeof(StyleValues)); styleValues.relief = TK_RELIEF_FLAT; styleValues.fgColor = textPtr->fgColor; + styleValues.underlineColor = textPtr->fgColor; styleValues.tkfont = textPtr->tkfont; styleValues.justify = TK_JUSTIFY_LEFT; styleValues.spacing1 = textPtr->spacing1; @@ -937,6 +941,11 @@ GetStyle( && (tagPtr->priority > underlinePrio)) { styleValues.underline = tagPtr->underline; underlinePrio = tagPtr->priority; + if (tagPtr->underlineColor != None) { + styleValues.underlineColor = tagPtr->underlineColor; + } else if (fgColor != None) { + styleValues.underlineColor = fgColor; + } } if ((tagPtr->elideString != NULL) && (tagPtr->priority > elidePrio)) { @@ -993,6 +1002,9 @@ GetStyle( mask |= GCStipple|GCFillStyle; } stylePtr->fgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); + mask = GCForeground; + gcValues.foreground = styleValues.underlineColor->pixel; + stylePtr->ulGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); stylePtr->sValuePtr = (StyleValues *) Tcl_GetHashKey(&textPtr->dInfoPtr->styleTable, hPtr); stylePtr->hPtr = hPtr; @@ -1033,6 +1045,9 @@ FreeStyle( if (stylePtr->fgGC != None) { Tk_FreeGC(textPtr->display, stylePtr->fgGC); } + if (stylePtr->ulGC != None) { + Tk_FreeGC(textPtr->display, stylePtr->ulGC); + } Tcl_DeleteHashEntry(stylePtr->hPtr); ckfree(stylePtr); } @@ -7876,7 +7891,7 @@ CharDisplayProc( y + baseline - sValuePtr->offset); if (sValuePtr->underline) { - TkUnderlineCharsInContext(display, dst, stylePtr->fgGC, + TkUnderlineCharsInContext(display, dst, stylePtr->ulGC, sValuePtr->tkfont, string, numBytes, ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset, @@ -7903,7 +7918,7 @@ CharDisplayProc( Tk_DrawChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont, string, numBytes, offsetX, y + baseline - sValuePtr->offset); if (sValuePtr->underline) { - Tk_UnderlineChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont, + Tk_UnderlineChars(display, dst, stylePtr->ulGC, sValuePtr->tkfont, string, offsetX, y + baseline - sValuePtr->offset, 0, numBytes); diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index bb512e4..ed0ef98 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -92,6 +92,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_STRING, "-underline", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, underlineString), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-underlinefg", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, underlineColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, wrapMode), TK_OPTION_NULL_OK, wrapStrings, 0}, @@ -534,7 +536,8 @@ TkTextTagCmd( || (tagPtr->fgStipple != None) || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) - || (tagPtr->underlineString != NULL)) { + || (tagPtr->underlineString != NULL) + || (tagPtr->underlineColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1052,6 +1055,7 @@ TkTextCreateTag( tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE; tagPtr->underlineString = NULL; tagPtr->underline = 0; + tagPtr->underlineColor = NULL; tagPtr->elideString = NULL; tagPtr->elide = 0; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; -- cgit v0.12 From ecdc7dbb08227389f593c55a3b769a4e1ec9c8aa Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:41:37 +0000 Subject: -underlinefg tag configuration option: documentation --- doc/text.n | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/text.n b/doc/text.n index 0216e5c..e88728c 100644 --- a/doc/text.n +++ b/doc/text.n @@ -589,6 +589,14 @@ unspecified for the tag (the default). \fIBoolean\fR specifies whether or not to draw an underline underneath characters. It may have any of the forms accepted by \fBTcl_GetBoolean\fR. .TP +.TP +\fB\-underlinefg \fIcolor\fR +. +\fIColor\fR specifies the color to use when displaying the underline. It may +have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not +been specified, or if it is specified as an empty string, then the color +specified by the \fB\-foreground\fR tag option is used. +.TP \fB\-wrap \fImode\fR . \fIMode\fR specifies how to handle lines that are wider than the text's -- cgit v0.12 From 797f245ca2d4aafd6a0f7ad853cccd32a7942171 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:42:17 +0000 Subject: -underlinefg tag configuration option: tests --- tests/textTag.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/textTag.test b/tests/textTag.test index ede86fd..ae71a48 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -347,6 +347,17 @@ test textTag-1.35 {configuration options} -constraints { } -cleanup { .t tag configure x -underline [lindex [.t tag configure x -underline] 3] } -returnCodes error -result {expected boolean value but got "stupid"} +test textTag-1.36 {tag configuration options} -body { + .t tag configure x -underlinefg red + .t tag cget x -underlinefg +} -cleanup { + .t tag configure x -underlinefg [lindex [.t tag configure x -underlinefg] 3] +} -result {red} +test textTag-1.37 {configuration options} -body { + .t tag configure x -underlinefg stupid +} -cleanup { + .t tag configure x -underlinefg [lindex [.t tag configure x -underlinefg] 3] +} -returnCodes error -result {unknown color name "stupid"} test textTag-2.1 {TkTextTagCmd - "add" option} -constraints { @@ -603,6 +614,13 @@ test textTag-5.4 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -result {-underline {} {} {} yes} +test textTag-5.4a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -underlinefg lightgreen + .t tag configure x -underlinefg +} -cleanup { + .t tag delete x +} -result {-underlinefg {} {} {} lightgreen} test textTag-5.5 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { -- cgit v0.12 From 7c5f4b62829c4efa7ee754d566c45a0be0ace440 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:44:23 +0000 Subject: -overstrikefg tag configuration option: implementation --- generic/tkText.c | 1 + generic/tkText.h | 2 ++ generic/tkTextDisp.c | 20 +++++++++++++++++--- generic/tkTextTag.c | 8 +++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 7010601..19dce65 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2294,6 +2294,7 @@ ConfigureText( || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) + || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) || (textPtr->selTagPtr->underlineColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; diff --git a/generic/tkText.h b/generic/tkText.h index 815841c..242785a 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -358,6 +358,8 @@ typedef struct TkTextTag { int overstrike; /* Non-zero means draw horizontal line through * middle of text. Only valid if * overstrikeString is non-NULL. */ + XColor *overstrikeColor; /* Color for the overstrike. NULL means same + * color as foreground. */ char *rMarginString; /* -rmargin option string (malloc-ed). NULL * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f246818..b74c6db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -140,6 +140,8 @@ typedef struct StyleValues { * baseline of line. */ int overstrike; /* Non-zero means draw overstrike through * text. */ + XColor *overstrikeColor; /* Foreground color for overstrike through + * text. */ int rMargin; /* Right margin, in pixels. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ @@ -168,8 +170,9 @@ typedef struct TextStyle { * referenced in Chunks. */ GC bgGC; /* Graphics context for background. None means * use widget background. */ - GC ulGC; /* Graphics context for underline. */ GC fgGC; /* Graphics context for foreground. */ + GC ulGC; /* Graphics context for underline. */ + GC ovGC; /* Graphics context for overstrike. */ StyleValues *sValuePtr; /* Raw information from which GCs were * derived. */ Tcl_HashEntry *hPtr; /* Pointer to entry in styleTable. Used to @@ -782,6 +785,7 @@ GetStyle( styleValues.relief = TK_RELIEF_FLAT; styleValues.fgColor = textPtr->fgColor; styleValues.underlineColor = textPtr->fgColor; + styleValues.overstrikeColor = textPtr->fgColor; styleValues.tkfont = textPtr->tkfont; styleValues.justify = TK_JUSTIFY_LEFT; styleValues.spacing1 = textPtr->spacing1; @@ -906,6 +910,11 @@ GetStyle( && (tagPtr->priority > overstrikePrio)) { styleValues.overstrike = tagPtr->overstrike; overstrikePrio = tagPtr->priority; + if (tagPtr->overstrikeColor != None) { + styleValues.overstrikeColor = tagPtr->overstrikeColor; + } else if (fgColor != None) { + styleValues.overstrikeColor = fgColor; + } } if ((tagPtr->rMarginString != NULL) && (tagPtr->priority > rMarginPrio)) { @@ -1005,6 +1014,8 @@ GetStyle( mask = GCForeground; gcValues.foreground = styleValues.underlineColor->pixel; stylePtr->ulGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); + gcValues.foreground = styleValues.overstrikeColor->pixel; + stylePtr->ovGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); stylePtr->sValuePtr = (StyleValues *) Tcl_GetHashKey(&textPtr->dInfoPtr->styleTable, hPtr); stylePtr->hPtr = hPtr; @@ -1048,6 +1059,9 @@ FreeStyle( if (stylePtr->ulGC != None) { Tk_FreeGC(textPtr->display, stylePtr->ulGC); } + if (stylePtr->ovGC != None) { + Tk_FreeGC(textPtr->display, stylePtr->ovGC); + } Tcl_DeleteHashEntry(stylePtr->hPtr); ckfree(stylePtr); } @@ -7901,7 +7915,7 @@ CharDisplayProc( Tk_FontMetrics fm; Tk_GetFontMetrics(sValuePtr->tkfont, &fm); - TkUnderlineCharsInContext(display, dst, stylePtr->fgGC, + TkUnderlineCharsInContext(display, dst, stylePtr->ovGC, sValuePtr->tkfont, string, numBytes, ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset @@ -7928,7 +7942,7 @@ CharDisplayProc( Tk_FontMetrics fm; Tk_GetFontMetrics(sValuePtr->tkfont, &fm); - Tk_UnderlineChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont, + Tk_UnderlineChars(display, dst, stylePtr->ovGC, sValuePtr->tkfont, string, offsetX, y + baseline - sValuePtr->offset - fm.descent - (fm.ascent * 3) / 10, diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index ed0ef98..e268352 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -66,6 +66,9 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_STRING, "-overstrike", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, overstrikeString), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, overstrikeColor), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-relief", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, @@ -93,7 +96,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, underlineString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-underlinefg", NULL, NULL, - NULL, -1, Tk_Offset(TkTextTag, underlineColor), TK_OPTION_NULL_OK, 0, 0}, + NULL, -1, Tk_Offset(TkTextTag, underlineColor), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, wrapMode), TK_OPTION_NULL_OK, wrapStrings, 0}, @@ -536,6 +540,7 @@ TkTextTagCmd( || (tagPtr->fgStipple != None) || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) + || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) || (tagPtr->underlineColor != NULL)) { tagPtr->affectsDisplay = 1; @@ -1038,6 +1043,7 @@ TkTextCreateTag( tagPtr->offset = 0; tagPtr->overstrikeString = NULL; tagPtr->overstrike = 0; + tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->selBorder = NULL; -- cgit v0.12 From 935d5f2814f55a18088b4ce4a3cfc6cb76fa86df Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:44:48 +0000 Subject: -overstrikefg tag configuration option: documentation --- doc/text.n | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/text.n b/doc/text.n index e88728c..fd18a59 100644 --- a/doc/text.n +++ b/doc/text.n @@ -500,6 +500,13 @@ Specifies whether or not to draw a horizontal rule through the middle of characters. \fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR. .TP +\fB\-overstrikefg \fIcolor\fR +. +\fIColor\fR specifies the color to use when displaying the overstrike. It may +have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not +been specified, or if it is specified as an empty string, then the color +specified by the \fB\-foreground\fR tag option is used. +.TP \fB\-relief \fIrelief\fR . \fIRelief\fR specifies the relief style to use for drawing the border, in any @@ -589,7 +596,6 @@ unspecified for the tag (the default). \fIBoolean\fR specifies whether or not to draw an underline underneath characters. It may have any of the forms accepted by \fBTcl_GetBoolean\fR. .TP -.TP \fB\-underlinefg \fIcolor\fR . \fIColor\fR specifies the color to use when displaying the underline. It may -- cgit v0.12 From 74d865bb3e520e131dc6655986fe79141120c2e9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:45:19 +0000 Subject: -overstrikefg tag configuration option: tests --- tests/textTag.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/textTag.test b/tests/textTag.test index ae71a48..c2feaa7 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -198,6 +198,17 @@ test textTag-1.21 {configuration options} -constraints { } -cleanup { .t tag configure x -overstrike [lindex [.t tag configure x -overstrike] 3] } -returnCodes error -result {expected boolean value but got "stupid"} +test textTag-1.21a {tag configuration options} -body { + .t tag configure x -overstrikefg red + .t tag cget x -overstrikefg +} -cleanup { + .t tag configure x -overstrikefg [lindex [.t tag configure x -overstrikefg] 3] +} -result {red} +test textTag-1.21b {configuration options} -body { + .t tag configure x -overstrikefg stupid +} -cleanup { + .t tag configure x -overstrikefg [lindex [.t tag configure x -overstrikefg] 3] +} -returnCodes error -result {unknown color name "stupid"} test textTag-1.22 {tag configuration options} -constraints { haveCourier12 } -body { @@ -630,6 +641,13 @@ test textTag-5.5 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -result {on} +test textTag-5.5a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -overstrikefg lightgreen + .t tag configure x -overstrikefg +} -cleanup { + .t tag delete x +} -result {-overstrikefg {} {} {} lightgreen} test textTag-5.6 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { -- cgit v0.12 From 30a85a7ace1cf7ea9de7828dfb84fde2af23148b Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:51:45 +0000 Subject: -lmargincolor tag configuration option: implementation --- generic/tkText.c | 3 ++- generic/tkText.h | 3 +++ generic/tkTextDisp.c | 26 ++++++++++++++++++++++++++ generic/tkTextTag.c | 6 +++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 19dce65..415e0bc 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2296,7 +2296,8 @@ ConfigureText( || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) - || (textPtr->selTagPtr->underlineColor != NULL)) { + || (textPtr->selTagPtr->underlineColor != NULL) + || (textPtr->selTagPtr->lMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 242785a..22df370 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -347,6 +347,9 @@ typedef struct TkTextTag { int lMargin2; /* Left margin for second and later display * lines of each text line, in pixels. Only * valid if lMargin2String is non-NULL. */ + Tk_3DBorder lMarginColor; /* Used for drawing background in left margins. + * This is used for both lmargin1 and lmargin2. + * NULL means no value specified here. */ char *offsetString; /* -offset option string (malloc-ed). NULL * means option not specified. */ int offset; /* Vertical offset of text's baseline from diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index b74c6db..c0d6384 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -136,6 +136,7 @@ typedef struct StyleValues { * line of each text line. */ int lMargin2; /* Left margin, in pixels, for second and * later display lines of each text line. */ + Tk_3DBorder lMarginColor; /* Color of left margins (1 and 2). */ int offset; /* Offset in pixels of baseline, relative to * baseline of line. */ int overstrike; /* Non-zero means draw overstrike through @@ -240,6 +241,10 @@ typedef struct DLine { int spaceBelow; /* How much extra space was added to the * bottom of the line because of spacing * options. This is included in height. */ + Tk_3DBorder lMarginColor; /* Background color of the area corresponding + * to the left margin of the display line. */ + int lMarginWidth; /* Pixel width of the area corresponding to + * the left margin. */ int length; /* Total length of line, in pixels. */ TkTextDispChunk *chunkPtr; /* Pointer to first chunk in list of all of * those that are displayed on this line of @@ -765,6 +770,7 @@ GetStyle( int fgPrio, fontPrio, fgStipplePrio; int underlinePrio, elidePrio, justifyPrio, offsetPrio; int lMargin1Prio, lMargin2Prio, rMarginPrio; + int lMarginColorPrio; int spacing1Prio, spacing2Prio, spacing3Prio; int overstrikePrio, tabPrio, tabStylePrio, wrapPrio; @@ -779,6 +785,7 @@ GetStyle( fgPrio = fontPrio = fgStipplePrio = -1; underlinePrio = elidePrio = justifyPrio = offsetPrio = -1; lMargin1Prio = lMargin2Prio = rMarginPrio = -1; + lMarginColorPrio = -1; spacing1Prio = spacing2Prio = spacing3Prio = -1; overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1; memset(&styleValues, 0, sizeof(StyleValues)); @@ -901,6 +908,11 @@ GetStyle( styleValues.lMargin2 = tagPtr->lMargin2; lMargin2Prio = tagPtr->priority; } + if ((tagPtr->lMarginColor != NULL) + && (tagPtr->priority > lMarginColorPrio)) { + styleValues.lMarginColor = tagPtr->lMarginColor; + lMarginColorPrio = tagPtr->priority; + } if ((tagPtr->offsetString != NULL) && (tagPtr->priority > offsetPrio)) { styleValues.offset = tagPtr->offset; @@ -1173,6 +1185,8 @@ LayoutDLine( dlPtr->nextPtr = NULL; dlPtr->flags = NEW_LAYOUT | OLD_Y_INVALID; dlPtr->logicalLinesMerged = 0; + dlPtr->lMarginColor = NULL; + dlPtr->lMarginWidth = 0; /* * This is not necessarily totally correct, where we have merged logical @@ -1447,6 +1461,7 @@ LayoutDLine( x = chunkPtr->stylePtr->sValuePtr->lMargin2; } + dlPtr->lMarginWidth = x; if (wrapMode == TEXT_WRAPMODE_NONE) { maxX = -1; } else { @@ -1758,6 +1773,7 @@ LayoutDLine( } dlPtr->height += dlPtr->spaceAbove + dlPtr->spaceBelow; dlPtr->baseline += dlPtr->spaceAbove; + dlPtr->lMarginColor = sValuePtr->lMarginColor; /* * Recompute line length: may have changed because of justification. @@ -2444,6 +2460,16 @@ DisplayDLine( Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT); /* + * Second, draw the background color of the left margin. + */ + if (dlPtr->lMarginColor != NULL) { + int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; + + Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, + (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + } + + /* * Next, draw background information for the whole line. */ diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index e268352..a3e55fc 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -61,6 +61,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-lmargin2", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0}, + {TK_OPTION_BORDER, "-lmargincolor", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-offset", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-overstrike", NULL, NULL, @@ -542,7 +544,8 @@ TkTextTagCmd( || (tagPtr->overstrikeString != NULL) || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) - || (tagPtr->underlineColor != NULL)) { + || (tagPtr->underlineColor != NULL) + || (tagPtr->lMarginColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1039,6 +1042,7 @@ TkTextCreateTag( tagPtr->lMargin1 = 0; tagPtr->lMargin2String = NULL; tagPtr->lMargin2 = 0; + tagPtr->lMarginColor = NULL; tagPtr->offsetString = NULL; tagPtr->offset = 0; tagPtr->overstrikeString = NULL; -- cgit v0.12 From 3c2928472dcfca0f3053ad349df8b64e98a6923c Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:52:15 +0000 Subject: -lmargincolor tag configuration option: documentation --- doc/text.n | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/text.n b/doc/text.n index fd18a59..1e6dbc2 100644 --- a/doc/text.n +++ b/doc/text.n @@ -486,6 +486,15 @@ much the line should be indented from the left edge of the window. option is only used when wrapping is enabled, and it only applies to the second and later display lines for a text line. .TP +\fB\-lmargincolor \fIcolor\fR +. +\fIColor\fR specifies the background color to use in regions that do not +contain characters because they are indented by \fB\-lmargin1\fR or +\fB\-lmargin2\fR. It may have any of the forms accepted by +\fBTk_GetColor\fR.If \fIcolor\fR has not been specified, or if it is +specified as an empty string, then the color specified by the +\fB-background\fR widget option is used. +.TP \fB\-offset \fIpixels\fR . \fIPixels\fR specifies an amount by which the text's baseline should be offset -- cgit v0.12 From 47cbb49b5a939e1af93b945c53daa3177d9aeef0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:52:33 +0000 Subject: -lmargincolor tag configuration option: tests --- tests/textTag.test | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index c2feaa7..9e0cf38 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -168,6 +168,17 @@ test textTag-1.17 {configuration options} -constraints { } -cleanup { .t tag configure x -lmargin2 [lindex [.t tag configure x -lmargin2] 3] } -returnCodes error -result {bad screen distance "bad"} +test textTag-1.17a {tag configuration options} -body { + .t tag configure x -lmargincolor lightgreen + .t tag cget x -lmargincolor +} -cleanup { + .t tag configure x -lmargincolor [lindex [.t tag configure x -lmargincolor] 3] +} -result {lightgreen} +test textTag-1.17b {configuration options} -body { + .t tag configure x -lmargincolor non-existent +} -cleanup { + .t tag configure x -lmargincolor [lindex [.t tag configure x -lmargincolor] 3] +} -returnCodes error -result {unknown color name "non-existent"} test textTag-1.18 {tag configuration options} -constraints { haveCourier12 } -body { @@ -705,16 +716,15 @@ test textTag-5.12 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -returnCodes error -result {bad screen distance "1.0q"} -test textTag-5.13 {TkTextTagCmd - "configure" option} -constraints { - haveCourier12 -} -body { +test textTag-5.13 {TkTextTagCmd - "configure" option} -body { .t tag delete x - .t tag configure x -lmargin1 2 -lmargin2 4 -rmargin 5 + .t tag configure x -lmargin1 2 -lmargin2 4 -rmargin 5 \ + -lmargincolor darkblue list [.t tag configure x -lmargin1] [.t tag configure x -lmargin2] \ - [.t tag configure x -rmargin] + [.t tag configure x -rmargin] [.t tag configure x -lmargincolor] } -cleanup { .t tag delete x -} -result {{-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} {-rmargin {} {} {} 5}} +} -result {{-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} {-rmargin {} {} {} 5} {-lmargincolor {} {} {} darkblue}} test textTag-5.14 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { @@ -731,6 +741,12 @@ test textTag-5.15 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -returnCodes error -result {bad screen distance "gorp"} +test textTag-5.15a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -lmargincolor rainbow +} -cleanup { + .t tag delete x +} -returnCodes error -result {unknown color name "rainbow"} test textTag-5.16 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { -- cgit v0.12 From 3cea177e222e8c8b59cfcd693faa3581340d2c3d Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:53:30 +0000 Subject: -rmargincolor tag configuration option: implementation --- generic/tkText.c | 3 ++- generic/tkText.h | 2 ++ generic/tkTextDisp.c | 29 +++++++++++++++++++++++++---- generic/tkTextTag.c | 6 +++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 415e0bc..0de648a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2297,7 +2297,8 @@ ConfigureText( || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) || (textPtr->selTagPtr->underlineColor != NULL) - || (textPtr->selTagPtr->lMarginColor != NULL)) { + || (textPtr->selTagPtr->lMarginColor != NULL) + || (textPtr->selTagPtr->rMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 22df370..8fab200 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -367,6 +367,8 @@ typedef struct TkTextTag { * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ + Tk_3DBorder rMarginColor; /* Used for drawing background in right margin. + * NULL means no value specified here. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ Pixmap selBgStipple; /* Stipple bitmap for background of selected text. diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c0d6384..c0dc017 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -144,6 +144,7 @@ typedef struct StyleValues { XColor *overstrikeColor; /* Foreground color for overstrike through * text. */ int rMargin; /* Right margin, in pixels. */ + Tk_3DBorder rMarginColor; /* Color of right margin. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ int spacing3; /* Spacing below last dline in text line. */ @@ -245,6 +246,10 @@ typedef struct DLine { * to the left margin of the display line. */ int lMarginWidth; /* Pixel width of the area corresponding to * the left margin. */ + Tk_3DBorder rMarginColor; /* Background color of the area corresponding + * to the right margin of the display line. */ + int rMarginWidth; /* Pixel width of the area corresponding to + * the right margin. */ int length; /* Total length of line, in pixels. */ TkTextDispChunk *chunkPtr; /* Pointer to first chunk in list of all of * those that are displayed on this line of @@ -770,7 +775,7 @@ GetStyle( int fgPrio, fontPrio, fgStipplePrio; int underlinePrio, elidePrio, justifyPrio, offsetPrio; int lMargin1Prio, lMargin2Prio, rMarginPrio; - int lMarginColorPrio; + int lMarginColorPrio, rMarginColorPrio; int spacing1Prio, spacing2Prio, spacing3Prio; int overstrikePrio, tabPrio, tabStylePrio, wrapPrio; @@ -785,7 +790,7 @@ GetStyle( fgPrio = fontPrio = fgStipplePrio = -1; underlinePrio = elidePrio = justifyPrio = offsetPrio = -1; lMargin1Prio = lMargin2Prio = rMarginPrio = -1; - lMarginColorPrio = -1; + lMarginColorPrio = rMarginColorPrio = -1; spacing1Prio = spacing2Prio = spacing3Prio = -1; overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1; memset(&styleValues, 0, sizeof(StyleValues)); @@ -933,6 +938,11 @@ GetStyle( styleValues.rMargin = tagPtr->rMargin; rMarginPrio = tagPtr->priority; } + if ((tagPtr->rMarginColor != NULL) + && (tagPtr->priority > rMarginColorPrio)) { + styleValues.rMarginColor = tagPtr->rMarginColor; + rMarginColorPrio = tagPtr->priority; + } if ((tagPtr->spacing1String != NULL) && (tagPtr->priority > spacing1Prio)) { styleValues.spacing1 = tagPtr->spacing1; @@ -1187,6 +1197,8 @@ LayoutDLine( dlPtr->logicalLinesMerged = 0; dlPtr->lMarginColor = NULL; dlPtr->lMarginWidth = 0; + dlPtr->rMarginColor = NULL; + dlPtr->rMarginWidth = 0; /* * This is not necessarily totally correct, where we have merged logical @@ -1774,6 +1786,10 @@ LayoutDLine( dlPtr->height += dlPtr->spaceAbove + dlPtr->spaceBelow; dlPtr->baseline += dlPtr->spaceAbove; dlPtr->lMarginColor = sValuePtr->lMarginColor; + dlPtr->rMarginColor = sValuePtr->rMarginColor; + if (wrapMode != TEXT_WRAPMODE_NONE) { + dlPtr->rMarginWidth = rMargin; + } /* * Recompute line length: may have changed because of justification. @@ -2460,13 +2476,18 @@ DisplayDLine( Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT); /* - * Second, draw the background color of the left margin. + * Second, draw the background color of the left and right margins. */ if (dlPtr->lMarginColor != NULL) { int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, - (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + } + if (dlPtr->rMarginColor != NULL) { + Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor, + dInfoPtr->maxX - dlPtr->rMarginWidth + dInfoPtr->curXPixelOffset, + y, dlPtr->rMarginWidth, dlPtr->height, 0, TK_RELIEF_FLAT); } /* diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a3e55fc..49d6a50 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -75,6 +75,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, + {TK_OPTION_BORDER, "-rmargincolor", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, @@ -545,7 +547,8 @@ TkTextTagCmd( || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) || (tagPtr->underlineColor != NULL) - || (tagPtr->lMarginColor != NULL)) { + || (tagPtr->lMarginColor != NULL) + || (tagPtr->rMarginColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1050,6 +1053,7 @@ TkTextCreateTag( tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; + tagPtr->rMarginColor = NULL; tagPtr->selBorder = NULL; tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; -- cgit v0.12 From c841d963af542a097122211248620383ff6098c0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:53:51 +0000 Subject: -rmargincolor tag configuration option: documentation --- doc/text.n | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/text.n b/doc/text.n index 1e6dbc2..84ad710 100644 --- a/doc/text.n +++ b/doc/text.n @@ -533,6 +533,14 @@ option is only used when wrapping is enabled. If a text line wraps, the right margin for each line on the display is determined by the first non-elided character of that display line. .TP +\fB\-rmargincolor \fIcolor\fR +. +\fIColor\fR specifies the background color to use in regions that do not +contain characters because they are indented by \fB\-rmargin1\fR. It may +have any of the forms accepted by \fBTk_GetColor\fR.If \fIcolor\fR has not +been specified, or if it is specified as an empty string, then the color +specified by the \fB-background\fR widget option is used. +.TP \fB\-selectbackground \fIcolor\fR \fIColor\fR specifies the background color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If -- cgit v0.12 From 6acf033f061f09ca43c0203318847b950110eb87 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:54:09 +0000 Subject: -rmargincolor tag configuration option: tests --- tests/textTag.test | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index 9e0cf38..f8d7033 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -251,45 +251,56 @@ test textTag-1.25 {configuration options} -constraints { .t tag configure x -rmargin [lindex [.t tag configure x -rmargin] 3] } -returnCodes error -result {bad screen distance "bad"} test textTag-1.25a {tag configuration options} -body { + .t tag configure x -rmargincolor darkblue + .t tag cget x -rmargincolor +} -cleanup { + .t tag configure x -rmargincolor [lindex [.t tag configure x -rmargincolor] 3] +} -result {darkblue} +test textTag-1.25b {configuration options} -body { + .t tag configure x -rmargincolor non-existent +} -cleanup { + .t tag configure x -rmargincolor [lindex [.t tag configure x -rmargincolor] 3] +} -returnCodes error -result {unknown color name "non-existent"} +test textTag-1.25c {tag configuration options} -body { .t tag configure x -selectbackground #012345 .t tag cget x -selectbackground } -cleanup { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -result {#012345} -test textTag-1.25b {configuration options} -body { +test textTag-1.25d {configuration options} -body { .t tag configure x -selectbackground non-existent } -cleanup { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} -test textTag-1.25c {tag configuration options} -body { +test textTag-1.25e {tag configuration options} -body { .t tag configure x -selectbgstipple gray50 .t tag cget x -selectbgstipple } -cleanup { .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] } -result {gray50} -test textTag-1.25d {configuration options} -body { +test textTag-1.25f {configuration options} -body { .t tag configure x -selectbgstipple badStipple } -cleanup { .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] } -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25e {tag configuration options} -body { +test textTag-1.25g {tag configuration options} -body { .t tag configure x -selectfgstipple gray50 .t tag cget x -selectfgstipple } -cleanup { .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] } -result {gray50} -test textTag-1.25f {configuration options} -body { +test textTag-1.25h {configuration options} -body { .t tag configure x -selectfgstipple badStipple } -cleanup { .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] } -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25g {tag configuration options} -body { +test textTag-1.25i {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25h {configuration options} -body { +test textTag-1.25j {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] @@ -719,12 +730,16 @@ test textTag-5.12 {TkTextTagCmd - "configure" option} -constraints { test textTag-5.13 {TkTextTagCmd - "configure" option} -body { .t tag delete x .t tag configure x -lmargin1 2 -lmargin2 4 -rmargin 5 \ - -lmargincolor darkblue + -lmargincolor darkblue -rmargincolor lightgreen list [.t tag configure x -lmargin1] [.t tag configure x -lmargin2] \ - [.t tag configure x -rmargin] [.t tag configure x -lmargincolor] + [.t tag configure x -rmargin] [.t tag configure x -lmargincolor] \ + [.t tag configure x -rmargincolor] } -cleanup { .t tag delete x -} -result {{-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} {-rmargin {} {} {} 5} {-lmargincolor {} {} {} darkblue}} +} -result [list {-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} \ + {-rmargin {} {} {} 5} \ + {-lmargincolor {} {} {} darkblue} {-rmargincolor {} {} {} lightgreen} \ + ] test textTag-5.14 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { @@ -755,6 +770,12 @@ test textTag-5.16 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -returnCodes error -result {bad screen distance "140.1.1"} +test textTag-5.16a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -rmargincolor rainbow +} -cleanup { + .t tag delete x +} -returnCodes error -result {unknown color name "rainbow"} .t tag delete x test textTag-5.17 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 -- cgit v0.12 From 0fe18b82571d24300bc235e6c37013742ee3b778 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 10:41:03 +0000 Subject: Fixed typo in comment (introduced by error in [6a21622c7e]) --- generic/tkText.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkText.h b/generic/tkText.h index 8fab200..f37e01a 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -407,7 +407,7 @@ typedef struct TkTextTag { * non-NULL. */ XColor *underlineColor; /* Color for the underline. NULL means same * color as foreground. */ - TkWrapMode wrapMode; /* How to hsandle wrap-around for this tag. + TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * Must be TEXT_WRAPMODE_CHAR, * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or * TEXT_WRAPMODE_NULL to use wrapmode for -- cgit v0.12 From 2d1dee7c0fdf51a57ac71ed493aa92e278a7720e Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 13:17:51 +0000 Subject: -lmargincolor tag configuration option: implementation slightly optimized since Tk_Fill3DRectangle is robust with respect to negative widths --- generic/tkTextDisp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c0dc017..f871fc1 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -2479,10 +2479,9 @@ DisplayDLine( * Second, draw the background color of the left and right margins. */ if (dlPtr->lMarginColor != NULL) { - int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; - Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, - (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset, + dlPtr->height, 0, TK_RELIEF_FLAT); } if (dlPtr->rMarginColor != NULL) { Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor, -- cgit v0.12 From d4e3294d3a4adb1370d84500401b26f7279119cc Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 8 Mar 2016 21:55:45 +0000 Subject: Backed out anything dealing with stippling, in accordance with discussion about TIP #443 --- doc/text.n | 16 ---------------- generic/tkText.c | 2 -- generic/tkText.h | 5 ----- generic/tkTextDisp.c | 20 ++++---------------- generic/tkTextTag.c | 8 -------- tests/textTag.test | 24 +----------------------- 6 files changed, 5 insertions(+), 70 deletions(-) diff --git a/doc/text.n b/doc/text.n index 84ad710..5d6ac19 100644 --- a/doc/text.n +++ b/doc/text.n @@ -548,22 +548,6 @@ items. It may have any of the forms accepted by \fBTk_GetColor\fR. If string, then the color specified by the \fB\-background\fR tag option is used. .TP -\fB\-selectbgstipple \fIbitmap\fR -. -\fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the -selected background. It may have any of the forms accepted by -\fBTk_GetBitmap\fR. If \fIbitmap\fR has not been specified, or if it is -specified as an empty string, then the bitmap specified by -\fB\-bgstipple\fR will be used for the background. -.TP -\fB\-selectfgstipple \fIbitmap\fR -. -\fIBitmap\fR specifies a bitmap that is used as a stipple pattern when drawing -selected text and other foreground information such as underlines. It may have any of -the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been -specified, or if it is specified as an empty string, then the bitmap specified by -\fB\-fgstipple\fR will be used. -.TP \fB\-selectforeground \fIcolor\fR \fIColor\fR specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If diff --git a/generic/tkText.c b/generic/tkText.c index 0de648a..88fe19a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2288,11 +2288,9 @@ ConfigureText( || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) - || (textPtr->selTagPtr->selBgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) - || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) diff --git a/generic/tkText.h b/generic/tkText.h index f37e01a..5d88784 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -371,13 +371,8 @@ typedef struct TkTextTag { * NULL means no value specified here. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ - Pixmap selBgStipple; /* Stipple bitmap for background of selected text. - * None means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ - Pixmap selFgStipple; /* Stipple bitmap for text and other - * foreground stuff when selected. None means - * no value specified here.*/ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d22bcb3..0849307 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -818,15 +818,11 @@ GetStyle( for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; - Pixmap bgStipple; XColor *fgColor; - Pixmap fgStipple; tagPtr = tagPtrs[i]; border = tagPtr->border; - bgStipple = tagPtr->bgStipple; fgColor = tagPtr->fgColor; - fgStipple = tagPtr->fgStipple; /* * If this is the selection tag, and inactiveSelBorder is NULL (the @@ -850,18 +846,10 @@ GetStyle( border = tagPtr->selBorder; } - if ((tagPtr->selBgStipple != None) && (isSelected)) { - bgStipple = tagPtr->selBgStipple; - } - if ((tagPtr->selFgColor != None) && (isSelected)) { fgColor = tagPtr->selFgColor; } - if ((tagPtr->selFgStipple != None) && (isSelected)) { - bgStipple = tagPtr->selFgStipple; - } - if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; @@ -880,9 +868,9 @@ GetStyle( styleValues.relief = tagPtr->relief; reliefPrio = tagPtr->priority; } - if ((bgStipple != None) + if ((tagPtr->bgStipple != None) && (tagPtr->priority > bgStipplePrio)) { - styleValues.bgStipple = bgStipple; + styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } if ((fgColor != None) && (tagPtr->priority > fgPrio)) { @@ -893,9 +881,9 @@ GetStyle( styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } - if ((fgStipple != None) + if ((tagPtr->fgStipple != None) && (tagPtr->priority > fgStipplePrio)) { - styleValues.fgStipple = fgStipple; + styleValues.fgStipple = tagPtr->fgStipple; fgStipplePrio = tagPtr->priority; } if ((tagPtr->justifyString != NULL) diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 49d6a50..a212615 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -79,10 +79,6 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, - NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_BITMAP, "-selectfgstipple", NULL, NULL, - NULL, -1, Tk_Offset(TkTextTag, selFgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, @@ -538,11 +534,9 @@ TkTextTagCmd( || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) - || (tagPtr->selBgStipple != None) || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) - || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) @@ -1055,9 +1049,7 @@ TkTextCreateTag( tagPtr->rMargin = 0; tagPtr->rMarginColor = NULL; tagPtr->selBorder = NULL; - tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; - tagPtr->selFgStipple = None; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; diff --git a/tests/textTag.test b/tests/textTag.test index f8d7033..88081d0 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -273,34 +273,12 @@ test textTag-1.25d {configuration options} -body { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} test textTag-1.25e {tag configuration options} -body { - .t tag configure x -selectbgstipple gray50 - .t tag cget x -selectbgstipple -} -cleanup { - .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] -} -result {gray50} -test textTag-1.25f {configuration options} -body { - .t tag configure x -selectbgstipple badStipple -} -cleanup { - .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] -} -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25g {tag configuration options} -body { - .t tag configure x -selectfgstipple gray50 - .t tag cget x -selectfgstipple -} -cleanup { - .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] -} -result {gray50} -test textTag-1.25h {configuration options} -body { - .t tag configure x -selectfgstipple badStipple -} -cleanup { - .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] -} -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25i {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25j {configuration options} -body { +test textTag-1.25f {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] -- cgit v0.12