TIP 443: More Tag Configuration Options for the Text Widget

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Fran├žois Vogel <fvogelnew1@free.fr>
State:          Final
Type:           Project
Vote:           Done
Created:        09-Feb-2016
Post-History:   
Keywords:       Tk
Tcl-Version:    8.6.6

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:

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:

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.

History