Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Bugfix [cda289a8ea]: The old handling/implementation of the selection options is tohubohu, so I used the opportunity to overwork it: (1) I added the tag options -inactivebackground and -inactiveforegound, and these options are tied to widget options -inactiveselectbackground and -inactiveselectforeground. (2) For symmetry reasons I added the tag options -inactiveselectbackground and -inactiveselectforeground, these options will overrule the options -inactivebackground and -inactivebackgound of the "sel" tag, provided that the actual tag has a higher priority. (3) The manual has been updated with new options. Furthermore section "THE SELECTION" has been refined. (4) In legacy widget tag option -selectbackground is tied to widget option -selectbackground if the tag option -selectbackground is not null, otherwise the widget option is tied to tag option "-background", this is very confusing, and not conform to documentation, this binding has been changed. Now the widget option -selectbackground is tied with tag option "-background" (of the "sel" tag), this is conform to (revised and legacy) documentation, it is a clear behavior, and allows more freedom in configuration. The tag options "-selectbackground" and "-selectforeground" now will overrule the options "-background" and "-foreground" of the "sel" tag, provided that the actual tag has a higher priority. (5) I changed test case textTag-5.23 according to (3). Moreover this test case has been extended for testing all bindings. BTW: Test case text-5.24 has been removed, it was a duplicate of prior textTag-5.23. (6) Complete rework of function MakeStyle(), the "sel" tag now will be handled separately, after all other tags have been processed, this makes it easier to follow the flow. (7) The old implementation has an erroneous resource management with the shared (tied) options of the "sel" tag and the selection options of the widget. This has been replaced with a proper implementation. Unfortunately the new implementation for resource management of shared options is a bit tricky, because the option table does not support shared options. (8). DEF_TEXT_INACTIVE_SELECT_BG_COLOR has been set to NULL for Windows, this should finally fix the issue of this bug report. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | revised_text | tip-466 |
Files: | files | file ages | folders |
SHA1: |
b2f64dc3df575ef3a4f32b8ab24fe56f |
User & Date: | gcramer 2017-05-26 14:53:54 |
References
2017-05-28
| ||
18:19 | Fixed errors of commit [b2f64dc3df] that prevented tests textDisp-2.23, textDisp-5.1 and textDisp-22.9 from passing check-in: 70f50bf6 user: fvogel tags: revised_text, tip-466 | |
15:25 | • Open ticket [cda289a8]: Revised text: text disappears when widget is out of focus plus 4 other changes artifact: 8c942bc6 user: fvogel | |
2017-05-26
| ||
14:54 | • Ticket [cda289a8]: 3 changes artifact: 63ee03df user: gcramer | |
Context
2017-05-27
| ||
07:57 | Bugfix [46d7a4d153]: erroneous reallocation with NULL instead of bitset. check-in: 6892f446 user: gcramer tags: revised_text, tip-466 | |
2017-05-26
| ||
14:53 | Bugfix [cda289a8ea]: The old handling/implementation of the selection options is tohubohu, so I used the opportunity to overwork it: (1) I added the tag options -inactivebackground and -inactiveforegound, and these options are tied to widget options -inactiveselectbackground and -inactiveselectforeground. (2) For symmetry reasons I added the tag options -inactiveselectbackground and -inactiveselectforeground, these options will overrule the options -inactivebackground and -inactivebackgound of the "sel" tag, provided that the actual tag has a higher priority. (3) The manual has been updated with new options. Furthermore section "THE SELECTION" has been refined. (4) In legacy widget tag option -selectbackground is tied to widget option -selectbackground if the tag option -selectbackground is not null, otherwise the widget option is tied to tag option "-background", this is very confusing, and not conform to documentation, this binding has been changed. Now the widget option -selectbackground is tied with tag option "-background" (of the "sel" tag), this is conform to (revised and legacy) documentation, it is a clear behavior, and allows more freedom in configuration. The tag options "-selectbackground" and "-selectforeground" now will overrule the options "-background" and "-foreground" of the "sel" tag, provided that the actual tag has a higher priority. (5) I changed test case textTag-5.23 according to (3). Moreover this test case has been extended for testing all bindings. BTW: Test case text-5.24 has been removed, it was a duplicate of prior textTag-5.23. (6) Complete rework of function MakeStyle(), the "sel" tag now will be handled separately, after all other tags have been processed, this makes it easier to follow the flow. (7) The old implementation has an erroneous resource management with the shared (tied) options of the "sel" tag and the selection options of the widget. This has been replaced with a proper implementation. Unfortunately the new implementation for resource management of shared options is a bit tricky, because the option table does not support shared options. (8). DEF_TEXT_INACTIVE_SELECT_BG_COLOR has been set to NULL for Windows, this should finally fix the issue of this bug report. check-in: b2f64dc3 user: gcramer tags: revised_text, tip-466 | |
2017-05-25
| ||
09:38 | "#ifdef MAC_OSX_TK" code replaced, the generic implementation should not contain platform specific code (only debugging code is an exception). check-in: a232ec01 user: gcramer tags: revised_text, tip-466 | |
Changes
Changes to doc/text.n.
︙ | ︙ | |||
895 896 897 898 899 900 901 902 903 904 905 906 907 908 | This tag option overrules the global option \fB\-hyphenrules\fR, this means that the global rules will be applied only to hyphens without tagged rules. .PP For the definition of hyphenation rules see widget option \fB\-hyphenrules\fR. .RE .TP \fB\-indentbackground \fIboolean\fR . If true then the background, set with \fB\-background\fR tag option, will be indented according to the \fB\-lmargin1\fR, and \fB\-lmargin2\fR tag options. This has the (intended) side effect that hovering the margin (left from indented text) will not trigger events. .TP | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | This tag option overrules the global option \fB\-hyphenrules\fR, this means that the global rules will be applied only to hyphens without tagged rules. .PP For the definition of hyphenation rules see widget option \fB\-hyphenrules\fR. .RE .TP \fB\-inactivebackground \fIcolor\fR . Color specifies the background color to use for characters associated with the tag, when the window does not have the focus. It may have any of the forms accepted by Tk_GetColor. If specified then it will overrule the \fB\-background\fR option of the \fBsel\fR tag, provided that the actual tag has a higher priority. .TP \fB\-inactiveforeground \fIcolor\fR . Color specifies the color to use when drawing text and other foreground information such as underlines, when the window does not have the focus. It may have any of the forms accepted by Tk_GetColor. If specified then it will overrule the \fB\-foreground\fR option of the \fBsel\fR tag, provided that the actual tag has a higher priority. .TP \fB\-inactiveselectbackground \fIcolor\fR . \fIColor\fR specifies the background color to use when displaying selected items, when the window does not have the focus. 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\-selectbackground\fR tag option is used. If specified then it will overrule the \fB\-inactivebackground\fR option of the \fBsel\fR tag, provided that the actual tag has a higher priority. .TP \fB\-inactiveselectforeground \fIcolor\fR . \fIColor\fR specifies the foreground color to use when displaying selected items, when the window does not have the focus. 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\-selectforeground\fR tag option is used. If specified then it will overrule the \fB\-inactiveforeground\fR option of the \fBsel\fR tag, provided that the actual tag has a higher priority. .TP \fB\-indentbackground \fIboolean\fR . If true then the background, set with \fB\-background\fR tag option, will be indented according to the \fB\-lmargin1\fR, and \fB\-lmargin2\fR tag options. This has the (intended) side effect that hovering the margin (left from indented text) will not trigger events. .TP |
︙ | ︙ | |||
972 973 974 975 976 977 978 | \fB\-foreground\fR tag option is used. .TP \fB\-overstrikefg \fIcolor\fR . Note that this option is deprecated, option \fB\-overstrikecolor\fR should be used instead. For compatibility reasons this option still will be supported, but may be removed in a future version. | < < < | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | \fB\-foreground\fR tag option is used. .TP \fB\-overstrikefg \fIcolor\fR . Note that this option is deprecated, option \fB\-overstrikecolor\fR should be used instead. For compatibility reasons this option still will be supported, but may be removed in a future version. See equivalent tag option \fB\-overstrikecolor\fR for a description. .TP \fB\-relief \fIrelief\fR . \fIRelief\fR specifies the relief style to use for drawing the border, in any of the forms accepted by \fBTk_GetRelief\fR. This option is used in conjunction with the \fB\-borderwidth\fR option to enable to the desired border appearance. |
︙ | ︙ | |||
1071 1072 1073 1074 1075 1076 1077 | \fB\-foreground\fR tag option is used. .TP \fB\-underlinefg \fIcolor\fR . Note that this option is deprecated, option \fB\-underlinecolor\fR should be used instead. For compatibility reasons this option still will be supported, but may be removed in a future version. | < < < | | | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | \fB\-foreground\fR tag option is used. .TP \fB\-underlinefg \fIcolor\fR . Note that this option is deprecated, option \fB\-underlinecolor\fR should be used instead. For compatibility reasons this option still will be supported, but may be removed in a future version. See equivalent tag option \fB\-underlinecolor\fR for a description. .TP \fB\-undo \fIboolean\fR . Specifies whether adding/removing this tag to/from text will be undone with \fBundo\fR operation. If this flag is \fIfalse\fR, then changes of tag associations will not be undone for this tag. The default is \fItrue\fR, except for the special selection flag \fBsel\fR, the default for this tag is \fIfalse\fR. .TP \fB\-wrap \fImode\fR . \fIMode\fR specifies how to handle lines that are wider than the text's window. This option only applies to a display line if it applies to the first non-elided character on that display line. It has the same legal values as the \fB\-wrap\fR option for the text widget: \fBnone\fR, \fBchar\fR, \fBword\fR, or \fBcodepoint\fR. If this tag option is specified, it overrides the \fB\-wrap\fR option for the text widget. .PP If a character has several tags associated with it, and if their display options conflict, then the options of the highest priority tag are used. If a particular display option has not been specified for a particular tag, or if it is specified as an empty string, then that option will never be used; the next-highest-priority tag's option will used instead. If no tag specifies a particular display option, then the default style for the widget will be used. |
︙ | ︙ | |||
1707 1708 1709 1710 1711 1712 1713 | Whenever the \fBsel\fR tag range changes a virtual event \fB<<Selection>>\fR is generated. .PP The \fBsel\fR tag is automatically defined when a text widget is created, and it may not be deleted with the .QW "\fIpathName \fBtag delete\fR" widget command. Furthermore, the \fB\-selectbackground\fR, | | > > | > | | < < | | | | | > > > > > > > > > > > > > > > > > | 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 | Whenever the \fBsel\fR tag range changes a virtual event \fB<<Selection>>\fR is generated. .PP The \fBsel\fR tag is automatically defined when a text widget is created, and it may not be deleted with the .QW "\fIpathName \fBtag delete\fR" widget command. Furthermore, the \fB\-selectbackground\fR, \fB\-selectborderwidth\fR, \fB\-selectforeground\fR, \fB\-inactiveselectbackground\fR, \fB\-inactiveselectforeground\fR, and \fB\-selectborderwidth\fR options for the text widget are tied to the \fB\-background\fR, \fB\-borderwidth\fR, \fB\-foreground\fR, \fB\-inactiveselectbackground\fR, \fB\-inactiveselectforeground\fR, and \fB\-borderwidth\fR options for the \fBsel\fR tag: changes in either will automatically be reflected in the other. This allows programmatic control over the visualization of the \fBsel\fR tag for foreground and background windows, or to have \fBsel\fR not shown at all for background windows. Each peer text widget has its own \fBsel\fR tag which can be separately configured and set. .PP The \fBsel\fR tag is overruling all other tags, except if a tag with higher priority has explicitly defined the selection attributes (\fB\-selectbackground\fR and \fB\-selectforeground\fR if the window is active; \fB\-inactiveselectbackground\fR and \fB\-inactiveselectforeground\fR if the window is inactive). .PP Note the specific behavior if \fB\-inactiveselectbackground\fR is not defined (empty): if the window does not have the focus, then the selection attributes of the text widget and all the attributes of the \fBsel\fR tag will not be regarded; this means that in general no selection will be shown, this is the default behavior on Windows. .PP Note the specific behavior on Mac: if the window does not have the focus, and does not have state \fBnormal\fR (see widget option \fB\-state\fR), then the selection attributes of the text widget and all the attributes of the \fBsel\fR tag will not be regarded; this means that per default no selection will be shown. .SH "THE INSERTION CURSOR" .PP The mark named \fBinsert\fR has special significance in text widgets. It is defined automatically when a text widget is created and it may not be unset with the .QW "\fIpathName \fBmark unset\fR" widget command. The \fBinsert\fR mark represents the position of the insertion |
︙ | ︙ |
Changes to generic/tkText.c.
︙ | ︙ | |||
286 287 288 289 290 291 292 | {TK_OPTION_STRING, "-hyphenrules", NULL, NULL, NULL, Tk_Offset(TkText, hyphenRulesPtr), -1, TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_COLOR, "-hyphencolor", "hyphenColor", "HyphenColor", DEF_TEXT_FG, -1, Tk_Offset(TkText, hyphenColor), TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_REDRAW}, {TK_OPTION_BOOLEAN, "-hyphens", "hyphens", "Hyphens", "0", -1, Tk_Offset(TkText, useHyphenSupport), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_BORDER, "-inactiveselectbackground", "inactiveSelectBackground", "Foreground", | | | | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | {TK_OPTION_STRING, "-hyphenrules", NULL, NULL, NULL, Tk_Offset(TkText, hyphenRulesPtr), -1, TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_COLOR, "-hyphencolor", "hyphenColor", "HyphenColor", DEF_TEXT_FG, -1, Tk_Offset(TkText, hyphenColor), TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_REDRAW}, {TK_OPTION_BOOLEAN, "-hyphens", "hyphens", "Hyphens", "0", -1, Tk_Offset(TkText, useHyphenSupport), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_BORDER, "-inactiveselectbackground", "inactiveSelectBackground", "Foreground", DEF_TEXT_INACTIVE_SELECT_BG_COLOR, -1, Tk_Offset(TkText, selAttrs.inactiveBorder), TK_OPTION_NULL_OK, DEF_TEXT_SELECT_MONO, 0}, {TK_OPTION_COLOR, "-inactiveselectforeground", "inactiveSelectForeground", "Background", DEF_TEXT_INACTIVE_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selAttrs.inactiveFgColor), TK_OPTION_NULL_OK, DEF_TEXT_SELECT_FG_MONO, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_TEXT_INSERT_BG, -1, Tk_Offset(TkText, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, -1, Tk_Offset(TkText, insertBorderWidth), 0, (ClientData) DEF_TEXT_INSERT_BD_MONO, 0}, {TK_OPTION_COLOR, "-insertforeground", "insertForeground", "InsertForeground", DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, insertFgColor), 0, 0, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", DEF_TEXT_INSERT_OFF_TIME, -1, Tk_Offset(TkText, insertOffTime), 0, 0, 0}, {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", DEF_TEXT_INSERT_ON_TIME, -1, Tk_Offset(TkText, insertOnTime), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-insertunfocussed", "insertUnfocussed", "InsertUnfocussed", DEF_TEXT_INSERT_UNFOCUSSED, -1, Tk_Offset(TkText, insertUnfocussed), |
︙ | ︙ | |||
327 328 329 330 331 332 333 | {TK_OPTION_PIXELS, "-pady", "padY", "Pad", DEF_TEXT_PADY, -1, Tk_Offset(TkText, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_TEXT_RELIEF, -1, Tk_Offset(TkText, relief), 0, 0, 0}, {TK_OPTION_INT, "-responsiveness", "responsiveness", "Responsiveness", "50", -1, Tk_Offset(TkText, responsiveness), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", | | > | | | | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | {TK_OPTION_PIXELS, "-pady", "padY", "Pad", DEF_TEXT_PADY, -1, Tk_Offset(TkText, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_TEXT_RELIEF, -1, Tk_Offset(TkText, relief), 0, 0, 0}, {TK_OPTION_INT, "-responsiveness", "responsiveness", "Responsiveness", "50", -1, Tk_Offset(TkText, responsiveness), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", DEF_TEXT_SELECT_COLOR, -1, Tk_Offset(TkText, selAttrs.border), 0, DEF_TEXT_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_TEXT_SELECT_BD_COLOR, Tk_Offset(TkText, selAttrs.borderWidthPtr), Tk_Offset(TkText, selAttrs.borderWidth), TK_OPTION_NULL_OK, DEF_TEXT_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_TEXT_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selAttrs.fgColor), TK_OPTION_NULL_OK, DEF_TEXT_SELECT_FG_MONO, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_TEXT_SET_GRID, -1, Tk_Offset(TkText, setGrid), 0, 0, 0}, {TK_OPTION_BOOLEAN, "-showendofline", "showEndOfLine", "ShowEndOfLine", "0", -1, Tk_Offset(TkText, showEndOfLine), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_BOOLEAN, "-showendoftext", "showEndOfText", "ShowEndOfText", "0", -1, Tk_Offset(TkText, showEndOfText), 0, 0, TK_TEXT_LINE_GEOMETRY}, |
︙ | ︙ | |||
709 710 711 712 713 714 715 | /* * Some helpers. */ static void WarnAboutDeprecatedStartLineOption() { static bool printWarning = true; if (printWarning) { | > | | 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | /* * Some helpers. */ static void WarnAboutDeprecatedStartLineOption() { static bool printWarning = true; if (printWarning) { fprintf(stderr, "tk::text: Option \"-startline\" is deprecated, " "please use option \"-startindex\".\n"); printWarning = false; } } static void WarnAboutDeprecatedEndLineOption() { static bool printWarning = true; if (printWarning) { fprintf(stderr, "tk::text: Option \"-endline\" is deprecated, " |
︙ | ︙ | |||
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | textPtr->cursor = None; textPtr->charWidth = 1; textPtr->spaceWidth = 1; textPtr->lineHeight = -1; textPtr->prevWidth = Tk_Width(newWin); textPtr->prevHeight = Tk_Height(newWin); textPtr->useHyphenSupport = -1; textPtr->prevSyncState = -1; textPtr->lastLineY = TK_TEXT_NEARBY_IS_UNDETERMINED; TkTextTagSetIncrRefCount(textPtr->curTagInfoPtr = sharedTextPtr->emptyTagInfoPtr); /* * This will add refCounts to textPtr. */ | > | 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | textPtr->cursor = None; textPtr->charWidth = 1; textPtr->spaceWidth = 1; textPtr->lineHeight = -1; textPtr->prevWidth = Tk_Width(newWin); textPtr->prevHeight = Tk_Height(newWin); textPtr->useHyphenSupport = -1; textPtr->hyphenRules = TK_TEXT_HYPHEN_MASK; textPtr->prevSyncState = -1; textPtr->lastLineY = TK_TEXT_NEARBY_IS_UNDETERMINED; TkTextTagSetIncrRefCount(textPtr->curTagInfoPtr = sharedTextPtr->emptyTagInfoPtr); /* * This will add refCounts to textPtr. */ |
︙ | ︙ | |||
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 | TkTextBindProc, textPtr); Tk_CreateSelHandler(textPtr->tkwin, XA_PRIMARY, XA_STRING, TextFetchSelection, textPtr, XA_STRING); if (Tk_InitOptions(interp, (char *) textPtr, optionTable, textPtr->tkwin) != TCL_OK) { Tk_DestroyWindow(textPtr->tkwin); return TCL_ERROR; } if (TkConfigureText(interp, textPtr, objc - 2, objv + 2) != TCL_OK) { Tk_DestroyWindow(textPtr->tkwin); return TCL_ERROR; } Tcl_SetObjResult(interp, TkNewWindowObj(textPtr->tkwin)); return TCL_OK; | > > > | 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | TkTextBindProc, textPtr); Tk_CreateSelHandler(textPtr->tkwin, XA_PRIMARY, XA_STRING, TextFetchSelection, textPtr, XA_STRING); if (Tk_InitOptions(interp, (char *) textPtr, optionTable, textPtr->tkwin) != TCL_OK) { Tk_DestroyWindow(textPtr->tkwin); return TCL_ERROR; } textPtr->textConfigAttrs = textPtr->selAttrs; textPtr->selTagPtr->attrs = textPtr->selAttrs; if (TkConfigureText(interp, textPtr, objc - 2, objv + 2) != TCL_OK) { Tk_DestroyWindow(textPtr->tkwin); return TCL_ERROR; } Tcl_SetObjResult(interp, TkNewWindowObj(textPtr->tkwin)); return TCL_OK; |
︙ | ︙ | |||
3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 | } obj = endIndexObj; } } myObjv[i] = obj; } rc = Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, objc, myObjv, textPtr->tkwin, &savedOptions, &mask); if (rc != TCL_OK) { if (startLineObj && startIndexObj) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "cannot use both, -startindex, and deprecated -startline", -1)); | > | 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 | } obj = endIndexObj; } } myObjv[i] = obj; } textPtr->selAttrs = textPtr->textConfigAttrs; rc = Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, objc, myObjv, textPtr->tkwin, &savedOptions, &mask); if (rc != TCL_OK) { if (startLineObj && startIndexObj) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "cannot use both, -startindex, and deprecated -startline", -1)); |
︙ | ︙ | |||
3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 | } (textPtr->startMarker = sharedTextPtr->startMarker)->refCount += 1; } } #else /* if !SUPPORT_DEPRECATED_STARTLINE_ENDLINE */ if (Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, objc, objv, textPtr->tkwin, &savedOptions, &mask) != TCL_OK) { tkTextDebug = oldTextDebug; return TCL_ERROR; } #endif /* SUPPORT_DEPRECATED_STARTLINE_ENDLINE */ if (sharedTextPtr->steadyMarks != textPtr->steadyMarks) { | > > | 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 | } (textPtr->startMarker = sharedTextPtr->startMarker)->refCount += 1; } } #else /* if !SUPPORT_DEPRECATED_STARTLINE_ENDLINE */ textPtr->selAttrs = textPtr->textConfigAttrs; if (Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, objc, objv, textPtr->tkwin, &savedOptions, &mask) != TCL_OK) { textPtr->selAttrs = textPtr->selTagPtr->attrs; tkTextDebug = oldTextDebug; return TCL_ERROR; } #endif /* SUPPORT_DEPRECATED_STARTLINE_ENDLINE */ if (sharedTextPtr->steadyMarks != textPtr->steadyMarks) { |
︙ | ︙ | |||
4069 4070 4071 4072 4073 4074 4075 | */ if (textPtr->hyphenRulesPtr) { if (TkTextParseHyphenRules(textPtr, textPtr->hyphenRulesPtr, &textPtr->hyphenRules) != TCL_OK) { goto error; } } else { | | | 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 | */ if (textPtr->hyphenRulesPtr) { if (TkTextParseHyphenRules(textPtr, textPtr->hyphenRulesPtr, &textPtr->hyphenRules) != TCL_OK) { goto error; } } else { textPtr->hyphenRules = TK_TEXT_HYPHEN_MASK; } if (oldHyphenRules != textPtr->hyphenRules && textPtr->hyphenate) { mask |= TK_TEXT_LINE_GEOMETRY; } /* * Parse tab stops. |
︙ | ︙ | |||
4259 4260 4261 4262 4263 4264 4265 | textPtr->currentMarkPtr = TkTextSetMark(textPtr, "current", &end); } } else { currentEpoch = TkBTreeEpoch(tree); } /* | | < < < < < < < < < < < > | < < | | < > > | | | > > | | | < | > > | 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 | textPtr->currentMarkPtr = TkTextSetMark(textPtr, "current", &end); } } else { currentEpoch = TkBTreeEpoch(tree); } /* * Don't allow negative values for specific attributes. */ textPtr->spacing1 = MAX(textPtr->spacing1, 0); textPtr->spacing2 = MAX(textPtr->spacing2, 0); textPtr->spacing3 = MAX(textPtr->spacing3, 0); textPtr->highlightWidth = MAX(textPtr->highlightWidth, 0); textPtr->borderWidth = MAX(textPtr->borderWidth, 0); textPtr->insertWidth = MAX(textPtr->insertWidth, 0); textPtr->syncTime = MAX(0, textPtr->syncTime); textPtr->selAttrs.borderWidth = MAX(textPtr->selAttrs.borderWidth, 0); /* * Make sure that configuration options are properly mirrored between the * widget record and the "sel" tags. */ if (textPtr->selAttrs.border != textPtr->textConfigAttrs.border) { textPtr->selTagPtr->attrs.border = textPtr->selAttrs.border; } if (textPtr->selAttrs.inactiveBorder != textPtr->textConfigAttrs.inactiveBorder) { textPtr->selTagPtr->attrs.inactiveBorder = textPtr->selAttrs.inactiveBorder; } if (textPtr->selAttrs.fgColor != textPtr->textConfigAttrs.fgColor) { textPtr->selTagPtr->attrs.fgColor = textPtr->selAttrs.fgColor; } if (textPtr->selAttrs.inactiveFgColor != textPtr->textConfigAttrs.inactiveFgColor) { textPtr->selTagPtr->attrs.inactiveFgColor = textPtr->selAttrs.inactiveFgColor; } if (textPtr->selAttrs.borderWidthPtr != textPtr->textConfigAttrs.borderWidthPtr) { textPtr->selTagPtr->attrs.borderWidthPtr = textPtr->selAttrs.borderWidthPtr; textPtr->selTagPtr->attrs.borderWidth = textPtr->selAttrs.borderWidth; } textPtr->textConfigAttrs = textPtr->selAttrs; textPtr->selAttrs = textPtr->selTagPtr->attrs; TkTextUpdateTagDisplayFlags(textPtr->selTagPtr); TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, false); /* * Claim the selection if we've suddenly started exporting it and there * are tagged characters. */ |
︙ | ︙ | |||
4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 | tkTextDebug = oldTextDebug; TK_BTREE_DEBUG(TkBTreeCheck(sharedTextPtr->tree)); return TCL_OK; error: Tk_RestoreSavedOptions(&savedOptions); tkTextDebug = oldTextDebug; return TCL_ERROR; } /* *--------------------------------------------------------------------------- * | > | 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 | tkTextDebug = oldTextDebug; TK_BTREE_DEBUG(TkBTreeCheck(sharedTextPtr->tree)); return TCL_OK; error: Tk_RestoreSavedOptions(&savedOptions); textPtr->selAttrs = textPtr->selTagPtr->attrs; tkTextDebug = oldTextDebug; return TCL_ERROR; } /* *--------------------------------------------------------------------------- * |
︙ | ︙ | |||
4578 4579 4580 4581 4582 4583 4584 | textPtr->prevHeight = Tk_Height(textPtr->tkwin); } static void ProcessDestroyNotify( TkText *textPtr) { | < < < < < < < < < < < < > > | 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 | textPtr->prevHeight = Tk_Height(textPtr->tkwin); } static void ProcessDestroyNotify( TkText *textPtr) { if (textPtr->setGrid) { Tk_UnsetGrid(textPtr->tkwin); textPtr->setGrid = false; } if (!(textPtr->flags & OPTIONS_FREED)) { /* Restore the original attributes. */ textPtr->selAttrs = textPtr->textConfigAttrs; Tk_FreeConfigOptions((char *) textPtr, textPtr->optionTable, textPtr->tkwin); textPtr->flags |= OPTIONS_FREED; } textPtr->flags |= DESTROYED; /* * Call 'DestroyTest' to handle the deletion for us. The actual |
︙ | ︙ | |||
4639 4640 4641 4642 4643 4644 4645 | textPtr->insertBlinkHandler = Tcl_CreateTimerHandler(textPtr->insertOnTime, TextBlinkProc, textPtr); } TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index); TkTextIndexForwChars(textPtr, &index, 1, &index2, COUNT_INDICES); TkTextChanged(NULL, textPtr, &index, &index2); } | | | | 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 | textPtr->insertBlinkHandler = Tcl_CreateTimerHandler(textPtr->insertOnTime, TextBlinkProc, textPtr); } TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index); TkTextIndexForwChars(textPtr, &index, 1, &index2, COUNT_INDICES); TkTextChanged(NULL, textPtr, &index, &index2); } if (textPtr->selAttrs.inactiveBorder != textPtr->selAttrs.border || textPtr->selAttrs.inactiveFgColor != textPtr->selAttrs.fgColor) { TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, false); } if (textPtr->highlightWidth > 0) { TkTextRedrawRegion(textPtr, 0, 0, textPtr->highlightWidth, textPtr->highlightWidth); } } } |
︙ | ︙ | |||
8550 8551 8552 8553 8554 8555 8556 | TkTextTag **tags = textPtr->sharedTextPtr->tagLookup; unsigned n = textPtr->sharedTextPtr->numTags; unsigned i; for (i = 0; i < n; ++i) { TkTextTag *tagPtr = tags[i]; | | | | 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 | TkTextTag **tags = textPtr->sharedTextPtr->tagLookup; unsigned n = textPtr->sharedTextPtr->numTags; unsigned i; for (i = 0; i < n; ++i) { TkTextTag *tagPtr = tags[i]; if (tagPtr && ((what & TK_DUMP_INCLUDE_SEL) || !tagPtr->isSelTag)) { TkTextInspectOptions(textPtr, tagPtr, tagPtr->optionTable, opts, flags); Tcl_DStringStartSublist(str); Tcl_DStringAppendElement(str, "configure"); Tcl_DStringAppendElement(str, tagPtr->name); if (Tcl_DStringLength(opts) > 2) { Tcl_DStringAppendElement(str, Tcl_DStringValue(opts)); } Tcl_DStringEndSublist(str); } } } if (what & TK_DUMP_TAG_BINDINGS) { TkTextTag **tags = textPtr->sharedTextPtr->tagLookup; unsigned n = textPtr->sharedTextPtr->numTags; unsigned i; for (i = 0; i < n; ++i) { TkTextTag *tagPtr = tags[i]; if (tagPtr && ((what & TK_DUMP_INCLUDE_SEL) || !tagPtr->isSelTag)) { GetBindings(textPtr, tagPtr->name, sharedTextPtr->tagBindingTable, str); } } } do { TkTextSegment *segPtr = nextPtr; |
︙ | ︙ |
Changes to generic/tkText.h.
︙ | ︙ | |||
790 791 792 793 794 795 796 797 798 799 800 801 802 803 | /* * Some constants for the mouse hovering: */ #define TK_TEXT_NEARBY_IS_UNDETERMINED INT_MAX /* is not yet determined */ #define TK_TEXT_IS_NEARBY INT_MIN /* is on border */ typedef struct TkTextTag { const char *name; /* Name of this tag. This field is actually a pointer to the key * from the entry in 'sharedTextPtr->tagTable', so it needn't be * freed explicitly. For "sel" tags this is just a static string, * so again need not be freed. */ const struct TkSharedText *sharedTextPtr; | > > > > > > > > | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 | /* * Some constants for the mouse hovering: */ #define TK_TEXT_NEARBY_IS_UNDETERMINED INT_MAX /* is not yet determined */ #define TK_TEXT_IS_NEARBY INT_MIN /* is on border */ typedef struct TkTextSharedAttrs { Tk_3DBorder border; /* Used for drawing background. NULL means no value specified here. */ Tk_3DBorder inactiveBorder; /* Used for drawing background. NULL means no value specified here. */ XColor *fgColor; /* Foreground color for text. NULL means no value specified here. */ XColor *inactiveFgColor; /* Foreground color for text. NULL means no value specified here. */ Tcl_Obj *borderWidthPtr; /* Width of 3-D border for background. */ int borderWidth; /* Width of 3-D border for background. */ } TkTextSharedAttrs; typedef struct TkTextTag { const char *name; /* Name of this tag. This field is actually a pointer to the key * from the entry in 'sharedTextPtr->tagTable', so it needn't be * freed explicitly. For "sel" tags this is just a static string, * so again need not be freed. */ const struct TkSharedText *sharedTextPtr; |
︙ | ︙ | |||
812 813 814 815 816 817 818 819 820 821 822 823 824 825 | uint32_t priority; /* Priority of this tag within widget. 0 means lowest priority. * Exactly one tag has each integer value between 0 and numTags-1. */ uint32_t index; /* Unique index for fast tag lookup. It is guaranteed that the index * number is less than 'TkBitSize(sharedTextPtr->usedTags)'.*/ uint32_t tagEpoch; /* Epoch of creation time. */ uint32_t refCount; /* Number of objects referring to us. */ bool isDisabled; /* This tag is disabled? */ /* * Information for tag collection [TkBTreeGetTags, TextInspectCmd, TkTextPickCurrent]. */ struct TkTextTag *nextPtr; /* Will be set by TkBTreeGetTags, TkBTreeClearTags, and TextInsertCmd. */ struct TkTextTag *succPtr; /* Only TextInspectCmd will use this attribute. */ | > | 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | uint32_t priority; /* Priority of this tag within widget. 0 means lowest priority. * Exactly one tag has each integer value between 0 and numTags-1. */ uint32_t index; /* Unique index for fast tag lookup. It is guaranteed that the index * number is less than 'TkBitSize(sharedTextPtr->usedTags)'.*/ uint32_t tagEpoch; /* Epoch of creation time. */ uint32_t refCount; /* Number of objects referring to us. */ bool isDisabled; /* This tag is disabled? */ bool isSelTag; /* This tag is the special "sel" tag? */ /* * Information for tag collection [TkBTreeGetTags, TextInspectCmd, TkTextPickCurrent]. */ struct TkTextTag *nextPtr; /* Will be set by TkBTreeGetTags, TkBTreeClearTags, and TextInsertCmd. */ struct TkTextTag *succPtr; /* Only TextInspectCmd will use this attribute. */ |
︙ | ︙ | |||
846 847 848 849 850 851 852 | * Information for displaying text with this tag. The information belows * acts as an override on information specified by lower-priority tags. * If no value is specified, then the next-lower-priority tag on the text * determins the value. The text widget itself provides defaults if no tag * specifies an override. */ | | | | < | 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | * Information for displaying text with this tag. The information belows * acts as an override on information specified by lower-priority tags. * If no value is specified, then the next-lower-priority tag on the text * determins the value. The text widget itself provides defaults if no tag * specifies an override. */ TkTextSharedAttrs attrs; /* Contains the following attributes: border, inactiveBorder, * fgColor, inactiveFgColor, and borderWidth. These attributes will * be shared with attributes from "sel" tag. */ Tcl_Obj *reliefPtr; /* -relief option object. NULL means option not specified. */ int relief; /* 3-D relief for background. */ Pixmap bgStipple; /* Stipple bitmap for background. None means no value specified here. */ char *indentBgString; /* Background will be indented accordingly to the -lmargin1, and * -lmargin2 options. */ bool indentBg; /* Background will be indented accordingly to the -lmargin1, and * -lmargin2 options. */ Tk_Font tkfont; /* Font for displaying text. NULL means no value specified here. */ Pixmap fgStipple; /* Stipple bitmap for text and other foreground stuff. None means * no value specified here.*/ char *justifyString; /* -justify option string (malloc-ed). NULL means option not * specified. */ TkTextJustify justify; /* How to justify text: TK_TEXT_JUSTIFY_LEFT, TK_TEXT_JUSTIFY_RIGHT, * TK_TEXT_JUSTIFY_CENTER, or TK_TEXT_JUSTIFY_FULL. Only valid if |
︙ | ︙ | |||
894 895 896 897 898 899 900 901 902 903 904 905 906 907 | * 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. */ 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 text line. Only valid * if spacing1String is non-NULL. */ char *spacing2String; /* -spacing2 option string (malloc-ed). NULL means option not * specified. */ int spacing2; /* Extra spacing between display lines for the same text line. Only | > > > > > | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | * 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. */ XColor *selFgColor; /* Foreground color for selected text. NULL means no value specified * here. */ Tk_3DBorder inactiveSelBorder; /* Used for drawing background for inactive selected text. * NULL means no value specified here. */ XColor *inactiveSelFgColor; /* Foreground color for inactive 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 text line. Only valid * if spacing1String is non-NULL. */ char *spacing2String; /* -spacing2 option string (malloc-ed). NULL means option not * specified. */ int spacing2; /* Extra spacing between display lines for the same text line. Only |
︙ | ︙ | |||
1348 1349 1350 1351 1352 1353 1354 1355 1356 | bool syncTime; /* Synchronization timeout, used for line metric calculation, default is * 200. */ /* * Information related to selection. */ TkTextTag *selTagPtr; /* Pointer to "sel" tag. Used to tell when a new selection * has been made. */ | > > > > > > > < < < < < < < < < < < < < | | | 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 | bool syncTime; /* Synchronization timeout, used for line metric calculation, default is * 200. */ /* * Information related to selection. */ TkTextSharedAttrs selAttrs; /* Contains the following attributes: border, inactiveBorder, * fgColor, inactiveFgColor, and borderWidth. These attributes will * be shared with attributes from "sel" tag. */ TkTextSharedAttrs textConfigAttrs; /* Contains the original attributes of the text widget. */ TkTextSharedAttrs selTagConfigAttrs; /* Contains the original attributes of the "sel" tag. */ TkTextTag *selTagPtr; /* Pointer to "sel" tag. Used to tell when a new selection * has been made. */ bool exportSelection; /* Non-zero means tie "sel" tag to X selection. */ TkTextSearch selSearch; /* Used during multi-pass selection retrievals. */ TkTextIndex selIndex; /* Used during multi-pass selection retrievals. This index * identifies the next character to be returned from the * selection. */ /* * Information related to insertion cursor: */ TkTextSegment *insertMarkPtr; /* Points to segment for "insert" mark. */ Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion cursor. */ XColor *insertFgColor; /* Foreground color for text behind a block cursor. * NULL means no value specified here. */ bool showInsertFgColor; /* Flag whether insertFgColor is relevant. */ int insertWidth; /* Total width of insert cursor. */ int insertBorderWidth; /* Width of 3-D border around insert cursor */ TkTextInsertUnfocussed insertUnfocussed; /* How to display the insert cursor when the * text widget does not have the focus. */ int insertOnTime; /* Number of milliseconds cursor should spend * in "on" state for each blink. */ |
︙ | ︙ |
Changes to generic/tkTextBTree.c.
︙ | ︙ | |||
12550 12551 12552 12553 12554 12555 12556 | assert(tagPtr); assert(!tagPtr->isDisabled); if (!textPtr || !tagPtr->textPtr || tagPtr->textPtr == textPtr) { tagPtr->epoch = 0; if (flags) { | | | 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 | assert(tagPtr); assert(!tagPtr->isDisabled); if (!textPtr || !tagPtr->textPtr || tagPtr->textPtr == textPtr) { tagPtr->epoch = 0; if (flags) { if (textPtr && tagPtr->isSelTag && textPtr == tagPtr->textPtr) { *flags |= TK_TEXT_IS_SELECTED; } if (tagPtr->elideString && (int) tagPtr->priority > highestPriority) { if (tagPtr->elide) { *flags |= TK_TEXT_IS_ELIDED; } else { *flags &= ~TK_TEXT_IS_ELIDED; |
︙ | ︙ |
Changes to generic/tkTextDisp.c.
︙ | ︙ | |||
1542 1543 1544 1545 1546 1547 1548 | SetupEolSegment(textPtr, dInfoPtr); SetupEotSegment(textPtr, dInfoPtr); if (textPtr->state == TK_TEXT_STATE_NORMAL && textPtr->blockCursorType && textPtr->showInsertFgColor) { XGCValues gcValues; | | | 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | SetupEolSegment(textPtr, dInfoPtr); SetupEotSegment(textPtr, dInfoPtr); if (textPtr->state == TK_TEXT_STATE_NORMAL && textPtr->blockCursorType && textPtr->showInsertFgColor) { XGCValues gcValues; gcValues.foreground = textPtr->insertFgColor->pixel; dInfoPtr->insertFgGC = Tk_GetGC(textPtr->tkwin, GCForeground, &gcValues); } /* * Note: Setup of defaultStyle must be postponed. */ |
︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 | * corresponds to *sValuePtr. * * Side effects: * A new entry may be created in the style table for the widget. * *---------------------------------------------------------------------- */ static TextStyle * MakeStyle( TkText *textPtr, TkTextTag *tagPtr, bool containsSelection) { StyleValues styleValues; TextStyle *stylePtr; Tcl_HashEntry *hPtr; XGCValues gcValues; unsigned long mask; bool isNew; /* * Find out what tags are present for the character, then compute a * StyleValues structure corresponding to those tags (scan through all of * the tags, saving information for the highest-priority tag). */ memset(&styleValues, 0, sizeof(StyleValues)); styleValues.relief = TK_RELIEF_FLAT; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > < < | > > > | | | > > | < < | | | < < < < < < < < < < < < < < < < < < | < < < < | < | < | > > | > > | < > > > | > | | | | < < < < < | < < < < < < < < < < < < < < < < | | < < | | | < < < < < < < < < < < | | | < < | < < | < < | < | < < < | < | | | < < | < < < < < < | | < < | > | < > | | | | < < > | < | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 | * corresponds to *sValuePtr. * * Side effects: * A new entry may be created in the style table for the widget. * *---------------------------------------------------------------------- */ static int FillStyle( const TkTextTag *tagPtr, StyleValues *stylePtr, bool haveFocus, bool containsSelection) { int selBorderPrio = -1; Tk_3DBorder border = tagPtr->attrs.border; XColor *fgColor = tagPtr->attrs.fgColor; if (!haveFocus) { if (tagPtr->attrs.inactiveBorder) { border = tagPtr->attrs.inactiveBorder; } if (tagPtr->attrs.inactiveFgColor) { fgColor = tagPtr->attrs.inactiveFgColor; } } if (containsSelection) { if (tagPtr->selBorder) { border = tagPtr->selBorder; if (haveFocus) { selBorderPrio = tagPtr->priority; } } if (tagPtr->selFgColor) { fgColor = tagPtr->selFgColor; } if (!haveFocus) { if (tagPtr->inactiveSelBorder) { border = tagPtr->inactiveSelBorder; selBorderPrio = tagPtr->priority; } if (tagPtr->inactiveSelFgColor) { fgColor = tagPtr->inactiveSelFgColor; } } } if (border) { stylePtr->border = border; } if (fgColor != None) { stylePtr->fgColor = fgColor; } if (tagPtr->reliefPtr) { stylePtr->relief = tagPtr->relief; } if (tagPtr->bgStipple != None) { stylePtr->bgStipple = tagPtr->bgStipple; } if (tagPtr->indentBgString != None) { stylePtr->indentBg = tagPtr->indentBg; } if (tagPtr->tkfont != None) { stylePtr->tkfont = tagPtr->tkfont; } if (tagPtr->fgStipple != None) { stylePtr->fgStipple = tagPtr->fgStipple; } if (tagPtr->justifyString) { stylePtr->justify = tagPtr->justify; } if (tagPtr->lMargin1String) { stylePtr->lMargin1 = tagPtr->lMargin1; } if (tagPtr->lMargin2String) { stylePtr->lMargin2 = tagPtr->lMargin2; } if (tagPtr->lMarginColor) { stylePtr->lMarginColor = tagPtr->lMarginColor; } if (tagPtr->offsetString) { stylePtr->offset = tagPtr->offset; } if (tagPtr->rMarginString) { stylePtr->rMargin = tagPtr->rMargin; } if (tagPtr->rMarginColor) { stylePtr->rMarginColor = tagPtr->rMarginColor; } if (tagPtr->spacing1String) { stylePtr->spacing1 = tagPtr->spacing1; } if (tagPtr->spacing2String) { stylePtr->spacing2 = tagPtr->spacing2; } if (tagPtr->spacing3String) { stylePtr->spacing3 = tagPtr->spacing3; } if (tagPtr->tabStringPtr) { stylePtr->tabArrayPtr = tagPtr->tabArrayPtr; } if (tagPtr->eolColor) { stylePtr->eolColor = tagPtr->eolColor; } if (tagPtr->hyphenColor) { stylePtr->hyphenColor = tagPtr->hyphenColor; } if (tagPtr->elideString) { stylePtr->elide = tagPtr->elide; } if (tagPtr->langPtr) { stylePtr->lang = tagPtr->lang; } if (tagPtr->hyphenRulesPtr) { stylePtr->hyphenRules = tagPtr->hyphenRules; } if (tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE) { stylePtr->tabStyle = tagPtr->tabStyle; } if (tagPtr->wrapMode != TEXT_WRAPMODE_NULL) { stylePtr->wrapMode = tagPtr->wrapMode; } if (tagPtr->attrs.borderWidthPtr && Tcl_GetString(tagPtr->attrs.borderWidthPtr)[0] != '\0') { stylePtr->borderWidth = tagPtr->attrs.borderWidth; } if (tagPtr->overstrikeString) { stylePtr->overstrike = tagPtr->overstrike; if (tagPtr->overstrikeColor != None) { stylePtr->overstrikeColor = tagPtr->overstrikeColor; } else if (tagPtr->attrs.fgColor != None) { stylePtr->overstrikeColor = tagPtr->attrs.fgColor; } } if (tagPtr->underlineString) { stylePtr->underline = tagPtr->underline; if (tagPtr->underlineColor != None) { stylePtr->underlineColor = tagPtr->underlineColor; } else if (tagPtr->attrs.fgColor != None) { stylePtr->underlineColor = tagPtr->attrs.fgColor; } } return selBorderPrio; } static TextStyle * MakeStyle( TkText *textPtr, TkTextTag *tagPtr, bool containsSelection) { StyleValues styleValues; TextStyle *stylePtr; Tcl_HashEntry *hPtr; XGCValues gcValues; unsigned long mask; int borderPrio; bool haveFocus; bool isNew; /* * Find out what tags are present for the character, then compute a * StyleValues structure corresponding to those tags (scan through all of * the tags, saving information for the highest-priority tag). */ memset(&styleValues, 0, sizeof(StyleValues)); styleValues.relief = TK_RELIEF_FLAT; styleValues.fgColor = None; styleValues.underlineColor = textPtr->fgColor; styleValues.overstrikeColor = textPtr->fgColor; styleValues.eolColor = textPtr->eolColor; styleValues.eotColor = textPtr->eotColor ? textPtr->eotColor : textPtr->eolColor; styleValues.hyphenColor = textPtr->hyphenColor; styleValues.tkfont = textPtr->tkfont; styleValues.justify = textPtr->justify; styleValues.spacing1 = textPtr->spacing1; styleValues.spacing2 = textPtr->spacing2; styleValues.spacing3 = textPtr->spacing3; styleValues.tabArrayPtr = textPtr->tabArrayPtr; styleValues.tabStyle = textPtr->tabStyle; styleValues.wrapMode = textPtr->wrapMode; styleValues.lang = textPtr->lang; styleValues.hyphenRules = textPtr->hyphenRules; haveFocus = !!(textPtr->flags & HAVE_FOCUS); borderPrio = -1; for ( ; tagPtr; tagPtr = tagPtr->nextPtr) { if (!tagPtr->isSelTag) { borderPrio = MAX(borderPrio, FillStyle(tagPtr, &styleValues, haveFocus, containsSelection)); } } /* * Setup attributes in case of selected text. */ if (containsSelection) { TkTextTag *tagPtr = textPtr->selTagPtr; if ((int) tagPtr->priority > borderPrio && (haveFocus /* * If this is the selection tag, and selAttrs.inactiveBorder is NULL * (the default on Windows), then we need to skip it if we don't have * the focus. */ || (textPtr->selAttrs.inactiveBorder /* * Don't show inactive selection in readonly widgets. */ && !(textPtr->state != TK_TEXT_STATE_NORMAL && *DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED == '1')))) { borderPrio = FillStyle(tagPtr, &styleValues, haveFocus, containsSelection); if (borderPrio == -1) { if (textPtr->selAttrs.border) { styleValues.border = textPtr->selAttrs.border; } if (textPtr->selAttrs.fgColor) { styleValues.fgColor = textPtr->selAttrs.fgColor; } if (!haveFocus) { if (textPtr->selAttrs.inactiveBorder) { styleValues.border = textPtr->selAttrs.inactiveBorder; } if (textPtr->selAttrs.inactiveFgColor) { styleValues.fgColor = textPtr->selAttrs.inactiveFgColor; } } } if (!styleValues.fgColor) { styleValues.fgColor = textPtr->selAttrs.fgColor; if (!haveFocus && textPtr->selAttrs.inactiveFgColor) { styleValues.fgColor = textPtr->selAttrs.inactiveFgColor; } } } } /* * Setup with fallback values if needed. */ if (styleValues.fgColor == None) { styleValues.fgColor = textPtr->fgColor; } if (styleValues.relief != TK_RELIEF_FLAT && !styleValues.border) { styleValues.border = textPtr->border; } /* * Use an existing style if there's one around that matches. */ hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable, (char *) &styleValues, (int *) &isNew); |
︙ | ︙ | |||
9209 9210 9211 9212 9213 9214 9215 | if (dInfoPtr->insertFgGC != None) { Tk_FreeGC(textPtr->display, dInfoPtr->insertFgGC); dInfoPtr->insertFgGC = None; } if (textPtr->state == TK_TEXT_STATE_NORMAL && textPtr->blockCursorType && textPtr->showInsertFgColor) { | | | 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 | if (dInfoPtr->insertFgGC != None) { Tk_FreeGC(textPtr->display, dInfoPtr->insertFgGC); dInfoPtr->insertFgGC = None; } if (textPtr->state == TK_TEXT_STATE_NORMAL && textPtr->blockCursorType && textPtr->showInsertFgColor) { gcValues.foreground = textPtr->insertFgColor->pixel; dInfoPtr->insertFgGC = Tk_GetGC(textPtr->tkwin, GCForeground, &gcValues); } maxX = MAX(Tk_Width(textPtr->tkwin) - dInfoPtr->x, dInfoPtr->x + 1); firstLineNo = TkBTreeLinesTo(sharedTextPtr->tree, NULL, TkBTreeGetStartLine(textPtr), NULL); lastLineNo = TkBTreeLinesTo(sharedTextPtr->tree, NULL, TkBTreeGetLastLine(textPtr), NULL); recomputeGeometry = (maxX != dInfoPtr->maxX) || (mask & TK_TEXT_LINE_GEOMETRY); |
︙ | ︙ |
Changes to generic/tkTextMark.c.
︙ | ︙ | |||
2531 2532 2533 2534 2535 2536 2537 | bool TkTextDrawBlockCursor( TkText *textPtr) /* The current text widget. */ { if (textPtr->blockCursorType) { if (textPtr->flags & HAVE_FOCUS) { | | | 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 | bool TkTextDrawBlockCursor( TkText *textPtr) /* The current text widget. */ { if (textPtr->blockCursorType) { if (textPtr->flags & HAVE_FOCUS) { if ((textPtr->flags & INSERT_ON) || textPtr->selAttrs.border == textPtr->insertBorder) { return true; } } else if (textPtr->insertUnfocussed == TK_TEXT_INSERT_NOFOCUS_SOLID) { return true; } } return false; |
︙ | ︙ | |||
2742 2743 2744 2745 2746 2747 2748 | * the cursor. */ if (textPtr->flags & HAVE_FOCUS) { if (textPtr->flags & INSERT_ON) { Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->insertBorder, x, y, width, height, textPtr->insertBorderWidth, TK_RELIEF_RAISED); | | | 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 | * the cursor. */ if (textPtr->flags & HAVE_FOCUS) { if (textPtr->flags & INSERT_ON) { Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->insertBorder, x, y, width, height, textPtr->insertBorderWidth, TK_RELIEF_RAISED); } else if (textPtr->selAttrs.border == textPtr->insertBorder) { Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->border, x, y, width, height, 0, TK_RELIEF_FLAT); } } else if (textPtr->insertUnfocussed == TK_TEXT_INSERT_NOFOCUS_HOLLOW) { if (textPtr->insertBorderWidth < 1) { /* * Hack to work around the fact that a "solid" border always paints in black. |
︙ | ︙ |
Changes to generic/tkTextTag.c.
︙ | ︙ | |||
65 66 67 68 69 70 71 | static const char *CONST tabStyleStrings[] = { "tabular", "wordprocessor", "", NULL }; static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_BORDER, "-background", NULL, NULL, | | | | > > > > > > > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | static const char *CONST tabStyleStrings[] = { "tabular", "wordprocessor", "", NULL }; static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_BORDER, "-background", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, attrs.border), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-bgstipple", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", NULL, NULL, "0", Tk_Offset(TkTextTag, attrs.borderWidthPtr), Tk_Offset(TkTextTag, attrs.borderWidth), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_STRING, "-elide", NULL, NULL, "0", -1, Tk_Offset(TkTextTag, elideString), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_COLOR, "-eolcolor", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, eolColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-fgstipple", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_FONT, "-font", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-foreground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, attrs.fgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-hyphencolor", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, hyphenColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-hyphenrules", NULL, NULL, NULL, Tk_Offset(TkTextTag, hyphenRulesPtr), -1, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-inactivebackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, attrs.inactiveBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-inactiveforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, attrs.inactiveFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-inactiveselectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, inactiveSelBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-inactiveselectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, inactiveSelFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-indentbackground", NULL, NULL, "0", -1, Tk_Offset(TkTextTag, indentBgString), TK_OPTION_DONT_SET_DEFAULT|TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-justify", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, justifyString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-lang", NULL, NULL, NULL, Tk_Offset(TkTextTag, langPtr), -1, TK_OPTION_NULL_OK, 0, 0}, |
︙ | ︙ | |||
343 344 345 346 347 348 349 | } else { TkTextIndexForwChars(textPtr, &index1, 1, &index2, COUNT_INDICES); } if (TagAddRemove(textPtr, &index1, &index2, tagPtr, addTag)) { anyChanges = true; } } | | | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | } else { TkTextIndexForwChars(textPtr, &index1, 1, &index2, COUNT_INDICES); } if (TagAddRemove(textPtr, &index1, &index2, tagPtr, addTag)) { anyChanges = true; } } if (tagPtr->isSelTag) { GrabSelection(textPtr, tagPtr, addTag, anyChanges); } if (anyChanges) { if (tagPtr->undo) { TkTextUpdateAlteredFlag(sharedTextPtr); } /* still need to trigger enter/leave events on tags that have changed */ |
︙ | ︙ | |||
442 443 444 445 446 447 448 | if ((tagPtr = TkTextClearTags(sharedTextPtr, textPtr, &index1, &index2, discardSelection))) { for ( ; tagPtr; tagPtr = tagPtr->nextPtr) { if (tagPtr->epoch != epoch) { tagPtr->epoch = epoch; arrayPtr[countTags++] = tagPtr; | | | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | if ((tagPtr = TkTextClearTags(sharedTextPtr, textPtr, &index1, &index2, discardSelection))) { for ( ; tagPtr; tagPtr = tagPtr->nextPtr) { if (tagPtr->epoch != epoch) { tagPtr->epoch = epoch; arrayPtr[countTags++] = tagPtr; if (tagPtr->isSelTag) { GrabSelection(textPtr, tagPtr, false, true); } if (tagPtr->undo) { anyChanges = true; } } } |
︙ | ︙ | |||
487 488 489 490 491 492 493 | * the hash table). Either way we don't want to delete it. */ continue; } tagPtr = Tcl_GetHashValue(hPtr); undo = tagPtr->undo; | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | * the hash table). Either way we don't want to delete it. */ continue; } tagPtr = Tcl_GetHashValue(hPtr); undo = tagPtr->undo; assert(!tagPtr->isSelTag); if (TkTextDeleteTag(textPtr, tagPtr, hPtr) && undo) { anyChanges = true; } } if (anyChanges) { TkTextUpdateAlteredFlag(sharedTextPtr); } |
︙ | ︙ | |||
627 628 629 630 631 632 633 | /* * If this is the 'sel' tag, then we don't actually need to call this for all peers. * * TODO: The current implementation is sloppy, we need only to refresh the ranges * with actual changes, and not all the ranges of this tag. */ | | | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | /* * If this is the 'sel' tag, then we don't actually need to call this for all peers. * * TODO: The current implementation is sloppy, we need only to refresh the ranges * with actual changes, and not all the ranges of this tag. */ TkTextRedrawTag(tagPtr->isSelTag ? NULL : sharedTextPtr, textPtr, NULL, NULL, tagPtr, false); } break; } case TAG_NAMES: return EnumerateTags(interp, textPtr, objc, objv); /* not reached */ |
︙ | ︙ | |||
793 794 795 796 797 798 799 | /* * If this is the 'sel' tag, then we don't actually need to call this for all peers. * * TODO: The current implementation is sloppy, we need only to refresh the ranges * with actual changes, and not all the ranges of this tag. */ | | | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 | /* * If this is the 'sel' tag, then we don't actually need to call this for all peers. * * TODO: The current implementation is sloppy, we need only to refresh the ranges * with actual changes, and not all the ranges of this tag. */ TkTextRedrawTag(tagPtr->isSelTag ? NULL : sharedTextPtr, textPtr, NULL, NULL, tagPtr, false); } break; } case TAG_RANGES: { TkTextIndex first, last; TkTextSearch tSearch; |
︙ | ︙ | |||
1020 1021 1022 1023 1024 1025 1026 | || tagPtr->spacing2String || tagPtr->spacing3String || tagPtr->tabStringPtr || tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE || tagPtr->wrapMode != TEXT_WRAPMODE_NULL) { tagPtr->affectsDisplay = true; tagPtr->affectsDisplayGeometry = true; | | > > | > > | 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | || tagPtr->spacing2String || tagPtr->spacing3String || tagPtr->tabStringPtr || tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE || tagPtr->wrapMode != TEXT_WRAPMODE_NULL) { tagPtr->affectsDisplay = true; tagPtr->affectsDisplayGeometry = true; } else if (tagPtr->attrs.border || tagPtr->attrs.inactiveBorder || tagPtr->selBorder || tagPtr->inactiveSelBorder || tagPtr->reliefPtr || tagPtr->bgStipple != None || tagPtr->indentBgString || tagPtr->attrs.fgColor || tagPtr->attrs.inactiveFgColor || tagPtr->selFgColor || tagPtr->inactiveSelFgColor || tagPtr->fgStipple != None || tagPtr->eolColor || tagPtr->hyphenColor || tagPtr->overstrikeString || tagPtr->overstrikeColor || tagPtr->underlineString || tagPtr->underlineColor |
︙ | ︙ | |||
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 | * * Side effects: * A new tag will be created if required, otherwise an existing tag * will be modified. * *---------------------------------------------------------------------- */ int TkConfigureTag( Tcl_Interp *interp, /* Current interpreter. */ TkText *textPtr, /* Info about overall widget. */ char const *tagName, /* Name of affected tag. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Remaining argument objects. */ { | > > > > > > > > > > > > > > > < > > > > > > > > > | 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 | * * Side effects: * A new tag will be created if required, otherwise an existing tag * will be modified. * *---------------------------------------------------------------------- */ static void SetupDefaultRelief( TkText *textPtr, TkTextTag *tagPtr) { if (tagPtr->isSelTag) { Tk_GetRelief(textPtr->interp, DEF_TEXT_SELECT_RELIEF, &tagPtr->relief); assert(strcmp(Tk_NameOfRelief(tagPtr->relief), DEF_TEXT_SELECT_RELIEF) == 0); if (tagPtr->reliefPtr) { Tcl_DecrRefCount(tagPtr->reliefPtr); } Tcl_IncrRefCount(tagPtr->reliefPtr = Tcl_NewStringObj(DEF_TEXT_SELECT_RELIEF, -1)); } else { tagPtr->relief = TK_RELIEF_FLAT; } } int TkConfigureTag( Tcl_Interp *interp, /* Current interpreter. */ TkText *textPtr, /* Info about overall widget. */ char const *tagName, /* Name of affected tag. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Remaining argument objects. */ { bool newTag; int mask = 0; TkSharedText *sharedTextPtr = textPtr->sharedTextPtr; TkTextTag *tagPtr = TkTextCreateTag(textPtr, tagName, &newTag); Tcl_Obj *reliefPtr = tagPtr->reliefPtr; const char *elideString = tagPtr->elideString; bool elide = tagPtr->elide; bool undo = tagPtr->undo; bool affectsDisplay = tagPtr->affectsDisplay; bool affectsLineHeight = false; int rc = TCL_OK; if (objc <= 1) { Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) tagPtr, tagPtr->optionTable, objc == 1 ? objv[0] : NULL, textPtr->tkwin); if (!objPtr) { return TCL_ERROR; } Tcl_SetObjResult(interp, objPtr); return TCL_OK; } if (tagPtr->isSelTag) { tagPtr->attrs = textPtr->selTagConfigAttrs; } if (Tk_SetOptions(interp, (char *) tagPtr, tagPtr->optionTable, objc, objv, textPtr->tkwin, NULL, &mask) != TCL_OK) { if (tagPtr->isSelTag) { tagPtr->attrs = textPtr->selAttrs; } return TCL_ERROR; } #if SUPPORT_DEPRECATED_TAG_OPTIONS if (mask & (TK_TEXT_DEPRECATED_OVERSTRIKE_FG|TK_TEXT_DEPRECATED_UNDERLINE_FG)) { static bool warnAboutOverstrikeFg = true; |
︙ | ︙ | |||
1122 1123 1124 1125 1126 1127 1128 | /* Some of the configuration options, like -underline and -justify, require * additional translation (this is needed because we need to distinguish a * particular value of an option from "unspecified"). */ | < | | | | | > | | > > | | | > | | | | | | < | < | < | < | < | < | | | | | | 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 | /* Some of the configuration options, like -underline and -justify, require * additional translation (this is needed because we need to distinguish a * particular value of an option from "unspecified"). */ tagPtr->attrs.borderWidth = MAX(0, tagPtr->attrs.borderWidth); if (tagPtr->langPtr) { if (!TkTextTestLangCode(interp, tagPtr->langPtr)) { rc = TCL_ERROR; } else { memcpy(tagPtr->lang, Tcl_GetString(tagPtr->langPtr), 3); } } else { memset(tagPtr->lang, 0, 3); } if (tagPtr->indentBgString) { if (Tcl_GetBoolean(interp, tagPtr->indentBgString, (int *) &tagPtr->indentBg) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->reliefPtr) { if (Tk_GetReliefFromObj(interp, tagPtr->reliefPtr, &tagPtr->relief) != TCL_OK) { rc = TCL_ERROR; } } else if (reliefPtr) { SetupDefaultRelief(textPtr, tagPtr); } if (tagPtr->justifyString) { const char *identifier = NULL; int j = -1; /* * Tk_Justify only knows "left", "right", and "center", so we have to parse by ourself. */ switch (*tagPtr->justifyString) { case 'l': identifier = "left"; j = TK_TEXT_JUSTIFY_LEFT; break; case 'r': identifier = "right"; j = TK_TEXT_JUSTIFY_RIGHT; break; case 'f': identifier = "full"; j = TK_TEXT_JUSTIFY_FULL; break; case 'c': identifier = "center"; j = TK_TEXT_JUSTIFY_CENTER; break; } if (j == -1 || strcmp(tagPtr->justifyString, identifier) != 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad justification \"%s\": must be left, right, full, or center", tagPtr->justifyString)); Tcl_SetErrorCode(interp, "TK", "VALUE", "JUSTIFY", NULL); rc = TCL_ERROR; } else { tagPtr->justify = j; } } if (tagPtr->lMargin1String) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->lMargin1String, &tagPtr->lMargin1) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->lMargin2String) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->lMargin2String, &tagPtr->lMargin2) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->offsetString) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->offsetString, &tagPtr->offset) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->overstrikeString) { if (Tcl_GetBoolean(interp, tagPtr->overstrikeString, (int *) &tagPtr->overstrike) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->rMarginString) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->rMarginString, &tagPtr->rMargin) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->spacing1String) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->spacing1String, &tagPtr->spacing1) != TCL_OK) { rc = TCL_ERROR; } tagPtr->spacing1 = MAX(0, tagPtr->spacing1); } if (tagPtr->spacing2String) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->spacing2String, &tagPtr->spacing2) != TCL_OK) { rc = TCL_ERROR; } tagPtr->spacing2 = MAX(0, tagPtr->spacing1); } if (tagPtr->spacing3String) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->spacing3String, &tagPtr->spacing3) != TCL_OK) { rc = TCL_ERROR; } tagPtr->spacing3 = MAX(0, tagPtr->spacing1); } if (tagPtr->tabArrayPtr) { free(tagPtr->tabArrayPtr); tagPtr->tabArrayPtr = NULL; } if (tagPtr->tabStringPtr) { if (!(tagPtr->tabArrayPtr = TkTextGetTabs(interp, textPtr, tagPtr->tabStringPtr))) { rc = TCL_ERROR; } } if (tagPtr->hyphenRulesPtr) { int oldHyphenRules = tagPtr->hyphenRules; if (TkTextParseHyphenRules(textPtr, tagPtr->hyphenRulesPtr, &tagPtr->hyphenRules) != TCL_OK) { rc = TCL_ERROR; } if (oldHyphenRules != tagPtr->hyphenRules && textPtr->hyphenate) { affectsDisplay = true; } } if (tagPtr->underlineString) { if (Tcl_GetBoolean(interp, tagPtr->underlineString, (int *) &tagPtr->underline) != TCL_OK) { rc = TCL_ERROR; } } if (tagPtr->elideString) { if (!elideString) { sharedTextPtr->numElisionTags += 1; } if (TkBitTest(sharedTextPtr->selectionTags, tagPtr->index)) { /* * It's not allowed to set the elide attribute of the special selection tag * to 'true' (this would cause errors, because this case is not implemented). */ free(tagPtr->elideString); tagPtr->elideString = NULL; tagPtr->elide = false; Tcl_SetObjResult(interp, Tcl_ObjPrintf( "not allowed to set elide option of selection tag \"%s\"", tagPtr->name)); Tcl_SetErrorCode(interp, "TK", "VALUE", "ELIDE", NULL); rc = TCL_ERROR; } if (Tcl_GetBoolean(interp, tagPtr->elideString, (int *) &tagPtr->elide) != TCL_OK) { rc = TCL_ERROR; } /* * Indices are potentially obsolete after changing -elide, * especially those computed with "display" or "any" * submodifier, therefore increase the epoch. */ |
︙ | ︙ | |||
1289 1290 1291 1292 1293 1294 1295 | } if (tagPtr->undo != undo) { TkBitPut(sharedTextPtr->dontUndoTags, tagPtr->index, !tagPtr->undo); } /* * If the "sel" tag was changed, be sure to mirror information | | < < < | > | > > > > > | > > > > > | > > > | | 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 | } if (tagPtr->undo != undo) { TkBitPut(sharedTextPtr->dontUndoTags, tagPtr->index, !tagPtr->undo); } /* * If the "sel" tag was changed, be sure to mirror information * from the tag back into the text widget record. */ if (tagPtr->isSelTag) { if (tagPtr->attrs.border != textPtr->selTagConfigAttrs.border) { textPtr->selAttrs.border = tagPtr->attrs.border; } if (tagPtr->attrs.inactiveBorder != textPtr->selTagConfigAttrs.inactiveBorder) { textPtr->selAttrs.inactiveBorder = tagPtr->attrs.inactiveBorder; } if (tagPtr->attrs.fgColor != textPtr->selTagConfigAttrs.fgColor) { textPtr->selAttrs.fgColor = tagPtr->attrs.fgColor; } if (tagPtr->attrs.inactiveFgColor != textPtr->selTagConfigAttrs.inactiveFgColor) { textPtr->selAttrs.inactiveFgColor = tagPtr->attrs.inactiveFgColor; } if (tagPtr->attrs.borderWidthPtr != textPtr->selTagConfigAttrs.borderWidthPtr) { textPtr->selAttrs.borderWidthPtr = tagPtr->attrs.borderWidthPtr; textPtr->selAttrs.borderWidth = tagPtr->attrs.borderWidth; } textPtr->selTagConfigAttrs = tagPtr->attrs; tagPtr->attrs = textPtr->selAttrs; } TkTextUpdateTagDisplayFlags(tagPtr); if (tagPtr->affectsDisplay) { affectsDisplay = true; } if (tagPtr->tkfont != None && tagPtr->tkfont != textPtr->tkfont) { |
︙ | ︙ | |||
1348 1349 1350 1351 1352 1353 1354 | * If this is the 'sel' tag, then we don't need to call this for all peers, unless * we actually want to synchronize sel-style changes across the peers. */ TkTextRedrawTag(sharedTextPtr, NULL, NULL, NULL, tagPtr, false); } | | | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 | * If this is the 'sel' tag, then we don't need to call this for all peers, unless * we actually want to synchronize sel-style changes across the peers. */ TkTextRedrawTag(sharedTextPtr, NULL, NULL, NULL, tagPtr, false); } return rc; } /* *---------------------------------------------------------------------- * * TkTextFontHeightChanged -- * |
︙ | ︙ | |||
1512 1513 1514 1515 1516 1517 1518 | */ for (j = TkTextTagSetFindFirst(oldTagInfoPtr); j != TK_TEXT_TAG_SET_NPOS; j = TkTextTagSetFindNext(oldTagInfoPtr, j)) { if (!TkTextTagSetTest(newTagInfoPtr, j)) { tagPtr = sharedTextPtr->tagLookup[j]; | < | < | | 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 | */ for (j = TkTextTagSetFindFirst(oldTagInfoPtr); j != TK_TEXT_TAG_SET_NPOS; j = TkTextTagSetFindNext(oldTagInfoPtr, j)) { if (!TkTextTagSetTest(newTagInfoPtr, j)) { tagPtr = sharedTextPtr->tagLookup[j]; if (!tagPtr->isSelTag && TagAddRemove(textPtr, &index[0], &index[1], tagPtr, false)) { anyChanges = true; if (tagPtr->undo) { altered = true; } } } } /* * Add new tags, but ignore the "sel" tag. */ for (j = TkTextTagSetFindFirst(newTagInfoPtr); j != TK_TEXT_TAG_SET_NPOS; j = TkTextTagSetFindNext(newTagInfoPtr, j)) { if (!TkTextTagSetTest(segPtr->tagInfoPtr, j)) { tagPtr = sharedTextPtr->tagLookup[j]; if (!tagPtr->isSelTag && TagAddRemove(textPtr, &index[0], &index[1], tagPtr, true)) { anyChanges = true; if (tagPtr->undo) { altered = true; } } } } |
︙ | ︙ | |||
1628 1629 1630 1631 1632 1633 1634 | const TkTextIndex *indexPtr2, const TkTextTag *tagPtr, bool affectsDisplayGeometry) { if (!TkTextRedrawTag(sharedTextPtr, textPtr, indexPtr1, indexPtr2, tagPtr, affectsDisplayGeometry)) { return false; } | < | | 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 | const TkTextIndex *indexPtr2, const TkTextTag *tagPtr, bool affectsDisplayGeometry) { if (!TkTextRedrawTag(sharedTextPtr, textPtr, indexPtr1, indexPtr2, tagPtr, affectsDisplayGeometry)) { return false; } if (textPtr && tagPtr == textPtr->selTagPtr) { GrabSelection(tagPtr->textPtr, tagPtr, TkTextTestTag(indexPtr1, tagPtr), true); } return true; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | bool add, /* 'true' means that we have added the "sel" tag; * 'false' means we have removed the "sel" tag. */ bool changed) /* 'false' means that the selection has not changed, nevertheless * the text widget should become the owner again. */ { bool ownSelection = add && textPtr->exportSelection && !(textPtr->flags & GOT_SELECTION); assert(tagPtr == textPtr->selTagPtr); if (changed || ownSelection) { /* * Send an event that the selection changed. This is * equivalent to: * event generate $textWidget <<Selection>> | > | 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 | bool add, /* 'true' means that we have added the "sel" tag; * 'false' means we have removed the "sel" tag. */ bool changed) /* 'false' means that the selection has not changed, nevertheless * the text widget should become the owner again. */ { bool ownSelection = add && textPtr->exportSelection && !(textPtr->flags & GOT_SELECTION); assert(textPtr); assert(tagPtr == textPtr->selTagPtr); if (changed || ownSelection) { /* * Send an event that the selection changed. This is * equivalent to: * event generate $textWidget <<Selection>> |
︙ | ︙ | |||
1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 | * to it to the hash table entry. */ tagPtr = memset(malloc(sizeof(TkTextTag)), 0, sizeof(TkTextTag)); tagPtr->name = name; tagPtr->index = index; tagPtr->priority = textPtr->sharedTextPtr->numEnabledTags; tagPtr->bgStipple = None; tagPtr->fgStipple = None; tagPtr->justify = TK_TEXT_JUSTIFY_LEFT; tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; tagPtr->undo = !isSelTag; tagPtr->sharedTextPtr = sharedTextPtr; tagPtr->undoTagListIndex = -1; tagPtr->refCount = 1; tagPtr->tagEpoch = ++sharedTextPtr->tagEpoch; DEBUG_ALLOC(tkTextCountNewTag++); tagPtr->optionTable = Tk_CreateOptionTable(textPtr->interp, tagOptionSpecs); assert(!tagPtr->reliefPtr); textPtr->sharedTextPtr->numTags += 1; textPtr->sharedTextPtr->numEnabledTags += 1; if (isSelTag) { tagPtr->textPtr = textPtr; | > < < < < < < < < < < < < < > | 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 | * to it to the hash table entry. */ tagPtr = memset(malloc(sizeof(TkTextTag)), 0, sizeof(TkTextTag)); tagPtr->name = name; tagPtr->index = index; tagPtr->priority = textPtr->sharedTextPtr->numEnabledTags; tagPtr->isSelTag = isSelTag; tagPtr->bgStipple = None; tagPtr->fgStipple = None; tagPtr->justify = TK_TEXT_JUSTIFY_LEFT; tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; tagPtr->undo = !isSelTag; tagPtr->sharedTextPtr = sharedTextPtr; tagPtr->undoTagListIndex = -1; tagPtr->refCount = 1; tagPtr->tagEpoch = ++sharedTextPtr->tagEpoch; DEBUG_ALLOC(tkTextCountNewTag++); tagPtr->optionTable = Tk_CreateOptionTable(textPtr->interp, tagOptionSpecs); assert(!tagPtr->reliefPtr); textPtr->sharedTextPtr->numTags += 1; textPtr->sharedTextPtr->numEnabledTags += 1; if (isSelTag) { tagPtr->textPtr = textPtr; textPtr->refCount += 1; TkBitSet(sharedTextPtr->selectionTags, index); TkBitSet(sharedTextPtr->dontUndoTags, index); } else { assert(hPtr); Tcl_SetHashValue(hPtr, tagPtr); } SetupDefaultRelief(textPtr, tagPtr); MarkIndex(sharedTextPtr, tagPtr, true); return tagPtr; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
2150 2151 2152 2153 2154 2155 2156 | if (!hPtr) { hPtr = Tcl_FindHashEntry(&sharedTextPtr->tagTable, tagPtr->name); } if (hPtr) { Tcl_DeleteHashEntry(hPtr); } else { | | > > > > > | 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 | if (!hPtr) { hPtr = Tcl_FindHashEntry(&sharedTextPtr->tagTable, tagPtr->name); } if (hPtr) { Tcl_DeleteHashEntry(hPtr); } else { assert(tagPtr->isSelTag); } /* * Let Tk do most of the hard work for us. */ if (tagPtr->isSelTag) { assert(tagPtr->textPtr); /* Restore the original values. */ tagPtr->attrs = tagPtr->textPtr->selTagConfigAttrs; } Tk_FreeConfigOptions((char *) tagPtr, tagPtr->optionTable, sharedTextPtr->peers->tkwin); /* * This associated information is managed by us. */ if (tagPtr->tabArrayPtr) { |
︙ | ︙ | |||
2223 2224 2225 2226 2227 2228 2229 | Tcl_HashEntry *hPtr) /* Pointer into hash table, can be NULL (but only for "sel"). */ { TkSharedText *sharedTextPtr = textPtr->sharedTextPtr; bool used; assert(!sharedTextPtr->undoStack || !TkTextUndoIsPerformingUndo(sharedTextPtr->undoStack)); assert(!sharedTextPtr->undoStack || !TkTextUndoIsPerformingRedo(sharedTextPtr->undoStack)); | | | 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 | Tcl_HashEntry *hPtr) /* Pointer into hash table, can be NULL (but only for "sel"). */ { TkSharedText *sharedTextPtr = textPtr->sharedTextPtr; bool used; assert(!sharedTextPtr->undoStack || !TkTextUndoIsPerformingUndo(sharedTextPtr->undoStack)); assert(!sharedTextPtr->undoStack || !TkTextUndoIsPerformingRedo(sharedTextPtr->undoStack)); assert(hPtr || tagPtr->isSelTag); used = !!tagPtr->rootPtr; if (used) { TkTextUndoInfo undoInfo; TkTextUndoInfo *undoInfoPtr; TkTextIndex startIndex; |
︙ | ︙ | |||
2261 2262 2263 2264 2265 2266 2267 | tagPtr->refCount += 1; TkTextUndoPushItem(sharedTextPtr->undoStack, undoInfo.token, undoInfo.byteSize); } } assert(!tagPtr->rootPtr); | | | 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 | tagPtr->refCount += 1; TkTextUndoPushItem(sharedTextPtr->undoStack, undoInfo.token, undoInfo.byteSize); } } assert(!tagPtr->rootPtr); if (!(textPtr->flags & DESTROYED) && tagPtr->isSelTag) { /* * Send an event that the selection changed. This is equivalent to: * event generate $textWidget <<Selection>> */ TkTextSelectionEvent(textPtr); } |
︙ | ︙ | |||
2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 | assert(tagPtr->refCount == 1); /* * Let Tk do most of the hard work for us. */ Tk_FreeConfigOptions((char *) tagPtr, tagPtr->optionTable, textPtr->tkwin); /* * This associated information is managed by us. */ if (tagPtr->tabArrayPtr) { | > > > > | 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 | assert(tagPtr->refCount == 1); /* * Let Tk do most of the hard work for us. */ if (tagPtr->isSelTag) { assert(tagPtr->textPtr); tagPtr->attrs = tagPtr->textPtr->selTagConfigAttrs; } Tk_FreeConfigOptions((char *) tagPtr, tagPtr->optionTable, textPtr->tkwin); /* * This associated information is managed by us. */ if (tagPtr->tabArrayPtr) { |
︙ | ︙ |
Changes to tests/textTag.test.
︙ | ︙ | |||
652 653 654 655 656 657 658 | test textTag-5.22 {TkTextTagCmd - "configure" option} -body { .t configure -selectborderwidth 20 .t tag configure sel -borderwidth {} .t cget -selectborderwidth } -result {} test textTag-5.23 {TkTextTagCmd - "configure" option} -body { set x {} | | | < < < < < < < < < < < < < | | | > > | > > > > > > > > > > > > | | > > > > | | | > > > | | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | test textTag-5.22 {TkTextTagCmd - "configure" option} -body { .t configure -selectborderwidth 20 .t tag configure sel -borderwidth {} .t cget -selectborderwidth } -result {} test textTag-5.23 {TkTextTagCmd - "configure" option} -body { set x {} # 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] # 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] # Mirroring happens between # the text widget option -inactiveselectbackground # and the tag option -inactivebackground .t tag configure sel -inactiveselectbackground {} .t configure -inactiveselectbackground black .t tag configure sel -inactivebackground yellow lappend x [.t cget -inactiveselectbackground] .t tag configure sel -inactivebackground orange .t configure -inactiveselectbackground blue lappend x [.t tag cget sel -inactivebackground] # Mirroring happens between # the text widget option -inactiveselectforeground # and the tag option -inactiveforeground .t tag configure sel -inactiveselectforeground {} .t configure -inactiveselectforeground black .t tag configure sel -inactiveforeground yellow lappend x [.t cget -inactiveselectforeground] .t tag configure sel -inactiveforeground orange .t configure -inactiveselectforeground blue lappend x [.t tag cget sel -inactiveforeground] # Mirroring happens between # the text widget option -selectborderwidth # and the tag option -borderwidth .t tag configure sel -borderwidth 0 .t configure -selectborderwidth 1 .t tag configure sel -borderwidth 2 lappend x [.t cget -selectborderwidth] .t tag configure sel -borderwidth 3 .t configure -selectborderwidth 4 lappend x [.t tag cget sel -borderwidth] return $x } -result {yellow blue yellow blue yellow blue yellow blue 2 4} test textTag-6.1 {TkTextTagCmd - "delete" option} -body { .t tag delete } -returnCodes error -result {wrong # args: should be ".t tag delete tagName ?tagName ...?"} test textTag-6.2 {TkTextTagCmd - "delete" option} -body { .t tag delete zork } -returnCodes ok -result {} |
︙ | ︙ |