\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#243: Supply Find Dialog for the Text Widget}
\date{March 16, 2005}
\author{Rüdiger Härtel}
\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 \#243}&\textbf{Supply Find Dialog for the Text Widget}\\\hline
Author&

Rüdiger Härtel \tipmail{r_haertel}{gmx.de}
\\
Created&Wednesday, \(\text{16}^{\text{th}}\) March 2005\\
Type&Project\\
Tcl Version&\(8.7\)\\
State&Draft\\
Vote&Pending\\
Version&\tipversion$Revision: 1.3 $\\
Keywords&Tk\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP adds a \textit{find dialog} to the Tk \textbf{text} widget.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

In using the \textbf{text} widget it often is a desire to search the input, and the text widget itself provides already all means to search text. However, until now there is no GUI based support, so each application developer needing it has to reinvent much of this particular wheel. Tk should provide a scripted find dialog in its library scripts so that simple applications can be built more easily and to a higher quality. Additionally, a \textit{replace dialog} is desirable, and it should be developed at the same time.

\section{Reference Implementation}

A reference implementation for a \textit{find dialog} is available at [\url{http://sf.net/tracker/?func=detail&aid=1167420&group_id=12997&atid=312997}].

\section{Example Use}
\begingroup\small\begin{verbatim}
 package require Tk
 namespace import ::msgcat::*
 
 mclocale en
 ::msgcat::mcset	en	LblSearchString		"Search String"
 ::msgcat::mcset	en	LblDirection		"Direction"
 ::msgcat::mcset	en	ChkBtnFindCaseOpt	"Case"
 ::msgcat::mcset	en	ChkBtnFindRegexpOpt	"Regexp"
 ::msgcat::mcset	en	RdoBtnFindDirOpt1	"Forward"
 ::msgcat::mcset	en	RdoBtnFindDirOpt2	"Backward"
 ::msgcat::mcset	en	BtnFind			"  Find  "
 ::msgcat::mcset	en	BtnFindNext		"  Next  "
 ::msgcat::mcset	en	BtnClose		"  Close  "
 
 set b1 .button
 set t1 .t1
 
 button $b1 -text Find -command [list \
        tk_textFind $t1 -searchstring hallo -highlightcolor green \
        -title "Find Dialog"]
 text $t1
 
 grid $b1 -row 0 -column 1
 grid $t1 -row 1 -column 0 -columnspan 2
 
 set fd [open [file join . tk_find.tcl] r]
 set content [read $fd]
 close $fd
 
 $t1 insert 0.0 $content
 set content ""
\end{verbatim}
\endgroup

\section{Copyright}

This document is in the public domain.

\section{Colophon}

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