| 1 |
'\" |
| 2 |
'\" Copyright 1991-1997 by Bell Labs Innovations for Lucent Technologies. |
| 3 |
'\" |
| 4 |
'\" Permission to use, copy, modify, and distribute this software and its |
| 5 |
'\" documentation for any purpose and without fee is hereby granted, provided |
| 6 |
'\" that the above copyright notice appear in all copies and that both that the |
| 7 |
'\" copyright notice and warranty disclaimer appear in supporting documentation, |
| 8 |
'\" and that the names of Lucent Technologies any of their entities not be used |
| 9 |
'\" in advertising or publicity pertaining to distribution of the software |
| 10 |
'\" without specific, written prior permission. |
| 11 |
'\" |
| 12 |
'\" Lucent Technologies disclaims all warranties with regard to this software, |
| 13 |
'\" including all implied warranties of merchantability and fitness. In no event |
| 14 |
'\" shall Lucent Technologies be liable for any special, indirect or |
| 15 |
'\" consequential damages or any damages whatsoever resulting from loss of use, |
| 16 |
'\" data or profits, whether in an action of contract, negligence or other |
| 17 |
'\" tortuous action, arising out of or in connection with the use or performance |
| 18 |
'\" of this software. |
| 19 |
'\" |
| 20 |
'\" Hypertext widget created by George Howlett. |
| 21 |
'\" |
| 22 |
.so man.macros |
| 23 |
.TH htext n BLT_VERSION BLT "BLT Built-In Commands" |
| 24 |
.BS |
| 25 |
'\" Note: do not modify the .SH NAME line immediately below! |
| 26 |
.SH NAME |
| 27 |
htext \- Create and manipulate hypertext widgets |
| 28 |
.SH SYNOPSIS |
| 29 |
\fBhtext\fP \fIpathName \fR?\fIoption value\fR?... |
| 30 |
.BE |
| 31 |
.SH DESCRIPTION |
| 32 |
.PP |
| 33 |
The \fBhtext\fR command creates a new window (given by the |
| 34 |
\fIpathName\fR argument) and makes it into a \fBhtext\fP widget. |
| 35 |
Additional options, described above, may be specified on the command line |
| 36 |
or in the option database to configure aspects of the widget such as its |
| 37 |
color and font. At the time this command is invoked, there must not |
| 38 |
exist a window named \fIpathName\fR, but \fIpathName\fR's parent must exist. |
| 39 |
The \fBhtext\fR command returns its \fIpathName\fR. |
| 40 |
.PP |
| 41 |
The \fBhtext\fP widget is hybrid of a non-editable text widget and |
| 42 |
a geometry manager (e.g. the packer). It displays text (optionally read |
| 43 |
from file) in a window. Text can be scrolled either horizontally or |
| 44 |
vertically using the \fBhtext\fR window as a viewport. |
| 45 |
In addition, Tcl commands can be embedded into |
| 46 |
the text which are evaluated as the text is parsed. Text between special |
| 47 |
double characters (percent signs "%%") is immediately passed to the Tcl |
| 48 |
interpreter for evaluation. |
| 49 |
.PP |
| 50 |
Furthermore, any widget or widget hierarchy can be packed in-line and made |
| 51 |
to appear on the current line of the text. Widgets are packed using the |
| 52 |
\fBhtext append\fP command. All widgets must be children of the |
| 53 |
\fBhtext\fP window and must already exist before packing. |
| 54 |
Once a widget has been packed it cannot be moved to a different |
| 55 |
position within the text. Widgets can be resized but they will remain |
| 56 |
at the same position within the text. |
| 57 |
.PP |
| 58 |
Before a file or text string is parsed by the \fBhtext\fR widget, |
| 59 |
all the widget's current children are destroyed. You can reload files or text |
| 60 |
without worrying about unmapping or destroying each child window beforehand. |
| 61 |
.PP |
| 62 |
Setting the either the \fB\-filename\fR or \fB\-text\fR configuration option |
| 63 |
will adjust the value of the other. If both options are set, the file |
| 64 |
takes precedence. When a new file is read using the \fB\-filename\fR option, |
| 65 |
the value of the \fB\-text\fR option is reset to the empty string. Likewise, |
| 66 |
when the \fB\-text\fR option is set, the string representing the |
| 67 |
\fB\-filename\fR option is cleared. |
| 68 |
.SH FILE FORMAT |
| 69 |
The format of \fBhtext\fP text file is typically ASCII text. |
| 70 |
Text enclosed by special double characters (by default, percent signs '%%') |
| 71 |
is interpreted and executed as Tcl commands. |
| 72 |
The special character may be specified by the \fB\-specialchar\fP option. |
| 73 |
In the following example of a \fBhtext\fP file, a button widget |
| 74 |
is appended to the text between the words "\fBa\fP" and "\fBwhich\fP". |
| 75 |
The \fIpathName\fR of the \fBhtext\fP widget is "\fB.ht\fP". |
| 76 |
.CS |
| 77 |
\fBThis will be displayed as normal text. |
| 78 |
But this will become a %% |
| 79 |
button .ht.button -text "button" -fg red |
| 80 |
.ht append .ht.button |
| 81 |
%% which can invoke a Tcl command.\fR |
| 82 |
.CE |
| 83 |
.LP |
| 84 |
.SH INDICES |
| 85 |
.PP |
| 86 |
Some of the widget operations (\fBselection\fR, \fRgotoline\fR, |
| 87 |
\fBsearch\fR, etc.) take one or more indices as arguments. |
| 88 |
An index is a string used to indicate a particular place within |
| 89 |
the text, such as the first and last characters in a range to be |
| 90 |
selected. |
| 91 |
.LP |
| 92 |
An index must have one of the following forms: |
| 93 |
.TP 12 |
| 94 |
\fIline\fB.\fIchar\fR |
| 95 |
Indicates \fIchar\fR'th character on line \fIline\fR. |
| 96 |
Both lines and characters are number from 0, so "0.0" is the |
| 97 |
first beginning of the text. \fIChar\fR may be undesignated. In |
| 98 |
this case a character position of 0 is assumed. |
| 99 |
.TP 12 |
| 100 |
\fB@\fIx\fB,\fIy\fR |
| 101 |
Indicates the character that covers the pixel whose x and y coordinates |
| 102 |
within the text's window are \fIx\fR and \fIy\fR. |
| 103 |
.TP 12 |
| 104 |
\fBend\fR |
| 105 |
Indicates the end of the text. |
| 106 |
.TP 12 |
| 107 |
\fBanchor\fR |
| 108 |
Indicates the anchor point for the selection, which is set with the |
| 109 |
\fBselection\fR operation. |
| 110 |
.TP 12 |
| 111 |
\fBsel.first\fR |
| 112 |
Indicates the first character in the selection. It is an error to |
| 113 |
use this form if the selection isn't in the entry window. |
| 114 |
.TP 12 |
| 115 |
\fBsel.last\fR |
| 116 |
.VS |
| 117 |
Indicates the character just after the last one in the selection. |
| 118 |
.VE |
| 119 |
It is an error to use this form if the selection isn't in the |
| 120 |
entry window. |
| 121 |
.SH "VARIABLES" |
| 122 |
.PP |
| 123 |
The following global Tcl variables are maintained when an |
| 124 |
\fBhtext\fR file is parsed. |
| 125 |
.TP |
| 126 |
\fBhtext(widget)\fR |
| 127 |
is the pathname of the \fBhtext\fP widget. |
| 128 |
.TP |
| 129 |
\fBhtext(file)\fR |
| 130 |
is the name of the file the \fBhtext\fP widget is currently parsing. |
| 131 |
It is the empty string when the \fB\-text\fP option is used. |
| 132 |
.TP |
| 133 |
\fBhtext(line)\fR |
| 134 |
is the current line number in the text. |
| 135 |
.PP |
| 136 |
This information might be used to construct hyper links |
| 137 |
between different files and/or lines. |
| 138 |
.LP |
| 139 |
.SH "SYNTAX" |
| 140 |
The \fBhtext\fP command creates a new Tcl command whose |
| 141 |
name is \fIpathName\fR. This command may be used to invoke various |
| 142 |
operations on the widget. It has the following general form: |
| 143 |
.DS |
| 144 |
\fIpathName oper \fR?\fIargs\fR? |
| 145 |
.DE |
| 146 |
\fIOper\fR and \fIargs\fR determine the exact behavior of the command. |
| 147 |
.PP |
| 148 |
.SH "OPERATIONS" |
| 149 |
The following operations are available for \fBhtext\fP widgets: |
| 150 |
.TP |
| 151 |
\fIpathName \fBappend \fIwindow \fR?\fIoption value\fR?... |
| 152 |
Embeds the widget \fIwindow\fP into the htext widget. \fIWindow\fP is |
| 153 |
the pathname of the widget to be embedded which must be a child of |
| 154 |
\fIpathName\fR. \fIWindow\fR will be positioned in the htext widget |
| 155 |
at the current location of the text. If \fIoption\fR and \fIvalue\fR |
| 156 |
pairs are present, they configure various aspects how \fIwindow\fR |
| 157 |
appears in \fIpathName\fR. The following options are available. |
| 158 |
.RS |
| 159 |
.TP |
| 160 |
\fB\-anchor \fIanchorPos\fR |
| 161 |
Specifies how \fIwindow\fR will be arranged if there is any extra |
| 162 |
space in the cavity surrounding the window. For example, if |
| 163 |
\fIanchorPos\fR is \fBcenter\fR then the window is centered in the |
| 164 |
cavity; if \fIanchorPos\fR is \fBw\fR then the window will be drawn |
| 165 |
such it touches the leftmost edge of the cavity. The default |
| 166 |
is \fBcenter\fR. |
| 167 |
.TP |
| 168 |
\fB\-fill \fIstyle\fR |
| 169 |
Specifies how the \fIwindow\fR should be stretched to occupy the extra |
| 170 |
space in the cavity surrounding it (if any exists). \fIStyle\fR is |
| 171 |
\fBnone\fR, \fBx\fR, \fBy\fR, \fBboth\fR. If \fIstyle\fR is \fBx\fR, |
| 172 |
the width of \fIwindow\fR is expanded to fill the cavity. If |
| 173 |
\fIstyle\fR is \fBy\fR, the height is expanded. The default is |
| 174 |
\fBnone\fR. |
| 175 |
.TP |
| 176 |
\fB\-height \fIpixels\fR |
| 177 |
Sets the height of the cavity surrounding \fIwindow\fR. If |
| 178 |
\fIpixels\fP is zero, the height of the cavity will be the same as the |
| 179 |
requested height of \fIwindow\fR. If \fIpixels\fR is less than the |
| 180 |
requested height of \fIwindow\fR, \fIwindow\fR will be reduced to fit |
| 181 |
the cavity. The default is \fB0\fR. |
| 182 |
.TP |
| 183 |
\fB\-ipadx \fIpad\fR |
| 184 |
Sets the amount of internal padding to be added to the width |
| 185 |
\fIwindow\fR. \fIPad\fR can be a list of one or two numbers. If |
| 186 |
\fIpad\fR has two elements, the left side of \fIwindow\fR is extended |
| 187 |
by the first value and the right side by the second value. If |
| 188 |
\fIpad\fR is just one value, both the left and right sides are padded |
| 189 |
by evenly by the value. The default is \fB0\fR. |
| 190 |
.TP |
| 191 |
\fB\-ipady \fIpad\fR |
| 192 |
Sets an amount of internal padding to be added to the height of |
| 193 |
\fIwindow\fR. \fIPad\fR can be a list of one or two numbers. If |
| 194 |
\fIpad\fR has two elements, the top of \fIwindow\fR is padded by the |
| 195 |
first value and the bottom by the second value. If \fIpad\fR is just |
| 196 |
one number, both the top and bottom are padded evenly by the value. |
| 197 |
The default is \fB0\fR. |
| 198 |
.TP |
| 199 |
\fB\-justify \fIjustify\fR |
| 200 |
Justifies \fIwindow\fR vertically within the cavity containing it |
| 201 |
in relation to the line of text. \fIJustify\fR is \fBtop\fP, |
| 202 |
\fBbottom\fR, or \fBcenter\fR. If \fIjustify\fR is \fBcenter\fR the |
| 203 |
widget is centered along the baseline of the line of text. The |
| 204 |
default is \fBcenter\fR. |
| 205 |
.TP |
| 206 |
\fB\-padx \fIpad\fR |
| 207 |
Sets the padding on the left and right sides of \fIwindow\fR. |
| 208 |
\fIPad\fR can be a list of one or two numbers. If \fIpad\fR has two |
| 209 |
elements, the left side of \fIwindow\fR is padded by the first value |
| 210 |
and the right side by the second value. If \fIpad\fR has just one |
| 211 |
value, both the left and right sides are padded evenly by the value. |
| 212 |
The default is \fB0\fR. |
| 213 |
.TP |
| 214 |
\fB\-pady \fIpad\fR |
| 215 |
Sets the padding above and below \fIwindow\fR. \fIPad\fR can be a |
| 216 |
list of one or two numbers. If \fIpad\fR has two elements, the area |
| 217 |
above \fIwindow\fR is padded by the first value and the area below by |
| 218 |
the second value. If \fIpad\fR is just one number, both the top and |
| 219 |
bottom are padded by the value. The default is \fB0\fR. |
| 220 |
.TP |
| 221 |
\fB\-relheight \fIvalue\fR |
| 222 |
Specifies the height of the cavity containing \fIwindow\fR relative to |
| 223 |
the height of \fIpathName\fR. \fIValue\fP is real number indicating |
| 224 |
the ratio of the height of the cavity to the height of \fIpathName\fR. |
| 225 |
As the height of \fIpathName\fR changes, so will the height of \fIwindow\fR. |
| 226 |
If \fIvalue\fR is 0.0 or less, the height of the cavity is the requested |
| 227 |
height \fIwindow\fR. The default is \fB0.0\fR. |
| 228 |
.TP |
| 229 |
\fB\-relwidth \fIvalue\fR |
| 230 |
Specifies the width of the cavity containing \fIwindow\fR relative to |
| 231 |
the width of \fIpathName\fR. \fIValue\fP is real number indicating |
| 232 |
the ratio of the width of the cavity to the width of \IpathName\fR. |
| 233 |
As the height of \fIpathName\fR changes, so will the height of \fIwindow\fR. |
| 234 |
If \fIvalue\fR is 0.0 or less, the width of the cavity is the |
| 235 |
requested width of \fIwindow\fR. The default is \fB0.0\fR. |
| 236 |
.TP |
| 237 |
\fB\-width \fIvalue\fR |
| 238 |
Species the width of the cavity containing the child window. |
| 239 |
\fIValue\fP must be in a form accepted by \fBTk_GetPixels\fR. |
| 240 |
If \fIvalue\fP is greater than zero, the cavity is resized to that width. |
| 241 |
If the requested window width is greater than the cavity's width, the |
| 242 |
window will be reduced to fit the cavity. |
| 243 |
By default, the cavity is requested width of the child window. |
| 244 |
.RE |
| 245 |
.TP |
| 246 |
\fIpathName \fBconfigure\fR ?\fIwindow\fR? ?\fIoption\fR? ?\fIvalue option value ...\fR? |
| 247 |
Queries or modifies the configuration options of the text widget or one |
| 248 |
of its embedded widgets. If no \fIwindow\fR argument is present, |
| 249 |
the htext widget itself is configured. Otherwise \fIwindow\fR |
| 250 |
is the pathname of a widget already embedded into the htext widget. |
| 251 |
Then this command configure the options for the embedded widget. |
| 252 |
.PP |
| 253 |
If \fIoption\fR isn't specified, a list describing all of the current |
| 254 |
options for \fIpathName\fR or \fIwindow\fR is returned. If |
| 255 |
\fIoption\fR is specified, but not \fIvalue\fR, then a list describing |
| 256 |
the option \fIoption\fR is returned. If one or more \fIoption\fR and |
| 257 |
\fIvalue\fR pairs are specified, then for each pair, the htext or embedded |
| 258 |
window option \fIoption\fR is set to \fIvalue\fR. |
| 259 |
.PP |
| 260 |
The following options are valid for the htext widget. |
| 261 |
.RS |
| 262 |
.TP |
| 263 |
\fB\-background\fR \fIcolor\fI |
| 264 |
Sets the background of the htext widget to \fIcolor\fR. This default is |
| 265 |
\fBwhite\fR. |
| 266 |
.TP |
| 267 |
\fB\-cursor\fR \fIcursor\fR |
| 268 |
Specifies the cursor for the htext widget. The default cursor is |
| 269 |
\fBpencil\fR. |
| 270 |
.TP |
| 271 |
\fB\-filename\fR \fIfileName\fR |
| 272 |
Specifies a \fBhtext\fP file to be displayed in the window. |
| 273 |
If the value is the empty string, the \fB\-text\fR option is used instead. |
| 274 |
See the section |
| 275 |
.SB FILE FORMAT |
| 276 |
for a description of the \fBhtext\fP |
| 277 |
file format. |
| 278 |
.TP |
| 279 |
\fB\-font\fR \fIfontName\fR |
| 280 |
Sets the font of the text in the htext widget to \fIfontName\fR. The |
| 281 |
default is \fB*-Helvetica-Bold-R-Normal-*-12-120-*\fR. |
| 282 |
.TP |
| 283 |
\fB\-foreground\fR \fIcolor\fR |
| 284 |
Sets the foreground of the htext widget to \fIcolor\fR. This is |
| 285 |
the color of the text. This default is \fBblack\fR. |
| 286 |
.TP |
| 287 |
\fB\-height\fR \fIpixels\fR |
| 288 |
Specifies the height of the htext widget window. |
| 289 |
.TP |
| 290 |
\fB\-linespacing\fR \fIpixels\fR |
| 291 |
Specifies the spacing between each line of text. The value must be in |
| 292 |
a form accepted by \fBTk_GetPixels\fR. The default value is 1 pixel. |
| 293 |
.TP |
| 294 |
\fB\-specialchar\fR \fInumber\fR |
| 295 |
Specifies the ASCII value of the special double character delimiters. |
| 296 |
In \fBhtext\fP files, the text between these special characters is |
| 297 |
evaluated as a block of Tcl commands. The default special character |
| 298 |
is the \fB0x25\fR (percent sign). |
| 299 |
.TP |
| 300 |
\fB\-text\fR \fItext\fR |
| 301 |
Specifies the text to be displayed in the htext widget. \fIText\fR |
| 302 |
can be any valid string of characters. See |
| 303 |
.SB "FILE FORMAT" |
| 304 |
for a description. |
| 305 |
.TP |
| 306 |
\fB\-xscrollcommand\fR \fIstring\fR |
| 307 |
Specifies the prefix for a command used to communicate with horizontal |
| 308 |
scrollbars. When the view in the htext widget's window changes (or |
| 309 |
whenever anything else occurs that could change the display in a |
| 310 |
scrollbar, such as a change in the total size of the widget's |
| 311 |
contents), the widget invoke \fIstring\fR concatenated by two numbers. |
| 312 |
Each of the numbers is a fraction between 0 and 1, which indicates a |
| 313 |
position in the document. If this option is not specified, then no |
| 314 |
command will be executed. |
| 315 |
.TP |
| 316 |
\fB\-yscrollcommand\fR \fIstring\fR |
| 317 |
Specifies the prefix for a command used to communicate with vertical |
| 318 |
scrollbars. When the view in the htext widget's window changes (or |
| 319 |
whenever anything else occurs that could change the display in a |
| 320 |
scrollbar, such as a change in the total size of the widget's |
| 321 |
contents), the widget invoke \fIstring\fR concatenated by two numbers. |
| 322 |
Each of the numbers is a fraction between 0 and 1, which indicates a |
| 323 |
position in the document. If this option is not specified, then no |
| 324 |
command will be executed. |
| 325 |
.TP |
| 326 |
\fB\-width\fR \fIpixels\fR |
| 327 |
Specifies the desired width of the viewport window. If the |
| 328 |
\fIpixels\fR is less than one, the window will grow to accommodate the |
| 329 |
widest line of text. |
| 330 |
.TP |
| 331 |
\fB\-xscrollunits\fR \fIpixels\fR |
| 332 |
Specifies the horizontal scrolling distance. The default is 10 pixels. |
| 333 |
.TP |
| 334 |
\fB\-yscrollunits\fR \fIpixels\fR |
| 335 |
Specifies the vertical scrolling distance. The default is 10 pixels. |
| 336 |
.RE |
| 337 |
.TP |
| 338 |
\fIpathName \fBgotoline \fR?\fIindex\fR? |
| 339 |
Sets the top line of the text to \fIindex\fP. \fIIndex\fP must be |
| 340 |
a valid text index (the character offset is ignored). |
| 341 |
If an \fIindex\fP isn't provided, the current line number is |
| 342 |
returned. |
| 343 |
.TP |
| 344 |
\fIpathName \fBscan mark \fIposition\fR |
| 345 |
Records \fIposition\fR and the current view in the text window; used in |
| 346 |
conjunction with later \fBscan dragto\fR commands. \fIPosition\fR must |
| 347 |
be in the form "\fI@x,y\fR, where \fIx\fR and \fIy\fR are window coordinates. |
| 348 |
Typically this |
| 349 |
command is associated with a mouse button press in the widget. It |
| 350 |
returns an empty string. |
| 351 |
.TP |
| 352 |
\fIpathName \fBscan dragto \fIposition\fR |
| 353 |
Computes the difference between \fIposition\fR and the position registered |
| 354 |
in the last \fBscan mark\fR command for the widget. |
| 355 |
The view is then adjusted |
| 356 |
up or down by 10 times the difference in coordinates. This command is |
| 357 |
can be associated with mouse motion events to produce the effect of |
| 358 |
dragging the text at high speed through the window. |
| 359 |
\fIPosition\fR must be in the form "\fI@x,y\fR, where \fIx\fR and |
| 360 |
\fIy\fR are window coordinates. The command returns an empty string. |
| 361 |
.TP |
| 362 |
\fIpathName \fBsearch \fIpattern\fR ?\fIfrom\fR? ?\fIto\fR? |
| 363 |
Returns the number of the next line matching \fIpattern\fR. \fIPattern\fR is |
| 364 |
a string which obeys the matching rules of \fBTcl_StringMatch\fR. |
| 365 |
\fIFrom\fR and \fIto\fR are text line numbers (inclusive) which |
| 366 |
bound the search. |
| 367 |
If no match for \fIpattern\fR can be found, \fB-1\fR is returned. |
| 368 |
.TP |
| 369 |
\fIpathName \fBxview \fR?\fIposition\fR? |
| 370 |
Moves the viewport horizontally to the new text x-coordinate position. |
| 371 |
\fIPosition\fR is the offset from the left side of the text to the current |
| 372 |
position and must be in a form accepted by \fBTk_GetPixels\fR. If \fIposition\fR |
| 373 |
is not present, the current text position is returned. |
| 374 |
.TP |
| 375 |
\fIpathName \fByview \fR?\fIposition\fR? |
| 376 |
Moves the viewport vertically to the new text y-coordinate position. |
| 377 |
\fIPosition\fR is the offset from the top of the text to the current |
| 378 |
position and must be in a form accepted by \fBTk_GetPixels\fR. If \fIposition\fR |
| 379 |
is not present, the current text position is returned. |
| 380 |
.SH BUGS |
| 381 |
Text with embedded tabs can be obscured by child windows when scrolled |
| 382 |
horizontally. |
| 383 |
.SH KEYWORDS |
| 384 |
hypertext, widget |