Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Tk::Text.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "TEXT 1"
132.TH TEXT 1 "2000-12-30" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "NAME"
134Tk::Text \- Create and manipulate Text widgets
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137\&\fBtext\fR \f(CW$text\fR ?\fIoptions\fR?
138.PP
139\&\fB\-background\fR \fB\-highlightbackground\fR \fB\-insertontime\fR \fB\-selectborderwidth\fR
140\&\fB\-borderwidth\fR \fB\-highlightcolor\fR \fB\-insertwidth\fR \fB\-selectforeground\fR
141\&\fB\-cursor\fR \fB\-highlightthickness\fR \fB\-padx\fR \fB\-setgrid\fR
142\&\fB\-exportselection\fR \fB\-insertbackground\fR \fB\-pady\fR \fB\-takefocus\fR
143\&\fB\-font\fR \fB\-insertborderwidth\fR \fB\-relief\fR \fB\-xscrollcommand\fR
144\&\fB\-foreground\fR \fB\-insertofftime\fR \fB\-selectbackground\fR \fB\-yscrollcommand\fR
145.SH "WIDGET-SPECIFIC OPTIONS"
146.IX Header "WIDGET-SPECIFIC OPTIONS"
147.IP "Name: \fBheight\fR" 4
148.IX Item "Name: height"
149.PD 0
150.IP "Class: \fBHeight\fR" 4
151.IX Item "Class: Height"
152.IP "Switch: \fB\-height\fR" 4
153.IX Item "Switch: -height"
154.PD
155Specifies the desired height for the window, in units of characters
156in the font given by the \fB\-font\fR option.
157Must be at least one.
158.IP "Name: \fBspacing1\fR" 4
159.IX Item "Name: spacing1"
160.PD 0
161.IP "Class: \fBSpacing1\fR" 4
162.IX Item "Class: Spacing1"
163.IP "Switch: \fB\-spacing1\fR" 4
164.IX Item "Switch: -spacing1"
165.PD
166Requests additional space above each text line in the widget,
167using any of the standard forms for screen distances.
168If a line wraps, this option only applies to the first line
169on the display.
170This option may be overriden with \fB\-spacing1\fR options in
171tags.
172.IP "Name: \fBspacing2\fR" 4
173.IX Item "Name: spacing2"
174.PD 0
175.IP "Class: \fBSpacing2\fR" 4
176.IX Item "Class: Spacing2"
177.IP "Switch: \fB\-spacing2\fR" 4
178.IX Item "Switch: -spacing2"
179.PD
180For lines that wrap (so that they cover more than one line on the
181display) this option specifies additional space to provide between
182the display lines that represent a single line of text.
183The value may have any of the standard forms for screen distances.
184This option may be overriden with \fB\-spacing2\fR options in
185tags.
186.IP "Name: \fBspacing3\fR" 4
187.IX Item "Name: spacing3"
188.PD 0
189.IP "Class: \fBSpacing3\fR" 4
190.IX Item "Class: Spacing3"
191.IP "Switch: \fB\-spacing3\fR" 4
192.IX Item "Switch: -spacing3"
193.PD
194Requests additional space below each text line in the widget,
195using any of the standard forms for screen distances.
196If a line wraps, this option only applies to the last line
197on the display.
198This option may be overriden with \fB\-spacing3\fR options in
199tags.
200.IP "Name: \fBstate\fR" 4
201.IX Item "Name: state"
202.PD 0
203.IP "Class: \fBState\fR" 4
204.IX Item "Class: State"
205.IP "Switch: \fB\-state\fR" 4
206.IX Item "Switch: -state"
207.PD
208Specifies one of two states for the text: \fBnormal\fR or \fBdisabled\fR.
209If the text is disabled then characters may not be inserted or deleted
210and no insertion cursor will be displayed, even if the input focus is
211in the widget.
212.IP "Name: \fBtabs\fR" 4
213.IX Item "Name: tabs"
214.PD 0
215.IP "Class: \fBTabs\fR" 4
216.IX Item "Class: Tabs"
217.IP "Switch: \fB\-tabs\fR" 4
218.IX Item "Switch: -tabs"
219.PD
220Specifies a set of tab stops for the window. The option's value consists
221of a list of screen distances giving the positions of the tab stops. Each
222position may optionally be followed in the next list element
223by one of the keywords \fBleft\fR, \fBright\fR, \fBcenter\fR,
224or \fBnumeric\fR, which specifies how to justify
225text relative to the tab stop. \fBLeft\fR is the default; it causes
226the text following the tab character to be positioned with its left edge
227at the tab position. \fBRight\fR means that the right edge of the text
228following the tab character is positioned at the tab position, and
229\&\fBcenter\fR means that the text is centered at the tab position.
230\&\fBNumeric\fR means that the decimal point in the text is positioned
231at the tab position; if there is no decimal point then the least
232significant digit of the number is positioned just to the left of the
233tab position; if there is no number in the text then the text is
234right-justified at the tab position.
235For example, \fB\-tabs => [qw/2c left 4c 6c center/]\fR creates three
236tab stops at two-centimeter intervals; the first two use left
237justification and the third uses center justification.
238If the list of tab stops does not have enough elements to cover all
239of the tabs in a text line, then Tk extrapolates new tab stops using
240the spacing and alignment from the last tab stop in the list.
241The value of the \fBtabs\fR option may be overridden by \fB\-tabs\fR
242options in tags.
243If no \fB\-tabs\fR option is specified, or if it is specified as
244an empty list, then Tk uses default tabs spaced every eight
245(average size) characters.
246.IP "Name: \fBwidth\fR" 4
247.IX Item "Name: width"
248.PD 0
249.IP "Class: \fBWidth\fR" 4
250.IX Item "Class: Width"
251.IP "Switch: \fB\-width\fR" 4
252.IX Item "Switch: -width"
253.PD
254Specifies the desired width for the window in units of characters
255in the font given by the \fB\-font\fR option.
256If the font doesn't have a uniform width then the width of the
257character ``0'' is used in translating from character units to
258screen units.
259.IP "Name: \fBwrap\fR" 4
260.IX Item "Name: wrap"
261.PD 0
262.IP "Class: \fBWrap\fR" 4
263.IX Item "Class: Wrap"
264.IP "Switch: \fB\-wrap\fR" 4
265.IX Item "Switch: -wrap"
266.PD
267Specifies how to handle lines in the text that are too long to be
268displayed in a single line of the text's window.
269The value must be \fBnone\fR or \fBchar\fR or \fBword\fR.
270A wrap mode of \fBnone\fR means that each line of text appears as
271exactly one line on the screen; extra characters that don't fit
272on the screen are not displayed.
273In the other modes each line of text will be broken up into several
274screen lines if necessary to keep all the characters visible.
275In \fBchar\fR mode a screen line break may occur after any character;
276in \fBword\fR mode a line break will only be made at word boundaries.
277.SH "DESCRIPTION"
278.IX Header "DESCRIPTION"
279The \fBText\fR method creates a new window (given by the
280\&\f(CW$text\fR argument) and makes it into a text widget.
281Additional
282options, described above, may be specified on the command line
283or in the option database
284to configure aspects of the text such as its default background color
285and relief. The \fBtext\fR command returns the
286path name of the new window.
287.PP
288A text widget displays one or more lines of text and allows that
289text to be edited.
290Text widgets support four different kinds of annotations on the
291text, called tags, marks, embedded windows or embedded images.
292Tags allow different portions of the text
293to be displayed with different fonts and colors.
294In addition, perl/Tk callbacks can be associated with tags so
295that scripts are invoked when particular actions such as keystrokes
296and mouse button presses occur in particular ranges of the text.
297See \*(L"\s-1TAGS\s0\*(R" below for more details.
298.PP
299The second form of annotation consists of marks, which are floating
300markers in the text.
301Marks are used to keep track of various interesting positions in the
302text as it is edited.
303See \*(L"\s-1MARKS\s0\*(R" below for more details.
304.PP
305The third form of annotation allows arbitrary windows to be
306embedded in a text widget.
307See \*(L"\s-1EMBEDDED\s0 \s-1WINDOWS\s0\*(R" below for more details.
308.PP
309The fourth form of annotation allows Tk images to be embedded in a text
310widget.
311See \*(L"\s-1EMBEDDED\s0 \s-1IMAGES\s0\*(R" below for more details.
312.SH "INDICES"
313.IX Header "INDICES"
314Many of the methods for texts take one or more indices
315as arguments.
316An index is a string used to indicate a particular place within
317a text, such as a place to insert characters or one endpoint of a
318range of characters to delete.
319Indices have the syntax
320.PP
321.Vb 1
322\& base modifier modifier modifier ...
323.Ve
324.PP
325Where \fIbase\fR gives a starting point and the \fImodifier\fRs
326adjust the index from the starting point (e.g. move forward or
327backward one character). Every index must contain a \fIbase\fR,
328but the \fImodifier\fRs are optional.
329.PP
330The \fIbase\fR for an index must have one of the following forms:
331.IP "\fIline\fR\fB.\fR\fIchar\fR" 4
332.IX Item "line.char"
333Indicates \fIchar\fR'th character on line \fIline\fR.
334Lines are numbered from 1 for consistency with other \s-1UNIX\s0 programs
335that use this numbering scheme.
336Within a line, characters are numbered from 0.
337If \fIchar\fR is \fBend\fR then it refers to the newline character
338that ends the line.
339.IP "\fB@\fR\fIx\fR\fB,\fR\fIy\fR" 4
340.IX Item "@x,y"
341Indicates the character that covers the pixel whose x and y coordinates
342within the text's window are \fIx\fR and \fIy\fR.
343.IP "\fBend\fR" 4
344.IX Item "end"
345Indicates the end of the text (the character just after the last
346newline).
347.IP "\fImark\fR" 4
348.IX Item "mark"
349Indicates the character just after the mark whose name is \fImark\fR.
350.IP "\fItag\fR\fB.first\fR" 4
351.IX Item "tag.first"
352Indicates the first character in the text that has been tagged with
353\&\fItag\fR.
354This form generates an error if no characters are currently tagged
355with \fItag\fR.
356.IP "\fItag\fR\fB.last\fR" 4
357.IX Item "tag.last"
358Indicates the character just after the last one in the text that has
359been tagged with \fItag\fR.
360This form generates an error if no characters are currently tagged
361with \fItag\fR.
362.IP "\fI$widget\fR" 4
363.IX Item "$widget"
364Indicates the position of the embedded window referenced by \fI$widget\fR.
365This form generates an error if \fI$widget\fR does not reference to an
366embedded window.
367.IP "\fIimageName\fR" 4
368.IX Item "imageName"
369Indicates the position of the embedded image whose name is
370\&\fIimageName\fR.
371This form generates an error if there is no embedded image
372by the given name.
373.Sp
374If the \fIbase\fR could match more than one of the above forms, such
375as a \fImark\fR and \fIimageName\fR both having the same value, then
376the form earlier in the above list takes precedence.
377If modifiers follow the base index, each one of them must have one
378of the forms listed below. Keywords such as \fBchars\fR and \fBwordend\fR
379may be abbreviated as long as the abbreviation is unambiguous.
380.IP "\fB+ \fR\fIcount\fR\fB chars\fR" 4
381.IX Item "+ count chars"
382Adjust the index forward by \fIcount\fR characters, moving to later
383lines in the text if necessary. If there are fewer than \fIcount\fR
384characters in the text after the current index, then set the index
385to the last character in the text.
386Spaces on either side of \fIcount\fR are optional.
387.IP "\fB\- \fR\fIcount\fR\fB chars\fR" 4
388.IX Item "- count chars"
389Adjust the index backward by \fIcount\fR characters, moving to earlier
390lines in the text if necessary. If there are fewer than \fIcount\fR
391characters in the text before the current index, then set the index
392to the first character in the text.
393Spaces on either side of \fIcount\fR are optional.
394.IP "\fB+ \fR\fIcount\fR\fB lines\fR" 4
395.IX Item "+ count lines"
396Adjust the index forward by \fIcount\fR lines, retaining the same
397character position within the line. If there are fewer than \fIcount\fR
398lines after the line containing the current index, then set the index
399to refer to the same character position on the last line of the text.
400Then, if the line is not long enough to contain a character at the indicated
401character position, adjust the character position to refer to the last
402character of the line (the newline).
403Spaces on either side of \fIcount\fR are optional.
404.IP "\fB\- \fR\fIcount\fR\fB lines\fR" 4
405.IX Item "- count lines"
406Adjust the index backward by \fIcount\fR lines, retaining the same
407character position within the line. If there are fewer than \fIcount\fR
408lines before the line containing the current index, then set the index
409to refer to the same character position on the first line of the text.
410Then, if the line is not long enough to contain a character at the indicated
411character position, adjust the character position to refer to the last
412character of the line (the newline).
413Spaces on either side of \fIcount\fR are optional.
414.IP "\fBlinestart\fR" 4
415.IX Item "linestart"
416Adjust the index to refer to the first character on the line.
417.IP "\fBlineend\fR" 4
418.IX Item "lineend"
419Adjust the index to refer to the last character on the line (the newline).
420.IP "\fBwordstart\fR" 4
421.IX Item "wordstart"
422Adjust the index to refer to the first character of the word containing
423the current index. A word consists of any number of adjacent characters
424that are letters, digits, or underscores, or a single character that
425is not one of these.
426.IP "\fBwordend\fR" 4
427.IX Item "wordend"
428Adjust the index to refer to the character just after the last one of the
429word containing the current index. If the current index refers to the last
430character of the text then it is not modified.
431.Sp
432If more than one modifier is present then they are applied in
433left-to-right order. For example, the index ``\fBend \- 1 chars\fR''
434refers to the next-to-last character in the text and
435``\fBinsert wordstart \- 1 c\fR'' refers to the character just before
436the first one in the word containing the insertion cursor.
437.SH "TAGS"
438.IX Header "TAGS"
439The first form of annotation in text widgets is a tag.
440A tag is a textual string that is associated with some of the characters
441in a text.
442Tags may contain arbitrary characters, but it is probably best to
443avoid using the the characters `` '' (space), \fB+\fR, or \fB\-\fR:
444these characters have special meaning in indices, so tags containing
445them can't be used as indices.
446There may be any number of tags associated with characters in a
447text.
448Each tag may refer to a single character, a range of characters, or
449several ranges of characters.
450An individual character may have any number of tags associated with it.
451.PP
452A priority order is defined among tags, and this order is used in
453implementing some of the tag-related functions described below.
454When a tag is defined (by associating it with characters or setting
455its display options or binding callbacks to it), it is given
456a priority higher than any existing tag.
457The priority order of tags may be redefined using the
458``\fI$text\fR\->\fBtagRaise\fR'' and ``\fI$text\fR\->\fBtagLower\fR''
459methods.
460.PP
461Tags serve three purposes in text widgets.
462First, they control the way information is displayed on the screen.
463By default, characters are displayed as determined by the
464\&\fBbackground\fR, \fBfont\fR, and \fBforeground\fR options for the
465text widget.
466However, display options may be associated with individual tags
467using the ``\fI$text\fR\->\fBtagConfigure\fR'' method.
468If a character has been tagged, then the display options associated
469with the tag override the default display style.
470The following options are currently supported for tags:
471.IP "\fB\-background\fR => \fIcolor\fR" 4
472.IX Item "-background => color"
473\&\fIColor\fR specifies the background color to use for characters
474associated with the tag.
475It may have any of the forms accepted by \fBTk_GetColor\fR.
476.IP "\fB\-bgstipple\fR => \fIbitmap\fR" 4
477.IX Item "-bgstipple => bitmap"
478\&\fIBitmap\fR specifies a bitmap that is used as a stipple pattern
479for the background.
480It may have any of the forms accepted by \fBTk_GetBitmap\fR.
481If \fIbitmap\fR hasn't been specified, or if it is specified
482as an empty string, then a solid fill will be used for the
483background.
484.IP "\fB\-borderwidth\fR => \fIpixels\fR" 4
485.IX Item "-borderwidth => pixels"
486\&\fIPixels\fR specifies the width of a 3\-D border to draw around
487the background.
488It may have any of the forms accepted by \fBTk_GetPixels\fR.
489This option is used in conjunction with the \fB\-relief\fR
490option to give a 3\-D appearance to the background for characters;
491it is ignored unless the \fB\-background\fR option
492has been set for the tag.
493.IP "\fB\-fgstipple\fR => \fIbitmap\fR" 4
494.IX Item "-fgstipple => bitmap"
495\&\fIBitmap\fR specifies a bitmap that is used as a stipple pattern
496when drawing text and other foreground information such as
497underlines.
498It may have any of the forms accepted by \fBTk_GetBitmap\fR.
499If \fIbitmap\fR hasn't been specified, or if it is specified
500as an empty string, then a solid fill will be used.
501.IP "\fB\-font\fR => \fIfontName\fR" 4
502.IX Item "-font => fontName"
503\&\fIFontName\fR is the name of a font to use for drawing characters.
504It may have any of the forms accepted by \fBTk_GetFontStruct\fR.
505.IP "\fB\-foreground\fR => \fIcolor\fR" 4
506.IX Item "-foreground => color"
507\&\fIColor\fR specifies the color to use when drawing text and other
508foreground information such as underlines.
509It may have any of the forms accepted by \fBTk_GetColor\fR.
510.IP "\fB\-justify\fR => \fIjustify\fR" 4
511.IX Item "-justify => justify"
512If the first character of a display line has a tag for which this
513option has been specified, then \fIjustify\fR determines how to
514justify the line.
515It must be one of \fBleft\fR, \fBright\fR, or \fBcenter\fR.
516If a line wraps, then the justification for each line on the
517display is determined by the first character of that display line.
518.IP "\fB\-lmargin1\fR => \fIpixels\fR" 4
519.IX Item "-lmargin1 => pixels"
520If the first character of a text line has a tag for which this
521option has been specified, then \fIpixels\fR specifies how
522much the line should be indented from the left edge of the
523window.
524\&\fIPixels\fR may have any of the standard forms for screen
525distances.
526If a line of text wraps, this option only applies to the
527first line on the display; the \fB\-lmargin2\fR option controls
528the indentation for subsequent lines.
529.IP "\fB\-lmargin2\fR => \fIpixels\fR" 4
530.IX Item "-lmargin2 => pixels"
531If the first character of a display line has a tag for which this
532option has been specified, and if the display line is not the
533first for its text line (i.e., the text line has wrapped), then
534\&\fIpixels\fR specifies how much the line should be indented from
535the left edge of the window.
536\&\fIPixels\fR may have any of the standard forms for screen
537distances.
538This option is only used when wrapping is enabled, and it only
539applies to the second and later display lines for a text line.
540.IP "\fB\-offset\fR => \fIpixels\fR" 4
541.IX Item "-offset => pixels"
542\&\fIPixels\fR specifies an amount by which the text's baseline
543should be offset vertically from the baseline of the overall
544line, in pixels.
545For example, a positive offset can be used for superscripts
546and a negative offset can be used for subscripts.
547\&\fIPixels\fR may have any of the standard forms for screen
548distances.
549.IP "\fB\-overstrike\fR => \fIboolean\fR" 4
550.IX Item "-overstrike => boolean"
551Specifies whether or not to draw a horizontal rule through
552the middle of characters.
553\&\fIBoolean\fR may have any of the forms accepted by \fBTk_GetBoolean\fR.
554.IP "\fB\-relief\fR => \fIrelief\fR" 4
555.IX Item "-relief => relief"
556\&\fIRelief\fR specifies the 3\-D relief to use for drawing backgrounds,
557in any of the forms accepted by \fBTk_GetRelief\fR.
558This option is used in conjunction with the \fB\-borderwidth\fR
559option to give a 3\-D appearance to the background for characters;
560it is ignored unless the \fB\-background\fR option
561has been set for the tag.
562.IP "\fB\-rmargin\fR => \fIpixels\fR" 4
563.IX Item "-rmargin => pixels"
564If the first character of a display line has a tag for which this
565option has been specified, then \fIpixels\fR specifies how wide
566a margin to leave between the end of the line and the right
567edge of the window.
568\&\fIPixels\fR may have any of the standard forms for screen
569distances.
570This option is only used when wrapping is enabled.
571If a text line wraps, the right margin for each line on the
572display is determined by the first character of that display
573line.
574.IP "\fB\-spacing1\fR => \fIpixels\fR" 4
575.IX Item "-spacing1 => pixels"
576\&\fIPixels\fR specifies how much additional space should be
577left above each text line, using any of the standard forms for
578screen distances.
579If a line wraps, this option only applies to the first
580line on the display.
581.IP "\fB\-spacing2\fR => \fIpixels\fR" 4
582.IX Item "-spacing2 => pixels"
583For lines that wrap, this option specifies how much additional
584space to leave between the display lines for a single text line.
585\&\fIPixels\fR may have any of the standard forms for screen
586distances.
587.IP "\fB\-spacing3\fR => \fIpixels\fR" 4
588.IX Item "-spacing3 => pixels"
589\&\fIPixels\fR specifies how much additional space should be
590left below each text line, using any of the standard forms for
591screen distances.
592If a line wraps, this option only applies to the last
593line on the display.
594.IP "\fB\-state\fR => \fIstate\fR" 4
595.IX Item "-state => state"
596\&\fIState\fR specifies if the text is \fIhidden\fR or \fInormal\fR.
597Hidden text is not displayed and takes no space on screen, but further
598on behaves just as normal text.
599.IP "\fB\-tabs\fR => \fItabList\fR" 4
600.IX Item "-tabs => tabList"
601\&\fITabList\fR specifies a set of tab stops in the same form
602as for the \fB\-tabs\fR option for the text widget. This
603option only applies to a display line if it applies to the
604first character on that display line.
605If this option is specified as an empty string, it cancels
606the option, leaving it unspecified for the tag (the default).
607If the option is specified as a non-empty string that is
608an empty list, such as \fB\-tabs =\fR \*(L" \*(R">, then it requests
609default 8\-character tabs as described for the \fBtabs\fR
610widget option.
611.IP "\fB\-underline\fR => \fIboolean\fR" 4
612.IX Item "-underline => boolean"
613\&\fIBoolean\fR specifies whether or not to draw an underline underneath
614characters.
615It may have any of the forms accepted by \fBTk_GetBoolean\fR.
616.IP "\fB\-wrap\fR => \fImode\fR" 4
617.IX Item "-wrap => mode"
618\&\fIMode\fR specifies how to handle lines that are wider than the
619text's window.
620It has the same legal values as the \fB\-wrap\fR option
621for the text widget: \fBnone\fR, \fBchar\fR, or \fBword\fR.
622If this tag option is specified, it overrides the \fB\-wrap\fR option
623for the text widget.
624.IP "\fB\-elide\fR => \fIvalue\fR" 4
625.IX Item "-elide => value"
626If value is true then text covered by the tag is not displayed.
627.IP "\fB\-data\fR => \fIvalue\fR" 4
628.IX Item "-data => value"
629Allows an arbitrary perl scalar \fIvalue\fR to be associated with the tag.
630.PP
631If a character has several tags associated with it, and if their
632display options conflict, then the options of the highest priority
633tag are used.
634If a particular display option hasn't been specified for a
635particular tag, or if it is specified as an empty string, then
636that option will never be used; the next-highest-priority
637tag's option will used instead.
638If no tag specifies a particular display option, then the default
639style for the widget will be used.
640.PP
641The second purpose for tags is event bindings.
642You can associate bindings with a tag in much the same way you can
643associate bindings with a widget class: whenever particular X
644events occur on characters with the given tag, a given
645<perl/Tk callback|Tk::callbacks> will be executed.
646Tag bindings can be used to give behaviors to ranges of characters;
647among other things, this allows hypertext-like
648features to be implemented.
649For details, see the description of the \fBtagBind\fR widget
650method below.
651.PP
652The third use for tags is in managing the selection.
653See \*(L"\s-1THE\s0 \s-1SELECTION\s0\*(R" below.
654.SH "MARKS"
655.IX Header "MARKS"
656The second form of annotation in text widgets is a mark.
657Marks are used for remembering particular places in a text.
658They are something like tags, in that they have names and
659they refer to places in the file, but a mark isn't associated
660with particular characters.
661Instead, a mark is associated with the gap between two characters.
662Only a single position may be associated with a mark at any given
663time.
664If the characters around a mark are deleted the mark will still
665remain; it will just have new neighbor characters.
666In contrast, if the characters containing a tag are deleted then
667the tag will no longer have an association with characters in
668the file.
669Marks may be manipulated with the ``\fI$text\fR\->\fBmark\fR'' text widget
670method, and their current locations may be determined by using the
671mark name as an index in methods.
672.PP
673Each mark also has a \fIgravity\fR, which is either \fBleft\fR or
674\&\fBright\fR.
675The gravity for a mark specifies what happens to the mark when
676text is inserted at the point of the mark.
677If a mark has left gravity, then the mark is treated as if it
678were attached to the character on its left, so the mark will
679remain to the left of any text inserted at the mark position.
680If the mark has right gravity, new text inserted at the mark
681position will appear to the right of the mark. The gravity
682for a mark defaults to \fBright\fR.
683.PP
684The name space for marks is different from that for tags: the
685same name may be used for both a mark and a tag, but they will refer
686to different things.
687.PP
688Two marks have special significance.
689First, the mark \fBinsert\fR is associated with the insertion cursor,
690as described under \*(L"\s-1THE\s0 \s-1INSERTION\s0 \s-1CURSOR\s0\*(R" below.
691Second, the mark \fBcurrent\fR is associated with the character
692closest to the mouse and is adjusted automatically to track the
693mouse position and any changes to the text in the widget (one
694exception: \fBcurrent\fR is not updated in response to mouse
695motions if a mouse button is down; the update will be deferred
696until all mouse buttons have been released).
697Neither of these special marks may be deleted.
698.SH "EMBEDDED WINDOWS"
699.IX Header "EMBEDDED WINDOWS"
700The third form of annotation in text widgets is an embedded window.
701Each embedded window annotation causes a window to be displayed
702at a particular point in the text.
703There may be any number of embedded windows in a text widget,
704and any widget may be used as an embedded window (subject to the
705usual rules for geometry management, which require the text window
706to be the parent of the embedded window or a descendant of its
707parent).
708The embedded window's position on the screen will be updated as the
709text is modified or scrolled, and it will be mapped and unmapped as
710it moves into and out of the visible area of the text widget.
711Each embedded window occupies one character's worth of index space
712in the text widget, and it may be referred to either by the name
713of its embedded window or by its position in the widget's
714index space.
715If the range of text containing the embedded window is deleted then
716the window is destroyed.
717.PP
718When an embedded window is added to a text widget with the
719\&\fBwidgetCreate\fR method, several configuration
720options may be associated with it.
721These options may be modified later with the \fBwidgetConfigure\fR
722method.
723The following options are currently supported:
724.IP "\fB\-align\fR => \fIwhere\fR" 4
725.IX Item "-align => where"
726If the window is not as tall as the line in which it is displayed,
727this option determines where the window is displayed in the line.
728\&\fIWhere\fR must have one of the values \fBtop\fR (align the top of the window
729with the top of the line), \fBcenter\fR (center the window
730within the range of the line), \fBbottom\fR (align the bottom of the
731window with the bottom of the line's area),
732or \fBbaseline\fR (align the bottom of the window with the baseline
733of the line).
734.IP "\fB\-create\fR => \fIcallback\fR" 4
735.IX Item "-create => callback"
736Specifies a callback that may be evaluated to create the window
737for the annotation.
738If no \fB\-window\fR option has been specified for the annotation
739this \fIcallback\fR will be evaluated when the annotation is about to
740be displayed on the screen.
741\&\fICallback\fR must create a window for the annotation and return
742the name of that window as its result.
743If the annotation's window should ever be deleted, \fIcallback\fR
744will be evaluated again the next time the annotation is displayed.
745.IP "\fB\-padx\fR => \fIpixels\fR" 4
746.IX Item "-padx => pixels"
747\&\fIPixels\fR specifies the amount of extra space to leave on
748each side of the embedded window.
749It may have any of the usual forms defined for a screen distance
750(see \fBTk_GetPixels\fR).
751.IP "\fB\-pady\fR => \fIpixels\fR" 4
752.IX Item "-pady => pixels"
753\&\fIPixels\fR specifies the amount of extra space to leave on
754the top and on the bottom of the embedded window.
755It may have any of the usual forms defined for a screen distance
756(see \fBTk_GetPixels\fR).
757.IP "\fB\-stretch\fR => \fIboolean\fR" 4
758.IX Item "-stretch => boolean"
759If the requested height of the embedded window is less than the
760height of the line in which it is displayed, this option can be
761used to specify whether the window should be stretched vertically
762to fill its line.
763If the \fB\-pady\fR option has been specified as well, then the
764requested padding will be retained even if the window is
765stretched.
766.IP "\fB\-window\fR => \fI$widget\fR" 4
767.IX Item "-window => $widget"
768Specifies the name of a window to display in the annotation.
769.SH "EMBEDDED IMAGES"
770.IX Header "EMBEDDED IMAGES"
771The final form of annotation in text widgets is an embedded image.
772Each embedded image annotation causes an image to be displayed
773at a particular point in the text.
774There may be any number of embedded images in a text widget,
775and a particular image may be embedded in multiple places in the same
776text widget.
777The embedded image's position on the screen will be updated as the
778text is modified or scrolled.
779Each embedded image occupies one character's worth of index space
780in the text widget, and it may be referred to either by
781its position in the widget's index space, or the name it is assigned
782when the image is inserted into the text widget with \fBimageCreate\fR.
783If the range of text containing the embedded image is deleted then
784that copy of the image is removed from the screen.
785.PP
786When an embedded image is added to a text widget with the \fBimage\fR
787create method, a name unique to this instance of the image
788is returned. This name may then be used to refer to this image
789instance. The name is taken to be the value of the \fB\-name\fR option
790(described below). If the \fB\-name\fR option is not provided, the
791\&\fB\-image\fR name is used instead. If the \fIimageName\fR is already
792in use in the text widget, then \fB#\fR\fInn\fR is added to the end of the
793\&\fIimageName\fR, where \fInn\fR is an arbitrary integer. This insures
794the \fIimageName\fR is unique.
795Once this name is assigned to this instance of the image, it does not
796change, even though the \fB\-image\fR or \fB\-name\fR values can be changed
797with \fBimage configure\fR.
798.PP
799When an embedded image is added to a text widget with the
800\&\fBimageCreate\fR method, several configuration
801options may be associated with it.
802These options may be modified later with the \fBimage configure\fR
803method.
804The following options are currently supported:
805.IP "\fB\-align\fR => \fIwhere\fR" 4
806.IX Item "-align => where"
807If the image is not as tall as the line in which it is displayed,
808this option determines where the image is displayed in the line.
809\&\fIWhere\fR must have one of the values \fBtop\fR (align the top of the image
810with the top of the line), \fBcenter\fR (center the image
811within the range of the line), \fBbottom\fR (align the bottom of the
812image with the bottom of the line's area),
813or \fBbaseline\fR (align the bottom of the image with the baseline
814of the line).
815.IP "\fB\-image\fR => \fIimage\fR" 4
816.IX Item "-image => image"
817Specifies the name of the Tk image to display in the annotation.
818If \fIimage\fR is not a valid Tk image, then an error is returned.
819.IP "\fB\-name\fR => \fIImageName\fR" 4
820.IX Item "-name => ImageName"
821Specifies the name by which this image instance may be referenced in
822the text widget. If \fIImageName\fR is not supplied, then the
823name of the Tk image is used instead.
824If the \fIimageName\fR is already in use, \fI#nn\fR is appended to
825the end of the name as described above.
826.IP "\fB\-padx\fR => \fIpixels\fR" 4
827.IX Item "-padx => pixels"
828\&\fIPixels\fR specifies the amount of extra space to leave on
829each side of the embedded image.
830It may have any of the usual forms defined for a screen distance.
831.IP "\fB\-pady\fR => \fIpixels\fR" 4
832.IX Item "-pady => pixels"
833\&\fIPixels\fR specifies the amount of extra space to leave on
834the top and on the bottom of the embedded image.
835It may have any of the usual forms defined for a screen distance.
836.SH "THE SELECTION"
837.IX Header "THE SELECTION"
838Selection support is implemented via tags.
839If the \fBexportSelection\fR option for the text widget is true
840then the \fBsel\fR tag will be associated with the selection:
841.IP "[1]" 4
842.IX Item "[1]"
843Whenever characters are tagged with \fBsel\fR the text widget
844will claim ownership of the selection.
845.IP "[2]" 4
846.IX Item "[2]"
847Attempts to retrieve the
848selection will be serviced by the text widget, returning all the
849characters with the \fBsel\fR tag.
850.IP "[3]" 4
851.IX Item "[3]"
852If the selection is claimed away by another application or by another
853window within this application, then the \fBsel\fR tag will be removed
854from all characters in the text.
855.Sp
856The \fBsel\fR tag is automatically defined when a text widget is
857created, and it may not be deleted with the ``\fI$text\fR\->\fBtagDelete\fR''
858method. Furthermore, the \fBselectBackground\fR,
859\&\fBselectBorderWidth\fR, and \fBselectForeground\fR options for
860the text widget are tied to the \fB\-background\fR,
861\&\fB\-borderwidth\fR, and \fB\-foreground\fR options for the \fBsel\fR
862tag: changes in either will automatically be reflected in the
863other.
864.SH "THE INSERTION CURSOR"
865.IX Header "THE INSERTION CURSOR"
866The mark named \fBinsert\fR has special significance in text widgets.
867It is defined automatically when a text widget is created and it
868may not be unset with the ``\fI$text\fR\->\fBmarkUnset\fR'' widget
869command.
870The \fBinsert\fR mark represents the position of the insertion
871cursor, and the insertion cursor will automatically be drawn at
872this point whenever the text widget has the input focus.
873.SH "WIDGET METHODS"
874.IX Header "WIDGET METHODS"
875The \fBText\fR method creates a widget object.
876This object supports the \fBconfigure\fR and \fBcget\fR methods
877described in Tk::options which can be used to enquire and
878modify the options described above.
879The widget also inherits all the methods provided by the generic
880Tk::Widget class.
881.PP
882The following additional methods are available for text widgets:
883.IP "\fI$text\fR\->\fBbbox\fR(\fIindex\fR)" 4
884.IX Item "$text->bbox(index)"
885Returns a list of four elements describing the screen area
886of the character given by \fIindex\fR.
887The first two elements of the list give the x and y coordinates
888of the upper-left corner of the area occupied by the
889character, and the last two elements give the width and height
890of the area.
891If the character is only partially visible on the screen, then
892the return value reflects just the visible part.
893If the character is not visible on the screen then the return
894value is an empty list.
895.IP "\fI$text\fR\->\fBcompare\fR(\fIindex1, op, index2\fR)" 4
896.IX Item "$text->compare(index1, op, index2)"
897Compares the indices given by \fIindex1\fR and \fIindex2\fR according
898to the relational operator given by \fIop\fR, and returns 1 if
899the relationship is satisfied and 0 if it isn't.
900\&\fIOp\fR must be one of the operators <, <=, ==, >=, >, or !=.
901If \fIop\fR is == then 1 is returned if the two indices refer to
902the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR
903refers to an earlier character in the text than \fIindex2\fR, and
904so on.
905.IP "\fI$text\fR\->\fBdebug\fR(?\fIboolean\fR?)" 4
906.IX Item "$text->debug(?boolean?)"
907If \fIboolean\fR is specified, then it must have one of the true or
908false values accepted by Tcl_GetBoolean.
909If the value is a true one then internal consistency checks will be
910turned on in the B\-tree code associated with text widgets.
911If \fIboolean\fR has a false value then the debugging checks will
912be turned off.
913In either case the command returns an empty string.
914If \fIboolean\fR is not specified then the command returns \fBon\fR
915or \fBoff\fR to indicate whether or not debugging is turned on.
916There is a single debugging switch shared by all text widgets: turning
917debugging on or off in any widget turns it on or off for all widgets.
918For widgets with large amounts of text, the consistency checks may
919cause a noticeable slow\-down.
920.IP "\fI$text\fR\->\fBdelete\fR(\fIindex1, \fR?\fIindex2\fR?)" 4
921.IX Item "$text->delete(index1, ?index2?)"
922Delete a range of characters from the text.
923If both \fIindex1\fR and \fIindex2\fR are specified, then delete
924all the characters starting with the one given by \fIindex1\fR
925and stopping just before \fIindex2\fR (i.e. the character at
926\&\fIindex2\fR is not deleted).
927If \fIindex2\fR doesn't specify a position later in the text
928than \fIindex1\fR then no characters are deleted.
929If \fIindex2\fR isn't specified then the single character at
930\&\fIindex1\fR is deleted.
931It is not allowable to delete characters in a way that would leave
932the text without a newline as the last character.
933The command returns an empty string.
934.IP "\fI$text\fR\->\fBdlineinfo\fR(\fIindex\fR)" 4
935.IX Item "$text->dlineinfo(index)"
936Returns a list with five elements describing the area occupied
937by the display line containing \fIindex\fR.
938The first two elements of the list give the x and y coordinates
939of the upper-left corner of the area occupied by the
940line, the third and fourth elements give the width and height
941of the area, and the fifth element gives the position of the baseline
942for the line, measured down from the top of the area.
943All of this information is measured in pixels.
944If the current wrap mode is \fBnone\fR and the line extends beyond
945the boundaries of the window,
946the area returned reflects the entire area of the line, including the
947portions that are out of the window.
948If the line is shorter than the full width of the window then the
949area returned reflects just the portion of the line that is occupied
950by characters and embedded windows.
951If the display line containing \fIindex\fR is not visible on
952the screen then the return value is an empty list.
953.IP "\fI$text\fR\->\fBdump\fR(?\fIswitches\fR?, \fIindex1, \fR?\fIindex2\fR?)" 4
954.IX Item "$text->dump(?switches?, index1, ?index2?)"
955Return the contents of the text widget from \fIindex1\fR up to,
956but not including \fIindex2\fR,
957including the text and
958information about marks, tags, and embedded windows.
959If \fIindex2\fR is not specified, then it defaults to
960one character past \fIindex1\fR. The information is returned
961in the following format:
962.Sp
963\&\fIkey1 value1 index1 key2 value2 index2\fR ...
964.PP
965The possible \fIkey\fR values are \fBtext\fR, \fBmark\fR,
966\&\fBtagon\fR, \fBtagoff\fR, and \fI$text\fR. The corresponding
967\&\fIvalue\fR is the text, mark name, tag name, or window name.
968The \fIindex\fR information is the index of the
969start of the text, the mark, the tag transition, or the window.
970One or more of the following switches (or abbreviations thereof)
971may be specified to control the dump:
972.IP "\fB\-all\fR" 4
973.IX Item "-all"
974Return information about all elements: text, marks, tags, and windows.
975This is the default.
976.IP "\fB\-command\fR => \fIcallback\fR" 4
977.IX Item "-command => callback"
978Instead of returning the information as the result of the dump operation,
979invoke the \fIcallback\fR on each element of the text widget within the range.
980The callback has three arguments appended to it before it is evaluated:
981the \fIkey\fR, \fIvalue\fR, and \fIindex\fR.
982.IP "\fB\-mark\fR" 4
983.IX Item "-mark"
984Include information about marks in the dump results.
985.IP "\fB\-tag\fR" 4
986.IX Item "-tag"
987Include information about tag transitions in the dump results. Tag information is
988returned as \fBtagon\fR and \fBtagoff\fR elements that indicate the
989begin and end of each range of each tag, respectively.
990.IP "\fB\-text\fR" 4
991.IX Item "-text"
992Include information about text in the dump results. The value is the
993text up to the next element or the end of range indicated by \fIindex2\fR.
994A text element does not span newlines. A multi-line block of text that
995contains no marks or tag transitions will still be dumped as a set
996of text seqments that each end with a newline. The newline is part
997of the value.
998.IP "\fB\-window\fR" 4
999.IX Item "-window"
1000Include information about embedded windows in the dump results.
1001The value of a window is its Tk pathname, unless the window
1002has not been created yet. (It must have a create script.)
1003In this case an empty string is returned, and you must query the
1004window by its index position to get more information.
1005.IP "\fI$text\fR\->\fBget\fR(\fIindex1, \fR?\fIindex2\fR?)" 4
1006.IX Item "$text->get(index1, ?index2?)"
1007Return a range of characters from the text.
1008The return value will be all the characters in the text starting
1009with the one whose index is \fIindex1\fR and ending just before
1010the one whose index is \fIindex2\fR (the character at \fIindex2\fR
1011will not be returned).
1012If \fIindex2\fR is omitted then the single character at \fIindex1\fR
1013is returned.
1014If there are no characters in the specified range (e.g. \fIindex1\fR
1015is past the end of the file or \fIindex2\fR is less than or equal
1016to \fIindex1\fR) then an empty string is returned.
1017If the specified range contains embedded windows, no information
1018about them is included in the returned string.
1019.IP "\fI$text\fR\->\fBimage\fR(\fIoption\fR, ?\fIarg, arg, ...\fR?)" 4
1020.IX Item "$text->image(option, ?arg, arg, ...?)"
1021.PD 0
1022.IP "\fI$text\fR\->\fBimage\fR\fIOption\fR(?\fIarg, arg, ...\fR?)" 4
1023.IX Item "$text->imageOption(?arg, arg, ...?)"
1024.PD
1025This method is used to manipulate embedded images.
1026The behavior of the method depends on the \fIoption\fR argument
1027that follows the \fBimage\fR prefix.
1028The following forms of the methods are currently supported:
1029.RS 4
1030.IP "\fI$text\fR\->\fBimageCget\fR(\fIindex, option\fR)" 8
1031.IX Item "$text->imageCget(index, option)"
1032Returns the value of a configuration option for an embedded image.
1033\&\fIIndex\fR identifies the embedded image, and \fIoption\fR
1034specifies a particular configuration option, which must be one of
1035the ones listed in \*(L"\s-1EMBEDDED\s0 \s-1IMAGES\s0\*(R".
1036.IP "\fI$text\fR\->\fBimageConfigure\fR(\fIindex, \fR?\fIoption, value, ...\fR?)" 8
1037.IX Item "$text->imageConfigure(index, ?option, value, ...?)"
1038Query or modify the configuration options for an embedded image.
1039If no \fIoption\fR is specified, returns a list describing all of
1040the available options for the embedded image at \fIindex\fR
1041(see Tk::options for information on the format of this list).
1042If \fIoption\fR is specified with no \fIvalue\fR, then the command
1043returns a list describing the one named option (this list will be
1044identical to the corresponding sublist of the value returned if no
1045\&\fIoption\fR is specified).
1046If one or more \fIoption-value\fR pairs are specified, then the command
1047modifies the given option(s) to have the given value(s); in
1048this case the command returns an empty string.
1049See \*(L"\s-1EMBEDDED\s0 \s-1IMAGES\s0\*(R" for information on the options that
1050are supported.
1051.IP "\fI$text\fR\->\fBimageCreate\fR(\fIindex, \fR?\fIoption, value, ...\fR?)" 8
1052.IX Item "$text->imageCreate(index, ?option, value, ...?)"
1053This command creates a new image annotation, which will appear
1054in the text at the position given by \fIindex\fR.
1055Any number of \fIoption-value\fR pairs may be specified to
1056configure the annotation.
1057Returns a unique identifier that may be used as an index to refer to
1058this image.
1059See \*(L"\s-1EMBEDDED\s0 \s-1IMAGES\s0\*(R" for information on the options that
1060are supported, and a description of the identifier returned.
1061.IP "\fI$text\fR\->\fBimageNames\fR" 8
1062.IX Item "$text->imageNames"
1063Returns a list whose elements are the names of all image instances currently
1064embedded in \f(CW$text\fR.
1065.RE
1066.RS 4
1067.RE
1068.IP "\fI$text\fR\->\fBindex\fR(\fIindex\fR)" 4
1069.IX Item "$text->index(index)"
1070Returns the position corresponding to \fIindex\fR in the form
1071\&\fIline.char\fR where \fIline\fR is the line number and \fIchar\fR
1072is the character number.
1073\&\fIIndex\fR may have any of the forms described under \*(L"\s-1INDICES\s0\*(R" above.
1074.IP "\fI$text\fR\->\fBinsert\fR(\fIindex, chars, \fR?\fItagList, chars, tagList, ...\fR?)" 4
1075.IX Item "$text->insert(index, chars, ?tagList, chars, tagList, ...?)"
1076Inserts all of the \fIchars\fR arguments just before the character at
1077\&\fIindex\fR.
1078If \fIindex\fR refers to the end of the text (the character after
1079the last newline) then the new text is inserted just before the
1080last newline instead.
1081If there is a single \fIchars\fR argument and no \fItagList\fR, then
1082the new text will receive any tags that are present on both the
1083character before and the character after the insertion point; if a tag
1084is present on only one of these characters then it will not be
1085applied to the new text.
1086If \fItagList\fR is specified then it consists of a list of
1087tag names; the new characters will receive all of the tags in
1088this list and no others, regardless of the tags present around
1089the insertion point.
1090If multiple \fIchars\fR\-\fItagList\fR argument pairs are present,
1091they produce the same effect as if a separate \fBinsert\fR widget
1092command had been issued for each pair, in order.
1093The last \fItagList\fR argument may be omitted.
1094.IP "\fI$text\fR\->\fBmark\fR(\fIoption, \fR?\fIarg, arg, ...\fR?)" 4
1095.IX Item "$text->mark(option, ?arg, arg, ...?)"
1096This command is used to manipulate marks. The exact behavior of
1097the command depends on the \fIoption\fR argument that follows
1098the \fBmark\fR argument. The following forms of the command
1099are currently supported:
1100.RS 4
1101.IP "\fI$text\fR\->\fBmarkGravity\fR(\fImarkName, \fR?\fIdirection\fR?)" 8
1102.IX Item "$text->markGravity(markName, ?direction?)"
1103If \fIdirection\fR is not specified, returns \fBleft\fR or \fBright\fR
1104to indicate which of its adjacent characters \fImarkName\fR is attached
1105to.
1106If \fIdirection\fR is specified, it must be \fBleft\fR or \fBright\fR;
1107the gravity of \fImarkName\fR is set to the given value.
1108.IP "\fI$text\fR\->\fBmarkNames\fR" 8
1109.IX Item "$text->markNames"
1110Returns a list whose elements are the names of all the marks that
1111are currently set.
1112.IP "\fI$text\fR\->\fBmarkNext\fR(\fIindex\fR)" 8
1113.IX Item "$text->markNext(index)"
1114Returns the name of the next mark at or after \fIindex\fR.
1115If \fIindex\fR is specified in numerical form, then the search for
1116the next mark begins at that index.
1117If \fIindex\fR is the name of a mark, then the search for
1118the next mark begins immediately after that mark.
1119This can still return a mark at the same position if
1120there are multiple marks at the same index.
1121These semantics mean that the \fBmark next\fR operation can be used to
1122step through all the marks in a text widget in the same order
1123as the mark information returned by the \fBdump\fR operation.
1124If a mark has been set to the special \fBend\fR index,
1125then it appears to be \fIafter\fR \fBend\fR with respect to the \fBmark next\fR operation.
1126An empty string is returned if there are no marks after \fIindex\fR.
1127.IP "\fI$text\fR\->\fBmarkPrevious\fR(\fIindex\fR)" 8
1128.IX Item "$text->markPrevious(index)"
1129Returns the name of the mark at or before \fIindex\fR.
1130If \fIindex\fR is specified in numerical form, then the search for
1131the previous mark begins with the character just before that index.
1132If \fIindex\fR is the name of a mark, then the search for
1133the next mark begins immediately before that mark.
1134This can still return a mark at the same position if
1135there are multiple marks at the same index.
1136These semantics mean that the \fBmark previous\fR operation can be used to
1137step through all the marks in a text widget in the reverse order
1138as the mark information returned by the \fBdump\fR operation.
1139An empty string is returned if there are no marks before \fIindex\fR.
1140.IP "\fI$text\fR\->\fBmarkSet\fR(\fImarkName, index\fR)" 8
1141.IX Item "$text->markSet(markName, index)"
1142Sets the mark named \fImarkName\fR to a position just before the
1143character at \fIindex\fR.
1144If \fImarkName\fR already exists, it is moved from its old position;
1145if it doesn't exist, a new mark is created.
1146This command returns an empty string.
1147.IP "\fI$text\fR\->\fBmarkUnset\fR(\fImarkName\fR?, \fImarkName, markName, ...\fR?)" 8
1148.IX Item "$text->markUnset(markName?, markName, markName, ...?)"
1149Remove the mark corresponding to each of the \fImarkName\fR arguments.
1150The removed marks will not be usable in indices and will not be
1151returned by future calls to ``\fI$text\fR\->\fBmarkNames\fR''.
1152This command returns an empty string.
1153.RE
1154.RS 4
1155.RE
1156.IP "\fI$text\fR\->\fBscan\fR(\fIoption\fR, \fIargs\fR) or" 4
1157.IX Item "$text->scan(option, args) or"
1158.PD 0
1159.IP "\fI$text\fR\->\fBscan\fR\fIoption\fR(\fIargs\fR)" 4
1160.IX Item "$text->scanoption(args)"
1161.PD
1162This method is used to implement scanning on texts. It has
1163two forms, depending on \fIoption\fR:
1164.RS 4
1165.IP "\fI$text\fR\->\fBscanMark\fR(\fIx, y\fR)" 8
1166.IX Item "$text->scanMark(x, y)"
1167Records \fIx\fR and \fIy\fR and the current view in the text window,
1168for use in conjunction with later \fBscanDragto\fR method.
1169Typically this method is associated with a mouse button press in
1170the widget. It returns an empty string.
1171.IP "\fI$text\fR\->\fBscanDragto\fR(\fIx, y\fR)" 8
1172.IX Item "$text->scanDragto(x, y)"
1173This command computes the difference between its \fIx\fR and \fIy\fR
1174arguments and the \fIx\fR and \fIy\fR arguments to the last
1175\&\fBscanMark\fR method for the widget.
1176It then adjusts the view by 10 times the difference in coordinates.
1177This command is typically associated
1178with mouse motion events in the widget, to produce the effect of
1179dragging the text at high speed through the window. The return
1180value is an empty string.
1181.RE
1182.RS 4
1183.RE
1184.IP "\fI$text\fR\->\fBsearch\fR(?\fIswitches\fR,? \fIpattern, index, \fR?\fIstopIndex\fR?)" 4
1185.IX Item "$text->search(?switches,? pattern, index, ?stopIndex?)"
1186Searches the text in \fI$text\fR starting at \fIindex\fR for a range
1187of characters that matches \fIpattern\fR.
1188If a match is found, the index of the first character in the match is
1189returned as result; otherwise an empty string is returned.
1190One or more of the following switches (or abbreviations thereof)
1191may be specified to control the search:
1192.RS 4
1193.IP "\fB\-forwards\fR" 8
1194.IX Item "-forwards"
1195The search will proceed forward through the text, finding the first
1196matching range starting at or after the position given by \fIindex\fR.
1197This is the default.
1198.IP "\fB\-backwards\fR" 8
1199.IX Item "-backwards"
1200The search will proceed backward through the text, finding the
1201matching range closest to \fIindex\fR whose first character
1202is before \fIindex\fR.
1203.IP "\fB\-exact\fR" 8
1204.IX Item "-exact"
1205Use exact matching: the characters in the matching range must be
1206identical to those in \fIpattern\fR.
1207This is the default.
1208.IP "\fB\-regexp\fR" 8
1209.IX Item "-regexp"
1210Treat \fIpattern\fR as a regular expression and match it against
1211the text using the rules for regular expressions (see the \fBregexp\fR
1212command for details).
1213.IP "\fB\-nocase\fR" 8
1214.IX Item "-nocase"
1215Ignore case differences between the pattern and the text.
1216.IP "\fB\-count\fR\fI varName\fR" 8
1217.IX Item "-count varName"
1218The argument following \fB\-count\fR gives the name of a variable;
1219if a match is found, the number of characters in the matching
1220range will be stored in the variable.
1221.IP "\fB\-hidden\fR" 8
1222.IX Item "-hidden"
1223Find hidden text as well. By default only displayed text is found.
1224.IP "\fB\-\-\fR" 8
1225.IX Item "--"
1226This switch has no effect except to terminate the list of switches:
1227the next argument will be treated as \fIpattern\fR even if it starts
1228with \fB\-\fR.
1229.RE
1230.RS 4
1231.RE
1232.PP
1233The matching range must be entirely within a single line of text.
1234For regular expression matching the newlines are removed from the ends
1235of the lines before matching: use the \fB$\fR feature in regular
1236expressions to match the end of a line.
1237For exact matching the newlines are retained.
1238If \fIstopIndex\fR is specified, the search stops at that index:
1239for forward searches, no match at or after \fIstopIndex\fR will
1240be considered; for backward searches, no match earlier in the
1241text than \fIstopIndex\fR will be considered.
1242If \fIstopIndex\fR is omitted, the entire text will be searched:
1243when the beginning or end of the text is reached, the search
1244continues at the other end until the starting location is reached
1245again; if \fIstopIndex\fR is specified, no wrap-around will occur.
1246.IP "\fI$text\fR\->\fBsee\fR(\fIindex\fR)" 4
1247.IX Item "$text->see(index)"
1248Adjusts the view in the window so that the character given by \fIindex\fR
1249is completely visible.
1250If \fIindex\fR is already visible then the command does nothing.
1251If \fIindex\fR is a short distance out of view, the command
1252adjusts the view just enough to make \fIindex\fR visible at the
1253edge of the window.
1254If \fIindex\fR is far out of view, then the command centers
1255\&\fIindex\fR in the window.
1256.IP "\fI$text\fR\->\fBtag\fR(\fIoption, \fR?\fIarg, arg, ...\fR?)" 4
1257.IX Item "$text->tag(option, ?arg, arg, ...?)"
1258This command is used to manipulate tags. The exact behavior of the
1259command depends on the \fIoption\fR argument that follows the
1260\&\fBtag\fR argument. The following forms of the command are currently
1261supported:
1262.RS 4
1263.IP "\fI$text\fR\->\fBtagAdd\fR(\fItagName, index1, \fR?\fIindex2, index1, index2, ...\fR?)" 8
1264.IX Item "$text->tagAdd(tagName, index1, ?index2, index1, index2, ...?)"
1265Associate the tag \fItagName\fR with all of the characters starting
1266with \fIindex1\fR and ending just before
1267\&\fIindex2\fR (the character at \fIindex2\fR isn't tagged).
1268A single command may contain any number of \fIindex1\fR\-\fIindex2\fR
1269pairs.
1270If the last \fIindex2\fR is omitted then the single character at
1271\&\fIindex1\fR is tagged.
1272If there are no characters in the specified range (e.g. \fIindex1\fR
1273is past the end of the file or \fIindex2\fR is less than or equal
1274to \fIindex1\fR) then the command has no effect.
1275.IP "\fI$text\fR\->\fBtagBind\fR(\fItagName, \fR?\fIsequence\fR?, ?\fIscript\fR?)" 8
1276.IX Item "$text->tagBind(tagName, ?sequence?, ?script?)"
1277This command associates \fIscript\fR with the tag given by
1278\&\fItagName\fR.
1279Whenever the event sequence given by \fIsequence\fR occurs for a
1280character that has been tagged with \fItagName\fR,
1281the script will be invoked.
1282This method is similar to the \fBbind\fR command except that
1283it operates on characters in a text rather than entire widgets.
1284See the Tk::bind documentation for complete details
1285on the syntax of \fIsequence\fR and the substitutions performed
1286on \fIscript\fR before invoking it.
1287If all arguments are specified then a new binding is created, replacing
1288any existing binding for the same \fIsequence\fR and \fItagName\fR
1289(if the first character of \fIscript\fR is ``+'' then \fIscript\fR
1290augments an existing binding rather than replacing it).
1291In this case the return value is an empty string.
1292If \fIscript\fR is omitted then the command returns the \fIscript\fR
1293associated with \fItagName\fR and \fIsequence\fR (an error occurs
1294if there is no such binding).
1295If both \fIscript\fR and \fIsequence\fR are omitted then the command
1296returns a list of all the sequences for which bindings have been
1297defined for \fItagName\fR.
1298.Sp
1299The only events for which bindings may be specified are those related
1300to the mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR,
1301\&\fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR) or virtual events.
1302Event bindings for a text widget use the \fBcurrent\fR mark described
1303under \*(L"\s-1MARKS\s0\*(R" above. An \fBEnter\fR event triggers for a tag when the tag
1304first becomes present on the current character, and a \fBLeave\fR event
1305triggers for a tag when it ceases to be present on the current character.
1306\&\fBEnter\fR and \fBLeave\fR events can happen either because the
1307\&\fBcurrent\fR mark moved or because the character at that position
1308changed. Note that these events are different than \fBEnter\fR and
1309\&\fBLeave\fR events for windows. Mouse and keyboard events are directed
1310to the current character. If a virtual event is used in a binding, that
1311binding can trigger only if the virtual event is defined by an underlying
1312mouse-related or keyboard-related event.
1313.Sp
1314It is possible for the current character to have multiple tags,
1315and for each of them to have a binding for a particular event
1316sequence.
1317When this occurs, one binding is invoked for each tag, in order
1318from lowest-priority to highest priority.
1319If there are multiple matching bindings for a single tag, then
1320the most specific binding is chosen (see the the documentation for
1321the \fBbind\fR command for details).
1322\&\fBcontinue\fR and \fBbreak\fR commands within binding scripts
1323are processed in the same way as for bindings created with
1324the \fBbind\fR command.
1325.Sp
1326If bindings are created for the widget as a whole using the
1327\&\fBbind\fR command, then those bindings will supplement the
1328tag bindings.
1329The tag bindings will be invoked first, followed by bindings
1330for the window as a whole.
1331.IP "\fI$text\fR\->\fBtagCget\fR(\fItagName, option\fR)" 8
1332.IX Item "$text->tagCget(tagName, option)"
1333This command returns the current value of the option named \fIoption\fR
1334associated with the tag given by \fItagName\fR.
1335\&\fIOption\fR may have any of the values accepted by the \fBtag configure\fR
1336method.
1337.IP "\fI$text\fR\->\fBtagConfigure\fR(\fItagName, \fR?\fIoption\fR?, ?\fIvalue\fR?, ?\fIoption, value, ...\fR?)" 8
1338.IX Item "$text->tagConfigure(tagName, ?option?, ?value?, ?option, value, ...?)"
1339This command is similar to the \fBconfigure\fR method except
1340that it modifies options associated with the tag given by \fItagName\fR
1341instead of modifying options for the overall text widget.
1342If no \fIoption\fR is specified, the command returns a list describing
1343all of the available options for \fItagName\fR
1344(see Tk::options for information on the format of this list).
1345If \fIoption\fR is specified with no \fIvalue\fR, then the command returns
1346a list describing the one named option (this list will be identical to
1347the corresponding sublist of the value returned if no \fIoption\fR
1348is specified).
1349If one or more \fIoption-value\fR pairs are specified, then the command
1350modifies the given option(s) to have the given value(s) in \fItagName\fR;
1351in this case the command returns an empty string.
1352See \*(L"\s-1TAGS\s0\*(R" above for details on the options available for tags.
1353.IP "\fI$text\fR\->\fBtagDelete\fR(\fItagName, \fR?\fItagName, ...\fR?)" 8
1354.IX Item "$text->tagDelete(tagName, ?tagName, ...?)"
1355Deletes all tag information for each of the \fItagName\fR
1356arguments.
1357The command removes the tags from all characters in the file
1358and also deletes any other information associated with the tags,
1359such as bindings and display information.
1360The command returns an empty string.
1361.IP "\fI$text\fR\->\fBtagLower\fR(\fItagName\fR?, \fIbelowThis\fR?)" 8
1362.IX Item "$text->tagLower(tagName?, belowThis?)"
1363Changes the priority of tag \fItagName\fR so that it is just lower
1364in priority than the tag whose name is \fIbelowThis\fR.
1365If \fIbelowThis\fR is omitted, then \fItagName\fR's priority
1366is changed to make it lowest priority of all tags.
1367.IP "\fI$text\fR\->\fBtagNames\fR(?\fIindex\fR?)" 8
1368.IX Item "$text->tagNames(?index?)"
1369Returns a list whose elements are the names of all the tags that
1370are active at the character position given by \fIindex\fR.
1371If \fIindex\fR is omitted, then the return value will describe
1372all of the tags that exist for the text (this includes all tags
1373that have been named in a ``\fI$text\fR\->\fBtag\fR'' widget
1374command but haven't been deleted by a ``\fI$text\fR\->\fBtagDelete\fR''
1375method, even if no characters are currently marked with
1376the tag).
1377The list will be sorted in order from lowest priority to highest
1378priority.
1379.IP "\fI$text\fR\->\fBtagNextrange\fR(\fItagName, index1, \fR?\fIindex2\fR?)" 8
1380.IX Item "$text->tagNextrange(tagName, index1, ?index2?)"
1381This command searches the text for a range of characters tagged
1382with \fItagName\fR where the first character of the range is
1383no earlier than the character at \fIindex1\fR and no later than
1384the character just before \fIindex2\fR (a range starting at
1385\&\fIindex2\fR will not be considered).
1386If several matching ranges exist, the first one is chosen.
1387The command's return value is a list containing
1388two elements, which are the index of the first character of the
1389range and the index of the character just after the last one in
1390the range.
1391If no matching range is found then the return value is an
1392empty string.
1393If \fIindex2\fR is not given then it defaults to the end of the text.
1394.IP "\fI$text\fR\->\fBtagPrevrange\fR(\fItagName, index1, \fR?\fIindex2\fR?)" 8
1395.IX Item "$text->tagPrevrange(tagName, index1, ?index2?)"
1396This command searches the text for a range of characters tagged
1397with \fItagName\fR where the first character of the range is
1398before the character at \fIindex1\fR and no earlier than
1399the character at \fIindex2\fR (a range starting at
1400\&\fIindex2\fR will be considered).
1401If several matching ranges exist, the one closest to \fIindex1\fR is chosen.
1402The command's return value is a list containing
1403two elements, which are the index of the first character of the
1404range and the index of the character just after the last one in
1405the range.
1406If no matching range is found then the return value is an
1407empty string.
1408If \fIindex2\fR is not given then it defaults to the beginning of the text.
1409.IP "\fI$text\fR\->\fBtagRaise\fR(\fItagName, \fR?\fIaboveThis\fR?)" 8
1410.IX Item "$text->tagRaise(tagName, ?aboveThis?)"
1411Changes the priority of tag \fItagName\fR so that it is just higher
1412in priority than the tag whose name is \fIaboveThis\fR.
1413If \fIaboveThis\fR is omitted, then \fItagName\fR's priority
1414is changed to make it highest priority of all tags.
1415.IP "\fI$text\fR\->\fBtagRanges\fR(\fItagName\fR)" 8
1416.IX Item "$text->tagRanges(tagName)"
1417Returns a list describing all of the ranges of text that have been
1418tagged with \fItagName\fR.
1419The first two elements of the list describe the first tagged range
1420in the text, the next two elements describe the second range, and
1421so on.
1422The first element of each pair contains the index of the first
1423character of the range, and the second element of the pair contains
1424the index of the character just after the last one in the
1425range.
1426If there are no characters tagged with \fItag\fR then an
1427empty string is returned.
1428.IP "\fI$text\fR\->\fBtagRemove\fR(\fItagName, index1, \fR?\fIindex2, index1, index2, ...\fR?)" 8
1429.IX Item "$text->tagRemove(tagName, index1, ?index2, index1, index2, ...?)"
1430Remove the tag \fItagName\fR from all of the characters starting
1431at \fIindex1\fR and ending just before
1432\&\fIindex2\fR (the character at \fIindex2\fR isn't affected).
1433A single command may contain any number of \fIindex1\fR\-\fIindex2\fR
1434pairs.
1435If the last \fIindex2\fR is omitted then the single character at
1436\&\fIindex1\fR is tagged.
1437If there are no characters in the specified range (e.g. \fIindex1\fR
1438is past the end of the file or \fIindex2\fR is less than or equal
1439to \fIindex1\fR) then the command has no effect.
1440This command returns an empty string.
1441.RE
1442.RS 4
1443.RE
1444.IP "\fI$text\fR\->\fBwidget\fR(\fIoption?, arg, arg, ...\fR?)" 4
1445.IX Item "$text->widget(option?, arg, arg, ...?)"
1446.PD 0
1447.IP "\fI$text\fR\->\fBwidget\fR\fIOption\fR(?\fIarg, arg, ...\fR?)" 4
1448.IX Item "$text->widgetOption(?arg, arg, ...?)"
1449.PD
1450This method is used to manipulate embedded windows.
1451The behavior of the method depends on the \fIoption\fR argument
1452that follows the \fBwindow\fR argument.
1453The following forms of the method are currently supported:
1454.RS 4
1455.IP "\fI$text\fR\->\fBwindowCget\fR(\fIindex, option\fR)" 8
1456.IX Item "$text->windowCget(index, option)"
1457Returns the value of a configuration option for an embedded window.
1458\&\fIIndex\fR identifies the embedded window, and \fIoption\fR
1459specifies a particular configuration option, which must be one of
1460the ones listed in \*(L"\s-1EMBEDDED\s0 \s-1WINDOWS\s0\*(R" above.
1461.IP "\fI$text\fR\->\fBwindowConfigure\fR(\fIindex\fR?, \fIoption, value, ...\fR?)" 8
1462.IX Item "$text->windowConfigure(index?, option, value, ...?)"
1463Query or modify the configuration options for an embedded window.
1464If no \fIoption\fR is specified, returns a list describing all of
1465the available options for the embedded window at \fIindex\fR
1466(see Tk::options for information on the format of this list).
1467If \fIoption\fR is specified with no \fIvalue\fR, then the command
1468returns a list describing the one named option (this list will be
1469identical to the corresponding sublist of the value returned if no
1470\&\fIoption\fR is specified).
1471If one or more \fIoption-value\fR pairs are specified, then the command
1472modifies the given option(s) to have the given value(s); in
1473this case the command returns an empty string.
1474See \*(L"\s-1EMBEDDED\s0 \s-1WINDOWS\s0\*(R" above for information on the options that
1475are supported.
1476.IP "\fI$text\fR\->\fBwindowCreate\fR(\fIindex\fR?, \fIoption, value, ...\fR?)" 8
1477.IX Item "$text->windowCreate(index?, option, value, ...?)"
1478This command creates a new window annotation, which will appear
1479in the text at the position given by \fIindex\fR.
1480Any number of \fIoption-value\fR pairs may be specified to
1481configure the annotation.
1482See \*(L"\s-1EMBEDDED\s0 \s-1WINDOWS\s0\*(R" above for information on the options that
1483are supported.
1484Returns an empty string.
1485.IP "\fI$text\fR\->\fBwindowNames\fR" 8
1486.IX Item "$text->windowNames"
1487Returns a list whose elements are the names of all windows currently
1488embedded in \f(CW$text\fR.
1489.RE
1490.RS 4
1491.RE
1492.IP "\fI$text\fR\->\fBxview\fR(\fIoption, args\fR)" 4
1493.IX Item "$text->xview(option, args)"
1494This command is used to query and change the horizontal position of the
1495text in the widget's window. It can take any of the following
1496forms:
1497.RS 4
1498.IP "\fI$text\fR\->\fBxview\fR" 8
1499.IX Item "$text->xview"
1500Returns a list containing two elements.
1501Each element is a real fraction between 0 and 1; together they describe
1502the portion of the document's horizontal span that is visible in
1503the window.
1504For example, if the first element is .2 and the second element is .6,
150520% of the text is off-screen to the left, the middle 40% is visible
1506in the window, and 40% of the text is off-screen to the right.
1507The fractions refer only to the lines that are actually visible in the
1508window: if the lines in the window are all very short, so that they
1509are entirely visible, the returned fractions will be 0 and 1,
1510even if there are other lines in the text that are
1511much wider than the window.
1512These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
1513option.
1514.IP "\fI$text\fR\->\fBxviewMoveto\fR(\fIfraction\fR)" 8
1515.IX Item "$text->xviewMoveto(fraction)"
1516Adjusts the view in the window so that \fIfraction\fR of the horizontal
1517span of the text is off-screen to the left.
1518\&\fIFraction\fR is a fraction between 0 and 1.
1519.IP "\fI$text\fR\->\fBxviewScroll\fR(\fInumber, what\fR)" 8
1520.IX Item "$text->xviewScroll(number, what)"
1521This command shifts the view in the window left or right according to
1522\&\fInumber\fR and \fIwhat\fR.
1523\&\fINumber\fR must be an integer.
1524\&\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
1525of one of these.
1526If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
1527\&\fInumber\fR average-width characters on the display; if it is
1528\&\fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
1529If \fInumber\fR is negative then characters farther to the left
1530become visible; if it is positive then characters farther to the right
1531become visible.
1532.RE
1533.RS 4
1534.RE
1535.IP "\fI$text\fR\->\fByview\fR(\fI?args\fR?)" 4
1536.IX Item "$text->yview(?args?)"
1537This command is used to query and change the vertical position of the
1538text in the widget's window.
1539It can take any of the following forms:
1540.RS 4
1541.IP "\fI$text\fR\->\fByview\fR" 8
1542.IX Item "$text->yview"
1543Returns a list containing two elements, both of which are real fractions
1544between 0 and 1.
1545The first element gives the position of the first character in the
1546top line in the window, relative to the text as a whole (0.5 means
1547it is halfway through the text, for example).
1548The second element gives the position of the character just after
1549the last one in the bottom line of the window,
1550relative to the text as a whole.
1551These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
1552option.
1553.IP "\fI$text\fR\->\fByviewMoveto\fR(\fIfraction\fR)" 8
1554.IX Item "$text->yviewMoveto(fraction)"
1555Adjusts the view in the window so that the character given by \fIfraction\fR
1556appears on the top line of the window.
1557\&\fIFraction\fR is a fraction between 0 and 1; 0 indicates the first
1558character in the text, 0.33 indicates the character one-third the
1559way through the text, and so on.
1560.IP "\fI$text\fR\->\fByviewScroll\fR(\fInumber, what\fR)" 8
1561.IX Item "$text->yviewScroll(number, what)"
1562This command adjust the view in the window up or down according to
1563\&\fInumber\fR and \fIwhat\fR.
1564\&\fINumber\fR must be an integer.
1565\&\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
1566If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
1567\&\fInumber\fR lines on the display; if it is \fBpages\fR then
1568the view adjusts by \fInumber\fR screenfuls.
1569If \fInumber\fR is negative then earlier positions in the text
1570become visible; if it is positive then later positions in the text
1571become visible.
1572.IP "\fI$text\fR\->\fByview\fR(?\fB\-pickplace\fR,? \fIindex\fR)" 8
1573.IX Item "$text->yview(?-pickplace,? index)"
1574Changes the view in the \fI$text\fR's window to make \fIindex\fR visible.
1575If the \fB\-pickplace\fR option isn't specified then \fIindex\fR will
1576appear at the top of the window.
1577If \fB\-pickplace\fR is specified then the widget chooses where
1578\&\fIindex\fR appears in the window:
1579.RS 8
1580.IP "[1]" 12
1581.IX Item "[1]"
1582If \fIindex\fR is already visible somewhere in the window then the
1583command does nothing.
1584.IP "[2]" 12
1585.IX Item "[2]"
1586If \fIindex\fR is only a few lines off-screen above the window then
1587it will be positioned at the top of the window.
1588.IP "[3]" 12
1589.IX Item "[3]"
1590If \fIindex\fR is only a few lines off-screen below the window then
1591it will be positioned at the bottom of the window.
1592.IP "[4]" 12
1593.IX Item "[4]"
1594Otherwise, \fIindex\fR will be centered in the window.
1595.RE
1596.RS 8
1597.RE
1598.RE
1599.RS 4
1600.RE
1601.PP
1602The \fB\-pickplace\fR option has been obsoleted by the \fBsee\fR widget
1603command (\fBsee\fR handles both x\- and y\-motion to make a location
1604visible, whereas \fB\-pickplace\fR only handles motion in y).
1605.IP "\fI$text\fR\->\fByview\fR(\fInumber\fR)" 4
1606.IX Item "$text->yview(number)"
1607This command makes the first character on the line after
1608the one given by \fInumber\fR visible at the top of the window.
1609\&\fINumber\fR must be an integer.
1610This command used to be used for scrolling, but now it is obsolete.
1611.SH "BINDINGS"
1612.IX Header "BINDINGS"
1613Tk automatically creates class bindings for texts that give them
1614the following default behavior.
1615In the descriptions below, ``word'' refers to a contiguous group
1616of letters, digits, or ``_'' characters, or any single character
1617other than these.
1618.IP "[1]" 4
1619.IX Item "[1]"
1620Clicking mouse button 1 positions the insertion cursor
1621just before the character underneath the mouse cursor, sets the
1622input focus to this widget, and clears any selection in the widget.
1623Dragging with mouse button 1 strokes out a selection between
1624the insertion cursor and the character under the mouse.
1625.IP "[2]" 4
1626.IX Item "[2]"
1627Double-clicking with mouse button 1 selects the word under the mouse
1628and positions the insertion cursor at the beginning of the word.
1629Dragging after a double click will stroke out a selection consisting
1630of whole words.
1631.IP "[3]" 4
1632.IX Item "[3]"
1633Triple-clicking with mouse button 1 selects the line under the mouse
1634and positions the insertion cursor at the beginning of the line.
1635Dragging after a triple click will stroke out a selection consisting
1636of whole lines.
1637.IP "[4]" 4
1638.IX Item "[4]"
1639The ends of the selection can be adjusted by dragging with mouse
1640button 1 while the Shift key is down; this will adjust the end
1641of the selection that was nearest to the mouse cursor when button
16421 was pressed.
1643If the button is double-clicked before dragging then the selection
1644will be adjusted in units of whole words; if it is triple-clicked
1645then the selection will be adjusted in units of whole lines.
1646.IP "[5]" 4
1647.IX Item "[5]"
1648Clicking mouse button 1 with the Control key down will reposition the
1649insertion cursor without affecting the selection.
1650.IP "[6]" 4
1651.IX Item "[6]"
1652If any normal printing characters are typed, they are
1653inserted at the point of the insertion cursor.
1654.IP "[7]" 4
1655.IX Item "[7]"
1656The view in the widget can be adjusted by dragging with mouse button 2.
1657If mouse button 2 is clicked without moving the mouse, the selection
1658is copied into the text at the position of the mouse cursor.
1659The Insert key also inserts the selection, but at the position of
1660the insertion cursor.
1661.IP "[8]" 4
1662.IX Item "[8]"
1663If the mouse is dragged out of the widget
1664while button 1 is pressed, the entry will automatically scroll to
1665make more text visible (if there is more text off-screen on the side
1666where the mouse left the window).
1667.IP "[9]" 4
1668.IX Item "[9]"
1669The Left and Right keys move the insertion cursor one character to the
1670left or right; they also clear any selection in the text.
1671If Left or Right is typed with the Shift key down, then the insertion
1672cursor moves and the selection is extended to include the new character.
1673Control-Left and Control-Right move the insertion cursor by words, and
1674Control-Shift-Left and Control-Shift-Right move the insertion cursor
1675by words and also extend the selection.
1676Control-b and Control-f behave the same as Left and Right, respectively.
1677Meta-b and Meta-f behave the same as Control-Left and Control\-Right,
1678respectively.
1679.IP "[10]" 4
1680.IX Item "[10]"
1681The Up and Down keys move the insertion cursor one line up or
1682down and clear any selection in the text.
1683If Up or Right is typed with the Shift key down, then the insertion
1684cursor moves and the selection is extended to include the new character.
1685Control-Up and Control-Down move the insertion cursor by paragraphs (groups
1686of lines separated by blank lines), and
1687Control-Shift-Up and Control-Shift-Down move the insertion cursor
1688by paragraphs and also extend the selection.
1689Control-p and Control-n behave the same as Up and Down, respectively.
1690.IP "[11]" 4
1691.IX Item "[11]"
1692The Next and Prior keys move the insertion cursor forward or backwards
1693by one screenful and clear any selection in the text.
1694If the Shift key is held down while Next or Prior is typed, then
1695the selection is extended to include the new character.
1696Control-v moves the view down one screenful without moving the
1697insertion cursor or adjusting the selection.
1698.IP "[12]" 4
1699.IX Item "[12]"
1700Control-Next and Control-Prior scroll the view right or left by one page
1701without moving the insertion cursor or affecting the selection.
1702.IP "[13]" 4
1703.IX Item "[13]"
1704Home and Control-a move the insertion cursor to the
1705beginning of its line and clear any selection in the widget.
1706Shift-Home moves the insertion cursor to the beginning of the line
1707and also extends the selection to that point.
1708.IP "[14]" 4
1709.IX Item "[14]"
1710End and Control-e move the insertion cursor to the
1711end of the line and clear any selection in the widget.
1712Shift-End moves the cursor to the end of the line and extends the selection
1713to that point.
1714.IP "[15]" 4
1715.IX Item "[15]"
1716Control-Home and Meta\-< move the insertion cursor to the beginning of
1717the text and clear any selection in the widget.
1718Control-Shift-Home moves the insertion cursor to the beginning of the text
1719and also extends the selection to that point.
1720.IP "[16]" 4
1721.IX Item "[16]"
1722Control-End and Meta\-> move the insertion cursor to the end of the
1723text and clear any selection in the widget.
1724Control-Shift-End moves the cursor to the end of the text and extends
1725the selection to that point.
1726.IP "[17]" 4
1727.IX Item "[17]"
1728The Select key and Control-Space set the selection anchor to the position
1729of the insertion cursor. They don't affect the current selection.
1730Shift-Select and Control-Shift-Space adjust the selection to the
1731current position of the insertion cursor, selecting from the anchor
1732to the insertion cursor if there was not any selection previously.
1733.IP "[18]" 4
1734.IX Item "[18]"
1735Control\-/ selects the entire contents of the widget.
1736.IP "[19]" 4
1737.IX Item "[19]"
1738Control\-\e clears any selection in the widget.
1739.IP "[20]" 4
1740.IX Item "[20]"
1741The F16 key (labelled Copy on many Sun workstations) or Meta-w
1742copies the selection in the widget to the clipboard, if there is a selection.
1743.IP "[21]" 4
1744.IX Item "[21]"
1745The F20 key (labelled Cut on many Sun workstations) or Control-w
1746copies the selection in the widget to the clipboard and deletes
1747the selection.
1748If there is no selection in the widget then these keys have no effect.
1749.IP "[22]" 4
1750.IX Item "[22]"
1751The F18 key (labelled Paste on many Sun workstations) or Control-y
1752inserts the contents of the clipboard at the position of the
1753insertion cursor.
1754.IP "[23]" 4
1755.IX Item "[23]"
1756The Delete key deletes the selection, if there is one in the widget.
1757If there is no selection, it deletes the character to the right of
1758the insertion cursor.
1759.IP "[24]" 4
1760.IX Item "[24]"
1761Backspace and Control-h delete the selection, if there is one
1762in the widget.
1763If there is no selection, they delete the character to the left of
1764the insertion cursor.
1765.IP "[25]" 4
1766.IX Item "[25]"
1767Control-d deletes the character to the right of the insertion cursor.
1768.IP "[26]" 4
1769.IX Item "[26]"
1770Meta-d deletes the word to the right of the insertion cursor.
1771.IP "[27]" 4
1772.IX Item "[27]"
1773Control-k deletes from the insertion cursor to the end of its line;
1774if the insertion cursor is already at the end of a line, then
1775Control-k deletes the newline character.
1776.IP "[28]" 4
1777.IX Item "[28]"
1778Control-o opens a new line by inserting a newline character in
1779front of the insertion cursor without moving the insertion cursor.
1780.IP "[29]" 4
1781.IX Item "[29]"
1782Meta-backspace and Meta-Delete delete the word to the left of the
1783insertion cursor.
1784.IP "[30]" 4
1785.IX Item "[30]"
1786Control-x deletes whatever is selected in the text widget.
1787.IP "[31]" 4
1788.IX Item "[31]"
1789Control-t reverses the order of the two characters to the right of
1790the insertion cursor.
1791.Sp
1792If the widget is disabled using the \fB\-state\fR option, then its
1793view can still be adjusted and text can still be selected,
1794but no insertion cursor will be displayed and no text modifications will
1795take place.
1796.Sp
1797The behavior of texts can be changed by defining new bindings for
1798individual widgets or by redefining the class bindings.
1799.SH "PERFORMANCE ISSUES"
1800.IX Header "PERFORMANCE ISSUES"
1801Text widgets should run efficiently under a variety
1802of conditions. The text widget uses about 2\-3 bytes of
1803main memory for each byte of text, so texts containing a megabyte
1804or more should be practical on most workstations.
1805Text is represented internally with a modified B\-tree structure
1806that makes operations relatively efficient even with large texts.
1807Tags are included in the B\-tree structure in a way that allows
1808tags to span large ranges or have many disjoint smaller ranges
1809without loss of efficiency.
1810Marks are also implemented in a way that allows large numbers of
1811marks.
1812In most cases it is fine to have large numbers of unique tags,
1813or a tag that has many distinct ranges.
1814.PP
1815One performance problem can arise if you have hundreds or thousands
1816of different tags that all have the following characteristics:
1817the first and last ranges of each tag are near the beginning and
1818end of the text, respectively,
1819or a single tag range covers most of the text widget.
1820The cost of adding and deleting tags like this is proportional
1821to the number of other tags with the same properties.
1822In contrast, there is no problem with having thousands of distinct
1823tags if their overall ranges are localized and spread uniformly throughout
1824the text.
1825.PP
1826Very long text lines can be expensive,
1827especially if they have many marks and tags within them.
1828.PP
1829The display line with the insert cursor is redrawn each time the
1830cursor blinks, which causes a steady stream of graphics traffic.
1831Set the \fB\-insertofftime\fR option to 0 avoid this.
1832.SH "SEE ALSO"
1833.IX Header "SEE ALSO"
1834Tk::ROText
1835Tk::TextUndo
1836.SH "KEYWORDS"
1837.IX Header "KEYWORDS"
1838text, widget