TIP #443: More Tag Configuration Options for the Text Widget
_____________________________________________________________________________
TIP:	443
Title:	More Tag Configuration Options for the Text Widget
Version:	$Revision: 1.9 $
Authors:	François Vogel <fvogelnew1@free.fr>
State:	Final
Type:	Project
Tcl-Version:	8.6.6
Vote:	Done
Created:	Tue Feb 09 00:00:00 UTC 2016
Keywords:	Tk
Abstract
Despite the text widget already has numerous configuration options, some users need more refinements and have requested new tag configuration options. This TIP proposes to add these options, when deemed relevant.
Rationale
Several users have reported they miss different tag configuration options in the text widget, stating they cannot achieve the rendering they target. Such RFE include:
RFE 1759972 [https://core.tcl.tk/tk/tktview/1759972], with Patch 3469780 [https://core.tcl.tk/tk/tktview/3469780]
RFE 220889 [https://core.tcl.tk/tk/tktview/220889]
RFE 1754048 [https://core.tcl.tk/tk/tktview/1754048]
Proposed Change
It is proposed to add the following tag configuration options to the Tk text widget:
-selectbackground color:
Specifies the background color to use when displaying selected items. It may have any of the forms accepted by Tk_GetColor. If color has not been specified, or if it is specified as an empty string, then the color specified by the -background tag option is used.
Note regarding the particular case of the "sel" tag: Currently, the "sel" tag -background tag option is mirrored with the -selectbackground text widget option. This makes sense. It does not make real sense to have -selectbackground applied to the "sel" tag (it is more intuitive to use -background for the "sel" tag). However, if the "sel" tag receives non-empty -selectbackground, then this tag option prevails on the -background tag option for mirroring, i.e. the -selectbackground tag option is mirrored with the -selectbackground widget option.
-selectforeground color:
Specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by Tk_GetColor. If color has not been specified, or if it is specified as an empty string, then the color specified by the -foreground tag option is used.
Note regarding the particular case of the "sel" tag: same principle as above for -selectbackground.
-underlinefg color:
Specifies the color to use when displaying the underline. It may have any of the forms accepted by Tk_GetColor. If color has not been specified, or if it is specified as an empty string, then the color specified by the -foreground tag option is used (if there is one, otherwise the the color specified by the -foreground widget option is used).
-overstrikefg color:
Specifies the color to use when displaying the overstrike. It may have any of the forms accepted by Tk_GetColor. If color has not been specified, or if it is specified as an empty string, then the color specified by the -foreground tag option is used (if there is one, otherwise the color specified by the -foreground widget option is used).
-lmargincolor color:
Color specifies the background color to use in regions that do not contain characters because they are indented by -lmargin1 or -lmargin2. It may have any of the forms accepted by Tk_GetColor. If color has not been specified, or if it is specified as an empty string, then the color specified by the -background widget option is used.
-rmargincolor color:
Color specifies the background color to use in regions that do not contain characters because they are indented by -rmargin. It may have any of the forms accepted by Tk_GetColor. If color has not been specified, or if it is specified as an empty string, then the color specified by the -background widget option is used.
Rejected additional tag configuration options
RFE 1759972 [https://core.tcl.tk/tk/tktview/1759972] requested stippling (-selectbgstipple, -selectfgstipple) for selected text. Also RFE 1754048 [https://core.tcl.tk/tk/tktview/1754048] requested stippling in left and right margins of the text widget (-lmargin1stipple, -lmargin2stipple, rmarginstipple).
Any new stippling options was rejected during the discussion about this TIP. Reasons were as follows:
"Stippling and anything related to Tk Bitmaps should be considered obsolete. Their use should be phased out, not expanded. (Bitmaps have very limited support in Tk, and stippling is virtually never used in modern user interfaces. In fact, AFAIK current graphics stacks -- cairo, Quartz, Direct3D, &c -- don't even support this operation."
"Stippling is something that is an artefact of a prior time, and it looks pretty bad now. These days, a way to specify an alpha value for the tag would be far more relevant, since then it would end up with a blend of the text foreground and background."
Reference Implementation
A reference implementation is available in branch tip-443 of the fossil repository.
Copyright
This document has been placed in the public domain.
_____________________________________________________________________________
Colophon
TIP AutoGenerator - written by Donal K. Fellows