Subject: -selectfgstipple tag configuration option: implementation

From: fvogel <[email-masked]>
Date: Tue, 9 Feb 2016 21:36:19 +0000

---
 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