]> www.wagner.pp.ru Git - oss/ck.git/blob - doc/text.n
Ck console graphics toolkit
[oss/ck.git] / doc / text.n
1 '\"
2 '\" Copyright (c) 1992 The Regents of the University of California.
3 '\" Copyright (c) 1994-1995 Sun Microsystems, Inc.
4 '\" Copyright (c) 1996-1999 Christian Werner
5 '\"
6 '\" See the file "license.terms" for information on usage and redistribution
7 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8 '\" 
9 .so man.macros
10 .TH text n 8.0 Ck "Ck Built-In Commands"
11 .BS
12 '\" Note:  do not modify the .SH NAME line immediately below!
13 .SH NAME
14 text \- Create and manipulate text widgets
15 .SH SYNOPSIS
16 \fBtext\fI \fIpathName \fR?\fIoptions\fR?
17 .SH "STANDARD OPTIONS"
18 .LP
19 .nf
20 .ta 4c 8c 12c
21 \fBattributes\fR        \fBselectAttributes\fR  \fBselectForeground\fR  \fBxScrollCommand\fR
22 \fBbackground\fR        \fBselectBackground\fR  \fBtakeFocus\fR \fByScrollCommand\fR
23 \fBforeground\fR
24 .fi
25 .LP
26 See the ``options'' manual entry for details on the standard options.
27 .SH "WIDGET-SPECIFIC OPTIONS"
28 .ta 4c
29 .LP
30 .nf
31 Name:   \fBheight\fR
32 Class:  \fBHeight\fR
33 Command-Line Switch:    \fB\-height\fR
34 .fi
35 .IP
36 Specifies the desired height for the window, in screen lines.
37 Must be at least one.
38 .LP
39 .nf
40 Name:   \fBstate\fR
41 Class:  \fBState\fR
42 Command-Line Switch:    \fB\-state\fR
43 .fi
44 .IP
45 Specifies one of two states for the text:  \fBnormal\fR or \fBdisabled\fR.
46 If the text is disabled then characters may not be inserted or deleted
47 and no insertion cursor will be displayed, even if the input focus is
48 in the widget.
49 .LP
50 .nf
51 Name:   \fBtabs\fR
52 Class:  \fBTabs\fR
53 Command-Line Switch:    \fB\-tabs\fR
54 .fi
55 .IP
56 Specifies a set of tab stops for the window.  The option's value consists
57 of a list of screen distances giving the positions of the tab stops.  Each
58 position may optionally be followed in the next list element
59 by one of the keywords \fBleft\fR, \fBright\fR, \fBcenter\fR,
60 or \fBnumeric\fR, which specifies how to justify
61 text relative to the tab stop.  \fBLeft\fR is the default; it causes
62 the text following the tab character to be positioned with its left edge
63 at the tab position.  \fBRight\fR means that the right edge of the text
64 following the tab character is positioned at the tab position, and
65 \fBcenter\fR means that the text is centered at the tab position.
66 \fBNumeric\fR means that the decimal point in the text is positioned
67 at the tab position;  if there is no decimal point then the least
68 significant digit of the number is positioned just to the left of the
69 tab position;  if there is no number in the text then the text is
70 right-justified at the tab position.
71 For example, \fB\-tabs {2 left 4 6 center}\fR creates three
72 tab stops at two-column intervals;  the first two use left
73 justification and the third uses center justification.
74 If the list of tab stops does not have enough elements to cover all
75 of the tabs in a text line, then Ck extrapolates new tab stops using
76 the spacing and alignment from the last tab stop in the list.
77 The value of the \fBtabs\fR option may be overridden by \fB\-tabs\fR
78 options in tags.
79 If no \fB\-tabs\fR option is specified, or if it is specified as
80 an empty list, then Ck uses default tabs spaced every eight columns.
81 .LP
82 .nf
83 Name:   \fBwidth\fR
84 Class:  \fBWidth\fR
85 Command-Line Switch:    \fB\-width\fR
86 .fi
87 .IP
88 Specifies the desired width for the window in screen columns.
89 .LP
90 .nf
91 Name:   \fBwrap\fR
92 Class:  \fBWrap\fR
93 Command-Line Switch:    \fB\-wrap\fR
94 .fi
95 .IP
96 Specifies how to handle lines in the text that are too long to be
97 displayed in a single line of the text's window.
98 The value must be \fBnone\fR or \fBchar\fR or \fBword\fR.
99 A wrap mode of \fBnone\fR means that each line of text appears as
100 exactly one line on the screen;  extra characters that don't fit
101 on the screen are not displayed.
102 In the other modes each line of text will be broken up into several
103 screen lines if necessary to keep all the characters visible.
104 In \fBchar\fR mode a screen line break may occur after any character;
105 in \fBword\fR mode a line break will only be made at word boundaries.
106 .BE
107
108 .SH DESCRIPTION
109 .PP
110 The \fBtext\fR command creates a new window (given by the
111 \fIpathName\fR argument) and makes it into a text widget.
112 Additional
113 options, described above, may be specified on the command line
114 or in the option database
115 to configure aspects of the text such as its colors and attributes.
116 The \fBtext\fR command returns the path name of the new window.
117 .PP
118 A text widget displays one or more lines of text and allows that
119 text to be edited.
120 Text widgets support two different kinds of annotations on the
121 text, called tags and marks.
122 Tags allow different portions of the text
123 to be displayed with different attributes and colors.
124 .\" In addition, Tcl commands can be associated with tags so
125 .\" that scripts are invoked when particular actions such as keystrokes
126 .\" and mouse button presses occur in particular ranges of the text.
127 See TAGS below for more details.
128 .PP
129 The second form of annotation consists of marks, which are floating
130 markers in the text.
131 Marks are used to keep track of various interesting positions in the
132 text as it is edited.
133 See MARKS below for more details.
134
135 .SH INDICES
136 .PP
137 Many of the widget commands for texts take one or more indices
138 as arguments.
139 An index is a string used to indicate a particular place within
140 a text, such as a place to insert characters or one endpoint of a
141 range of characters to delete.
142 Indices have the syntax
143 .IP
144 \fIbase modifier modifier modifier ...\fR
145 .LP
146 Where \fIbase\fR gives a starting point and the \fImodifier\fRs
147 adjust the index from the starting point (e.g. move forward or
148 backward one character).  Every index must contain a \fIbase\fR,
149 but the \fImodifier\fRs are optional.
150 .LP
151 The \fIbase\fR for an index must have one of the following forms:
152 .TP 12
153 \fIline\fB.\fIchar\fR
154 Indicates \fIchar\fR'th character on line \fIline\fR.
155 Lines are numbered from 1 for consistency with other UNIX programs
156 that use this numbering scheme.
157 Within a line, characters are numbered from 0.
158 .TP 12
159 \fB@\fIx\fB,\fIy\fR
160 Indicates the character that covers the place whose x and y coordinates
161 within the text's window are \fIx\fR and \fIy\fR.
162 .TP 12
163 \fBend\fR
164 Indicates the end of the text (the character just after the last
165 newline).
166 .TP 12
167 \fImark\fR
168 Indicates the character just after the mark whose name is \fImark\fR.
169 .TP 12
170 \fItag\fB.first\fR
171 Indicates the first character in the text that has been tagged with
172 \fItag\fR.
173 This form generates an error if no characters are currently tagged
174 with \fItag\fR.
175 .TP 12
176 \fItag\fB.last\fR
177 Indicates the character just after the last one in the text that has
178 been tagged with \fItag\fR.
179 This form generates an error if no characters are currently tagged
180 with \fItag\fR.
181 .LP
182 If modifiers follow the base index, each one of them must have one
183 of the forms listed below.  Keywords such as \fBchars\fR and \fBwordend\fR
184 may be abbreviated as long as the abbreviation is unambiguous.
185 .TP
186 \fB+ \fIcount\fB chars\fR
187 Adjust the index forward by \fIcount\fR characters, moving to later
188 lines in the text if necessary.  If there are fewer than \fIcount\fR
189 characters in the text after the current index, then set the index
190 to the last character in the text.
191 Spaces on either side of \fIcount\fR are optional.
192 .TP
193 \fB\- \fIcount\fB chars\fR
194 Adjust the index backward by \fIcount\fR characters, moving to earlier
195 lines in the text if necessary.  If there are fewer than \fIcount\fR
196 characters in the text before the current index, then set the index
197 to the first character in the text.
198 Spaces on either side of \fIcount\fR are optional.
199 .TP
200 \fB+ \fIcount\fB lines\fR
201 Adjust the index forward by \fIcount\fR lines, retaining the same
202 character position within the line.  If there are fewer than \fIcount\fR
203 lines after the line containing the current index, then set the index
204 to refer to the same character position on the last line of the text.
205 Then, if the line is not long enough to contain a character at the indicated
206 character position, adjust the character position to refer to the last
207 character of the line (the newline).
208 Spaces on either side of \fIcount\fR are optional.
209 .TP
210 \fB\- \fIcount\fB lines\fR
211 Adjust the index backward by \fIcount\fR lines, retaining the same
212 character position within the line.  If there are fewer than \fIcount\fR
213 lines before the line containing the current index, then set the index
214 to refer to the same character position on the first line of the text.
215 Then, if the line is not long enough to contain a character at the indicated
216 character position, adjust the character position to refer to the last
217 character of the line (the newline).
218 Spaces on either side of \fIcount\fR are optional.
219 .TP
220 \fBlinestart\fR
221 Adjust the index to refer to the first character on the line.
222 .TP
223 \fBlineend\fR
224 Adjust the index to refer to the last character on the line (the newline).
225 .TP
226 \fBwordstart\fR
227 Adjust the index to refer to the first character of the word containing
228 the current index.  A word consists of any number of adjacent characters
229 that are letters, digits, or underscores, or a single character that
230 is not one of these.
231 .TP
232 \fBwordend\fR
233 Adjust the index to refer to the character just after the last one of the
234 word containing the current index.  If the current index refers to the last
235 character of the text then it is not modified.
236 .LP
237 If more than one modifier is present then they are applied in
238 left-to-right order.  For example, the index ``\fBend \- 1 chars\fR''
239 refers to the next-to-last character in the text and
240 ``\fBinsert wordstart \- 1 c\fR'' refers to the character just before
241 the first one in the word containing the insertion cursor.
242
243 .SH TAGS
244 .PP
245 The first form of annotation in text widgets is a tag.
246 A tag is a textual string that is associated with some of the characters
247 in a text.
248 Tags may contain arbitrary characters, but it is probably best to
249 avoid using the the characters `` '' (space), \fB+\fR, or \fB\-\fR:
250 these characters have special meaning in indices, so tags containing
251 them can't be used as indices.
252 There may be any number of tags associated with characters in a
253 text.
254 Each tag may refer to a single character, a range of characters, or
255 several ranges of characters.
256 An individual character may have any number of tags associated with it.
257 .PP
258 A priority order is defined among tags, and this order is used in
259 implementing some of the tag-related functions described below.
260 When a tag is defined (by associating it with characters or setting
261 its display options
262 .\" or binding commands
263 to it), it is given
264 a priority higher than any existing tag.
265 The priority order of tags may be redefined using the
266 ``\fIpathName \fBtag raise\fR'' and ``\fIpathName \fBtag lower\fR''
267 widget commands.
268 .PP
269 .\" Tags serve three purposes in text widgets.
270 Tags serve two purposes in text widgets.
271 First, they control the way information is displayed on the screen.
272 By default, characters are displayed as determined by the
273 \fBbackground\fR, \fBattributes\fR, and \fBforeground\fR options for the
274 text widget.
275 However, display options may be associated with individual tags
276 using the ``\fIpathName \fBtag configure\fR'' widget command.
277 If a character has been tagged, then the display options associated
278 with the tag override the default display style.
279 The following options are currently supported for tags:
280 .TP
281 \fB\-attributes \fIattrList\fR
282 \fIAttrList\fR specifies the attributes to use for characters associated
283 with the tag.
284 .TP
285 \fB\-background \fIcolor\fR
286 \fIColor\fR specifies the background color to use for characters
287 associated with the tag.
288 .TP
289 \fB\-foreground \fIcolor\fR
290 \fIColor\fR specifies the color to use when drawing text and other
291 foreground information such as underlines.
292 It may have any of the forms accepted by \fBTk_GetColor\fR.
293 .TP
294 \fB\-justify \fIjustify\fR
295 If the first character of a display line has a tag for which this
296 option has been specified, then \fIjustify\fR determines how to
297 justify the line.
298 It must be one of \fBleft\fR, \fBright\fR, or \fBcenter\fR.
299 If a line wraps, then the justification for each line on the
300 display is determined by the first character of that display line.
301 .TP
302 \fB\-lmargin1 \fIcolumns\fR
303 If the first character of a text line has a tag for which this
304 option has been specified, then \fIcolumns\fR specifies how
305 much the line should be indented from the left edge of the
306 window.
307 If a line of text wraps, this option only applies to the
308 first line on the display;  the \fB\-lmargin2\fR option controls
309 the indentation for subsequent lines.
310 .TP
311 \fB\-lmargin2 \fIcolumns\fR
312 If the first character of a display line has a tag for which this
313 option has been specified, and if the display line is not the
314 first for its text line (i.e., the text line has wrapped), then
315 \fIcolumns\fR specifies how much the line should be indented from
316 the left edge of the window.
317 This option is only used when wrapping is enabled, and it only
318 applies to the second and later display lines for a text line.
319 .TP
320 \fB\-rmargin \fIcolumns\fR
321 If the first character of a display line has a tag for which this
322 option has been specified, then \fIcolumns\fR specifies how wide
323 a margin to leave between the end of the line and the right
324 edge of the window.
325 This option is only used when wrapping is enabled.
326 If a text line wraps, the right margin for each line on the
327 display is determined by the first character of that display
328 line.
329 .TP
330 \fB\-tabs \fItabList\fR
331 \fITabList\fR specifies a set of tab stops in the same form
332 as for the \fB\-tabs\fR option for the text widget.  This
333 option only applies to a display line if it applies to the
334 first character on that display line.
335 If this option is specified as an empty string, it cancels
336 the option, leaving it unspecified for the tag (the default).
337 If the option is specified as a non-empty string that is
338 an empty list, such as \fB\-tags\0{\0}\fR, then it requests
339 default 8-character tabs as described for the \fBtags\fR
340 widget option.
341 .TP
342 \fB\-wrap \fImode\fR
343 \fIMode\fR specifies how to handle lines that are wider than the
344 text's window.
345 It has the same legal values as the \fB\-wrap\fR option
346 for the text widget:  \fBnone\fR, \fBchar\fR, or \fBword\fR.
347 If this tag option is specified, it overrides the \fB\-wrap\fR option
348 for the text widget.
349 .PP
350 If a character has several tags associated with it, and if their
351 display options conflict, then the options of the highest priority
352 tag are used.
353 If a particular display option hasn't been specified for a
354 particular tag, or if it is specified as an empty string, then
355 that option will never be used;  the next-highest-priority
356 tag's option will used instead.
357 If no tag specifies a particular display option, then the default
358 style for the widget will be used.
359 .\" .PP
360 .\" The second purpose for tags is event bindings.
361 .\" You can associate bindings with a tag in much the same way you can
362 .\" associate bindings with a widget class:  whenever particular X
363 .\" events occur on characters with the given tag, a given
364 .\" Tcl command will be executed.
365 .\" Tag bindings can be used to give behaviors to ranges of characters;
366 .\" among other things, this allows hypertext-like
367 .\" features to be implemented.
368 .\" For details, see the description of the \fBtag bind\fR widget
369 .\" command below.
370 .PP
371 .\" The third use for tags is in managing the selection.
372 The second use for tags is in managing the selection.
373 See THE SELECTION below.
374
375 .SH MARKS
376 .PP
377 The second form of annotation in text widgets is a mark.
378 Marks are used for remembering particular places in a text.
379 They are something like tags, in that they have names and
380 they refer to places in the file, but a mark isn't associated
381 with particular characters.
382 Instead, a mark is associated with the gap between two characters.
383 Only a single position may be associated with a mark at any given
384 time.
385 If the characters around a mark are deleted the mark will still
386 remain;  it will just have new neighbor characters.
387 In contrast, if the characters containing a tag are deleted then
388 the tag will no longer have an association with characters in
389 the file.
390 Marks may be manipulated with the ``\fIpathName \fBmark\fR'' widget
391 command, and their current locations may be determined by using the
392 mark name as an index in widget commands.
393 .PP
394 Each mark also has a \fIgravity\fR, which is either \fBleft\fR or
395 \fBright\fR.
396 The gravity for a mark specifies what happens to the mark when
397 text is inserted at the point of the mark.
398 If a mark has left gravity, then the mark is treated as if it
399 were attached to the character on its left, so the mark will
400 remain to the left of any text inserted at the mark position.
401 If the mark has right gravity, new text inserted at the mark
402 position will appear to the right of the mark.  The gravity
403 for a mark defaults to \fBright\fR.
404 .PP
405 The name space for marks is different from that for tags:  the
406 same name may be used for both a mark and a tag, but they will refer
407 to different things.
408 .PP
409 Two marks have special significance.
410 First, the mark \fBinsert\fR is associated with the insertion cursor,
411 as described under THE INSERTION CURSOR below.
412 Second, the mark \fBcurrent\fR is associated with the character
413 closest to the mouse and is adjusted automatically to track the
414 mouse position and any changes to the text in the widget (one
415 exception:  \fBcurrent\fR is not updated in response to mouse
416 motions if a mouse button is down;  the update will be deferred
417 until all mouse buttons have been released).
418 Neither of these special marks may be deleted.
419
420 .SH THE SELECTION
421 .PP
422 Selection support is implemented via tags.
423 The \fBsel\fR tag is automatically defined when a text widget is
424 created, and it may not be deleted with the ``\fIpathName \fBtag delete\fR''
425 widget command.  Furthermore, the \fBselectBackground\fR,
426 \fBselectAttributes\fR, and \fBselectForeground\fR options for
427 the text widget are tied to the \fB\-background\fR,
428 \fB\-attributes\fR, and \fB\-foreground\fR options for the \fBsel\fR
429 tag:  changes in either will automatically be reflected in the
430 other.
431
432 .SH THE INSERTION CURSOR
433 .PP
434 The mark named \fBinsert\fR has special significance in text widgets.
435 It is defined automatically when a text widget is created and it
436 may not be unset with the ``\fIpathName \fBmark unset\fR'' widget
437 command.
438 The \fBinsert\fR mark represents the position of the insertion
439 cursor, and the insertion cursor will automatically be moved to
440 this point whenever the text widget has the input focus.
441
442 .SH "WIDGET COMMAND"
443 .PP
444 The \fBtext\fR command creates a new Tcl command whose
445 name is the same as the path name of the text's window.  This
446 command may be used to invoke various
447 operations on the widget.  It has the following general form:
448 .DS C
449 \fIpathName option \fR?\fIarg arg ...\fR?
450 .DE
451 \fIPathName\fR is the name of the command, which is the same as
452 the text widget's path name.  \fIOption\fR and the \fIarg\fRs
453 determine the exact behavior of the command.  The following
454 commands are possible for text widgets:
455 .TP
456 \fIpathName \fBbbox \fIindex\fR
457 Returns a list of four elements describing the screen area
458 of the character given by \fIindex\fR.
459 The first two elements of the list give the x and y coordinates
460 of the upper-left corner of the area occupied by the
461 character, and the last two elements give the width and height
462 of the area.
463 If the character is not visible on the screen then the return
464 value is an empty list.
465 .TP
466 \fIpathName \fBcget\fR \fIoption\fR
467 Returns the current value of the configuration option given
468 by \fIoption\fR.
469 \fIOption\fR may have any of the values accepted by the \fBtext\fR
470 command.
471 .TP
472 \fIpathName \fBcompare\fR \fIindex1 op index2\fR
473 Compares the indices given by \fIindex1\fR and \fIindex2\fR according
474 to the relational operator given by \fIop\fR, and returns 1 if
475 the relationship is satisfied and 0 if it isn't.
476 \fIOp\fR must be one of the operators <, <=, ==, >=, >, or !=.
477 If \fIop\fR is == then 1 is returned if the two indices refer to
478 the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR
479 refers to an earlier character in the text than \fIindex2\fR, and
480 so on.
481 .TP
482 \fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
483 Query or modify the configuration options of the widget.
484 If no \fIoption\fR is specified, returns a list describing all of
485 the available options for \fIpathName\fR. If \fIoption\fR is specified
486 with no \fIvalue\fR, then the command returns a list describing the
487 one named option (this list will be identical to the corresponding
488 sublist of the value returned if no \fIoption\fR is specified).  If
489 one or more \fIoption\-value\fR pairs are specified, then the command
490 modifies the given widget option(s) to have the given value(s);  in
491 this case the command returns an empty string.
492 \fIOption\fR may have any of the values accepted by the \fBtext\fR
493 command.
494 .TP
495 \fIpathName \fBdebug \fR?\fIboolean\fR?
496 If \fIboolean\fR is specified, then it must have one of the true or
497 false values accepted by Tcl_GetBoolean.
498 If the value is a true one then internal consistency checks will be
499 turned on in the B-tree code associated with text widgets.
500 If \fIboolean\fR has a false value then the debugging checks will
501 be turned off.
502 In either case the command returns an empty string.
503 If \fIboolean\fR is not specified then the command returns \fBon\fR
504 or \fBoff\fR to indicate whether or not debugging is turned on.
505 There is a single debugging switch shared by all text widgets:  turning
506 debugging on or off in any widget turns it on or off for all widgets.
507 For widgets with large amounts of text, the consistency checks may
508 cause a noticeable slow-down.
509 .TP
510 \fIpathName \fBdelete \fIindex1 \fR?\fIindex2\fR?
511 Delete a range of characters from the text.
512 If both \fIindex1\fR and \fIindex2\fR are specified, then delete
513 all the characters starting with the one given by \fIindex1\fR
514 and stopping just before \fIindex2\fR (i.e. the character at
515 \fIindex2\fR is not deleted).
516 If \fIindex2\fR doesn't specify a position later in the text
517 than \fIindex1\fR then no characters are deleted.
518 If \fIindex2\fR isn't specified then the single character at
519 \fIindex1\fR is deleted.
520 It is not allowable to delete characters in a way that would leave
521 the text without a newline as the last character.
522 The command returns an empty string.
523 .TP
524 \fIpathName \fBdlineinfo \fIindex\fR
525 Returns a list with five elements describing the area occupied
526 by the display line containing \fIindex\fR.
527 The first two elements of the list give the x and y coordinates
528 of the upper-left corner of the area occupied by the
529 line, the third and fourth elements give the width and height
530 of the area, and the fifth element gives the position of the baseline
531 for the line (always zero).
532 All of this information is measured in screen coordinates.
533 If the current wrap mode is \fBnone\fR and the line extends beyond
534 the boundaries of the window,
535 the area returned reflects the entire area of the line, including the
536 portions that are out of the window.
537 If the line is shorter than the full width of the window then the
538 area returned reflects just the portion of the line that is occupied
539 by characters.
540 If the display line containing \fIindex\fR is not visible on
541 the screen then the return value is an empty list.
542 .TP
543 \fIpathName \fBget \fIindex1 \fR?\fIindex2\fR?
544 Return a range of characters from the text.
545 The return value will be all the characters in the text starting
546 with the one whose index is \fIindex1\fR and ending just before
547 the one whose index is \fIindex2\fR (the character at \fIindex2\fR
548 will not be returned).
549 If \fIindex2\fR is omitted then the single character at \fIindex1\fR
550 is returned.
551 If there are no characters in the specified range (e.g. \fIindex1\fR
552 is past the end of the file or \fIindex2\fR is less than or equal
553 to \fIindex1\fR) then an empty string is returned.
554 .TP
555 \fIpathName \fBindex \fIindex\fR
556 Returns the position corresponding to \fIindex\fR in the form
557 \fIline.char\fR where \fIline\fR is the line number and \fIchar\fR
558 is the character number.
559 \fIIndex\fR may have any of the forms described under INDICES above.
560 .TP
561 \fIpathName \fBinsert \fIindex chars \fR?\fItagList chars tagList ...\fR?
562 Inserts all of the \fIchars\fR arguments just before the character at
563 \fIindex\fR.
564 If \fIindex\fR refers to the end of the text (the character after
565 the last newline) then the new text is inserted just before the
566 last newline instead.
567 If there is a single \fIchars\fR argument and no \fItagList\fR, then
568 the new text will receive any tags that are present on both the
569 character before and the character after the insertion point; if a tag
570 is present on only one of these characters then it will not be
571 applied to the new text.
572 If \fItagList\fR is specified then it consists of a list of
573 tag names;  the new characters will receive all of the tags in
574 this list and no others, regardless of the tags present around
575 the insertion point.
576 If multiple \fIchars\fR\-\fItagList\fR argument pairs are present,
577 they produce the same effect as if a separate \fBinsert\fR widget
578 command had been issued for each pair, in order.
579 The last \fItagList\fR argument may be omitted.
580 .TP
581 \fIpathName \fBmark \fIoption \fR?\fIarg arg ...\fR?
582 This command is used to manipulate marks.  The exact behavior of
583 the command depends on the \fIoption\fR argument that follows
584 the \fBmark\fR argument.  The following forms of the command
585 are currently supported:
586 .RS
587 .TP
588 \fIpathName \fBmark gravity \fImarkName\fR ?\fIdirection\fR?
589 If \fIdirection\fR is not specified, returns \fBleft\fR or \fBright\fR
590 to indicate which of its adjacent characters \fImarkName\fR is attached
591 to.
592 If \fIdirection\fR is specified, it must be \fBleft\fR or \fBright\fR;
593 the gravity of \fImarkName\fR is set to the given value.
594 .TP
595 \fIpathName \fBmark names\fR
596 Returns a list whose elements are the names of all the marks that
597 are currently set.
598 .TP
599 \fIpathName \fBmark set \fImarkName index\fR
600 Sets the mark named \fImarkName\fR to a position just before the
601 character at \fIindex\fR.
602 If \fImarkName\fR already exists, it is moved from its old position;
603 if it doesn't exist, a new mark is created.
604 This command returns an empty string.
605 .TP
606 \fIpathName \fBmark unset \fImarkName \fR?\fImarkName markName ...\fR?
607 Remove the mark corresponding to each of the \fImarkName\fR arguments.
608 The removed marks will not be usable in indices and will not be
609 returned by future calls to ``\fIpathName \fBmark names\fR''.
610 This command returns an empty string.
611 .RE
612 .TP
613 \fIpathName \fBsearch \fR?\fIswitches\fR? \fIpattern index \fR?\fIstopIndex\fR?
614 Searches the text in \fIpathName\fR starting at \fIindex\fR for a range
615 of characters that matches \fIpattern\fR.
616 If a match is found, the index of the first character in the match is
617 returned as result;  otherwise an empty string is returned.
618 One or more of the following switches (or abbreviations thereof)
619 may be specified to control the search:
620 .RS
621 .TP
622 \fB\-forwards\fR
623 The search will proceed forward through the text, finding the first
624 matching range starting at a position later than \fIindex\fR.
625 This is the default.
626 .TP
627 \fB\-backwards\fR
628 The search will proceed backward through the text, finding the
629 matching range closest to \fIindex\fR whose first character
630 is before \fIindex\fR.
631 .TP
632 \fB\-exact\fR
633 Use exact matching:  the characters in the matching range must be
634 identical to those in \fIpattern\fR.
635 This is the default.
636 .TP
637 \fB\-regexp\fR
638 Treat \fIpattern\fR as a regular expression and match it against
639 the text using the rules for regular expressions (see the \fBregexp\fR
640 command for details).
641 .TP
642 \fB\-nocase\fR
643 Ignore case differences between the pattern and the text.
644 .TP
645 \fB\-count\fI varName\fR
646 The argument following \fB\-count\fR gives the name of a variable;
647 if a match is found, the number of characters in the matching
648 range will be stored in the variable.
649 .TP
650 \fB\-\-\fR
651 This switch has no effect except to terminate the list of switches:
652 the next argument will be treated as \fIpattern\fR even if it starts
653 with \fB\-\fR.
654 .LP
655 The matching range must be entirely within a single line of text.
656 For regular expression matching the newlines are removed from the ends
657 of the lines before matching:  use the \fB$\fR feature in regular
658 expressions to match the end of a line.
659 For exact matching the newlines are retained.
660 If \fIstopIndex\fR is specified, the search stops at that index:
661 for forward searches, no match at or after \fIstopIndex\fR will
662 be considered;  for backward searches, no match earlier in the
663 text than \fIstopIndex\fR will be considered.
664 If \fIstopIndex\fR is omitted, the entire text will be searched:
665 when the beginning or end of the text is reached, the search
666 continues at the other end until the starting location is reached
667 again;  if \fIstopIndex\fR is specified, no wrap-around will occur.
668 .RE
669 .TP
670 \fIpathName \fBsee \fIindex\fR
671 Adjusts the view in the window so that the character given by \fIindex\fR
672 is visible.
673 If \fIindex\fR is already visible then the command does nothing.
674 If \fIindex\fR is a short distance out of view, the command
675 adjusts the view just enough to make \fIindex\fR visible at the
676 edge of the window.
677 If \fIindex\fR is far out of view, then the command centers
678 \fIindex\fR in the window.
679 .TP
680 \fIpathName \fBtag \fIoption \fR?\fIarg arg ...\fR?
681 This command is used to manipulate tags.  The exact behavior of the
682 command depends on the \fIoption\fR argument that follows the
683 \fBtag\fR argument.  The following forms of the command are currently
684 supported:
685 .RS
686 .TP
687 \fIpathName \fBtag add \fItagName index1 \fR?\fIindex2 index1 index2 ...\fR?
688 Associate the tag \fItagName\fR with all of the characters starting
689 with \fIindex1\fR and ending just before
690 \fIindex2\fR (the character at \fIindex2\fR isn't tagged).
691 A single command may contain any number of \fIindex1\fR\-\fIindex2\fR
692 pairs.
693 If the last \fIindex2\fR is omitted then the single character at
694 \fIindex1\fR is tagged.
695 If there are no characters in the specified range (e.g. \fIindex1\fR
696 is past the end of the file or \fIindex2\fR is less than or equal
697 to \fIindex1\fR) then the command has no effect.
698 .\" .TP
699 .\" \fIpathName \fBtag bind \fItagName\fR ?\fIsequence\fR? ?\fIscript\fR?
700 .\" This command associates \fIscript\fR with the tag given by
701 .\" \fItagName\fR.
702 .\" Whenever the event sequence given by \fIsequence\fR occurs for a
703 .\" character that has been tagged with \fItagName\fR,
704 .\" the script will be invoked.
705 .\" This widget command is similar to the \fBbind\fR command except that
706 .\" it operates on characters in a text rather than entire widgets.
707 .\" See the \fBbind\fR manual entry for complete details
708 .\" on the syntax of \fIsequence\fR and the substitutions performed
709 .\" on \fIscript\fR before invoking it.
710 .\" If all arguments are specified then a new binding is created, replacing
711 .\" any existing binding for the same \fIsequence\fR and \fItagName\fR
712 .\" (if the first character of \fIscript\fR is ``+'' then \fIscript\fR
713 .\" augments an existing binding rather than replacing it).
714 .\" In this case the return value is an empty string.
715 .\" If \fIscript\fR is omitted then the command returns the \fIscript\fR
716 .\" associated with \fItagName\fR and \fIsequence\fR (an error occurs
717 .\" if there is no such binding).
718 .\" If both \fIscript\fR and \fIsequence\fR are omitted then the command
719 .\" returns a list of all the sequences for which bindings have been
720 .\" defined for \fItagName\fR.
721 .\" .RS
722 .\" .LP
723 .\" The only events for which bindings may be specified are those related
724 .\" to the mouse and keyboard, such as \fBEnter\fR, \fBLeave\fR,
725 .\" \fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR.
726 .\" Event bindings for a text widget use the \fBcurrent\fR mark
727 .\" described under MARKS above.
728 .\" An \fBEnter\fR event triggers for a tag when the tag first
729 .\" becomes present on the current character, and a \fBLeave\fR
730 .\" event triggers for a tag when it ceases to be present on
731 .\" the current character.
732 .\" \fBEnter\fR and \fBLeave\fR events can happen either because the
733 .\" \fBcurrent\fR mark moved or because the character at that
734 .\" position changed.
735 .\" Note that these events are different than \fBEnter\fR and \fBLeave\fR
736 .\" events for windows.
737 .\" Mouse and keyboard events are directed to the current character.
738 .\" .LP
739 .\" It is possible for the current character to have multiple tags,
740 .\" and for each of them to have a binding for a particular event
741 .\" sequence.
742 .\" When this occurs, one binding is invoked for each tag, in order
743 .\" from lowest-priority to highest priority.
744 .\" If there are multiple matching bindings for a single tag, then
745 .\" the most specific binding is chosen (see the manual entry for
746 .\" the \fBbind\fR command for details).
747 .\" \fBcontinue\fR and \fBbreak\fR commands within binding scripts
748 .\" are processed in the same way as for bindings created with
749 .\" the \fBbind\fR command.
750 .\" .LP
751 .\" If bindings are created for the widget as a whole using the
752 .\" \fBbind\fR command, then those bindings will supplement the
753 .\" tag bindings.
754 .\" The tag bindings will be invoked first, followed by bindings
755 .\" for the window as a whole.
756 .\" .RE
757 .TP
758 \fIpathName \fBtag cget\fR \fItagName option\fR
759 This command returns the current value of the option named \fIoption\fR
760 associated with the tag given by \fItagName\fR.
761 \fIOption\fR may have any of the values accepted by the \fBtag configure\fR
762 widget command.
763 .TP
764 \fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
765 This command is similar to the \fBconfigure\fR widget command except
766 that it modifies options associated with the tag given by \fItagName\fR
767 instead of modifying options for the overall text widget.
768 If no \fIoption\fR is specified, the command returns a list describing
769 all of the available options for \fItagName\fR.
770 If \fIoption\fR is specified with no \fIvalue\fR, then the command returns
771 a list describing the one named option (this list will be identical to
772 the corresponding sublist of the value returned if no \fIoption\fR
773 is specified).
774 If one or more \fIoption\-value\fR pairs are specified, then the command
775 modifies the given option(s) to have the given value(s) in \fItagName\fR;
776 in this case the command returns an empty string.
777 See TAGS above for details on the options available for tags.
778 .TP
779 \fIpathName \fBtag delete \fItagName \fR?\fItagName ...\fR?
780 Deletes all tag information for each of the \fItagName\fR
781 arguments.
782 The command removes the tags from all characters in the file
783 and also deletes any other information associated with the tags,
784 such as bindings and display information.
785 The command returns an empty string.
786 .TP
787 \fIpathName\fB tag lower \fItagName \fR?\fIbelowThis\fR?
788 Changes the priority of tag \fItagName\fR so that it is just lower
789 in priority than the tag whose name is \fIbelowThis\fR.
790 If \fIbelowThis\fR is omitted, then \fItagName\fR's priority
791 is changed to make it lowest priority of all tags.
792 .TP
793 \fIpathName \fBtag names \fR?\fIindex\fR?
794 Returns a list whose elements are the names of all the tags that
795 are active at the character position given by \fIindex\fR.
796 If \fIindex\fR is omitted, then the return value will describe
797 all of the tags that exist for the text (this includes all tags
798 that have been named in a ``\fIpathName \fBtag\fR'' widget
799 command but haven't been deleted by a ``\fIpathName \fBtag delete\fR''
800 widget command, even if no characters are currently marked with
801 the tag).
802 The list will be sorted in order from lowest priority to highest
803 priority.
804 .TP
805 \fIpathName \fBtag nextrange \fItagName index1 \fR?\fIindex2\fR?
806 This command searches the text for a range of characters tagged
807 with \fItagName\fR where the first character of the range is
808 no earlier than the character at \fIindex1\fR and no later than
809 the character just before \fIindex2\fR (a range starting at
810 \fIindex2\fR will not be considered).
811 If several matching ranges exist, the first one is chosen.
812 The command's return value is a list containing
813 two elements, which are the index of the first character of the
814 range and the index of the character just after the last one in
815 the range.
816 If no matching range is found then the return value is an
817 empty string.
818 If \fIindex2\fR is not given then it defaults to the end of the text.
819 .TP
820 \fIpathName\fB tag raise \fItagName \fR?\fIaboveThis\fR?
821 Changes the priority of tag \fItagName\fR so that it is just higher
822 in priority than the tag whose name is \fIaboveThis\fR.
823 If \fIaboveThis\fR is omitted, then \fItagName\fR's priority
824 is changed to make it highest priority of all tags.
825 .TP
826 \fIpathName \fBtag ranges \fItagName\fR
827 Returns a list describing all of the ranges of text that have been
828 tagged with \fItagName\fR.
829 The first two elements of the list describe the first tagged range
830 in the text, the next two elements describe the second range, and
831 so on.
832 The first element of each pair contains the index of the first
833 character of the range, and the second element of the pair contains
834 the index of the character just after the last one in the
835 range.
836 If there are no characters tagged with \fItag\fR then an
837 empty string is returned.
838 .TP
839 \fIpathName \fBtag remove \fItagName index1 \fR?\fIindex2 index1 index2 ...\fR?
840 Remove the tag \fItagName\fR from all of the characters starting
841 at \fIindex1\fR and ending just before
842 \fIindex2\fR (the character at \fIindex2\fR isn't affected).
843 A single command may contain any number of \fIindex1\fR\-\fIindex2\fR
844 pairs.
845 If the last \fIindex2\fR is omitted then the single character at
846 \fIindex1\fR is tagged.
847 If there are no characters in the specified range (e.g. \fIindex1\fR
848 is past the end of the file or \fIindex2\fR is less than or equal
849 to \fIindex1\fR) then the command has no effect.
850 This command returns an empty string.
851 .RE
852 .TP
853 \fIpathName \fBxview \fIoption args\fR
854 This command is used to query and change the horizontal position of the
855 text in the widget's window.  It can take any of the following
856 forms:
857 .RS
858 .TP
859 \fIpathName \fBxview\fR
860 Returns a list containing two elements.
861 Each element is a real fraction between 0 and 1;  together they describe
862 the portion of the document's horizontal span that is visible in
863 the window.
864 For example, if the first element is .2 and the second element is .6,
865 20% of the text is off-screen to the left, the middle 40% is visible
866 in the window, and 40% of the text is off-screen to the right.
867 The fractions refer only to the lines that are actually visible in the
868 window:  if the lines in the window are all very short, so that they
869 are entirely visible, the returned fractions will be 0 and 1,
870 even if there are other lines in the text that are
871 much wider than the window.
872 These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
873 option.
874 .TP
875 \fIpathName \fBxview moveto\fI fraction\fR
876 Adjusts the view in the window so that \fIfraction\fR of the horizontal
877 span of the text is off-screen to the left.
878 \fIFraction\fR is a fraction between 0 and 1.
879 .TP
880 \fIpathName \fBxview scroll \fInumber what\fR
881 This command shifts the view in the window left or right according to
882 \fInumber\fR and \fIwhat\fR.
883 \fINumber\fR must be an integer.
884 \fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
885 of one of these.
886 If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
887 \fInumber\fR average-width characters on the display;  if it is
888 \fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
889 If \fInumber\fR is negative then characters farther to the left
890 become visible;  if it is positive then characters farther to the right
891 become visible.
892 .RE
893 .TP
894 \fIpathName \fByview \fI?args\fR?
895 This command is used to query and change the vertical position of the
896 text in the widget's window.
897 It can take any of the following forms:
898 .RS
899 .TP
900 \fIpathName \fByview\fR
901 Returns a list containing two elements, both of which are real fractions
902 between 0 and 1.
903 The first element gives the position of the first character in the
904 top line in the window, relative to the text as a whole (0.5 means
905 it is halfway through the text, for example).
906 The second element gives the position of the character just after
907 the last one in the bottom line of the window,
908 relative to the text as a whole.
909 These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
910 option.
911 .TP
912 \fIpathName \fByview moveto\fI fraction\fR
913 Adjusts the view in the window so that the character given by \fIfraction\fR
914 appears on the top line of the window.
915 \fIFraction\fR is a fraction between 0 and 1;  0 indicates the first
916 character in the text, 0.33 indicates the character one-third the
917 way through the text, and so on.
918 .TP
919 \fIpathName \fByview scroll \fInumber what\fR
920 This command adjust the view in the window up or down according to
921 \fInumber\fR and \fIwhat\fR.
922 \fINumber\fR must be an integer.
923 \fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
924 If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
925 \fInumber\fR lines on the display;  if it is \fBpages\fR then
926 the view adjusts by \fInumber\fR screenfuls.
927 If \fInumber\fR is negative then earlier positions in the text
928 become visible;  if it is positive then later positions in the text
929 become visible.
930 .TP
931 \fIpathName \fByview \fR?\fB\-pickplace\fR? \fIindex\fR
932 Changes the view in the widget's window to make \fIindex\fR visible.
933 If the \fB\-pickplace\fR option isn't specified then \fIindex\fR will
934 appear at the top of the window.
935 If \fB\-pickplace\fR is specified then the widget chooses where
936 \fIindex\fR appears in the window:
937 .RS
938 .IP [1]
939 If \fIindex\fR is already visible somewhere in the window then the
940 command does nothing.
941 .IP [2]
942 If \fIindex\fR is only a few lines off-screen above the window then
943 it will be positioned at the top of the window.
944 .IP [3]
945 If \fIindex\fR is only a few lines off-screen below the window then
946 it will be positioned at the bottom of the window.
947 .IP [4]
948 Otherwise, \fIindex\fR will be centered in the window.
949 .LP
950 The \fB\-pickplace\fR option has been obsoleted by the \fBsee\fR widget
951 command (\fBsee\fR handles both x- and y-motion to make a location
952 visible, whereas \fB\-pickplace\fR only handles motion in y).
953 .RE
954 .TP
955 \fIpathName \fByview \fInumber\fR
956 This command makes the first character on the line after
957 the one given by \fInumber\fR visible at the top of the window.
958 \fINumber\fR must be an integer.
959 This command used to be used for scrolling, but now it is obsolete.
960 .RE
961
962 .SH BINDINGS
963 .PP
964 Ck automatically creates class bindings for texts that give them
965 the following default behavior.
966 In the descriptions below, ``word'' refers to a contiguous group
967 of letters, digits, or ``_'' characters, or any single character
968 other than these.
969 .IP [1]
970 Clicking mouse button 1 positions the insertion cursor
971 just before the character underneath the mouse cursor, sets the
972 input focus to this widget, and clears any selection in the widget.
973 .IP [2]
974 If any normal printing characters are typed, they are
975 inserted at the point of the insertion cursor.
976 .IP [3]
977 The Left and Right keys move the insertion cursor one character to the
978 left or right;  they also clear any selection in the text.
979 Control-b and Control-f behave the same as Left and Right, respectively.
980 .IP [4]
981 The Up and Down keys move the insertion cursor one line up or
982 down and clear any selection in the text.
983 Control-p and Control-n behave the same as Up and Down, respectively.
984 .IP [5]
985 The Next and Prior keys move the insertion cursor forward or backwards
986 by one screenful and clear any selection in the text.
987 Control-v moves the view down one screenful without moving the
988 insertion cursor or adjusting the selection.
989 .IP [6]
990 Home and Control-a move the insertion cursor to the
991 beginning of its line and clear any selection in the widget.
992 .IP [7]
993 End and Control-e move the insertion cursor to the
994 end of the line and clear any selection in the widget.
995 .IP [8]
996 The Delete key deletes the selection, if there is one in the widget.
997 If there is no selection, it deletes the character to the right of
998 the insertion cursor.
999 .IP [9]
1000 Backspace and Control-h delete the selection, if there is one
1001 in the widget.
1002 If there is no selection, they delete the character to the left of
1003 the insertion cursor.
1004 .IP [10]
1005 Control-d deletes the character to the right of the insertion cursor.
1006 .IP [11]
1007 Control-k deletes from the insertion cursor to the end of its line;
1008 if the insertion cursor is already at the end of a line, then
1009 Control-k deletes the newline character.
1010 .IP [12]
1011 Control-o opens a new line by inserting a newline character in
1012 front of the insertion cursor without moving the insertion cursor.
1013 .IP [13]
1014 Control-x moves the input focus to the next widget in focus order.
1015 .IP [14]
1016 Control-t reverses the order of the two characters to the right of
1017 the insertion cursor. 
1018 .PP
1019 If the widget is disabled using the \fB\-state\fR option, then its
1020 view can still be adjusted and text can still be selected,
1021 but no insertion cursor will be displayed and no text modifications will
1022 take place.
1023 .PP
1024 The behavior of texts can be changed by defining new bindings for
1025 individual widgets or by redefining the class bindings.
1026
1027 .SH "PERFORMANCE ISSUES"
1028 .PP
1029 Text widgets should run efficiently under a variety
1030 of conditions.  The text widget uses about 2-3 bytes of
1031 main memory for each byte of text, so texts containing a megabyte
1032 or more should be practical on most workstations.
1033 Text is represented internally with a modified B-tree structure
1034 that makes operations relatively efficient even with large texts.
1035 Tags are included in the B-tree structure in a way that allows
1036 tags to span large ranges or have many disjoint smaller ranges
1037 without loss of efficiency.
1038 Marks are also implemented in a way that allows large numbers of
1039 marks.
1040 The only known mode of operation where a text widget may not run
1041 efficiently is if it has a very large number of different tags.
1042 Hundreds of tags should be fine, or even a thousand,
1043 but tens of thousands of tags will make texts consume a lot of
1044 memory and run slowly.
1045
1046 .SH KEYWORDS
1047 text, widget