home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _7bc168260ccfddffa6c22bf0abe4450c < prev    next >
Encoding:
Text File  |  2004-06-01  |  81.4 KB  |  2,216 lines

  1. #  Copyright (c) 1992 The Regents of the University of California.
  2. #  Copyright (c) 1994-1996 Sun Microsystems, Inc.
  3. #  Copyright (c) 2002 O'Reilly & Associates Inc.
  4. #  See the file "license.terms" for information on usage and redistribution
  5. #  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  6. #
  7. #
  8.  
  9. =head1 NAME
  10.  
  11. Tk::Text - Create and manipulate Text widgets
  12.  
  13. =for category  Tk Widget Classes
  14.  
  15. =head1 SYNOPSIS
  16.  
  17. B<text> $text ?I<options>?
  18.  
  19. B<-background>    B<-highlightbackground>    B<-insertontime>    B<-selectborderwidth>
  20. B<-borderwidth>    B<-highlightcolor>    B<-insertwidth>    B<-selectforeground>
  21. B<-cursor>    B<-highlightthickness>    B<-padx>    B<-setgrid>
  22. B<-exportselection>    B<-insertbackground>    B<-pady>    B<-takefocus>
  23. B<-font>    B<-insertborderwidth>    B<-relief>    B<-xscrollcommand>
  24. B<-foreground>    B<-insertofftime>    B<-selectbackground>    B<-yscrollcommand>
  25.  
  26. =head1 WIDGET-SPECIFIC OPTIONS
  27.  
  28. =over 4
  29.  
  30. =item Name:    B<height>
  31.  
  32. =item Class:    B<Height>
  33.  
  34. =item Switch:    B<-height>
  35.  
  36. Specifies the desired height for the window, in units of characters
  37. in the font given by the B<-font> option.
  38. Must be at least one.
  39.  
  40. =item Name:    B<spacing1>
  41.  
  42. =item Class:    B<Spacing1>
  43.  
  44. =item Switch:    B<-spacing1>
  45.  
  46. Requests additional space above each text line in the widget,
  47. using any of the standard forms for screen distances.
  48. If a line wraps, this option only applies to the first line
  49. on the display.
  50. This option may be overriden with B<-spacing1> options in
  51. tags.
  52.  
  53. =item Name:    B<spacing2>
  54.  
  55. =item Class:    B<Spacing2>
  56.  
  57. =item Switch:    B<-spacing2>
  58.  
  59. For lines that wrap (so that they cover more than one line on the
  60. display) this option specifies additional space to provide between
  61. the display lines that represent a single line of text.
  62. The value may have any of the standard forms for screen distances.
  63. This option may be overriden with B<-spacing2> options in
  64. tags.
  65.  
  66. =item Name:    B<spacing3>
  67.  
  68. =item Class:    B<Spacing3>
  69.  
  70. =item Switch:    B<-spacing3>
  71.  
  72. Requests additional space below each text line in the widget,
  73. using any of the standard forms for screen distances.
  74. If a line wraps, this option only applies to the last line
  75. on the display.
  76. This option may be overriden with B<-spacing3> options in
  77. tags.
  78.  
  79. =item Name:    B<state>
  80.  
  81. =item Class:    B<State>
  82.  
  83. =item Switch:    B<-state>
  84.  
  85. Specifies one of two states for the text:  B<normal> or B<disabled>.
  86. If the text is disabled then characters may not be inserted or deleted
  87. and no insertion cursor will be displayed, even if the input focus is
  88. in the widget.
  89.  
  90. =item Name:    B<tabs>
  91.  
  92. =item Class:    B<Tabs>
  93.  
  94. =item Switch:    B<-tabs>
  95.  
  96. Specifies a set of tab stops for the window.  The option's value consists
  97. of a list of screen distances giving the positions of the tab stops.  Each
  98. position may optionally be followed in the next list element
  99. by one of the keywords B<left>, B<right>, B<center>,
  100. or B<numeric>, which specifies how to justify
  101. text relative to the tab stop.  B<Left> is the default; it causes
  102. the text following the tab character to be positioned with its left edge
  103. at the tab position.  B<Right> means that the right edge of the text
  104. following the tab character is positioned at the tab position, and
  105. B<center> means that the text is centered at the tab position.
  106. B<Numeric> means that the decimal point in the text is positioned
  107. at the tab position;  if there is no decimal point then the least
  108. significant digit of the number is positioned just to the left of the
  109. tab position;  if there is no number in the text then the text is
  110. right-justified at the tab position.
  111. For example, B<-tabs =E<gt> [qw/2c left 4c 6c center/]> creates three
  112. tab stops at two-centimeter intervals;  the first two use left
  113. justification and the third uses center justification.
  114. If the list of tab stops does not have enough elements to cover all
  115. of the tabs in a text line, then Tk extrapolates new tab stops using
  116. the spacing and alignment from the last tab stop in the list.
  117. The value of the B<tabs> option may be overridden by B<-tabs>
  118. options in tags.
  119. If no B<-tabs> option is specified, or if it is specified as
  120. an empty list, then Tk uses default tabs spaced every eight
  121. (average size) characters.
  122.  
  123. =item Name:    B<width>
  124.  
  125. =item Class:    B<Width>
  126.  
  127. =item Switch:    B<-width>
  128.  
  129. Specifies the desired width for the window in units of characters
  130. in the font given by the B<-font> option.
  131. If the font doesn't have a uniform width then the width of the
  132. character ``0'' is used in translating from character units to
  133. screen units.
  134.  
  135. =item Name:    B<wrap>
  136.  
  137. =item Class:    B<Wrap>
  138.  
  139. =item Switch:    B<-wrap>
  140.  
  141. Specifies how to handle lines in the text that are too long to be
  142. displayed in a single line of the text's window.
  143. The value must be B<none> or B<char> or B<word>.
  144. A wrap mode of B<none> means that each line of text appears as
  145. exactly one line on the screen;  extra characters that don't fit
  146. on the screen are not displayed.
  147. In the other modes each line of text will be broken up into several
  148. screen lines if necessary to keep all the characters visible.
  149. In B<char> mode a screen line break may occur after any character;
  150. in B<word> mode a line break will only be made at word boundaries.
  151.  
  152. =back
  153.  
  154. =head1 DESCRIPTION
  155.  
  156. The B<Text> method creates a new window (given by the
  157. $text argument) and makes it into a text widget.
  158. Additional
  159. options, described above, may be specified on the command line
  160. or in the option database
  161. to configure aspects of the text such as its default background color
  162. and relief.  The B<text> command returns the
  163. path name of the new window.
  164.  
  165. A text widget displays one or more lines of text and allows that
  166. text to be edited.
  167. Text widgets support four different kinds of annotations on the
  168. text, called tags, marks, embedded windows or embedded images.
  169. Tags allow different portions of the text
  170. to be displayed with different fonts and colors.
  171. In addition, L<perl\/Tk callbacks|Tk::callbacks> can be associated with tags so
  172. that scripts are invoked when particular actions such as keystrokes
  173. and mouse button presses occur in particular ranges of the text.
  174. See L<"TAGS"> below for more details.
  175.  
  176. The second form of annotation consists of marks, which are floating
  177. markers in the text.
  178. Marks are used to keep track of various interesting positions in the
  179. text as it is edited.
  180. See L<"MARKS"> below for more details.
  181.  
  182. The third form of annotation allows arbitrary windows to be
  183. embedded in a text widget.
  184. See L<"EMBEDDED WINDOWS"> below for more details.
  185.  
  186. The fourth form of annotation allows Tk images to be embedded in a text
  187. widget.
  188. See L<"EMBEDDED IMAGES"> below for more details.
  189.  
  190. The Perl/Tk B<Text> widget does not support undo/redo, use the B<TextUndo>
  191. widget instead.
  192.  
  193. =head1 INDICES
  194.  
  195. Many of the methods for texts take one or more indices
  196. as arguments.
  197. An index is a string used to indicate a particular place within
  198. a text, such as a place to insert characters or one endpoint of a
  199. range of characters to delete.
  200. Indices have the syntax
  201.  
  202.  base modifier modifier modifier ...
  203.  
  204. Where I<base> gives a starting point and the I<modifier>s
  205. adjust the index from the starting point (e.g. move forward or
  206. backward one character).  Every index must contain a I<base>,
  207. but the I<modifier>s are optional.
  208.  
  209. The I<base> for an index must have one of the following forms:
  210.  
  211. =over 4
  212.  
  213. =item I<line>B<.>I<char>
  214.  
  215. Indicates I<char>'th character on line I<line>.
  216. Lines are numbered from 1 for consistency with other UNIX programs
  217. that use this numbering scheme.
  218. Within a line, characters are numbered from 0.
  219. If I<char> is B<end> then it refers to the newline character
  220. that ends the line.
  221.  
  222. =item B<@>I<x>B<,>I<y>
  223.  
  224. Indicates the character that covers the pixel whose x and y coordinates
  225. within the text's window are I<x> and I<y>.
  226.  
  227. =item B<end>
  228.  
  229. Indicates the end of the text (the character just after the last
  230. newline).
  231.  
  232. =item I<mark>
  233.  
  234. Indicates the character just after the mark whose name is I<mark>.
  235.  
  236. =item I<tag>B<.first>
  237.  
  238. Indicates the first character in the text that has been tagged with
  239. I<tag>.
  240. This form generates an error if no characters are currently tagged
  241. with I<tag>.
  242.  
  243. =item I<tag>B<.last>
  244.  
  245. Indicates the character just after the last one in the text that has
  246. been tagged with I<tag>.
  247. This form generates an error if no characters are currently tagged
  248. with I<tag>.
  249.  
  250. =item I<$widget>
  251.  
  252. Indicates the position of the embedded window referenced by I<$widget>.
  253. This form generates an error if I<$widget> does not reference to an
  254. embedded window.
  255.  
  256. =item I<imageName>
  257.  
  258. Indicates the position of the embedded image whose name is
  259. I<imageName>.
  260. This form generates an error if there is no embedded image
  261. by the given name.
  262.  
  263. If the I<base> could match more than one of the above forms, such
  264. as a I<mark> and I<imageName> both having the same value, then
  265. the form earlier in the above list takes precedence.
  266. If modifiers follow the base index, each one of them must have one
  267. of the forms listed below.  Keywords such as B<chars> and B<wordend>
  268. may be abbreviated as long as the abbreviation is unambiguous.
  269.  
  270. =item B<+ >I<count>B< chars>
  271.  
  272. Adjust the index forward by I<count> characters, moving to later
  273. lines in the text if necessary.  If there are fewer than I<count>
  274. characters in the text after the current index, then set the index
  275. to the last character in the text.
  276. Spaces on either side of I<count> are optional.
  277.  
  278. =item B<- >I<count>B< chars>
  279.  
  280. Adjust the index backward by I<count> characters, moving to earlier
  281. lines in the text if necessary.  If there are fewer than I<count>
  282. characters in the text before the current index, then set the index
  283. to the first character in the text.
  284. Spaces on either side of I<count> are optional.
  285.  
  286. =item B<+ >I<count>B< lines>
  287.  
  288. Adjust the index forward by I<count> lines, retaining the same
  289. character position within the line.  If there are fewer than I<count>
  290. lines after the line containing the current index, then set the index
  291. to refer to the same character position on the last line of the text.
  292. Then, if the line is not long enough to contain a character at the indicated
  293. character position, adjust the character position to refer to the last
  294. character of the line (the newline).
  295. Spaces on either side of I<count> are optional.
  296.  
  297. =item B<- >I<count>B< lines>
  298.  
  299. Adjust the index backward by I<count> lines, retaining the same
  300. character position within the line.  If there are fewer than I<count>
  301. lines before the line containing the current index, then set the index
  302. to refer to the same character position on the first line of the text.
  303. Then, if the line is not long enough to contain a character at the indicated
  304. character position, adjust the character position to refer to the last
  305. character of the line (the newline).
  306. Spaces on either side of I<count> are optional.
  307.  
  308. =item B<linestart>
  309.  
  310. Adjust the index to refer to the first character on the line.
  311.  
  312. =item B<lineend>
  313.  
  314. Adjust the index to refer to the last character on the line (the newline).
  315.  
  316. =item B<wordstart>
  317.  
  318. Adjust the index to refer to the first character of the word containing
  319. the current index.  A word consists of any number of adjacent characters
  320. that are letters, digits, or underscores, or a single character that
  321. is not one of these.
  322.  
  323. =item B<wordend>
  324.  
  325. Adjust the index to refer to the character just after the last one of the
  326. word containing the current index.  If the current index refers to the last
  327. character of the text then it is not modified.
  328.  
  329. If more than one modifier is present then they are applied in
  330. left-to-right order.  For example, the index ``B<end - 1 chars>''
  331. refers to the next-to-last character in the text and
  332. ``B<insert wordstart - 1 c>'' refers to the character just before
  333. the first one in the word containing the insertion cursor.
  334.  
  335. =back
  336.  
  337. =head1 TAGS
  338.  
  339. The first form of annotation in text widgets is a tag.
  340. A tag is a textual string that is associated with some of the characters
  341. in a text.
  342. Tags may contain arbitrary characters, but it is probably best to
  343. avoid using the the characters `` '' (space), B<+>, or B<->:
  344. these characters have special meaning in indices, so tags containing
  345. them can't be used as indices.
  346. There may be any number of tags associated with characters in a
  347. text.
  348. Each tag may refer to a single character, a range of characters, or
  349. several ranges of characters.
  350. An individual character may have any number of tags associated with it.
  351.  
  352. A priority order is defined among tags, and this order is used in
  353. implementing some of the tag-related functions described below.
  354. When a tag is defined (by associating it with characters or setting
  355. its display options or binding callbacks to it), it is given
  356. a priority higher than any existing tag.
  357. The priority order of tags may be redefined using the
  358. ``I<$text>-E<gt>B<tagRaise>'' and ``I<$text>-E<gt>B<tagLower>''
  359. methods.
  360.  
  361. Tags serve three purposes in text widgets.
  362. First, they control the way information is displayed on the screen.
  363. By default, characters are displayed as determined by the
  364. B<background>, B<font>, and B<foreground> options for the
  365. text widget.
  366. However, display options may be associated with individual tags
  367. using the ``I<$text>-E<gt>B<tagConfigure>'' method.
  368. If a character has been tagged, then the display options associated
  369. with the tag override the default display style.
  370. The following options are currently supported for tags:
  371.  
  372. =over 4
  373.  
  374. =item B<-background> =E<gt> I<color>
  375.  
  376. I<Color> specifies the background color to use for characters
  377. associated with the tag.
  378. It may have any of the forms accepted by B<Tk_GetColor>.
  379.  
  380. =item B<-bgstipple> =E<gt> I<bitmap>
  381.  
  382. I<Bitmap> specifies a bitmap that is used as a stipple pattern
  383. for the background.
  384. It may have any of the forms accepted by B<Tk_GetBitmap>.
  385. If I<bitmap> hasn't been specified, or if it is specified
  386. as an empty string, then a solid fill will be used for the
  387. background.
  388.  
  389. =item B<-borderwidth> =E<gt> I<pixels>
  390.  
  391. I<Pixels> specifies the width of a 3-D border to draw around
  392. the background.
  393. It may have any of the forms accepted by B<Tk_GetPixels>.
  394. This option is used in conjunction with the B<-relief>
  395. option to give a 3-D appearance to the background for characters;
  396. it is ignored unless the B<-background> option
  397. has been set for the tag.
  398.  
  399. =item B<-elide> =E<gt> boolean
  400.  
  401. Elide  specifies whether the data should be elided.  Elided data
  402. is not displayed and takes no space on screen,  but  further  on
  403. behaves just as normal data.
  404.  
  405. =item B<-data> =E<gt> I<value>
  406.  
  407. Allows an arbitrary perl scalar I<value> to be associated with the tag.
  408.  
  409. =item B<-fgstipple> =E<gt> I<bitmap>
  410.  
  411. I<Bitmap> specifies a bitmap that is used as a stipple pattern
  412. when drawing text and other foreground information such as
  413. underlines.
  414. It may have any of the forms accepted by B<Tk_GetBitmap>.
  415. If I<bitmap> hasn't been specified, or if it is specified
  416. as an empty string, then a solid fill will be used.
  417.  
  418. =item B<-font> =E<gt> I<fontName>
  419.  
  420. I<FontName> is the name of a font to use for drawing characters.
  421. It may have any of the forms accepted by B<Tk_GetFontStruct>.
  422.  
  423. =item B<-foreground> =E<gt> I<color>
  424.  
  425. I<Color> specifies the color to use when drawing text and other
  426. foreground information such as underlines.
  427. It may have any of the forms accepted by B<Tk_GetColor>.
  428.  
  429. =item B<-justify> =E<gt> I<justify>
  430.  
  431. If the first character of a display line has a tag for which this
  432. option has been specified, then I<justify> determines how to
  433. justify the line.
  434. It must be one of B<left>, B<right>, or B<center>.
  435. If a line wraps, then the justification for each line on the
  436. display is determined by the first character of that display line.
  437.  
  438. =item B<-lmargin1> =E<gt> I<pixels>
  439.  
  440. If the first character of a text line has a tag for which this
  441. option has been specified, then I<pixels> specifies how
  442. much the line should be indented from the left edge of the
  443. window.
  444. I<Pixels> may have any of the standard forms for screen
  445. distances.
  446. If a line of text wraps, this option only applies to the
  447. first line on the display;  the B<-lmargin2> option controls
  448. the indentation for subsequent lines.
  449.  
  450. =item B<-lmargin2> =E<gt> I<pixels>
  451.  
  452. If the first character of a display line has a tag for which this
  453. option has been specified, and if the display line is not the
  454. first for its text line (i.e., the text line has wrapped), then
  455. I<pixels> specifies how much the line should be indented from
  456. the left edge of the window.
  457. I<Pixels> may have any of the standard forms for screen
  458. distances.
  459. This option is only used when wrapping is enabled, and it only
  460. applies to the second and later display lines for a text line.
  461.  
  462. =item B<-offset> =E<gt> I<pixels>
  463.  
  464. I<Pixels> specifies an amount by which the text's baseline
  465. should be offset vertically from the baseline of the overall
  466. line, in pixels.
  467. For example, a positive offset can be used for superscripts
  468. and a negative offset can be used for subscripts.
  469. I<Pixels> may have any of the standard forms for screen
  470. distances.
  471.  
  472. =item B<-overstrike> =E<gt> I<boolean>
  473.  
  474. Specifies whether or not to draw a horizontal rule through
  475. the middle of characters.
  476. I<Boolean> may have any of the forms accepted by B<Tk_GetBoolean>.
  477.  
  478. =item B<-relief> =E<gt> I<relief>
  479.  
  480. I<Relief> specifies the 3-D relief to use for drawing backgrounds,
  481. in any of the forms accepted by B<Tk_GetRelief>.
  482. This option is used in conjunction with the B<-borderwidth>
  483. option to give a 3-D appearance to the background for characters;
  484. it is ignored unless the B<-background> option
  485. has been set for the tag.
  486.  
  487. =item B<-rmargin> =E<gt> I<pixels>
  488.  
  489. If the first character of a display line has a tag for which this
  490. option has been specified, then I<pixels> specifies how wide
  491. a margin to leave between the end of the line and the right
  492. edge of the window.
  493. I<Pixels> may have any of the standard forms for screen
  494. distances.
  495. This option is only used when wrapping is enabled.
  496. If a text line wraps, the right margin for each line on the
  497. display is determined by the first character of that display
  498. line.
  499.  
  500. =item B<-spacing1> =E<gt> I<pixels>
  501.  
  502. I<Pixels> specifies how much additional space should be
  503. left above each text line, using any of the standard forms for
  504. screen distances.
  505. If a line wraps, this option only applies to the first
  506. line on the display.
  507.  
  508. =item B<-spacing2> =E<gt> I<pixels>
  509.  
  510. For lines that wrap, this option specifies how much additional
  511. space to leave between the display lines for a single text line.
  512. I<Pixels> may have any of the standard forms for screen
  513. distances.
  514.  
  515. =item B<-spacing3> =E<gt> I<pixels>
  516.  
  517. I<Pixels> specifies how much additional space should be
  518. left below each text line, using any of the standard forms for
  519. screen distances.
  520. If a line wraps, this option only applies to the last
  521. line on the display.
  522.  
  523. =item B<-tabs> =E<gt> I<tabList>
  524.  
  525. I<TabList> specifies a set of tab stops in the same form
  526. as for the B<-tabs> option for the text widget.  This
  527. option only applies to a display line if it applies to the
  528. first character on that display line.
  529. If this option is specified as an empty string, it cancels
  530. the option, leaving it unspecified for the tag (the default).
  531. If the option is specified as a non-empty string that is
  532. an empty list, such as B<-tabs => " ">, then it requests
  533. default 8-character tabs as described for the B<tabs>
  534. widget option.
  535.  
  536. =item B<-underline> =E<gt> I<boolean>
  537.  
  538. I<Boolean> specifies whether or not to draw an underline underneath
  539. characters.
  540. It may have any of the forms accepted by B<Tk_GetBoolean>.
  541.  
  542. =item B<-wrap> =E<gt> I<mode>
  543.  
  544. I<Mode> specifies how to handle lines that are wider than the
  545. text's window.
  546. It has the same legal values as the B<-wrap> option
  547. for the text widget:  B<none>, B<char>, or B<word>.
  548. If this tag option is specified, it overrides the B<-wrap> option
  549. for the text widget.
  550.  
  551. =back
  552.  
  553. If a character has several tags associated with it, and if their
  554. display options conflict, then the options of the highest priority
  555. tag are used.
  556. If a particular display option hasn't been specified for a
  557. particular tag, or if it is specified as an empty string, then
  558. that option will never be used;  the next-highest-priority
  559. tag's option will used instead.
  560. If no tag specifies a particular display option, then the default
  561. style for the widget will be used.
  562.  
  563. The second purpose for tags is event bindings.
  564. You can associate bindings with a tag in much the same way you can
  565. associate bindings with a widget class:  whenever particular X
  566. events occur on characters with the given tag, a given
  567. <perl/Tk callback|Tk::callbacks> will be executed.
  568. Tag bindings can be used to give behaviors to ranges of characters;
  569. among other things, this allows hypertext-like
  570. features to be implemented.
  571. For details, see the description of the B<tagBind> widget
  572. method below.
  573.  
  574. The third use for tags is in managing the selection.
  575. See L<"THE SELECTION"> below.
  576.  
  577. =head1 MARKS
  578.  
  579. The second form of annotation in text widgets is a mark.
  580. Marks are used for remembering particular places in a text.
  581. They are something like tags, in that they have names and
  582. they refer to places in the file, but a mark isn't associated
  583. with particular characters.
  584. Instead, a mark is associated with the gap between two characters.
  585. Only a single position may be associated with a mark at any given
  586. time.
  587. If the characters around a mark are deleted the mark will still
  588. remain;  it will just have new neighbor characters.
  589. In contrast, if the characters containing a tag are deleted then
  590. the tag will no longer have an association with characters in
  591. the file.
  592. Marks may be manipulated with the ``I<$text>-E<gt>B<mark>'' text widget
  593. method, and their current locations may be determined by using the
  594. mark name as an index in methods.
  595.  
  596. Each mark also has a I<gravity>, which is either B<left> or
  597. B<right>.
  598. The gravity for a mark specifies what happens to the mark when
  599. text is inserted at the point of the mark.
  600. If a mark has left gravity, then the mark is treated as if it
  601. were attached to the character on its left, so the mark will
  602. remain to the left of any text inserted at the mark position.
  603. If the mark has right gravity, new text inserted at the mark
  604. position will appear to the right of the mark.  The gravity
  605. for a mark defaults to B<right>.
  606.  
  607. The name space for marks is different from that for tags:  the
  608. same name may be used for both a mark and a tag, but they will refer
  609. to different things.
  610.  
  611. Two marks have special significance.
  612. First, the mark B<insert> is associated with the insertion cursor,
  613. as described under L<"THE INSERTION CURSOR"> below.
  614. Second, the mark B<current> is associated with the character
  615. closest to the mouse and is adjusted automatically to track the
  616. mouse position and any changes to the text in the widget (one
  617. exception:  B<current> is not updated in response to mouse
  618. motions if a mouse button is down;  the update will be deferred
  619. until all mouse buttons have been released).
  620. Neither of these special marks may be deleted.
  621.  
  622. =head1 EMBEDDED WINDOWS
  623.  
  624. The third form of annotation in text widgets is an embedded window.
  625. Each embedded window annotation causes a window to be displayed
  626. at a particular point in  the text.
  627. There may be any number of embedded windows in a text widget,
  628. and any widget may be used as an embedded window (subject to the
  629. usual rules for geometry management, which require the text window
  630. to be the parent of the embedded window or a descendant of its
  631. parent).
  632. The embedded window's position on the screen will be updated as the
  633. text is modified or scrolled, and it will be mapped and unmapped as
  634. it moves into and out of the visible area of the text widget.
  635. Each embedded window occupies one character's worth of index space
  636. in the text widget, and it may be referred to either by the name
  637. of its embedded window or by its position in the widget's
  638. index space.
  639. If the range of text containing the embedded window is deleted then
  640. the window is destroyed.
  641.  
  642. When an embedded window is added to a text widget with the
  643. B<widgetCreate> method, several configuration
  644. options may be associated with it.
  645. These options may be  modified later with the B<widgetConfigure>
  646. method.
  647. The following options are currently supported:
  648.  
  649. =over 4
  650.  
  651. =item B<-align> =E<gt> I<where>
  652.  
  653. If the window is not as tall as the line in which it is displayed,
  654. this option determines where the window is displayed in the line.
  655. I<Where> must have one of the values B<top> (align the top of the window
  656. with the top of the line), B<center> (center the window
  657. within the range of the line), B<bottom> (align the bottom of the
  658. window with the bottom of the line's area),
  659. or B<baseline> (align the bottom of the window with the baseline
  660. of the line).
  661.  
  662. =item B<-create> =E<gt> I<callback>
  663.  
  664. Specifies a L<callback|Tk::callbacks> that may be evaluated to create the window
  665. for the annotation.
  666. If no B<-window> option has been specified for the annotation
  667. this I<callback> will be evaluated when the annotation is about to
  668. be displayed on the screen.
  669. I<Callback> must create a window for the annotation and return
  670. the name of that window as its result.
  671. If the annotation's window should ever be deleted, I<callback>
  672. will be evaluated again the next time the annotation is displayed.
  673.  
  674. =item B<-padx> =E<gt> I<pixels>
  675.  
  676. I<Pixels> specifies the amount of extra space to leave on
  677. each side of the embedded window.
  678. It may have any of the usual forms defined for a screen distance
  679. (see B<Tk_GetPixels>).
  680.  
  681. =item B<-pady> =E<gt> I<pixels>
  682.  
  683. I<Pixels> specifies the amount of extra space to leave on
  684. the top and on the bottom of the embedded window.
  685. It may have any of the usual forms defined for a screen distance
  686. (see B<Tk_GetPixels>).
  687.  
  688. =item B<-stretch> =E<gt> I<boolean>
  689.  
  690. If the requested height of the embedded window is less than the
  691. height of the line in which it is displayed, this option can be
  692. used to specify whether the window should be stretched vertically
  693. to fill its line.
  694. If the B<-pady> option has been specified as well, then the
  695. requested padding will be retained even if the window is
  696. stretched.
  697.  
  698. =item B<-window> =E<gt> I<$widget>
  699.  
  700. Specifies the name of a window to display in the annotation.
  701.  
  702. =back
  703.  
  704. =head1 EMBEDDED IMAGES
  705.  
  706. The final form of annotation in text widgets is an embedded image.
  707. Each embedded image annotation causes an image to be displayed
  708. at a particular point in  the text.
  709. There may be any number of embedded images in a text widget,
  710. and a particular image may be embedded in multiple places in the same
  711. text widget.
  712. The embedded image's position on the screen will be updated as the
  713. text is modified or scrolled.
  714. Each embedded image occupies one character's worth of index space
  715. in the text widget, and it may be referred to either by
  716. its position in the widget's index space, or the name it is assigned
  717. when the image is inserted into the text widget with B<imageCreate>.
  718. If the range of text containing the embedded image is deleted then
  719. that copy of the image is removed from the screen.
  720.  
  721. When an embedded image is added to a text widget with the B<image>
  722. create method, a name unique to this instance of the image
  723. is returned.  This name may then be used to refer to this image
  724. instance.  The name is taken to be the value of the B<-name> option
  725. (described below).  If the B<-name> option is not provided, the
  726. B<-image> name is used instead.  If the I<imageName> is already
  727. in use in the text widget, then B<#>I<nn> is added to the end of the
  728. I<imageName>, where I<nn> is an arbitrary integer.  This insures
  729. the I<imageName> is unique.
  730. Once this name is assigned to this instance of the image, it does not
  731. change, even though the B<-image> or B<-name> values can be changed
  732. with B<image configure>.
  733.  
  734. When an embedded image is added to a text widget with the
  735. B<imageCreate> method, several configuration
  736. options may be associated with it.
  737. These options may be modified later with the B<image configure>
  738. method.
  739. The following options are currently supported:
  740.  
  741. =over 4
  742.  
  743. =item B<-align> =E<gt> I<where>
  744.  
  745. If the image is not as tall as the line in which it is displayed,
  746. this option determines where the image is displayed in the line.
  747. I<Where> must have one of the values B<top> (align the top of the image
  748. with the top of the line), B<center> (center the image
  749. within the range of the line), B<bottom> (align the bottom of the
  750. image with the bottom of the line's area),
  751. or B<baseline> (align the bottom of the image with the baseline
  752. of the line).
  753.  
  754. =item B<-image> =E<gt> I<image>
  755.  
  756. Specifies the name of the Tk image to display in the annotation.
  757. If I<image> is not a valid Tk image, then an error is returned.
  758.  
  759. =item B<-name> =E<gt> I<ImageName>
  760.  
  761. Specifies the name by which this image instance may be referenced in
  762. the text widget. If I<ImageName> is not supplied, then the
  763. name of the Tk image is used instead.
  764. If the I<imageName> is already in use, I<#nn> is appended to
  765. the end of the name as described above.
  766.  
  767. =item B<-padx> =E<gt> I<pixels>
  768.  
  769. I<Pixels> specifies the amount of extra space to leave on
  770. each side of the embedded image.
  771. It may have any of the usual forms defined for a screen distance.
  772.  
  773. =item B<-pady> =E<gt> I<pixels>
  774.  
  775. I<Pixels> specifies the amount of extra space to leave on
  776. the top and on the bottom of the embedded image.
  777. It may have any of the usual forms defined for a screen distance.
  778.  
  779. =back
  780.  
  781. =head1 THE SELECTION
  782.  
  783. Selection support is implemented via tags.
  784. If the B<exportSelection> option for the text widget is true
  785. then the B<sel> tag will be associated with the selection:
  786.  
  787. =over 4
  788.  
  789. =item [1]
  790.  
  791. Whenever characters are tagged with B<sel> the text widget
  792. will claim ownership of the selection.
  793.  
  794. =item [2]
  795.  
  796. Attempts to retrieve the
  797. selection will be serviced by the text widget, returning all the
  798. characters with the B<sel> tag.
  799.  
  800. =item [3]
  801.  
  802. If the selection is claimed away by another application or by another
  803. window within this application, then the B<sel> tag will be removed
  804. from all characters in the text.
  805.  
  806. =item [4]
  807.  
  808. Whenever the sel tag range changes a virtual event B<<<Selection>>>
  809. is generated.
  810.  
  811. The B<sel> tag is automatically defined when a text widget is
  812. created, and it may not be deleted with the ``I<$text>-E<gt>B<tagDelete>''
  813. method.  Furthermore, the B<selectBackground>,
  814. B<selectBorderWidth>, and B<selectForeground> options for
  815. the text widget are tied to the B<-background>,
  816. B<-borderwidth>, and B<-foreground> options for the B<sel>
  817. tag:  changes in either will automatically be reflected in the
  818. other.
  819.  
  820. =back
  821.  
  822. =head1 THE INSERTION CURSOR
  823.  
  824. The mark named B<insert> has special significance in text widgets.
  825. It is defined automatically when a text widget is created and it
  826. may not be unset with the ``I<$text>-E<gt>B<markUnset>'' widget
  827. command.
  828. The B<insert> mark represents the position of the insertion
  829. cursor, and the insertion cursor will automatically be drawn at
  830. this point whenever the text widget has the input focus.
  831.  
  832. =head1 THE MODIFIED FLAG
  833.  
  834. The text widget can keep track of changes to the content of the  widget
  835. by means of the modified flag. Inserting or deleting text will set this
  836. flag. The flag can be queried, set and cleared programatically as well.
  837. Whenever  the flag changes state a B<<<Modified>>> virtual event is gener-
  838. ated. See the edit modified widget command for more details.
  839.  
  840.  
  841. =head1 WIDGET METHODS
  842.  
  843. The B<Text> method creates a widget object.
  844. This object supports the B<configure> and B<cget> methods
  845. described in L<Tk::options> which can be used to enquire and
  846. modify the options described above.
  847. The widget also inherits all the methods provided by the generic
  848. L<Tk::Widget|Tk::Widget> class.
  849.  
  850. The following additional methods are available for text widgets.
  851. In addition, the extended text widget methods as documented
  852. in I<"Mastering Perl/Tk"> are included in this pod (with
  853. permission from the publisher, B<O'Reilly and Associates Inc.>).
  854.  
  855. =over 4
  856.  
  857. =item I<$text>-E<gt>B<adjustSelect>
  858.  
  859. Moves the end point of the selection and anchor point to the
  860. mouse pointer location.
  861.  
  862. =item I<$text>-E<gt>B<bbox>(I<index>)
  863.  
  864. Returns a list of four elements describing the screen area
  865. of the character given by I<index>.
  866. The first two elements of the list give the x and y coordinates
  867. of the upper-left corner of the area occupied by the
  868. character, and the last two elements give the width and height
  869. of the area.
  870. If the character is only partially visible on the screen, then
  871. the return value reflects just the visible part.
  872. If the character is not visible on the screen then the return
  873. value is an empty list.
  874.  
  875. =item I<$text>-E<gt>B<clipboardColumnCopy>
  876.  
  877. Performs a rectangular copy of the currently selected text with
  878. basic compensation for tab characters.
  879.  
  880. =item I<$text>-E<gt>B<clipboardColumnCut>
  881.  
  882. Performs a rectangular cut of the currently selected text with
  883. basic compensation for tab characters.
  884.  
  885. =item I<$text>-E<gt>B<clipboardColumnPaste>
  886.  
  887. Performs a rectangular paste of the text in the clipboard. The
  888. upper-left corner is specified by the current position of the
  889. insert mark with basic compensation for tab characters.
  890.  
  891. =item I<$text>-E<gt>B<compare>(I<index1, op, index2>)
  892.  
  893. Compares the indices given by I<index1> and I<index2> according
  894. to the relational operator given by I<op>, and returns 1 if
  895. the relationship is satisfied and 0 if it isn't.
  896. I<Op> must be one of the operators E<lt>, E<lt>=, ==, E<gt>=, E<gt>, or !=.
  897. If I<op> is == then 1 is returned if the two indices refer to
  898. the same character, if I<op> is E<lt> then 1 is returned if I<index1>
  899. refers to an earlier character in the text than I<index2>, and
  900. so on.
  901.  
  902. =item I<$text>-E<gt>B<Contents>(I<?args>?)
  903.  
  904. Query or change the entire contents of the text widget. If no
  905. arguments are given, the entire contents of the text widget are
  906. returned. If any arguments are given, the entire contents of the
  907. text widget are deleted and replaced by the argument list.
  908.  
  909. =item I<$text>-E<gt>B<debug>(?I<boolean>?)
  910.  
  911. If I<boolean> is specified, then it must have one of the true or
  912. false values accepted by Tcl_GetBoolean.
  913. If the value is a true one then internal consistency checks will be
  914. turned on in the B-tree code associated with text widgets.
  915. If I<boolean> has a false value then the debugging checks will
  916. be turned off.
  917. In either case the command returns an empty string.
  918. If I<boolean> is not specified then the command returns B<on>
  919. or B<off> to indicate whether or not debugging is turned on.
  920. There is a single debugging switch shared by all text widgets:  turning
  921. debugging on or off in any widget turns it on or off for all widgets.
  922. For widgets with large amounts of text, the consistency checks may
  923. cause a noticeable slow-down.
  924.  
  925. =item I<$text>-E<gt>B<delete>(I<index1, >?I<index2>?)
  926.  
  927. Delete a range of characters from the text.
  928. If both I<index1> and I<index2> are specified, then delete
  929. all the characters starting with the one given by I<index1>
  930. and stopping just before I<index2> (i.e. the character at
  931. I<index2> is not deleted).
  932. If I<index2> doesn't specify a position later in the text
  933. than I<index1> then no characters are deleted.
  934. If I<index2> isn't specified then the single character at
  935. I<index1> is deleted.
  936. It is not allowable to delete characters in a way that would leave
  937. the text without a newline as the last character.
  938. The command returns an empty string.
  939. If more indices are given, multiple ranges of text will
  940. be deleted.  All indices are first checked for  validity  before
  941. any deletions are made.  They are sorted and the text is removed
  942. from the last range to the first range to deleted text does  not
  943. cause  a  undesired  index  shifting  side-effects.  If multiple
  944. ranges with the same start index are  given,  then  the  longest
  945. range  is used.  If overlapping ranges are given, then they will
  946. be merged into spans that do not cause deletion of text  outside
  947. the given ranges due to text shifted during deletion.
  948.  
  949. =item I<$text>-E<gt>B<deleteSelected>
  950.  
  951. Delete the currently selected text.
  952.  
  953. =item I<$text>-E<gt>B<deleteTextTaggedWith>(I<tag>)
  954.  
  955. Delete the text tagged with the I<tag> parameter.
  956.  
  957. =item I<$text>-E<gt>B<deleteToEndofLine>
  958.  
  959. Delete from the insert mark location to the end of line.
  960.  
  961. =item I<$text>-E<gt>B<dlineinfo>(I<index>)
  962.  
  963. Returns a list with five elements describing the area occupied
  964. by the display line containing I<index>.
  965. The first two elements of the list give the x and y coordinates
  966. of the upper-left corner of the area occupied by the
  967. line, the third and fourth elements give the width and height
  968. of the area, and the fifth element gives the position of the baseline
  969. for the line, measured down from the top of the area.
  970. All of this information is measured in pixels.
  971. If the current wrap mode is B<none> and the line extends beyond
  972. the boundaries of the window,
  973. the area returned reflects the entire area of the line, including the
  974. portions that are out of the window.
  975. If the line is shorter than the full width of the window then the
  976. area returned reflects just the portion of the line that is occupied
  977. by characters and embedded windows.
  978. If the display line containing I<index> is not visible on
  979. the screen then the return value is an empty list.
  980.  
  981. =item I<$text>-E<gt>B<dump>(?I<switches>?, I<index1, >?I<index2>?)
  982.  
  983. Return the contents of the text widget from I<index1> up to,
  984. but not including I<index2>,
  985. including the text and
  986. information about marks, tags, and embedded windows.
  987. If I<index2> is not specified, then it defaults to
  988. one character past I<index1>.  The information is returned
  989. in the following format:
  990.  
  991. I<key1 value1 index1 key2 value2 index2> ...
  992.  
  993. The possible I<key> values are B<text>, B<mark>,
  994. B<tagon>, B<tagoff>, and I<$text>.  The corresponding
  995. I<value> is the text, mark name, tag name, or window name.
  996. The I<index> information is the index of the
  997. start of the text, the mark, the tag transition, or the window.
  998. One or more of the following switches (or abbreviations thereof)
  999. may be specified to control the dump:
  1000.  
  1001. =over 4
  1002.  
  1003. =item B<-all>
  1004.  
  1005. Return information about all elements: text, marks, tags, and windows.
  1006. This is the default.
  1007.  
  1008. =item B<-command> =E<gt> I<callback>
  1009.  
  1010. Instead of returning the information as the result of the dump operation,
  1011. invoke the I<callback> on each element of the text widget within the range.
  1012. The callback has three arguments appended to it before it is evaluated:
  1013. the I<key>, I<value>, and I<index>.
  1014.  
  1015. =item B<-mark>
  1016.  
  1017. Include information about marks in the dump results.
  1018.  
  1019. =item B<-tag>
  1020.  
  1021. Include information about tag transitions in the dump results. Tag information is
  1022. returned as B<tagon> and B<tagoff> elements that indicate the
  1023. begin and end of each range of each tag, respectively.
  1024.  
  1025. =item B<-text>
  1026.  
  1027. Include information about text in the dump results.  The value is the
  1028. text up to the next element or the end of range indicated by I<index2>.
  1029. A text element does not span newlines.  A multi-line block of text that
  1030. contains no marks or tag transitions will still be dumped as a set
  1031. of text seqments that each end with a newline.  The newline is part
  1032. of the value.
  1033.  
  1034. =item B<-window>
  1035.  
  1036. =back
  1037.  
  1038. Include information about embedded windows in the dump results.
  1039. The value of a window is its Tk pathname, unless the window
  1040. has not been created yet.  (It must have a create script.)
  1041. In this case an empty string is returned, and you must query the
  1042. window by its index position to get more information.
  1043.  
  1044. =item I<$text>-E<gt>B<edit>( I< option, ?arg, arg ...?> );
  1045.  
  1046. This  command controls the undo mechanism and the modified flag.
  1047. The exact behavior of the command depends on the option argument
  1048. that follows the edit argument.  The following forms of the command
  1049. are currently supported:
  1050.  
  1051. =over 4
  1052.  
  1053. =item I<$text>-E<gt>B<editModified>( ?boolean? );
  1054.  
  1055. If boolean is not specified, returns the modified flag of
  1056. the widget. The insert, delete, edit undo and  edit  redo
  1057. commands  or the user can set or clear the modified flag.
  1058. If boolean is specified, sets the modified  flag  of  the
  1059. widget to boolean.
  1060.  
  1061. =item I<$text>-E<gt>B<editRedo>;
  1062.  
  1063. (Not implemented, use B<TextUndo>.)  When the B<-undo> option is true,
  1064. reapplies the last undone edits provided no other edits were done
  1065. since then. Generates an error when the redo stack is empty.  Does
  1066. nothing when the B<-undo> option is false.
  1067.  
  1068. =item I<$text>-E<gt>B<editReset>;
  1069.  
  1070. (Not implemented, use B<TextUndo>.) Clears the undo and redo stacks.
  1071.  
  1072. =item I<$text>-E<gt>B<editSeparator>;
  1073.  
  1074. (Not implemented, use B<TextUndo>.) Inserts a separator (boundary) on
  1075. the undo stack. Does nothing when the -undo option is false.
  1076.  
  1077. =item I<$text>-E<gt>B<editUndo>;
  1078.  
  1079. (Not implemented, use B<TextUndo>.) Undoes the last edit action when
  1080. the -undo option is true.  An edit action is defined as all the insert
  1081. and delete commands that are recorded on the undo stack in between two
  1082. separators. Generates an error when the undo stack is empty.  Does
  1083. nothing when the -undo option is false.
  1084.  
  1085. =back
  1086.  
  1087. =item I<$text>-E<gt>B<FindAll>(I<mode, case, pattern>)
  1088.  
  1089. Removes any current selections and then performs a global text
  1090. search. All matches are tagged with the B<sel> tag.
  1091.  
  1092. I<mode> can be be B<-exact> or B<-regexp>. See the B<search> command
  1093. for more information
  1094.  
  1095. I<case> can be B<-nocase> or B<-case>. See the B<search> command
  1096. for more information
  1097.  
  1098. I<pattern> is an exact string to match if I<mode> is B<-exact> or a
  1099. regular expression if the match I<mode> is B<-regexp>.
  1100.  
  1101.  
  1102. =item I<$text>-E<gt>B<FindAndReplaceAll>(I<mode, case, find, replace>)
  1103.  
  1104. Same as the B<FindAll> method, however additionally substitutes the
  1105. matched text with the characters I<replace>.
  1106.  
  1107. =item I<$text>-E<gt>B<FindAndReplacePopUp>
  1108.  
  1109. Creates a find-and-replace popup window if one does not already exist.
  1110. If there is currently selected text, then the 'find' field will be
  1111. 'pre-filled' with the selection.
  1112.  
  1113. =item I<$text>-E<gt>B<FindNext>(I<direction, mode, case, pattern>)
  1114.  
  1115. Removes any current selections and then performs a forward or reverse
  1116. text search. All matches are tagged with the B<sel> tag. I<direction>
  1117. can be B<-forward> or B<-reverse>. I<mode, case> and I<pattern> are
  1118. as for the B<FindAll> method.
  1119.  
  1120. =item I<$text>-E<gt>B<FindPopUp>
  1121.  
  1122. Creates a find popup, if one does not yet exist. If there is currently
  1123. selected text, then the 'find' field will be 'pre-filled' with the
  1124. selection.
  1125.  
  1126. =item I<$text>-E<gt>B<FindSelectionNext>
  1127.  
  1128. Gets the currently selected text and removes all selections. It then
  1129. finds the next exact, case-sensitive string that matches in a forward
  1130. direction and selects the text and makes the new selection visible.
  1131.  
  1132. =item I<$text>-E<gt>B<FindSelectionPrevious>
  1133.  
  1134. Gets the currently selected text and removes all selections. It then
  1135. finds the next exact, case-sensitive string that matches in a reverse
  1136. direction and selects the text and makes the new selection visible.
  1137.  
  1138. =item I<$text>-E<gt>B<get>(I<index1, >?I<index2>?)
  1139.  
  1140. Return a range of characters from the text.  The return value will be
  1141. all the characters in the text starting with the one whose index is
  1142. I<index1> and ending just before the one whose index is I<index2> (the
  1143. character at I<index2> will not be returned).  If I<index2> is omitted
  1144. then the single character at I<index1> is returned.  If there are no
  1145. characters in the specified range (e.g. I<index1> is past the end of
  1146. the file or I<index2> is less than or equal to I<index1>) then an
  1147. empty string is returned.  If the specified range contains embedded
  1148. windows, no information about them is included in the returned string.
  1149. If multiple index pairs are given, multiple ranges of text will be
  1150. returned in a list.  Invalid ranges will not be represented with empty
  1151. strings in the list.  The ranges are returned in the order passed to
  1152. B<get>.
  1153.  
  1154. =item I<$text>-E<gt>B<getSelected>
  1155.  
  1156. Return the currently selected text.
  1157.  
  1158. =item I<$text>-E<gt>B<GetTextTaggedWith>(I<tag>)
  1159.  
  1160. Return the text tagged with the I<tag> parameter.
  1161.  
  1162. =item I<$text>-E<gt>B<GotoLineNumber>(I<line_number>)
  1163.  
  1164. Set the insert mark to I<line_number> and ensures the line is
  1165. visible.
  1166.  
  1167. =item I<$text>-E<gt>B<GotoLineNumberPopUp>(I<line_number>)
  1168.  
  1169. Displays a popup, pre-filling it with selected numeric text
  1170. (if any), or the line number from B<GotoLineNumber> (if any).
  1171.  
  1172. =item I<$text>-E<gt>B<image>(I<option>, ?I<arg, arg, ...>?)
  1173.  
  1174. =item I<$text>-E<gt>B<image>I<Option>(?I<arg, arg, ...>?)
  1175.  
  1176. This method is used to manipulate embedded images.
  1177. The behavior of the method depends on the I<option> argument
  1178. that follows the B<image> prefix.
  1179. The following forms of the methods are currently supported:
  1180.  
  1181. =over 8
  1182.  
  1183. =item I<$text>-E<gt>B<imageCget>(I<index, option>)
  1184.  
  1185. Returns the value of a configuration option for an embedded image.
  1186. I<Index> identifies the embedded image, and I<option>
  1187. specifies a particular configuration option, which must be one of
  1188. the ones listed in L<"EMBEDDED IMAGES">.
  1189.  
  1190. =item I<$text>-E<gt>B<imageConfigure>(I<index, >?I<option, value, ...>?)
  1191.  
  1192. Query or modify the configuration options for an embedded image.
  1193. If no I<option> is specified, returns a list describing all of
  1194. the available options for the embedded image at I<index>
  1195. (see L<Tk::options> for information on the format of this list).
  1196. If I<option> is specified with no I<value>, then the command
  1197. returns a list describing the one named option (this list will be
  1198. identical to the corresponding sublist of the value returned if no
  1199. I<option> is specified).
  1200. If one or more I<option-value> pairs are specified, then the command
  1201. modifies the given option(s) to have the given value(s);  in
  1202. this case the command returns an empty string.
  1203. See L<"EMBEDDED IMAGES"> for information on the options that
  1204. are supported.
  1205.  
  1206. =item I<$text>-E<gt>B<imageCreate>(I<index, >?I<option, value, ...>?)
  1207.  
  1208. This command creates a new image annotation, which will appear
  1209. in the text at the position given by I<index>.
  1210. Any number of I<option-value> pairs may be specified to
  1211. configure the annotation.
  1212. Returns a unique identifier that may be used as an index to refer to
  1213. this image.
  1214. See L<"EMBEDDED IMAGES"> for information on the options that
  1215. are supported, and a description of the identifier returned.
  1216.  
  1217. =item I<$text>-E<gt>B<imageNames>
  1218.  
  1219. Returns a list whose elements are the names of all image instances currently
  1220. embedded in $text.
  1221.  
  1222. =back
  1223.  
  1224. =item I<$text>-E<gt>B<index>(I<index>)
  1225.  
  1226. Returns the position corresponding to I<index> in the form
  1227. I<line.char> where I<line> is the line number and I<char>
  1228. is the character number.
  1229. I<Index> may have any of the forms described under L<"INDICES"> above.
  1230.  
  1231. =item I<$text>-E<gt>B<insert>(I<index, chars, >?I<tagList, chars, tagList, ...>?)
  1232.  
  1233. Inserts all of the I<chars> arguments just before the character at
  1234. I<index>.
  1235. If I<index> refers to the end of the text (the character after
  1236. the last newline) then the new text is inserted just before the
  1237. last newline instead.
  1238. If there is a single I<chars> argument and no I<tagList>, then
  1239. the new text will receive any tags that are present on both the
  1240. character before and the character after the insertion point; if a tag
  1241. is present on only one of these characters then it will not be
  1242. applied to the new text.
  1243. If I<tagList> is specified then it consists of a list of
  1244. tag names;  the new characters will receive all of the tags in
  1245. this list and no others, regardless of the tags present around
  1246. the insertion point.
  1247. If multiple I<chars>-I<tagList> argument pairs are present,
  1248. they produce the same effect as if a separate B<insert> widget
  1249. command had been issued for each pair, in order.
  1250. The last I<tagList> argument may be omitted.
  1251.  
  1252. =item I<$text>-E<gt>B<Insert>(I<string>)
  1253.  
  1254. Do NOT confuse this with the lower-case B<insert> method.
  1255. Insert I<string> at the point of the insertion cursor. If there is
  1256. a selection in the text, and it covers the point of the insertion
  1257. cursor, then it deletes the selection before inserting.
  1258.  
  1259. =item I<$text>-E<gt>B<InsertKeypress>(I<character>)
  1260.  
  1261. Inserts I<character> at the B<insert> mark. If in overstrike mode,
  1262. it firsts deletes the character at the B<insert> mark.
  1263.  
  1264. =item I<$text>-E<gt>B<InsertSelection>
  1265.  
  1266. Inserts the current selection at the B<insert> mark.
  1267.  
  1268. =item I<$text>-E<gt>B<insertTab>
  1269.  
  1270. Inserts a tab (\t) character at the B<insert> mark.
  1271.  
  1272. =item I<$text>-E<gt>B<mark>(I<option, >?I<arg, arg, ...>?)
  1273.  
  1274. This command is used to manipulate marks.  The exact behavior of
  1275. the command depends on the I<option> argument that follows
  1276. the B<mark> argument.  The following forms of the command
  1277. are currently supported:
  1278.  
  1279. =over 8
  1280.  
  1281. =item I<$text>-E<gt>B<markGravity>(I<markName, >?I<direction>?)
  1282.  
  1283. If I<direction> is not specified, returns B<left> or B<right>
  1284. to indicate which of its adjacent characters I<markName> is attached
  1285. to.
  1286. If I<direction> is specified, it must be B<left> or B<right>;
  1287. the gravity of I<markName> is set to the given value.
  1288.  
  1289. =item I<$text>-E<gt>B<markNames>
  1290.  
  1291. Returns a list whose elements are the names of all the marks that
  1292. are currently set.
  1293.  
  1294. =item I<$text>-E<gt>B<markNext>(I<index>)
  1295.  
  1296. Returns the name of the next mark at or after I<index>.
  1297. If I<index> is specified in numerical form, then the search for
  1298. the next mark begins at that index.
  1299. If I<index> is the name of a mark, then the search for
  1300. the next mark begins immediately after that mark.
  1301. This can still return a mark at the same position if
  1302. there are multiple marks at the same index.
  1303. These semantics mean that the B<mark next> operation can be used to
  1304. step through all the marks in a text widget in the same order
  1305. as the mark information returned by the B<dump> operation.
  1306. If a mark has been set to the special B<end> index,
  1307. then it appears to be I<after> B<end> with respect to the B<mark next> operation.
  1308. An empty string is returned if there are no marks after I<index>.
  1309.  
  1310. =item I<$text>-E<gt>B<markPrevious>(I<index>)
  1311.  
  1312. Returns the name of the mark at or before I<index>.
  1313. If I<index> is specified in numerical form, then the search for
  1314. the previous mark begins with the character just before that index.
  1315. If I<index> is the name of a mark, then the search for
  1316. the next mark begins immediately before that mark.
  1317. This can still return a mark at the same position if
  1318. there are multiple marks at the same index.
  1319. These semantics mean that the B<mark previous> operation can be used to
  1320. step through all the marks in a text widget in the reverse order
  1321. as the mark information returned by the B<dump> operation.
  1322. An empty string is returned if there are no marks before I<index>.
  1323.  
  1324. =item I<$text>-E<gt>B<markSet>(I<markName, index>)
  1325.  
  1326. Sets the mark named I<markName> to a position just before the
  1327. character at I<index>.
  1328. If I<markName> already exists, it is moved from its old position;
  1329. if it doesn't exist, a new mark is created.
  1330. This command returns an empty string.
  1331.  
  1332. =item I<$text>-E<gt>B<markUnset>(I<markName>?, I<markName, markName, ...>?)
  1333.  
  1334. Remove the mark corresponding to each of the I<markName> arguments.
  1335. The removed marks will not be usable in indices and will not be
  1336. returned by future calls to ``I<$text>-E<gt>B<markNames>''.
  1337. This command returns an empty string.
  1338.  
  1339. =back
  1340.  
  1341. =item I<$text>-E<gt>B<markExists>(I<markname>)
  1342.  
  1343. Returns true if I<markname> exists - false otherwise.
  1344.  
  1345. =item I<$text>-E<gt>B<menu>(I<?menu?>)
  1346.  
  1347. If I<menu> reference is given as an argument, then the text widget
  1348. menu is adjusted to use this new I<menu>. If the I<menu> argument
  1349. is B<undef>, then this command disables the current text widget menu.
  1350. If the I<menu> argument is omitted altogether, then the current text
  1351. widget menu reference is returned.
  1352.  
  1353. =item I<$text>-E<gt>B<openLine>
  1354.  
  1355. Inserts a newline (\n) at the insert mark.
  1356.  
  1357. =item I<$text>-E<gt>B<OverstrikeMode>(I<?boolean?>)
  1358.  
  1359. Returns the overstrike mode if I<boolean> is omitted or sets the
  1360. overstrike mode to I<boolean>. True means overstrike mode is enabled.
  1361.  
  1362. =item I<$text>-E<gt>B<PostPopupMenu>(I<x,y>)
  1363.  
  1364. Creates a popup menu at the specified (I<x,y>) pixel coordinates. The
  1365. default menu has File, Edit, Search and View menu items which cascade
  1366. to sub-menus for further commands. There is an implicit E<lt>Button-3E<gt>
  1367. binding to this method that posts the menu over the cursor.
  1368.  
  1369. =item I<$text>-E<gt>B<ResetAnchor>
  1370.  
  1371. Sets the selection anchor to whichever end is farthest from the index
  1372. argument.
  1373.  
  1374. =item I<$text>-E<gt>B<scan>(I<option>, I<args>) or
  1375.  
  1376. =item I<$text>-E<gt>B<scan>I<option>(I<args>)
  1377.  
  1378. This method is used to implement scanning on texts.  It has
  1379. two forms, depending on I<option>:
  1380.  
  1381. =over 8
  1382.  
  1383. =item I<$text>-E<gt>B<scanMark>(I<x, y>)
  1384.  
  1385. Records I<x> and I<y> and the current view in the text window,
  1386. for use in conjunction with later B<scanDragto> method.
  1387. Typically this method is associated with a mouse button press in
  1388. the widget.  It returns an empty string.
  1389.  
  1390. =item I<$text>-E<gt>B<scanDragto>(I<x, y>)
  1391.  
  1392. This command computes the difference between its I<x> and I<y>
  1393. arguments and the I<x> and I<y> arguments to the last
  1394. B<scanMark> method for the widget.
  1395. It then adjusts the view by 10 times the difference in coordinates.
  1396. This command is typically associated
  1397. with mouse motion events in the widget, to produce the effect of
  1398. dragging the text at high speed through the window.  The return
  1399. value is an empty string.
  1400.  
  1401. =back
  1402.  
  1403. =item I<$text>-E<gt>B<search>(?I<switches>,? I<pattern, index, >?I<stopIndex>?)
  1404.  
  1405. Searches the text in I<$text> starting at I<index> for a range
  1406. of characters that matches I<pattern>.
  1407. If a match is found, the index of the first character in the match is
  1408. returned as result;  otherwise an empty string is returned.
  1409. One or more of the following switches (or abbreviations thereof)
  1410. may be specified to control the search:
  1411.  
  1412. =over 8
  1413.  
  1414. =item B<-forwards>
  1415.  
  1416. The search will proceed forward through the text, finding the first
  1417. matching range starting at or after the position given by I<index>.
  1418. This is the default.
  1419.  
  1420. =item B<-backwards>
  1421.  
  1422. The search will proceed backward through the text, finding the
  1423. matching range closest to I<index> whose first character
  1424. is before I<index>.
  1425.  
  1426. =item B<-exact>
  1427.  
  1428. Use exact matching:  the characters in the matching range must be
  1429. identical to those in I<pattern>.
  1430. This is the default.
  1431.  
  1432. =item B<-regexp>
  1433.  
  1434. Treat I<pattern> as a regular expression and match it against
  1435. the text using the rules for regular expressions (see the B<regexp>
  1436. command for details).
  1437.  
  1438. =item B<-nocase>
  1439.  
  1440. Ignore case differences between the pattern and the text.
  1441.  
  1442. =item B<-count>I< varName>
  1443.  
  1444. The argument following B<-count> gives the name of a variable;
  1445. if a match is found, the number of characters in the matching
  1446. range will be stored in the variable.
  1447.  
  1448. =item B<-hidden>
  1449.  
  1450. Find hidden text as well. By default only displayed text is found.
  1451.  
  1452. =item B<-->
  1453.  
  1454. This switch has no effect except to terminate the list of switches:
  1455. the next argument will be treated as I<pattern> even if it starts
  1456. with B<->.
  1457.  
  1458. =back
  1459.  
  1460. =back
  1461.  
  1462. The matching range must be entirely within a single line of text.
  1463. For regular expression matching the newlines are removed from the ends
  1464. of the lines before matching:  use the B<$> feature in regular
  1465. expressions to match the end of a line.
  1466. For exact matching the newlines are retained.
  1467. If I<stopIndex> is specified, the search stops at that index:
  1468. for forward searches, no match at or after I<stopIndex> will
  1469. be considered;  for backward searches, no match earlier in the
  1470. text than I<stopIndex> will be considered.
  1471. If I<stopIndex> is omitted, the entire text will be searched:
  1472. when the beginning or end of the text is reached, the search
  1473. continues at the other end until the starting location is reached
  1474. again;  if I<stopIndex> is specified, no wrap-around will occur.
  1475.  
  1476. =over 4
  1477.  
  1478. =item I<$text>-E<gt>B<see>(I<index>)
  1479.  
  1480. Adjusts the view in the window so that the character given by I<index>
  1481. is completely visible.
  1482. If I<index> is already visible then the command does nothing.
  1483. If I<index> is a short distance out of view, the command
  1484. adjusts the view just enough to make I<index> visible at the
  1485. edge of the window.
  1486. If I<index> is far out of view, then the command centers
  1487. I<index> in the window.
  1488.  
  1489. =item I<$text>-E<gt>B<selectAll>
  1490.  
  1491. Selects all the text in the widget.
  1492.  
  1493. =item I<$text>-E<gt>B<selectLine>
  1494.  
  1495. Selects the line with the insert mark.
  1496.  
  1497. =item I<$text>-E<gt>B<selectWord>
  1498.  
  1499. Selects the word with the insert mark.
  1500.  
  1501. =item I<$text>-E<gt>B<SetCursor>(I<position>)
  1502.  
  1503. Moves the insert mark to I<position>.
  1504.  
  1505. =item I<$text>-E<gt>B<tag>(I<option, >?I<arg, arg, ...>?)
  1506.  
  1507. This command is used to manipulate tags.  The exact behavior of the
  1508. command depends on the I<option> argument that follows the
  1509. B<tag> argument.  The following forms of the command are currently
  1510. supported:
  1511.  
  1512. =over 8
  1513.  
  1514. =item I<$text>-E<gt>B<tagAdd>(I<tagName, index1, >?I<index2, index1, index2, ...>?)
  1515.  
  1516. Associate the tag I<tagName> with all of the characters starting
  1517. with I<index1> and ending just before
  1518. I<index2> (the character at I<index2> isn't tagged).
  1519. A single command may contain any number of I<index1>-I<index2>
  1520. pairs.
  1521. If the last I<index2> is omitted then the single character at
  1522. I<index1> is tagged.
  1523. If there are no characters in the specified range (e.g. I<index1>
  1524. is past the end of the file or I<index2> is less than or equal
  1525. to I<index1>) then the command has no effect.
  1526.  
  1527. =item I<$text>-E<gt>B<tagBind>(I<tagName, >?I<sequence>?, ?I<script>?)
  1528.  
  1529. This command associates I<script> with the tag given by
  1530. I<tagName>.
  1531. Whenever the event sequence given by I<sequence> occurs for a
  1532. character that has been tagged with I<tagName>,
  1533. the script will be invoked.
  1534. This method is similar to the B<bind> command except that
  1535. it operates on characters in a text rather than entire widgets.
  1536. See the L<Tk::bind> documentation for complete details
  1537. on the syntax of I<sequence> and the substitutions performed
  1538. on I<script> before invoking it.
  1539. If all arguments are specified then a new binding is created, replacing
  1540. any existing binding for the same I<sequence> and I<tagName>
  1541. (if the first character of I<script> is ``+'' then I<script>
  1542. augments an existing binding rather than replacing it).
  1543. In this case the return value is an empty string.
  1544. If I<script> is omitted then the command returns the I<script>
  1545. associated with I<tagName> and I<sequence> (an error occurs
  1546. if there is no such binding).
  1547. If both I<script> and I<sequence> are omitted then the command
  1548. returns a list of all the sequences for which bindings have been
  1549. defined for I<tagName>.
  1550.  
  1551. The only events for which bindings may be specified are those related
  1552. to the mouse and keyboard (such as B<Enter>, B<Leave>,
  1553. B<ButtonPress>, B<Motion>, and B<KeyPress>) or virtual events.
  1554. Event bindings for a text widget use the B<current> mark described
  1555. under L<"MARKS"> above.  An B<Enter> event triggers for a tag when the tag
  1556. first becomes present on the current character, and a B<Leave> event
  1557. triggers for a tag when it ceases to be present on the current character.
  1558. B<Enter> and B<Leave> events can happen either because the
  1559. B<current> mark moved or because the character at that position
  1560. changed.  Note that these events are different than B<Enter> and
  1561. B<Leave> events for windows.  Mouse and keyboard events are directed
  1562. to the current character.  If a virtual event is used in a binding, that
  1563. binding can trigger only if the virtual event is defined by an underlying
  1564. mouse-related or keyboard-related event.
  1565.  
  1566. It is possible for the current character to have multiple tags,
  1567. and for each of them to have a binding for a particular event
  1568. sequence.
  1569. When this occurs, one binding is invoked for each tag, in order
  1570. from lowest-priority to highest priority.
  1571. If there are multiple matching bindings for a single tag, then
  1572. the most specific binding is chosen (see the the documentation for
  1573. the B<bind> command for details).
  1574. B<continue> and B<break> commands within binding scripts
  1575. are processed in the same way as for bindings created with
  1576. the B<bind> command.
  1577.  
  1578. If bindings are created for the widget as a whole using the
  1579. B<bind> command, then those bindings will supplement the
  1580. tag bindings.
  1581. The tag bindings will be invoked first, followed by bindings
  1582. for the window as a whole.
  1583.  
  1584. =item I<$text>-E<gt>B<tagCget>(I<tagName, option>)
  1585.  
  1586. This command returns the current value of the option named I<option>
  1587. associated with the tag given by I<tagName>.
  1588. I<Option> may have any of the values accepted by the B<tag configure>
  1589. method.
  1590.  
  1591. =item I<$text>-E<gt>B<tagConfigure>(I<tagName, >?I<option>?, ?I<value>?, ?I<option, value, ...>?)
  1592.  
  1593. This command is similar to the B<configure> method except
  1594. that it modifies options associated with the tag given by I<tagName>
  1595. instead of modifying options for the overall text widget.
  1596. If no I<option> is specified, the command returns a list describing
  1597. all of the available options for I<tagName>
  1598. (see L<Tk::options> for information on the format of this list).
  1599. If I<option> is specified with no I<value>, then the command returns
  1600. a list describing the one named option (this list will be identical to
  1601. the corresponding sublist of the value returned if no I<option>
  1602. is specified).
  1603. If one or more I<option-value> pairs are specified, then the command
  1604. modifies the given option(s) to have the given value(s) in I<tagName>;
  1605. in this case the command returns an empty string.
  1606. See L<"TAGS"> above for details on the options available for tags.
  1607.  
  1608. =item I<$text>-E<gt>B<tagDelete>(I<tagName, >?I<tagName, ...>?)
  1609.  
  1610. Deletes all tag information for each of the I<tagName>
  1611. arguments.
  1612. The command removes the tags from all characters in the file
  1613. and also deletes any other information associated with the tags,
  1614. such as bindings and display information.
  1615. The command returns an empty string.
  1616.  
  1617. =item I<$text>-E<gt>B<tagLower>(I<tagName>?, I<belowThis>?)
  1618.  
  1619. Changes the priority of tag I<tagName> so that it is just lower
  1620. in priority than the tag whose name is I<belowThis>.
  1621. If I<belowThis> is omitted, then I<tagName>'s priority
  1622. is changed to make it lowest priority of all tags.
  1623.  
  1624. =item I<$text>-E<gt>B<tagNames>(?I<index>?)
  1625.  
  1626. Returns a list whose elements are the names of all the tags that
  1627. are active at the character position given by I<index>.
  1628. If I<index> is omitted, then the return value will describe
  1629. all of the tags that exist for the text (this includes all tags
  1630. that have been named in a ``I<$text>-E<gt>B<tag>'' widget
  1631. command but haven't been deleted by a ``I<$text>-E<gt>B<tagDelete>''
  1632. method, even if no characters are currently marked with
  1633. the tag).
  1634. The list will be sorted in order from lowest priority to highest
  1635. priority.
  1636.  
  1637. =item I<$text>-E<gt>B<tagNextrange>(I<tagName, index1, >?I<index2>?)
  1638.  
  1639. This command searches the text for a range of characters tagged
  1640. with I<tagName> where the first character of the range is
  1641. no earlier than the character at I<index1> and no later than
  1642. the character just before I<index2> (a range starting at
  1643. I<index2> will not be considered).
  1644. If several matching ranges exist, the first one is chosen.
  1645. The command's return value is a list containing
  1646. two elements, which are the index of the first character of the
  1647. range and the index of the character just after the last one in
  1648. the range.
  1649. If no matching range is found then the return value is an
  1650. empty string.
  1651. If I<index2> is not given then it defaults to the end of the text.
  1652.  
  1653. =item I<$text>-E<gt>B<tagPrevrange>(I<tagName, index1, >?I<index2>?)
  1654.  
  1655. This command searches the text for a range of characters tagged
  1656. with I<tagName> where the first character of the range is
  1657. before the character at I<index1> and no earlier than
  1658. the character at I<index2> (a range starting at
  1659. I<index2> will be considered).
  1660. If several matching ranges exist, the one closest to I<index1> is chosen.
  1661. The command's return value is a list containing
  1662. two elements, which are the index of the first character of the
  1663. range and the index of the character just after the last one in
  1664. the range.
  1665. If no matching range is found then the return value is an
  1666. empty string.
  1667. If I<index2> is not given then it defaults to the beginning of the text.
  1668.  
  1669. =item I<$text>-E<gt>B<tagRaise>(I<tagName, >?I<aboveThis>?)
  1670.  
  1671. Changes the priority of tag I<tagName> so that it is just higher
  1672. in priority than the tag whose name is I<aboveThis>.
  1673. If I<aboveThis> is omitted, then I<tagName>'s priority
  1674. is changed to make it highest priority of all tags.
  1675.  
  1676. =item I<$text>-E<gt>B<tagRanges>(I<tagName>)
  1677.  
  1678. Returns a list describing all of the ranges of text that have been
  1679. tagged with I<tagName>.
  1680. The first two elements of the list describe the first tagged range
  1681. in the text, the next two elements describe the second range, and
  1682. so on.
  1683. The first element of each pair contains the index of the first
  1684. character of the range, and the second element of the pair contains
  1685. the index of the character just after the last one in the
  1686. range.
  1687. If there are no characters tagged with I<tag> then an
  1688. empty string is returned.
  1689.  
  1690. =item I<$text>-E<gt>B<tagRemove>(I<tagName, index1, >?I<index2, index1, index2, ...>?)
  1691.  
  1692. Remove the tag I<tagName> from all of the characters starting
  1693. at I<index1> and ending just before
  1694. I<index2> (the character at I<index2> isn't affected).
  1695. A single command may contain any number of I<index1>-I<index2>
  1696. pairs.
  1697. If the last I<index2> is omitted then the single character at
  1698. I<index1> is tagged.
  1699. If there are no characters in the specified range (e.g. I<index1>
  1700. is past the end of the file or I<index2> is less than or equal
  1701. to I<index1>) then the command has no effect.
  1702. This command returns an empty string.
  1703.  
  1704. =back
  1705.  
  1706. =item I<$text>-E<gt>B<ToggleInsertMode>
  1707.  
  1708. Toggles the current overstrike mode.
  1709.  
  1710. =item I<$text>-E<gt>B<unselectAll>
  1711.  
  1712. Unselects all the text in the widget.
  1713.  
  1714. =item I<$text>-E<gt>B<WhatLineNumberPopup>
  1715.  
  1716. Creates a popup that displays the current line number of the
  1717. insert mark.
  1718.  
  1719. =item I<$text>->B<widget>(I<option?, arg, arg, ...>?)
  1720.  
  1721. =item I<$text>->B<widget>I<Option>(?I<arg, arg, ...>?)
  1722.  
  1723. This method is used to manipulate embedded windows.
  1724. The behavior of the method depends on the I<option> argument
  1725. that follows the B<window> argument.
  1726. The following forms of the method are currently supported:
  1727.  
  1728. =over 8
  1729.  
  1730. =item I<$text>->B<windowCget>(I<index, option>)
  1731.  
  1732. Returns the value of a configuration option for an embedded window.
  1733. I<Index> identifies the embedded window, and I<option>
  1734. specifies a particular configuration option, which must be one of
  1735. the ones listed in L<"EMBEDDED WINDOWS"> above.
  1736.  
  1737. =item I<$text>->B<windowConfigure>(I<index>?, I<option, value, ...>?)
  1738.  
  1739. Query or modify the configuration options for an embedded window.
  1740. If no I<option> is specified, returns a list describing all of
  1741. the available options for the embedded window at I<index>
  1742. (see L<Tk::options> for information on the format of this list).
  1743. If I<option> is specified with no I<value>, then the command
  1744. returns a list describing the one named option (this list will be
  1745. identical to the corresponding sublist of the value returned if no
  1746. I<option> is specified).
  1747. If one or more I<option-value> pairs are specified, then the command
  1748. modifies the given option(s) to have the given value(s);  in
  1749. this case the command returns an empty string.
  1750. See L<"EMBEDDED WINDOWS"> above for information on the options that
  1751. are supported.
  1752.  
  1753. =item I<$text>->B<windowCreate>(I<index>?, I<option, value, ...>?)
  1754.  
  1755. This command creates a new window annotation, which will appear
  1756. in the text at the position given by I<index>.
  1757. Any number of I<option-value> pairs may be specified to
  1758. configure the annotation.
  1759. See L<"EMBEDDED WINDOWS"> above for information on the options that
  1760. are supported.
  1761. Returns an empty string.
  1762.  
  1763. =item I<$text>->B<windowNames>
  1764.  
  1765. Returns a list whose elements are the names of all windows currently
  1766. embedded in $text.
  1767.  
  1768. =back
  1769.  
  1770. =item I<$text>->B<xview>(I<option, args>)
  1771.  
  1772. This command is used to query and change the horizontal position of the
  1773. text in the widget's window.  It can take any of the following
  1774. forms:
  1775.  
  1776. =over 8
  1777.  
  1778. =item I<$text>->B<xview>
  1779.  
  1780. Returns a list containing two elements.
  1781. Each element is a real fraction between 0 and 1;  together they describe
  1782. the portion of the document's horizontal span that is visible in
  1783. the window.
  1784. For example, if the first element is .2 and the second element is .6,
  1785. 20% of the text is off-screen to the left, the middle 40% is visible
  1786. in the window, and 40% of the text is off-screen to the right.
  1787. The fractions refer only to the lines that are actually visible in the
  1788. window:  if the lines in the window are all very short, so that they
  1789. are entirely visible, the returned fractions will be 0 and 1,
  1790. even if there are other lines in the text that are
  1791. much wider than the window.
  1792. These are the same values passed to scrollbars via the B<-xscrollcommand>
  1793. option.
  1794.  
  1795. =item I<$text>-E<gt>B<xviewMoveto>(I<fraction>)
  1796.  
  1797. Adjusts the view in the window so that I<fraction> of the horizontal
  1798. span of the text is off-screen to the left.
  1799. I<Fraction> is a fraction between 0 and 1.
  1800.  
  1801. =item I<$text>-E<gt>B<xviewScroll>(I<number, what>)
  1802.  
  1803. This command shifts the view in the window left or right according to
  1804. I<number> and I<what>.
  1805. I<Number> must be an integer.
  1806. I<What> must be either B<units> or B<pages> or an abbreviation
  1807. of one of these.
  1808. If I<what> is B<units>, the view adjusts left or right by
  1809. I<number> average-width characters on the display;  if it is
  1810. B<pages> then the view adjusts by I<number> screenfuls.
  1811. If I<number> is negative then characters farther to the left
  1812. become visible;  if it is positive then characters farther to the right
  1813. become visible.
  1814.  
  1815. =back
  1816.  
  1817. =item I<$text>-E<gt>B<yview>(I<?args>?)
  1818.  
  1819. This command is used to query and change the vertical position of the
  1820. text in the widget's window.
  1821. It can take any of the following forms:
  1822.  
  1823. =over 8
  1824.  
  1825. =item I<$text>-E<gt>B<yview>
  1826.  
  1827. Returns a list containing two elements, both of which are real fractions
  1828. between 0 and 1.
  1829. The first element gives the position of the first character in the
  1830. top line in the window, relative to the text as a whole (0.5 means
  1831. it is halfway through the text, for example).
  1832. The second element gives the position of the character just after
  1833. the last one in the bottom line of the window,
  1834. relative to the text as a whole.
  1835. These are the same values passed to scrollbars via the B<-yscrollcommand>
  1836. option.
  1837.  
  1838. =item I<$text>-E<gt>B<yviewMoveto>(I<fraction>)
  1839.  
  1840. Adjusts the view in the window so that the character given by I<fraction>
  1841. appears on the top line of the window.
  1842. I<Fraction> is a fraction between 0 and 1;  0 indicates the first
  1843. character in the text, 0.33 indicates the character one-third the
  1844. way through the text, and so on.
  1845.  
  1846. =item I<$text>-E<gt>B<yviewScroll>(I<number, what>)
  1847.  
  1848. This command adjust the view in the window up or down according to
  1849. I<number> and I<what>.
  1850. I<Number> must be an integer.
  1851. I<What> must be either B<units> or B<pages>.
  1852. If I<what> is B<units>, the view adjusts up or down by
  1853. I<number> lines on the display;  if it is B<pages> then
  1854. the view adjusts by I<number> screenfuls.
  1855. If I<number> is negative then earlier positions in the text
  1856. become visible;  if it is positive then later positions in the text
  1857. become visible.
  1858.  
  1859. =item I<$text>->B<yview>(?B<-pickplace>,? I<index>)
  1860.  
  1861. Changes the view in the I<$text>'s window to make I<index> visible.
  1862. If the B<-pickplace> option isn't specified then I<index> will
  1863. appear at the top of the window.
  1864. If B<-pickplace> is specified then the widget chooses where
  1865. I<index> appears in the window:
  1866.  
  1867. =over 12
  1868.  
  1869. =item [1]
  1870.  
  1871. If I<index> is already visible somewhere in the window then the
  1872. command does nothing.
  1873.  
  1874. =item [2]
  1875.  
  1876. If I<index> is only a few lines off-screen above the window then
  1877. it will be positioned at the top of the window.
  1878.  
  1879. =item [3]
  1880.  
  1881. If I<index> is only a few lines off-screen below the window then
  1882. it will be positioned at the bottom of the window.
  1883.  
  1884. =item [4]
  1885.  
  1886. Otherwise, I<index> will be centered in the window.
  1887.  
  1888. =back
  1889.  
  1890. =back
  1891.  
  1892. =back
  1893.  
  1894. The B<-pickplace> option has been obsoleted by the B<see> widget
  1895. command (B<see> handles both x- and y-motion to make a location
  1896. visible, whereas B<-pickplace> only handles motion in y).
  1897.  
  1898. =over 4
  1899.  
  1900. =item I<$text>-E<gt>B<yview>(I<number>)
  1901.  
  1902. This command makes the first character on the line after
  1903. the one given by I<number> visible at the top of the window.
  1904. I<Number> must be an integer.
  1905. This command used to be used for scrolling, but now it is obsolete.
  1906.  
  1907. =back
  1908.  
  1909. =head1 BINDINGS
  1910.  
  1911. Tk automatically creates class bindings for texts that give them
  1912. the following default behavior.
  1913. In the descriptions below, ``word'' refers to a contiguous group
  1914. of letters, digits, or ``_'' characters, or any single character
  1915. other than these.
  1916.  
  1917. =over 4
  1918.  
  1919. =item [1]
  1920.  
  1921. Clicking mouse button 1 positions the insertion cursor
  1922. just before the character underneath the mouse cursor, sets the
  1923. input focus to this widget, and clears any selection in the widget.
  1924. Dragging with mouse button 1 strokes out a selection between
  1925. the insertion cursor and the character under the mouse.
  1926.  
  1927. =item [2]
  1928.  
  1929. Double-clicking with mouse button 1 selects the word under the mouse
  1930. and positions the insertion cursor at the beginning of the word.
  1931. Dragging after a double click will stroke out a selection consisting
  1932. of whole words.
  1933.  
  1934. =item [3]
  1935.  
  1936. Triple-clicking with mouse button 1 selects the line under the mouse
  1937. and positions the insertion cursor at the beginning of the line.
  1938. Dragging after a triple click will stroke out a selection consisting
  1939. of whole lines.
  1940.  
  1941. =item [4]
  1942.  
  1943. The ends of the selection can be adjusted by dragging with mouse
  1944. button 1 while the Shift key is down;  this will adjust the end
  1945. of the selection that was nearest to the mouse cursor when button
  1946. 1 was pressed.
  1947. If the button is double-clicked before dragging then the selection
  1948. will be adjusted in units of whole words;  if it is triple-clicked
  1949. then the selection will be adjusted in units of whole lines.
  1950.  
  1951. =item [5]
  1952.  
  1953. Clicking mouse button 1 with the Control key down will reposition the
  1954. insertion cursor without affecting the selection.
  1955.  
  1956. =item [6]
  1957.  
  1958. If any normal printing characters are typed, they are
  1959. inserted at the point of the insertion cursor.
  1960.  
  1961. =item [7]
  1962.  
  1963. The view in the widget can be adjusted by dragging with mouse button 2.
  1964. If mouse button 2 is clicked without moving the mouse, the selection
  1965. is copied into the text at the position of the mouse cursor.
  1966. The Insert key also inserts the selection, but at the position of
  1967. the insertion cursor.
  1968.  
  1969. =item [8]
  1970.  
  1971. If the mouse is dragged out of the widget
  1972. while button 1 is pressed, the entry will automatically scroll to
  1973. make more text visible (if there is more text off-screen on the side
  1974. where the mouse left the window).
  1975.  
  1976. =item [9]
  1977.  
  1978. The Left and Right keys move the insertion cursor one character to the
  1979. left or right;  they also clear any selection in the text.
  1980. If Left or Right is typed with the Shift key down, then the insertion
  1981. cursor moves and the selection is extended to include the new character.
  1982. Control-Left and Control-Right move the insertion cursor by words, and
  1983. Control-Shift-Left and Control-Shift-Right move the insertion cursor
  1984. by words and also extend the selection.
  1985. Control-b and Control-f behave the same as Left and Right, respectively.
  1986. Meta-b and Meta-f behave the same as Control-Left and Control-Right,
  1987. respectively.
  1988.  
  1989. =item [10]
  1990.  
  1991. The Up and Down keys move the insertion cursor one line up or
  1992. down and clear any selection in the text.
  1993. If Up or Right is typed with the Shift key down, then the insertion
  1994. cursor moves and the selection is extended to include the new character.
  1995. Control-Up and Control-Down move the insertion cursor by paragraphs (groups
  1996. of lines separated by blank lines), and
  1997. Control-Shift-Up and Control-Shift-Down move the insertion cursor
  1998. by paragraphs and also extend the selection.
  1999. Control-p and Control-n behave the same as Up and Down, respectively.
  2000.  
  2001. =item [11]
  2002.  
  2003. The Next and Prior keys move the insertion cursor forward or backwards
  2004. by one screenful and clear any selection in the text.
  2005. If the Shift key is held down while Next or Prior is typed, then
  2006. the selection is extended to include the new character.
  2007. Control-v moves the view down one screenful without moving the
  2008. insertion cursor or adjusting the selection.
  2009.  
  2010. =item [12]
  2011.  
  2012. Control-Next and Control-Prior scroll the view right or left by one page
  2013. without moving the insertion cursor or affecting the selection.
  2014.  
  2015. =item [13]
  2016.  
  2017. Home and Control-a move the insertion cursor to the
  2018. beginning of its line and clear any selection in the widget.
  2019. Shift-Home moves the insertion cursor to the beginning of the line
  2020. and also extends the selection to that point.
  2021.  
  2022. =item [14]
  2023.  
  2024. End and Control-e move the insertion cursor to the
  2025. end of the line and clear any selection in the widget.
  2026. Shift-End moves the cursor to the end of the line and extends the selection
  2027. to that point.
  2028.  
  2029. =item [15]
  2030.  
  2031. Control-Home and Meta-E<lt> move the insertion cursor to the beginning of
  2032. the text and clear any selection in the widget.
  2033. Control-Shift-Home moves the insertion cursor to the beginning of the text
  2034. and also extends the selection to that point.
  2035.  
  2036. =item [16]
  2037.  
  2038. Control-End and Meta-E<gt> move the insertion cursor to the end of the
  2039. text and clear any selection in the widget.
  2040. Control-Shift-End moves the cursor to the end of the text and extends
  2041. the selection to that point.
  2042.  
  2043. =item [17]
  2044.  
  2045. The Select key and Control-Space set the selection anchor to the position
  2046. of the insertion cursor.  They don't affect the current selection.
  2047. Shift-Select and Control-Shift-Space adjust the selection to the
  2048. current position of the insertion cursor, selecting from the anchor
  2049. to the insertion cursor if there was not any selection previously.
  2050.  
  2051. =item [18]
  2052.  
  2053. Control-/ selects the entire contents of the widget.
  2054.  
  2055. =item [19]
  2056.  
  2057. Control-\ clears any selection in the widget.
  2058.  
  2059. =item [20]
  2060.  
  2061. The F16 key (labelled Copy on many Sun workstations) or Meta-w
  2062. copies the selection in the widget to the clipboard, if there is a selection.
  2063.  
  2064. =item [21]
  2065.  
  2066. The F20 key (labelled Cut on many Sun workstations) or Control-w
  2067. copies the selection in the widget to the clipboard and deletes
  2068. the selection.
  2069. If there is no selection in the widget then these keys have no effect.
  2070.  
  2071. =item [22]
  2072.  
  2073. The F18 key (labelled Paste on many Sun workstations) or Control-y
  2074. inserts the contents of the clipboard at the position of the
  2075. insertion cursor.
  2076.  
  2077. =item [23]
  2078.  
  2079. The Delete key deletes the selection, if there is one in the widget.
  2080. If there is no selection, it deletes the character to the right of
  2081. the insertion cursor.
  2082.  
  2083. =item [24]
  2084.  
  2085. Backspace and Control-h delete the selection, if there is one
  2086. in the widget.
  2087. If there is no selection, they delete the character to the left of
  2088. the insertion cursor.
  2089.  
  2090. =item [25]
  2091.  
  2092. Control-d deletes the character to the right of the insertion cursor.
  2093.  
  2094. =item [26]
  2095.  
  2096. Meta-d deletes the word to the right of the insertion cursor.
  2097.  
  2098. =item [27]
  2099.  
  2100. Control-k deletes from the insertion cursor to the end of its line;
  2101. if the insertion cursor is already at the end of a line, then
  2102. Control-k deletes the newline character.
  2103.  
  2104. =item [28]
  2105.  
  2106. Control-o opens a new line by inserting a newline character in
  2107. front of the insertion cursor without moving the insertion cursor.
  2108.  
  2109. =item [29]
  2110.  
  2111. Meta-backspace and Meta-Delete delete the word to the left of the
  2112. insertion cursor.
  2113.  
  2114. =item [30]
  2115.  
  2116. Control-x deletes whatever is selected in the text widget.
  2117.  
  2118. =item [31]
  2119.  
  2120. Control-t reverses the order of the two characters to the right of
  2121. the insertion cursor.
  2122.  
  2123. =item [32]
  2124.  
  2125. Control-z (and Control-underscore on UNIX when tk_strictMotif is
  2126. true)  undoes  the last edit action if the -undo option is true.
  2127. Does nothing otherwise.
  2128.  
  2129. =item [33]
  2130.  
  2131. Control-Z (or Control-y on Windows) reapplies the last undone edit
  2132. action if the -undo option is true. Does nothing otherwise.
  2133.  
  2134. =back
  2135.  
  2136. If the widget is disabled using the B<-state> option, then its
  2137. view can still be adjusted and text can still be selected,
  2138. but no insertion cursor will be displayed and no text modifications will
  2139. take place.
  2140.  
  2141. The behavior of texts can be changed by defining new bindings for
  2142. individual widgets or by redefining the class bindings.
  2143.  
  2144.  
  2145. =head1 TIED INTERFACE
  2146.  
  2147. The Perl/Tk Text widget also has built-in TIEHANDLE methods for
  2148. B<print> and B<printf> statements. This means you can print to file
  2149. handles tied to a Text widget, and the tied methods automatically
  2150. insert the print statement's arguments into the Text widget.
  2151.  
  2152. For example:
  2153.  
  2154.  #!/usr/local/bin/perl -w
  2155.  use POSIX 'acos';
  2156.  use Tk;
  2157.  use strict;
  2158.  
  2159.  my $mw = MainWindow->new;
  2160.  my $text = $mw->Text(qw/-width 40 -height 10/)->pack;
  2161.  
  2162.  tie *STDOUT, ref $text, $text;
  2163.  
  2164.  print "Hello Text World!\n";
  2165.  printf "pi ~= %1.5f", acos(-1.0);
  2166.  
  2167.  MainLoop;
  2168.  
  2169.  
  2170. =head1 PERFORMANCE ISSUES
  2171.  
  2172. Text widgets should run efficiently under a variety
  2173. of conditions.  The text widget uses about 2-3 bytes of
  2174. main memory for each byte of text, so texts containing a megabyte
  2175. or more should be practical on most workstations.
  2176. Text is represented internally with a modified B-tree structure
  2177. that makes operations relatively efficient even with large texts.
  2178. Tags are included in the B-tree structure in a way that allows
  2179. tags to span large ranges or have many disjoint smaller ranges
  2180. without loss of efficiency.
  2181. Marks are also implemented in a way that allows large numbers of
  2182. marks.
  2183. In most cases it is fine to have large numbers of unique tags,
  2184. or a tag that has many distinct ranges.
  2185.  
  2186. One performance problem can arise if you have hundreds or thousands
  2187. of different tags that all have the following characteristics:
  2188. the first and last ranges of each tag are near the beginning and
  2189. end of the text, respectively,
  2190. or a single tag range covers most of the text widget.
  2191. The cost of adding and deleting tags like this is proportional
  2192. to the number of other tags with the same properties.
  2193. In contrast, there is no problem with having thousands of distinct
  2194. tags if their overall ranges are localized and spread uniformly throughout
  2195. the text.
  2196.  
  2197. Very long text lines can be expensive,
  2198. especially if they have many marks and tags within them.
  2199.  
  2200. The display line with the insert cursor is redrawn each time the
  2201. cursor blinks, which causes a steady stream of graphics traffic.
  2202. Set the B<-insertofftime> option to 0 avoid this.
  2203.  
  2204. =head1 SEE ALSO
  2205.  
  2206. L<Tk::ROText|Tk::ROText>
  2207. L<Tk::TextUndo|Tk::TextUndo>
  2208.  
  2209. =head1 KEYWORDS
  2210.  
  2211. text, widget
  2212.  
  2213. =cut
  2214.  
  2215.  
  2216.