Charles.Forsyth20060303-partialeea662d19 years agoHistory
1188 lines · 50.7 KB · Text
RawDownload
.TH TEXT 9.SH NAMEtext \- Create and manipulate text widgets.SH SYNOPSIS\f5text\fI \fIpathName \fR?\fIoptions\fR?.SH STANDARD OPTIONS.EX-background  -pady              -takefocus-borderwidth -relief            -xscrollcommand-font        -selectbackground  -yscrollcommand-foreground  -selectborderwidth-padx        -selectforeground.EE.SH "WIDGET-SPECIFIC OPTIONS".TP.B -height \fIdist\fPSpecifies the desired height for the window..TP.B -spacing1 \fIdist\fPRequests additional space above each text line in the widget,using any of the standard forms for screen distances.If a line wraps, this option only applies to the first lineon the display.This option may be overriden with \f5-spacing1\fR options intags..TP.B -spacing2 \fIdist\fPFor lines that wrap (so that they cover more than one line on thedisplay) this option specifies additional space to provide betweenthe display lines that represent a single line of text.The value may have any of the standard forms for screen distances.This option may be overriden with \f5-spacing2\fR options intags..TP.B -spacing3 \fIdist\fPRequests additional space below each text line in the widget,using any of the standard forms for screen distances.If a line wraps, this option only applies to the last lineon the display.This option may be overriden with \f5-spacing3\fR options intags..TP.B -state \fPstate\fPSpecifies one of two states for the text:  \f5normal\fR or \f5disabled\fR.If the text is disabled then characters may not be inserted or deletedand no insertion cursor will be displayed, even if the input focus isin the widget..TP.B -tabs \fIdist\fPSpecifies a set of tab stops for the window.  The option's value consistsof a list of \fIdist\fP values giving the positions of the tab stops.  Each\fIdist\fP may optionally be followed in the next list elementby one of the keywords \f5left\fR, \f5right\fR, \f5center\fR,or \f5numeric\fR, which specifies how to justifytext relative to the tab stop.  \f5Left\fR is the default; it causesthe text following the tab character to be positioned with its left edgeat the tab position.  \f5Right\fR means that the right edge of the textfollowing the tab character is positioned at the tab position, and\f5center\fR means that the text is centered at the tab position.\f5Numeric\fR means that the decimal point in the text is positionedat the tab position;  if there is no decimal point then the leastsignificant digit of the number is positioned just to the left of thetab position;  if there is no number in the text then the text isright-justified at the tab position.For example, \f5-tabs {2c left 4c 6c center}\fR creates threetab stops at two-centimeter intervals;  the first two use leftjustification and the third uses center justification.If the list of tab stops does not have enough elements to cover allof the tabs in a text line, then Tk extrapolates new tab stops usingthe spacing and alignment from the last tab stop in the list.The value of the \f5tabs\fR option may be overridden by \f5-tabs\fRoptions in tags.If no \f5-tabs\fR option is specified, or if it is specified asan empty list, then Tk uses default tabs spaced every eight(average size) characters..TP.B -width \fIdist\fPSpecifies the desired width for the window..TP.B -wrap \fIval\fPSpecifies how to handle lines in the text that are too long to bedisplayed in a single line of the text's window.The value must be \f5none\fR or \f5char\fR or \f5word\fR.A wrap mode of \f5none\fR means that each line of text appears asexactly one line on the screen;  extra characters that don't fiton the screen are not displayed.In the other modes each line of text will be broken up into severalscreen lines if necessary to keep all the characters visible.In \f5char\fR mode a screen line break may occur after any character;in \f5word\fR mode a line break will only be made at word boundaries. .SH DESCRIPTIONThe \f5text\fR command creates a new window (given by the\fIpathName\fR argument) and makes it into a text widget.Additionaloptions, described above, may be specified on the command lineto configure aspects of the text such as its default background colourand relief.  The \f5text\fR command returns thepath name of the new window..PPA text widget displays one or more lines of text and allows thattext to be edited.Text widgets support three different kinds of annotations on thetext, called tags, marks, and embedded windows.Tags allow different portions of the textto be displayed with different fonts and colours.In addition, Tk commands can be associated with tags sothat scripts are invoked when particular actions such as keystrokesand mouse button presses occur in particular ranges of the text.See TAGS below for more details..PPThe second form of annotation consists of marks, which are floatingmarkers in the text.Marks are used to keep track of various interesting positions in thetext as it is edited.See MARKS below for more details..PPThe third form of annotation allows arbitrary windows to beembedded in a text widget.See EMBEDDED WINDOWS below for more details. .SH INDICESMany of the widget commands for texts take one or more indicesas arguments.An index is a string used to indicate a particular place withina text, such as a place to insert characters or one endpoint of arange of characters to delete.Indices have the syntax.RS.EX\fIbase modifier modifier modifier ...\fR.EE.REWhere \fIbase\fR gives a starting point and the \fImodifier\fRsadjust the index from the starting point (e.g. move forward orbackward one character).  Every index must contain a \fIbase\fR,but the \fImodifier\fRs are optional..PPThe \fIbase\fR for an index must have one of the following forms:.TP 12\fIline\f5.\fIchar\fRIndicates \fIchar\fR'th character on line \fIline\fR.Lines are numbered from 1 for consistency with other UNIX programsthat use this numbering scheme.Within a line, characters are numbered from 0.If \fIchar\fR is \f5end\fR then it refers to the newline characterthat ends the line..TP 12\f5@\fIx\f5,\fIy\fRIndicates the character that covers the pixel whose x and y coordinateswithin the text's window are \fIx\fR and \fIy\fR..TP 12\f5end\fRIndicates the end of the text (the character just after the lastnewline)..TP 12\fImark\fRIndicates the character just after the mark whose name is \fImark\fR..TP 12\fItag\f5.first\fRIndicates the first character in the text that has been tagged with\fItag\fR.This form generates an error if no characters are currently taggedwith \fItag\fR..TP 12\fItag\f5.last\fRIndicates the character just after the last one in the text that hasbeen tagged with \fItag\fR.This form generates an error if no characters are currently taggedwith \fItag\fR..TP 12\fIpathName\fRIndicates the position of the embedded window whose name is\fIpathName\fR.This form generates an error if there is no embedded windowby the given name..PPIf modifiers follow the base index, each one of them must have oneof the forms listed below..TP\f5+ \fIcount\f5 chars\fRAdjust the index forward by \fIcount\fR characters, moving to laterlines in the text if necessary.  If there are fewer than \fIcount\fRcharacters in the text after the current index, then set the indexto the last character in the text.Spaces on either side of \fIcount\fR are optional..TP\f5\- \fIcount\f5 chars\fRAdjust the index backward by \fIcount\fR characters, moving to earlierlines in the text if necessary.  If there are fewer than \fIcount\fRcharacters in the text before the current index, then set the indexto the first character in the text.Spaces on either side of \fIcount\fR are optional..TP\f5+ \fIcount\f5 lines\fRAdjust the index forward by \fIcount\fR lines, retaining the samecharacter position within the line.  If there are fewer than \fIcount\fRlines after the line containing the current index, then set the indexto refer to the same character position on the last line of the text.Then, if the line is not long enough to contain a character at the indicatedcharacter position, adjust the character position to refer to the lastcharacter of the line (the newline).Spaces on either side of \fIcount\fR are optional..TP\f5\- \fIcount\f5 lines\fRAdjust the index backward by \fIcount\fR lines, retaining the samecharacter position within the line.  If there are fewer than \fIcount\fRlines before the line containing the current index, then set the indexto refer to the same character position on the first line of the text.Then, if the line is not long enough to contain a character at the indicatedcharacter position, adjust the character position to refer to the lastcharacter of the line (the newline).Spaces on either side of \fIcount\fR are optional..TP\f5linestart\fRAdjust the index to refer to the first character on the line..TP\f5lineend\fRAdjust the index to refer to the last character on the line (the newline)..TP\f5wordstart\fRAdjust the index to refer to the first character of the word containingthe current index.  A word consists of any number of adjacent charactersthat are letters, digits, or underscores, or a single character thatis not one of these..TP\f5wordend\fRAdjust the index to refer to the character just after the last one of theword containing the current index.  If the current index refers to the lastcharacter of the text then it is not modified..PPIf more than one modifier is present then they are applied inleft-to-right order.  For example, the index ``\f5end \- 1 chars\fR''refers to the next-to-last character in the text and the index``\f5insert wordstart \- 1 c\fR'' refers to the character just beforethe first one in the word containing the insertion cursor. .SH TAGSThe first form of annotation in text widgets is a tag.A tag is a textual string that is associated with some of the charactersin a text.Tags may contain arbitrary characters, but it is probably best toavoid using the the characters `` '' (space), \f5+\fR, or \f5-\fR:these characters have special meaning in indices, so tags containingthem can't be used as indices. The tag name may not begin with a digit.There may be any number of tags associated with characters in atext.Each tag may refer to a single character, a range of characters, orseveral ranges of characters.An individual character may have any number of tags associated with it..PPA priority order is defined among tags, and this order is used inimplementing some of the tag-related functions described below.When a tag is defined (by associating it with characters or settingits display options or binding commands to it), it is givena priority higher than any existing tag.The priority order of tags may be redefined using the``\fIpathName \f5tag raise\fR'' and ``\fIpathName \f5tag lower\fR''widget commands..PPTags serve three purposes in text widgets.First, they control the way information is displayed on the screen.By default, characters are displayed as determined by the\f5background\fR, \f5font\fR, and \f5foreground\fR options for thetext widget.However, display options may be associated with individual tagsusing the ``\fIpathName \f5tag configure\fR'' widget command.If a character has been tagged, then the display options associatedwith the tag override the default display style.The following options are currently supported for tags:.TP\f5-background \fIcolour\fR\fIColor\fR specifies the background colour to use for charactersassociated with the tag..TP\f5-borderwidth \fIdist\fR\fIDist\fR specifies the width of a 3-D border to draw aroundthe background.This option is used in conjunction with the \f5-relief\fRoption to give a 3-D appearance to the background for characters;it is ignored unless the \f5-background\fR optionhas been set for the tag..TP\f5-font \fIfont\fR\fIFont\fR is the name of a font to use for drawing characters..TP\f5-foreground \fIcolour\fR\fIColor\fR specifies the colour to use when drawing text and otherforeground information such as underlines..TP\f5-justify \fIjustify\fRIf the first character of a display line has a tag for which thisoption has been specified, then \fIjustify\fR determines how tojustify the line.It must be one of \f5left\fR, \f5right\fR, or \f5center\fR.If a line wraps, then the justification for each line on thedisplay is determined by the first character of that display line..TP\f5-lmargin1 \fIdist\fRIf the first character of a text line has a tag for which thisoption has been specified, then \fIdist\fR specifies howmuch the line should be indented from the left edge of thewindow.\fIDist\fR may have any of the standard forms for screendistances.If a line of text wraps, this option only applies to thefirst line on the display;  the \f5-lmargin2\fR option controlsthe indentation for subsequent lines..TP\f5-lmargin2 \fIdist\fRIf the first character of a display line has a tag for which thisoption has been specified, and if the display line is not thefirst for its text line (i.e., the text line has wrapped), then\fIdist\fR specifies how much the line should be indented fromthe left edge of the window.\fIDist\fR may have any of the standard forms for screendistances.This option is only used when wrapping is enabled, and it onlyapplies to the second and later display lines for a text line..TP\f5-offset \fIdist\fR\fIDist\fR specifies an amount by which the text's baselineshould be offset vertically from the baseline of the overallline, in pixels.For example, a positive offset can be used for superscriptsand a negative offset can be used for subscripts.\fIDist\fR may have any of the standard forms for screendistances..TP\f5-overstrike \fIboolean\fRSpecifies whether or not to draw a horizontal rule throughthe middle of characters..TP\f5-relief \fIrelief\fR\fIRelief\fR specifies the 3-D relief to use for drawing backgrounds.This option is used in conjunction with the \f5-borderwidth\fRoption to give a 3-D appearance to the background for characters;it is ignored unless the \f5-background\fR optionhas been set for the tag..TP\f5-rmargin \fIdist\fRIf the first character of a display line has a tag for which thisoption has been specified, then \fIdist\fR specifies how widea margin to leave between the end of the line and the rightedge of the window.This option is only used when wrapping is enabled.If a text line wraps, the right margin for each line on thedisplay is determined by the first character of that displayline..TP\f5-spacing1 \fIdist\fR\fIDist\fR specifies how much additional space should beleft above each text line, using any of the standard forms forscreen distances.If a line wraps, this option only applies to the firstline on the display..TP\f5-spacing2 \fIdist\fRFor lines that wrap, this option specifies how much additionalspace to leave between the display lines for a single text line.\fIDist\fR may have any of the standard forms for screendistances..TP\f5-spacing3 \fIdist\fR\fIDist\fR specifies how much additional space should beleft below each text line, using any of the standard forms forscreen distances.If a line wraps, this option only applies to the lastline on the display..TP\f5-tabs \fItabList\fR\fITabList\fR specifies a set of tab stops in the same formas for the \f5-tabs\fR option for the text widget.  Thisoption only applies to a display line if it applies to thefirst character on that display line.If this option is specified as an empty string, it cancelsthe option, leaving it unspecified for the tag (the default).If the option is specified as a non-empty string that isan empty list, such as \f5-tags\0{\0}\fR, then it requestsdefault 8-character tabs as described for the \f5tabs\fRwidget option..TP\f5-underline \fIboolean\fR\fIBoolean\fR specifies whether or not to draw an underline underneathcharacters..TP\f5-wrap \fImode\fR\fIMode\fR specifies how to handle lines that are wider than thetext's window.It has the same legal values as the \f5-wrap\fR optionfor the text widget:  \f5none\fR, \f5char\fR, or \f5word\fR.If this tag option is specified, it overrides the \f5-wrap\fR optionfor the text widget..PPIf a character has several tags associated with it, and if theirdisplay options conflict, then the options of the highest prioritytag are used.If a particular display option hasn't been specified for aparticular tag, or if it is specified as an empty string, thenthat option will never be used;  the next-highest-prioritytag's option will be used instead.If no tag specifies a particular display option, then the defaultstyle for the widget will be used..PPThe second purpose for tags is event bindings.You can associate bindings with a tag in much the same way you canassociate bindings with a widget class:  whenever particularevents occur on characters with the given tag, a givenTk command will be executed.Tag bindings can be used to give behaviours to ranges of characters;among other things, this allows hypertext-likefeatures to be implemented.For details, see the description of the \f5tag bind\fR widgetcommand below..PPThe third use for tags is in managing the selection.See THE SELECTION below. .SH MARKSThe second form of annotation in text widgets is a mark.Marks are used for remembering particular places in a text.They are something like tags, in that they have names andthey refer to places in the file, but a mark isn't associatedwith particular characters.Instead, a mark is associated with the gap between two characters.Only a single position may be associated with a mark at any giventime.If the characters around a mark are deleted the mark will stillremain;  it will just have new neighbour characters.In contrast, if the characters containing a tag are deleted thenthe tag will no longer have an association with characters inthe file.Marks may be manipulated with the ``\fIpathName \f5mark\fR'' widgetcommand, and their current locations may be determined by using themark name as an index in widget commands..PPEach mark also has a \fIgravity\fR, which is either \f5left\fR or\f5right\fR.The gravity for a mark specifies what happens to the mark whentext is inserted at the point of the mark.If a mark has left gravity, then the mark is treated as if itwere attached to the character on its left, so the mark willremain to the left of any text inserted at the mark position.If the mark has right gravity, new text inserted at the markposition will appear to the right of the mark.  The gravityfor a mark defaults to \f5right\fR..PPThe name space for marks is different from that for tags:  thesame name may be used for both a mark and a tag, but they will referto different things..PPTwo marks have special significance.First, the mark \f5insert\fR is associated with the insertion cursor,as described under THE INSERTION CURSOR below.Second, the mark \f5current\fR is associated with the characterclosest to the mouse and is adjusted automatically to track themouse position and any changes to the text in the widget (oneexception:  \f5current\fR is not updated in response to mousemotions if a mouse button is down;  the update will be deferreduntil all mouse buttons have been released).Neither of these special marks may be deleted. .SH EMBEDDED WINDOWSThe third form of annotation in text widgets is an embedded window.Each embedded window annotation causes a window to be displayedat a particular point in  the text.There may be any number of embedded windows in a text widget,and any widget may be used as an embedded window.The embedded window's position on the screen will be updated as thetext is modified or scrolled.Each embedded window occupies one character's worth of index spacein the text widget, and it may be referred to either by the nameof its embedded window or by its position in the widget'sindex space.If the range of text containing the embedded window is deleted and thewindow is a child of the text widget then the window is destroyed..PPWhen an embedded window is added to a text widget with the\f5window create\fR widget command, several configurationoptions may be associated with it.These options may be  modified later with the \f5window configure\fRwidget command.The following options are currently supported:.TP\f5-align \fIwhere\fRIf the window is not as tall as the line in which it is displayed,this option determines where the window is displayed in the line.\fIWhere\fR must have one of the values \f5top\fR (align the top of the windowwith the top of the line), \f5center\fR (center the windowwithin the range of the line), \f5bottom\fR (align the bottom of thewindow with the bottom of the line's area),or \f5baseline\fR (align the bottom of the window with the baselineof the line)..TP\f5-padx \fIdist\fR\fIDist\fR specifies the amount of extra space to leave oneach side of the embedded window.It may have any of the usual forms defined for a screen distance..TP\f5-pady \fIdist\fR

Lines 1–500 of 1188.