home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / doc / text.n < prev    next >
Encoding:
Text File  |  1993-04-01  |  34.4 KB  |  819 lines

  1. '\"
  2. '\" Copyright (c) 1992 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/text.n,v 1.11 93/04/01 09:52:57 ouster Exp $ SPRITE (Berkeley)
  22. '/" 
  23. .so man.macros
  24. .HS text tk
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. text \- Create and manipulate text widgets
  29. .SH SYNOPSIS
  30. \fBtext\fI \fIpathName \fR?\fIoptions\fR?
  31. .SH "STANDARD OPTIONS"
  32. .LP
  33. .nf
  34. .ta 4c 8c 12c
  35. \fBbackground\fR    \fBforeground\fR    \fBinsertWidth\fR    \fBselectBorderWidth\fR
  36. \fBborderWidth\fR    \fBinsertBackground\fR    \fBpadX\fR    \fBselectForeground\fR
  37. \fBcursor\fR    \fBinsertBorderWidth\fR    \fBpadY\fR    \fBsetGrid\fR
  38. \fBexportSelection\fR    \fBinsertOffTime\fR    \fBrelief\fR    \fByScrollCommand\fR
  39. \fBfont\fR    \fBinsertOnTime\fR    \fBselectBackground\fR
  40. .fi
  41. .LP
  42. See the ``options'' manual entry for details on the standard options.
  43. .SH "WIDGET-SPECIFIC OPTIONS"
  44. .LP
  45. .nf
  46. Name:    \fBheight\fR
  47. Class:    \fBHeight\fR
  48. Command-Line Switch:    \fB\-height\fR
  49. .fi
  50. .IP
  51. Specifies the desired height for the window, in units of characters.
  52. Must be at least one.
  53. .LP
  54. .nf
  55. Name:    \fBstate\fR
  56. Class:    \fBState\fR
  57. Command-Line Switch:    \fB\-state\fR
  58. .fi
  59. .IP
  60. Specifies one of two states for the text:  \fBnormal\fR or \fBdisabled\fR.
  61. If the text is disabled then characters may not be inserted or deleted
  62. and no insertion cursor will be displayed, even if the input focus is
  63. in the widget.
  64. .LP
  65. .nf
  66. Name:    \fBwidth\fR
  67. Class:    \fBWidth\fR
  68. Command-Line Switch:    \fB\-width\fR
  69. .fi
  70. .IP
  71. Specifies the desired width for the window in units of characters.
  72. If the font doesn't have a uniform width then the width of the
  73. character ``0'' is used in translating from character units to
  74. screen units.
  75. .LP
  76. .nf
  77. Name:    \fBwrap\fR
  78. Class:    \fBWrap\fR
  79. Command-Line Switch:    \fB\-wrap\fR
  80. .fi
  81. .IP
  82. Specifies how to handle lines in the text that are too long to be
  83. displayed in a single line of the text's window.
  84. The value must be \fBnone\fR or \fBchar\fR or \fBword\fR.
  85. A wrap mode of \fBnone\fR means that each line of text appears as
  86. exactly one line on the screen;  extra characters that don't fit
  87. on the screen are not displayed.
  88. In the other modes each line of text will be broken up into several
  89. screen lines if necessary to keep all the characters visible.
  90. In \fBchar\fR mode a screen line break may occur after any character;
  91. in \fBword\fR mode a line break will only be made at word boundaries.
  92. .BE
  93.  
  94. .SH DESCRIPTION
  95. .PP
  96. The \fBtext\fR command creates a new window (given by the
  97. \fIpathName\fR argument) and makes it into a text widget.
  98. Additional
  99. options, described above, may be specified on the command line
  100. or in the option database
  101. to configure aspects of the text such as its default background color
  102. and relief.  The \fBtext\fR command returns the
  103. path name of the new window.
  104. .PP
  105. A text widget displays one or more lines of text and allows that
  106. text to be edited.
  107. Text widgets support three different kinds of annotations on the
  108. text, called tags, marks, and windows.
  109. Tags allow different portions of the text
  110. to be displayed with different fonts and colors.
  111. In addition, Tcl commands can be associated with tags so
  112. that commands are invoked when particular actions such as keystrokes
  113. and mouse button presses occur in particular ranges of the text.
  114. See TAGS below for more details.
  115. .PP
  116. The second form of annotation consists of marks, which are floating
  117. markers in the text.
  118. Marks are used to keep track of various interesting positions in the
  119. text as it is edited.
  120. See MARKS below for more details.
  121. .PP
  122. The third form of annotation allows arbitrary windows to be displayed
  123. in the text widget.
  124. See WINDOWS below for more details.
  125.  
  126. .SH INDICES
  127. .PP
  128. Many of the widget commands for texts take one or more indices
  129. as arguments.
  130. An index is a string used to indicate a particular place within
  131. a text, such as a place to insert characters or one endpoint of a
  132. range of characters to delete.
  133. Indices have the syntax
  134. .IP
  135. \fIbase modifier modifier modifier ...\fR
  136. .LP
  137. Where \fIbase\fR gives a starting point and the \fImodifier\fRs
  138. adjust the index from the starting point (e.g. move forward or
  139. backward one character).  Every index must contain a \fIbase\fR,
  140. but the \fImodifier\fRs are optional.
  141. .LP
  142. The \fIbase\fR for an index must have one of the following forms:
  143. .TP 12
  144. \fIline\fB.\fIchar\fR
  145. Indicates \fIchar\fR'th character on line \fIline\fR.
  146. Lines are numbered from 1 for consistency with other UNIX programs
  147. that use this numbering scheme.
  148. Within a line, characters are numbered from 0.
  149. .TP 12
  150. \fB@\fIx\fB,\fIy\fR
  151. Indicates the character that covers the pixel whose x and y coordinates
  152. within the text's window are \fIx\fR and \fIy\fR.
  153. .TP 12
  154. \fBend\fR
  155. Indicates the last character in the text, which is always a newline
  156. character.
  157. .TP 12
  158. \fImark\fR
  159. Indicates the character just after the mark whose name is \fImark\fR.
  160. .TP 12
  161. \fItag\fB.first\fR
  162. Indicates the first character in the text that has been tagged with
  163. \fItag\fR.
  164. This form generates an error if no characters are currently tagged
  165. with \fItag\fR.
  166. .TP 12
  167. \fItag\fB.last\fR
  168. Indicates the character just after the last one in the text that has
  169. been tagged with \fItag\fR.
  170. This form generates an error if no characters are currently tagged
  171. with \fItag\fR.
  172. .LP
  173. If modifiers follow the base index, each one of them must have one
  174. of the forms listed below.  Keywords such as \fBchars\fR and \fBwordend\fR
  175. may be abbreviated as long as the abbreviation is unambiguous.
  176. .TP
  177. \fB+ \fIcount\fB chars\fR
  178. Adjust the index forward by \fIcount\fR characters, moving to later
  179. lines in the text if necessary.  If there are fewer than \fIcount\fR
  180. characters in the text after the current index, then set the index
  181. to the last character in the text.
  182. Spaces on either side of \fIcount\fR are optional.
  183. .TP
  184. \fB\- \fIcount\fB chars\fR
  185. Adjust the index backward by \fIcount\fR characters, moving to earlier
  186. lines in the text if necessary.  If there are fewer than \fIcount\fR
  187. characters in the text before the current index, then set the index
  188. to the first character in the text.
  189. Spaces on either side of \fIcount\fR are optional.
  190. .TP
  191. \fB+ \fIcount\fB lines\fR
  192. Adjust the index forward by \fIcount\fR lines, retaining the same
  193. character position within the line.  If there are fewer than \fIcount\fR
  194. lines after the line containing the current index, then set the index
  195. to refer to the same character position on the last line of the text.
  196. Then, if the line is not long enough to contain a character at the indicated
  197. character position, adjust the character position to refer to the last
  198. character of the line (the newline).
  199. Spaces on either side of \fIcount\fR are optional.
  200. .TP
  201. \fB\- \fIcount\fB lines\fR
  202. Adjust the index backward by \fIcount\fR lines, retaining the same
  203. character position within the line.  If there are fewer than \fIcount\fR
  204. lines before the line containing the current index, then set the index
  205. to refer to the same character position on the first line of the text.
  206. Then, if the line is not long enough to contain a character at the indicated
  207. character position, adjust the character position to refer to the last
  208. character of the line (the newline).
  209. Spaces on either side of \fIcount\fR are optional.
  210. .TP
  211. \fBlinestart\fR
  212. Adjust the index to refer to the first character on the line.
  213. .TP
  214. \fBlineend\fR
  215. Adjust the index to refer to the last character on the line (the newline).
  216. .TP
  217. \fBwordstart\fR
  218. Adjust the index to refer to the first character of the word containing
  219. the current index.  A word consists of any number of adjacent characters
  220. that are letters, digits, or underscores, or a single character that
  221. is not one of these.
  222. .TP
  223. \fBwordend\fR
  224. Adjust the index to refer to the character just after the last one of the
  225. word containing the current index.  If the current index refers to the last
  226. character of the text then it is not modified.
  227. .LP
  228. If more than one modifier is present then they are applied in
  229. left-to-right order.  For example, the index ``\fBend \- 1 chars\fR''
  230. refers to the next-to-last character in the text and
  231. ``\fBinsert wordstart \- 1 c\fR'' refers to the character just before
  232. the first one in the word containing the insertion cursor.
  233.  
  234. .SH TAGS
  235. .PP
  236. The first form of annotation in text widgets is a tag.
  237. A tag is a textual string that is associated with some of the characters
  238. in a text.
  239. There may be any number of tags associated with characters in a
  240. text.
  241. Each tag may refer to a single character, a range of characters, or
  242. several ranges of characters.
  243. An individual character may have any number of tags associated with it.
  244. .PP
  245. A priority order is defined among tags, and this order is used in
  246. implementing some of the tag-related functions described below.
  247. When a tag is defined (by associating it with characters or setting
  248. its display options or binding commands to it), it is given
  249. a priority higher than any existing tag.
  250. The priority order of tags may be redefined using the
  251. ``\fIpathName \fBtag raise\fR'' and ``\fIpathName \fBtag lower\fR''
  252. widget commands.
  253. .PP
  254. Tags serve three purposes in text widgets.
  255. First, they control the way information is displayed on the screen.
  256. By default, characters are displayed as determined by the
  257. \fBbackground\fR, \fBfont\fR, and \fBforeground\fR options for the
  258. text widget.
  259. However, display options may be associated with individual tags
  260. using the ``\fIpathName \fBtag configure\fR'' widget command.
  261. If a character has been tagged, then the display options associated
  262. with the tag override the default display style.
  263. The following options are currently supported for tags:
  264. .TP
  265. \fB\-background \fIcolor\fR
  266. \fIColor\fR specifies the background color to use for characters
  267. associated with the tag.
  268. It may have any of the forms accepted by \fBTk_GetColor\fR.
  269. .TP
  270. \fB\-bgstipple \fIbitmap\fR
  271. \fIBitmap\fR specifies a bitmap that is used as a stipple pattern
  272. for the background.
  273. It may have any of the forms accepted by \fBTk_GetBitmap\fR.
  274. If \fIbitmap\fR hasn't been specified, or if it is specified
  275. as an empty string, then a solid fill will be used for the
  276. background.
  277. .TP
  278. \fB\-borderwidth \fIpixels\fR
  279. \fIPixels\fR specifies the width of a 3-D border to draw around
  280. the background.
  281. It may have any of the forms accepted by \fBTk_GetPixels\fR.
  282. This option is used in conjunction with the \fB\-relief\fR
  283. option to give a 3-D appearance to the background for characters;
  284. it is ignored unless the \fB\-background\fR option
  285. has been set for the tag.
  286. .TP
  287. \fB\-fgstipple \fIbitmap\fR
  288. \fIBitmap\fR specifies a bitmap that is used as a stipple pattern
  289. when drawing text and other foreground information such as
  290. underlines.
  291. It may have any of the forms accepted by \fBTk_GetBitmap\fR.
  292. If \fIbitmap\fR hasn't been specified, or if it is specified
  293. as an empty string, then a solid fill will be used.
  294. .TP
  295. \fB\-font \fIfontName\fR
  296. \fIFontName\fR is the name of a font to use for drawing characters.
  297. It may have any of the forms accepted by \fBTk_GetFontStruct\fR.
  298. .TP
  299. \fB\-foreground \fIcolor\fR
  300. \fIColor\fR specifies the color to use when drawing text and other
  301. foreground information such as underlines.
  302. It may have any of the forms accepted by \fBTk_GetColor\fR.
  303. .TP
  304. \fB\-relief \fIrelief\fR
  305. \fIRelief specifies the 3-D relief to use for drawing backgrounds,
  306. in any of the forms accepted by \fBTk_GetRelief\fR.
  307. This option is used in conjunction with the \fB\-borderwidth\fR
  308. option to give a 3-D appearance to the background for characters;
  309. it is ignored unless the \fB\-background\fR option
  310. has been set for the tag.
  311. .TP
  312. \fB\-underline \fIboolean\fR
  313. \fIBoolean\fR specifies whether or not to draw an underline underneath
  314. characters.
  315. It may have any of the forms accepted by \fBTk_GetBoolean\fR.
  316. .PP
  317. If a character has several tags associated with it, and if their
  318. display options conflict, then the options of the highest priority
  319. tag are used.
  320. If a particular display option hasn't been specified for a
  321. particular tag, or if it is specified as an empty string, then
  322. that option will never be used;  the next-highest-priority
  323. tag's option will used instead.
  324. If no tag specifies a particular display optionl, then the default
  325. style for the widget will be used.
  326. .PP
  327. The second purpose for tags is event bindings.
  328. You can associate bindings with a tag in much the same way you can
  329. associate bindings with a widget class:  whenever particular X
  330. events occur on characters with the given tag, a given
  331. Tcl command will be executed.
  332. Tag bindings can be used to give behaviors to ranges of characters;
  333. among other things, this allows hypertext-like
  334. features to be implemented.
  335. For details, see the description of the \fBtag bind\fR widget
  336. command below.
  337. .PP
  338. The third use for tags is in managing the selection.
  339. See THE SELECTION below.
  340.  
  341. .SH MARKS
  342. .PP
  343. The second form of annotation in text widgets is a mark.
  344. Marks are used for remembering particular places in a text.
  345. They are something like tags, in that they have names and
  346. they refer to places in the file, but a mark isn't associated
  347. with particular characters.
  348. Instead, a mark is associated with the gap between two characters.
  349. Only a single position may be associated with a mark at any given
  350. time.
  351. If the characters around a mark are deleted the mark will still
  352. remain;  it will just have new neighbor characters.
  353. In contrast, if the characters containing a tag are deleted then
  354. the tag will no longer have an association with characters in
  355. the file.
  356. Marks may be manipulated with the ``\fIpathName \fBmark\fR'' widget
  357. command, and their current locations may be determined by using the
  358. mark name as an index in widget commands.
  359. .PP
  360. The name space for marks is different from that for tags:  the
  361. same name may be used for both a mark and a tag, but they will refer
  362. to different things.
  363. .PP
  364. Two marks have special significance.
  365. First, the mark \fBinsert\fR is associated with the insertion cursor,
  366. as described under THE INSERTION CURSOR below.
  367. Second, the mark \fBcurrent\fR is associated with the character
  368. closest to the mouse and is adjusted automatically to track the
  369. mouse position and any changes to the text in the widget (one
  370. exception:  \fBcurrent\fR is not updated in response to mouse
  371. motions if a mouse button is down;  the update will be deferred
  372. until all mouse buttons have been released).
  373. Neither of these special marks may be unset.
  374.  
  375. .SH WINDOWS
  376. .PP
  377. The third form of annotation in text widgets is a window.
  378. Window support isn't implemented yet, but when it is it will be
  379. described here.
  380.  
  381. .SH THE SELECTION
  382. .PP
  383. Text widgets support the standard X selection.
  384. Selection support is implemented via tags.
  385. If the \fBexportSelection\fR option for the text widget is true
  386. then the \fBsel\fR tag will be associated with the selection:
  387. .IP [1]
  388. Whenever characters are tagged with \fBsel\fR the text widget
  389. will claim ownership of the selection.
  390. .IP [2]
  391. Attempts to retrieve the
  392. selection will be serviced by the text widget, returning all the
  393. charaters with the \fBsel\fR tag.
  394. .IP [3]
  395. If the selection is claimed away by another application or by another
  396. window within this application, then the \fBsel\fR tag will be removed
  397. from all characters in the text.
  398. .PP
  399. The \fBsel\fR tag is automatically defined when a text widget is
  400. created, and it may not be deleted with the ``\fIpathName \fBtag delete\fR''
  401. widget command.  Furthermore, the \fBselectBackground\fR,
  402. \fBselectBorderWidth\fR, and \fBselectForeground\fR options for
  403. the text widget are tied to the \fB\-background\fR,
  404. \fB\-borderwidth\fR, and \fB\-foreground\fR options for the \fBsel\fR
  405. tag:  changes in either will automatically be reflected in the
  406. other.
  407.  
  408. .SH THE INSERTION CURSOR
  409. .PP
  410. The mark named \fBinsert\fR has special significance in text widgets.
  411. It is defined automatically when a text widget is created and it
  412. may not be unset with the ``\fIpathName \fBmark unset\fR'' widget
  413. command.
  414. The \fBinsert\fR mark represents the position of the insertion
  415. cursor, and the insertion cursor will automatically be drawn at
  416. this point whenever the text widget has the input focus.
  417.  
  418. .SH "WIDGET COMMAND"
  419. .PP
  420. The \fBtext\fR command creates a new Tcl command whose
  421. name is the same as the path name of the text's window.  This
  422. command may be used to invoke various
  423. operations on the widget.  It has the following general form:
  424. .DS C
  425. \fIpathName option \fR?\fIarg arg ...\fR?
  426. .DE
  427. \fIPathName\fR is the name of the command, which is the same as
  428. the text widget's path name.  \fIOption\fR and the \fIarg\fRs
  429. determine the exact behavior of the command.  The following
  430. commands are possible for text widgets:
  431. .TP
  432. \fIpathName \fBcompare\fR \fIindex1 op index2\fR
  433. Compares the indices given by \fIindex1\fR and \fIindex2\fR according
  434. to the relational operator given by \fIop\fR, and returns 1 if
  435. the relationship is satisfied and 0 if it isn't.
  436. \fIOp\fR must be one of the operators <, <=, ==, >=, >, or !=.
  437. If \fIop\fR is == then 1 is returned if the two indices refer to
  438. the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR
  439. refers to an earlier character in the text than \fIindex2\fR, and
  440. so on.
  441. .TP
  442. \fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
  443. Query or modify the configuration options of the widget.
  444. If no \fIoption\fR is specified, returns a list describing all of
  445. the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
  446. information on the format of this list).  If \fIoption\fR is specified
  447. with no \fIvalue\fR, then the command returns a list describing the
  448. one named option (this list will be identical to the corresponding
  449. sublist of the value returned if no \fIoption\fR is specified).  If
  450. one or more \fIoption\-value\fR pairs are specified, then the command
  451. modifies the given widget option(s) to have the given value(s);  in
  452. this case the command returns an empty string.
  453. \fIOption\fR may have any of the values accepted by the \fBtext\fR
  454. command.
  455. .TP
  456. \fIpathName \fBdebug \fR?\fIboolean\fR?
  457. If \fIboolean\fR is specified, then it must have one of the true or
  458. false values accepted by Tcl_GetBoolean.
  459. If the value is a true one then internal consistency checks will be
  460. turned on in the B-tree code associated with text widgets.
  461. If \fIboolean\fR has a false value then the debugging checks will
  462. be turned off.
  463. In either case the command returns an empty string.
  464. If \fIboolean\fR is not specified then the command returns \fBon\fR
  465. or \fBoff\fR to indicate whether or not debugging is turned on.
  466. There is a single debugging switch shared by all text widgets:  turning
  467. debugging on or off in any widget turns it on or off for all widgets.
  468. For widgets with large amounts of text, the consistency checks may
  469. cause a noticeable slow-down.
  470. .TP
  471. \fIpathName \fBdelete \fIindex1 \fR?\fIindex2\fR?
  472. Delete a range of characters from the text.
  473. If both \fIindex1\fR and \fIindex2\fR are specified, then delete
  474. all the characters starting with the one given by \fIindex1\fR
  475. and stopping just before \fIindex2\fR (i.e. the character at
  476. \fIindex2\fR is not deleted).
  477. If \fIindex2\fR doesn't specify a position later in the text
  478. than \fIindex1\fR then no characters are deleted.
  479. If \fIindex2\fR isn't specified then the single character at
  480. \fIindex1\fR is deleted.
  481. It is not allowable to delete characters in a way that would leave
  482. the text without a newline as the last character.
  483. The command returns an empty string.
  484. .TP
  485. \fIpathName \fBget \fIindex1 \fR?\fIindex2\fR?
  486. Return a range of characters from the text.
  487. The return value will be all the characters in the text starting
  488. with the one whose index is \fIindex1\fR and ending just before
  489. the one whose index is \fIindex2\fR (the character at \fIindex2\fR
  490. will not be returned).
  491. If \fIindex2\fR is omitted then the single character at \fIindex1\fR
  492. is returned.
  493. If there are no characters in the specified range (e.g. \fIindex1\fR
  494. is past the end of the file or \fIindex2\fR is less than or equal
  495. to \fIindex1\fR) then an empty string is returned.
  496. .TP
  497. \fIpathName \fBindex \fIindex\fR
  498. Returns the position corresponding to \fIindex\fR in the form
  499. \fIline.char\fR where \fIline\fR is the line number and \fIchar\fR
  500. is the character number.
  501. \fIIndex\fR may have any of the forms described under INDICES above.
  502. .TP
  503. \fIpathName \fBinsert \fIindex chars
  504. Inserts \fIchars\fR into the text just before the character at
  505. \fIindex\fR and returns an empty string.
  506. It is not possible to insert characters after the last newline
  507. of the text.
  508. .TP
  509. \fIpathName \fBmark \fIoption \fR?\fIarg arg ...\fR?
  510. This command is used to manipulate marks.  The exact behavior of
  511. the command depends on the \fIoption\fR argument that follows
  512. the \fBmark\fR argument.  The following forms of the command
  513. are currently supported:
  514. .RS
  515. .TP
  516. \fIpathName \fBmark names\fR
  517. Returns a list whose elements are the names of all the marks that
  518. are currently set.
  519. .TP
  520. \fIpathName \fBmark set \fImarkName index\fR
  521. Sets the mark named \fImarkName\fR to a position just before the
  522. character at \fIindex\fR.
  523. If \fImarkName\fR already exists, it is moved from its old position;
  524. if it doesn't exist, a new mark is created.
  525. This command returns an empty string.
  526. .TP
  527. \fIpathName \fBmark unset \fImarkName \fR?\fImarkName markName ...\fR?
  528. Remove the mark corresponding to each of the \fImarkName\fR arguments.
  529. The removed marks will not be usable in indices and will not be
  530. returned by future calls to ``\fIpathName \fBmark names\fR''.
  531. This command returns an empty string.
  532. .RE
  533. .TP
  534. \fIpathName \fBscan\fR \fIoption args\fR
  535. This command is used to implement scanning on texts.  It has
  536. two forms, depending on \fIoption\fR:
  537. .RS
  538. .TP
  539. \fIpathName \fBscan mark \fIy\fR
  540. Records \fIy\fR and the current view in the text window;  used in
  541. conjunction with later \fBscan dragto\fR commands.  Typically this
  542. command is associated with a mouse button press in the widget.  It
  543. returns an empty string.
  544. .TP
  545. \fIpathName \fBscan dragto \fIy\fR
  546. This command computes the difference between its \fIy\fR argument
  547. and the \fIy\fR argument to the last \fBscan mark\fR command for
  548. the widget.  It then adjusts the view up or down by 10 times the
  549. difference in y-coordinates.  This command is typically associated
  550. with mouse motion events in the widget, to produce the effect of
  551. dragging the text at high speed through the window.  The return
  552. value is an empty string.
  553. .RE
  554. .TP
  555. \fIpathName \fBtag \fIoption \fR?\fIarg arg ...\fR?
  556. This command is used to manipulate tags.  The exact behavior of the
  557. command depends on the \fIoption\fR argument that follows the
  558. \fBtag\fR argument.  The following forms of the command are currently
  559. supported:
  560. .RS
  561. .TP
  562. \fIpathName \fBtag add \fItagName index1 \fR?\fIindex2\fR?
  563. Associate the tag \fItagName\fR with all of the characters starting
  564. with \fIindex1\fR and ending just before
  565. \fIindex2\fR (the character at \fIindex2\fR isn't tagged).
  566. If \fIindex2\fR is omitted then the single character at
  567. \fIindex1\fR is tagged.
  568. If there are no characters in the specified range (e.g. \fIindex1\fR
  569. is past the end of the file or \fIindex2\fR is less than or equal
  570. to \fIindex1\fR) then the command has no effect.
  571. This command returns an empty string.
  572. .TP
  573. \fIpathName \fBtag bind \fItagName\fR ?\fIsequence\fR? ?\fIcommand\fR?
  574. This command associates \fIcommand\fR with the tag given by
  575. \fItagName\fR.
  576. Whenever the event sequence given by \fIsequence\fR occurs for a
  577. character that has been tagged with \fItagName\fR,
  578. the command will be invoked.
  579. This widget command is similar to the \fBbind\fR command except that
  580. it operates on characters in a text rather than entire widgets.
  581. See the \fBbind\fR manual entry for complete details
  582. on the syntax of \fIsequence\fR and the substitutions performed
  583. on \fIcommand\fR before invoking it.
  584. If all arguments are specified then a new binding is created, replacing
  585. any existing binding for the same \fIsequence\fR and \fItagName\fR
  586. (if the first character of \fIcommand\fR is ``+'' then \fIcommand\fR
  587. augments an existing binding rather than replacing it).
  588. In this case the return value is an empty string.
  589. If \fIcommand\fR is omitted then the command returns the \fIcommand\fR
  590. associated with \fItagName\fR and \fIsequence\fR (an error occurs
  591. if there is no such binding).
  592. If both \fIcommand\fR and \fIsequence\fR are omitted then the command
  593. returns a list of all the sequences for which bindings have been
  594. defined for \fItagName\fR.
  595. .RS
  596. .LP
  597. The only events for which bindings may be specified are those related
  598. to the mouse and keyboard, such as \fBEnter\fR, \fBLeave\fR,
  599. \fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR.
  600. Event bindings for a text widget use the \fBcurrent\fR mark
  601. described under MARKS above.
  602. \fBEnter\fR events trigger for a character when it
  603. becomes the current character (i.e. the \fBcurrent\fR mark moves
  604. to just in front of that character).
  605. \fBLeave\fR events trigger for a character when it ceases to be
  606. the current item (i.e. the \fBcurrent\fR mark moves away from
  607. that character, or the character is deleted).
  608. These events are different than \fBEnter\fR and \fBLeave\fR
  609. events for windows.
  610. Mouse and keyboard events are directed to the current character.
  611. .LP
  612. It is possible for the current character to have multiple tags,
  613. and for each of them to have a binding for a particular event
  614. sequence.
  615. When this occurs, the binding from the highest priority tag is
  616. used.
  617. If a particular tag doesn't have a binding that matches an
  618. event, then the tag is ignored and tags with lower priority
  619. will be checked.
  620. .LP
  621. If bindings are created for the widget as a whole using the
  622. \fBbind\fR command, then those bindings will supplement the
  623. tag bindings.
  624. This means that a single event can trigger two Tcl scripts,
  625. one for a widget-level binding and one for a tag-level
  626. binding.
  627. .RE
  628. .TP
  629. \fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
  630. This command is similar to the \fBconfigure\fR widget command except
  631. that it modifies options associated with the tag given by \fItagName\fR
  632. instead of modifying options for the overall text widget.
  633. If no \fIoption\fR is specified, the command returns a list describing
  634. all of the available options for \fItagName\fR (see \fBTk_ConfigureInfo\fR
  635. for information on the format of this list).
  636. If \fIoption\fR is specified with no \fIvalue\fR, then the command returns
  637. a list describing the one named option (this list will be identical to
  638. the corresponding sublist of the value returned if no \fIoption\fR
  639. is specified).
  640. If one or more \fIoption\-value\fR pairs are specified, then the command
  641. modifies the given option(s) to have the given value(s) in \fItagName\fR;
  642. in this case the command returns an empty string.
  643. See TAGS above for details on the options available for tags.
  644. .TP
  645. \fIpathName \fBtag delete \fItagName \fR?\fItagName ...\fR?
  646. Deletes all tag information for each of the \fItagName\fR
  647. arguments.
  648. The command removes the tags from all characters in the file
  649. and also deletes any other information associated with the tags,
  650. such as bindings and display information.
  651. The command returns an empty string.
  652. .TP
  653. \fIpathName\fBtag lower \fItagName \fR?\fIbelowThis\fR?
  654. Changes the priority of tag \fItagName\fR so that it is just lower
  655. in priority than the tag whose name is \fIbelowThis\fR.
  656. If \fIbelowThis\fR is omitted, then \fItagName\fR's priority
  657. is changed to make it lowest priority of all tags.
  658. .TP
  659. \fIpathName \fBtag names \fR?\fIindex\fR?
  660. Returns a list whose elements are the names of all the tags that
  661. are active at the character position given by \fIindex\fR.
  662. If \fIindex\fR is omitted, then the return value will describe
  663. all of the tags that exist for the text (this includes all tags
  664. that have been named in a ``\fIpathName \fBtag\fR'' widget
  665. command but haven't been deleted by a ``\fIpathName \fBtag delete\fR''
  666. widget command, even if no characters are currently marked with
  667. the tag).
  668. The list will be sorted in order from lowest priority to highest
  669. priority.
  670. .TP
  671. \fIpathName \fBtag nextrange \fItagName index1 \fR?\fIindex2\fR?
  672. This command searches the text for a range of characters tagged
  673. with \fItagName\fR where the first character of the range is
  674. no earlier than the character at \fIindex1\fR and no later than
  675. the character just before \fIindex2\fR (a range starting at
  676. \fIindex2\fR will not be considered).
  677. If several matching ranges exist, the first one is chosen.
  678. The command's return value is a list containing
  679. two elements, which are the index of the first character of the
  680. range and the index of the character just after the last one in
  681. the range.
  682. If no matching range is found then the return value is an
  683. empty string.
  684. If \fIindex2\fR is not given then it defaults to the end of the text.
  685. .TP
  686. \fIpathName\fBtag raise \fItagName \fR?\fIaboveThis\fR?
  687. Changes the priority of tag \fItagName\fR so that it is just higher
  688. in priority than the tag whose name is \fIaboveThis\fR.
  689. If \fIaboveThis\fR is omitted, then \fItagName\fR's priority
  690. is changed to make it highest priority of all tags.
  691. .TP
  692. \fIpathName \fBtag ranges \fItagName\fR
  693. Return a list describing all of the ranges of text that have been
  694. tagged with \fItagName\fR.
  695. The list consists of zero or more pairs of elements, with each
  696. pair describing a range of characters that have been tagged
  697. with \fItagName\fR.
  698. The first element of the pair contains the index of the first
  699. character of the range, and the second element of the pair contains
  700. the index of the character just after the last one in the
  701. range.
  702. The list is sorted so that the first tagged range in the text is
  703. described by the first two elements of the list, and so on.
  704. If there are no characters tagged with \fItag\fR then an
  705. empty string is returned.
  706. .TP
  707. \fIpathName \fBtag remove \fItagName index1 \fR?\fIindex2\fR?
  708. Remove the tag \fItagName\fR from all of the characters starting
  709. at \fIindex1\fR and ending just before
  710. \fIindex2\fR (the character at \fIindex2\fR isn't affected).
  711. If \fIindex2\fR is omitted then the single character at
  712. \fIindex1\fR is untagged.
  713. If there are no characters in the specified range (e.g. \fIindex1\fR
  714. is past the end of the file or \fIindex2\fR is less than or equal
  715. to \fIindex1\fR) then the command has no effect.
  716. This command returns an empty string.
  717. .RE
  718. .TP
  719. \fIpathName \fByview \fR?\fB\-pickplace\fR? \fIwhat\fR
  720. This command changes the view in the widget's window so that the line
  721. given by \fIwhat\fR is visible in the window.
  722. \fIWhat\fR may be either an absolute line number, where 0 corresponds
  723. to the first line of the file, or an index with any of the forms
  724. described under INDICES above.
  725. The first form (absolute line number) is used in the commands issued
  726. by scrollbars to control the widget's view.
  727. If the \fB\-pickplace\fR option isn't specified then \fIwhat\fR will
  728. appear at the top of the window.
  729. If \fB\-pickplace\fR is specified then the widget chooses where
  730. \fIwhat\fR appears in the window:
  731. .RS
  732. .IP [1]
  733. If \fIwhat\fR is already visible somewhere in the window then the
  734. command does nothing.
  735. .IP [2]
  736. If \fIwhat\fR is only a few lines off-screen above the window then
  737. it will be positioned at the top of the window.
  738. .IP [3]
  739. If \fIwhat\fR is only a few lines off-screen below the window then
  740. it will be positioned at the bottom of the window.
  741. .IP [4]
  742. Otherwise, \fIwhat\fR will be centered in the window.
  743. .LP
  744. The \fB\-pickplace\fR option is typically used after inserting text
  745. to make sure that the insertion cursor is still visible on the screen.
  746. This command returns an empty string.
  747. .RE
  748.  
  749. .SH BINDINGS
  750. .PP
  751. Tk automatically creates class bindings for texts that give them
  752. the following default behavior:
  753. .IP [1]
  754. Pressing mouse button 1 in an text positions the insertion cursor
  755. just before the character underneath the mouse cursor and sets the
  756. input focus to this widget.
  757. .IP [2]
  758. Dragging with mouse button 1 strokes out a selection between
  759. the insertion cursor and the character under the mouse.
  760. .IP [3]
  761. If you double-press mouse button 1 then the word under the mouse cursor
  762. will be selected, the insertion cursor will be positioned at the
  763. beginning of the word, and dragging the mouse will stroke out a selection
  764. whole words at a time.
  765. .IP [4]
  766. If you triple-press mouse button 1 then the line under the mouse cursor
  767. will be selected, the insertion cursor will be positioned at the
  768. beginning of the line, and dragging the mouse will stroke out a selection
  769. whole line at a time.
  770. .IP [5]
  771. The ends of the selection can be adjusted by dragging with mouse
  772. button 1 while the shift key is down;  this will adjust the end
  773. of the selection that was nearest to the mouse cursor when button
  774. 1 was pressed.  If the selection was made in word or line mode then
  775. it will be adjusted in this same mode.
  776. .IP [6]
  777. The view in the text can be adjusted by dragging with mouse button 2.
  778. .IP [7]
  779. If the input focus is in a text widget and characters are typed on the
  780. keyboard, the characters are inserted just before the insertion cursor.
  781. .IP [8]
  782. Control+h and the Backspace and Delete keys erase the character just
  783. before the insertion cursor.
  784. .IP [9]
  785. Control+v inserts the current selection just before the insertion cursor.
  786. .IP [10]
  787. Control+d deletes the selected characters;  an error occurs if the selection
  788. is not in this widget.
  789. .PP
  790. If the text is disabled using the \fBstate\fR option, then the text's
  791. view can still be adjusted and text in the text can still be selected,
  792. but no insertion cursor will be displayed and no text modifications will
  793. take place.
  794. .PP
  795. The behavior of texts can be changed by defining new bindings for
  796. individual widgets or by redefining the class bindings.
  797.  
  798. .SH "PERFORMANCE ISSUES"
  799. .PP
  800. Text widgets should run efficiently under a variety
  801. of conditions.  The text widget uses about 2-3 bytes of
  802. main memory for each byte of text, so texts containing a megabyte
  803. or more should be practical on most workstations.
  804. Text is represented internally with a modified B-tree structure
  805. that makes operations relatively efficient even with large texts.
  806. Tags are included in the B-tree structure in a way that allows
  807. tags to span large ranges or have many disjoint smaller ranges
  808. without loss of efficiency.
  809. Marks are also implemented in a way that allows large numbers of
  810. marks.
  811. The only known mode of operation where a text widget may not run
  812. efficiently is if it has a very large number of different tags.
  813. Hundreds of tags should be fine, or even a thousand,
  814. but tens of thousands of tags will make texts consume a lot of
  815. memory and run slowly.
  816.  
  817. .SH KEYWORDS
  818. text, widget
  819.