\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#443: More Tag Configuration Options for the Text Widget}
\date{February 09, 2016}
\author{François Vogel}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#443}&\textbf{More Tag Configuration Options for the Text Widget}\\\hline
Author&

François Vogel \tipmail{fvogelnew1}{free.fr}
\\
Created&Tuesday, \(\text{9}^{\text{th}}\) February 2016\\
Type&Project\\
Tcl Version&\(8.6.6\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.9 $\\
Keywords&Tk\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

Despite the \textbf{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.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

Several users have reported they miss different tag configuration options in the \textbf{text} widget, stating they cannot achieve the rendering they target. Such RFE include:
\begin{itemize}
\item{}
RFE 1759972 [\url{https://core.tcl.tk/tk/tktview/1759972}], with Patch 3469780 [\url{https://core.tcl.tk/tk/tktview/3469780}]
\item{}
RFE 220889 [\url{https://core.tcl.tk/tk/tktview/220889}]
\item{}
RFE 1754048 [\url{https://core.tcl.tk/tk/tktview/1754048}]
\end{itemize}

\section{Proposed Change}

It is proposed to add the following tag configuration options to the Tk \textbf{text} widget:

\textbf{-selectbackground} \textit{color}:

\begin{quote}
Specifies the background color to use when displaying selected items. It may have any of the forms accepted by \textbf{Tk\_GetColor}. If \textit{color} has not been specified, or if it is specified as an empty string, then the color specified by the \textbf{-background} tag option is used.
\end{quote}

\begin{quote}
Note regarding the particular case of the ``sel'' tag: Currently, the ``sel'' tag \textbf{-background} tag option is mirrored with the \textbf{-selectbackground} text widget option. This makes sense. It does not make real sense to have \textbf{-selectbackground} applied to the ``sel'' tag (it is more intuitive to use \textbf{-background} for the ``sel'' tag). However, if the ``sel'' tag receives non-empty \textbf{-selectbackground}, then this tag option prevails on the \textbf{-background} tag option for mirroring, i.e. the \textbf{-selectbackground} tag option is mirrored with the \textbf{-selectbackground} widget option.
\end{quote}

\textbf{-selectforeground} \textit{color}:

\begin{quote}
Specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \textbf{Tk\_GetColor}. If \textit{color} has not been specified, or if it is specified as an empty string, then the color specified by the \textbf{-foreground} tag option is used.
\end{quote}

\begin{quote}
Note regarding the particular case of the ``sel'' tag: same principle as above for \textbf{-selectbackground}.
\end{quote}

\textbf{-underlinefg} \textit{color}:

\begin{quote}
Specifies the color to use when displaying the underline. It may have any of the forms accepted by \textbf{Tk\_GetColor}. If \textit{color} has not been specified, or if it is specified as an empty string, then the color specified by the \textbf{-foreground} tag option is used (if there is one, otherwise the the color specified by the \textbf{-foreground} widget option is used).
\end{quote}

\textbf{-overstrikefg} \textit{color}:

\begin{quote}
Specifies the color to use when displaying the overstrike. It may have any of the forms accepted by \textbf{Tk\_GetColor}. If \textit{color} has not been specified, or if it is specified as an empty string, then the color specified by the \textbf{-foreground} tag option is used (if there is one, otherwise the color specified by the \textbf{-foreground} widget option is used).
\end{quote}

\textbf{-lmargincolor} \textit{color}:

\begin{quote}
\textit{Color} specifies the background color to use in regions that do not contain characters because they are indented by \textbf{-lmargin1} or \textbf{-lmargin2}. It may have any of the forms accepted by \textbf{Tk\_GetColor}. If \textit{color} has not been specified, or if it is specified as an empty string, then the color specified by the \textbf{-background} widget option is used.
\end{quote}

\textbf{-rmargincolor} \textit{color}:

\begin{quote}
\textit{Color} specifies the background color to use in regions that do not contain characters because they are indented by \textbf{-rmargin}. It may have any of the forms accepted by \textbf{Tk\_GetColor}. If \textit{color} has not been specified, or if it is specified as an empty string, then the color specified by the \textbf{-background} widget option is used.
\end{quote}

\section{Rejected additional tag configuration options}

RFE 1759972 [\url{https://core.tcl.tk/tk/tktview/1759972}] requested stippling (\textbf{-selectbgstipple}, \textbf{-selectfgstipple}) for selected text. Also RFE 1754048 [\url{https://core.tcl.tk/tk/tktview/1754048}] requested stippling in left and right margins of the text widget (\textbf{-lmargin1stipple}, \textbf{-lmargin2stipple}, \textbf{rmarginstipple}).

Any new stippling options was rejected during the discussion about this TIP. Reasons were as follows:
\begin{itemize}
\item{}
``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.''
\item{}
``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.''
\end{itemize}

\section{Reference Implementation}

A reference implementation is available in branch tip-443 of the fossil repository.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
