summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-02-09 21:23:23 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-02-09 21:23:23 (GMT)
commitb258e6b408ef99ed31fdde484f21548851eca156 (patch)
tree11d3f289c1d49dc3eb2042f5243f7eb241923eaa
parent8f151700b10bf8811876305e284738707d4ad237 (diff)
downloadtk-b258e6b408ef99ed31fdde484f21548851eca156.zip
tk-b258e6b408ef99ed31fdde484f21548851eca156.tar.gz
tk-b258e6b408ef99ed31fdde484f21548851eca156.tar.bz2
-selectbackground tag configuration option: implementation
-rw-r--r--generic/tkText.c7
-rw-r--r--generic/tkText.h2
-rw-r--r--generic/tkTextDisp.c13
-rw-r--r--generic/tkTextTag.c10
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;