Debian Codegraph @

html/htext.html

raw symbols SCIP
1 <!-- manual page source format generated by PolyglotMan v3.0.8+XFree86, -->
2 <!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
3
4 <HTML>
5 <HEAD>
6 <TITLE>htext(n) manual page</TITLE>
7 </HEAD>
8 <BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red">
9 <A HREF="#toc">Table of Contents</A><P>
10
11 <H2><A NAME="sect0" HREF="#toc0">Name</A></H2>
12 htext - Create and manipulate hypertext widgets
13
14 <H2><A NAME="sect1" HREF="#toc1">Synopsis</A></H2>
15 <B>htext</B> <I>pathName </I>?<I>option value</I>?...
16 <H2><A NAME="sect2" HREF="#toc2">Description</A></H2>
17 <P>
18 The <B>htext</B> command creates
19 a new window (given by the <I>pathName</I> argument) and makes it into a <B>htext</B>
20 widget. Additional options, described above, may be specified on the command
21 line or in the option database to configure aspects of the widget such
22 as its color and font. At the time this command is invoked, there must
23 not exist a window named <I>pathName</I>, but <I>pathName</I>'s parent must exist. The
24 <B>htext</B> command returns its <I>pathName</I>. <P>
25 The <B>htext</B> widget is hybrid of a non-editable
26 text widget and a geometry manager (e.g. the packer). It displays text (optionally
27 read from file) in a window. Text can be scrolled either horizontally or
28 vertically using the <B>htext</B> window as a viewport. In addition, Tcl commands
29 can be embedded into the text which are evaluated as the text is parsed.
30 Text between special double characters (percent signs "%%") is immediately
31 passed to the Tcl interpreter for evaluation. <P>
32 Furthermore, any widget
33 or widget hierarchy can be packed in-line and made to appear on the current
34 line of the text. Widgets are packed using the <B>htext append</B> command. All
35 widgets must be children of the <B>htext</B> window and must already exist before
36 packing. Once a widget has been packed it cannot be moved to a different
37 position within the text. Widgets can be resized but they will remain
38 at the same position within the text. <P>
39 Before a file or text string is parsed
40 by the <B>htext</B> widget, all the widget's current children are destroyed. You
41 can reload files or text without worrying about unmapping or destroying
42 each child window beforehand. <P>
43 Setting the either the <B>-filename</B> or <B>-text</B> configuration
44 option will adjust the value of the other. If both options are set, the
45 file takes precedence. When a new file is read using the <B>-filename</B> option,
46 the value of the <B>-text</B> option is reset to the empty string. Likewise, when
47 the <B>-text</B> option is set, the string representing the <B>-filename</B> option is
48 cleared.
49 <H2><A NAME="sect3" HREF="#toc3">File Format</A></H2>
50 The format of <B>htext</B> text file is typically ASCII text.
51 Text enclosed by special double characters (by default, percent signs
52 '%%') is interpreted and executed as Tcl commands. The special character
53 may be specified by the <B>-specialchar</B> option. In the following example of
54 a <B>htext</B> file, a button widget is appended to the text between the words
55 "<I>a</I>" and "<I>which</I>". The <I>pathName</I> of the <B>htext</B> widget is "<I>.ht</I>". <BR>
56 <CODE><I>This will be displayed as normal text. <BR>
57 </I>But this will become a %% <BR>
58 button .ht.button -text "button" -fg red<BR>
59 .ht append .ht.button <BR>
60 %% which can invoke a Tcl command.<BR>
61 <P>
62
63 <H2><A NAME="sect4" HREF="#toc4"></CODE><P>Indices</A></H2>
64 <P>
65 Some of the widget operations (<B>selection</B>, gotoline, <B>search</B>, etc.)
66 take one or more indices as arguments. An index is a string used to indicate
67 a particular place within the text, such as the first and last characters
68 in a range to be selected. <P>
69 An index must have one of the following forms:
70
71 <DL>
72
73 <DT><I>line<B>.<I>char</I></B></I> </DT>
74 <DD>Indicates <I>char</I>'th character on line <I>line</I>. Both lines and characters
75 are number from 0, so "0.0" is the first beginning of the text. <I>Char</I> may
76 be undesignated. In this case a character position of 0 is assumed. </DD>
77
78 <DT><B>@<I>x<B>,<I>y</I></B></I></B>
79 </DT>
80 <DD>Indicates the character that covers the pixel whose x and y coordinates
81 within the text's window are <I>x</I> and <I>y</I>. </DD>
82
83 <DT><B>end</B> </DT>
84 <DD>Indicates the end of the text. </DD>
85
86 <DT><B>anchor</B>
87 </DT>
88 <DD>Indicates the anchor point for the selection, which is set with the <B>selection</B>
89 operation. </DD>
90
91 <DT><B>sel.first</B> </DT>
92 <DD>Indicates the first character in the selection. It is
93 an error to use this form if the selection isn't in the entry window. </DD>
94
95 <DT><B>sel.last</B>
96 </DT>
97 <DD>Indicates the character just after the last one in the selection. It is
98 an error to use this form if the selection isn't in the entry window. </DD>
99 </DL>
100
101 <H2><A NAME="sect5" HREF="#toc5">Variables</A></H2>
102 <P>
103 The
104 following global Tcl variables are maintained when an <B>htext</B> file is parsed.
105
106 <DL>
107
108 <DT><B>htext(widget)</B> </DT>
109 <DD>is the pathname of the <B>htext</B> widget. </DD>
110
111 <DT><B>htext(file)</B> </DT>
112 <DD>is the
113 name of the file the <B>htext</B> widget is currently parsing. It is the empty
114 string when the <B>-text</B> option is used. </DD>
115
116 <DT><B><A HREF="htext.l.html">htext(line)</B></A>
117 </DT>
118 <DD>is the current line number
119 in the text. </DD>
120 </DL>
121 <P>
122 This information might be used to construct hyper links
123 between different files and/or lines. <P>
124
125 <H2><A NAME="sect6" HREF="#toc6">Syntax</A></H2>
126 The <B>htext</B> command creates a
127 new Tcl command whose name is <I>pathName</I>. This command may be used to invoke
128 various operations on the widget. It has the following general form: <BR>
129 <P>
130 <CODE><I>pathName oper </I>?<I>args</I>?<BR>
131 </CODE><P><I>Oper</I> and <I>args</I> determine the exact behavior of the command. <P>
132
133 <H2><A NAME="sect7" HREF="#toc7">Operations</A></H2>
134 The
135 following operations are available for <B>htext</B> widgets:
136 <DL>
137
138 <DT><I>pathName <B>append <I>window
139 </I></B></I>?<I>option value</I>?... </DT>
140 <DD>Embeds the widget <I>window</I> into the htext widget. <I>Window</I>
141 is the pathname of the widget to be embedded which must be a child of <I>pathName</I>.
142 <I>Window</I> will be positioned in the htext widget at the current location
143 of the text. If <I>option</I> and <I>value</I> pairs are present, they configure various
144 aspects how <I>window</I> appears in <I>pathName</I>. The following options are available.
145 <blockquote></DD>
146
147 <DT><B>-anchor <I>anchorPos</I></B> </DT>
148 <DD>Specifies how <I>window</I> will be arranged if there is any
149 extra space in the cavity surrounding the window. For example, if <I>anchorPos</I>
150 is <B>center</B> then the window is centered in the cavity; if <I>anchorPos</I> is <B>w</B>
151 then the window will be drawn such it touches the leftmost edge of the
152 cavity. The default is <I>center</I>. </DD>
153
154 <DT><B>-fill <I>style</I></B> </DT>
155 <DD>Specifies how the <I>window</I> should
156 be stretched to occupy the extra space in the cavity surrounding it (if
157 any exists). <I>Style</I> is <I>none</I>, <I>x</I>, <I>y</I>, <I>both</I>. If <I>style</I> is <I>x</I>, the width of <I>window</I>
158 is expanded to fill the cavity. If <I>style</I> is <B>y</B>, the height is expanded.
159 The default is <I>none</I>. </DD>
160
161 <DT><B>-height <I>pixels</I></B> </DT>
162 <DD>Sets the height of the cavity surrounding
163 <I>window</I>. If <I>pixels</I> is zero, the height of the cavity will be the same as
164 the requested height of <I>window</I>. If <I>pixels</I> is less than the requested height
165 of <I>window</I>, <I>window</I> will be reduced to fit the cavity. The default is <I>0</I>. </DD>
166
167 <DT><B>-ipadx
168 <I>pad</I></B> </DT>
169 <DD>Sets the amount of internal padding to be added to the width <I>window</I>.
170 <I>Pad</I> can be a list of one or two numbers. If <I>pad</I> has two elements, the
171 left side of <I>window</I> is extended by the first value and the right side by
172 the second value. If <I>pad</I> is just one value, both the left and right sides
173 are padded by evenly by the value. The default is <I>0</I>. </DD>
174
175 <DT><B>-ipady <I>pad</I></B> </DT>
176 <DD>Sets an amount
177 of internal padding to be added to the height of <I>window</I>. <I>Pad</I> can be a list
178 of one or two numbers. If <I>pad</I> has two elements, the top of <I>window</I> is padded
179 by the first value and the bottom by the second value. If <I>pad</I> is just one
180 number, both the top and bottom are padded evenly by the value. The default
181 is <I>0</I>. </DD>
182
183 <DT><B>-justify <I>justify</I></B> </DT>
184 <DD>Justifies <I>window</I> vertically within the cavity containing
185 it in relation to the line of text. <I>Justify</I> is <B>top</B>, <B>bottom</B>, or <B>center</B>.
186 If <I>justify</I> is <I>center</I> the widget is centered along the baseline of the
187 line of text. The default is <I>center</I>. </DD>
188
189 <DT><B>-padx <I>pad</I></B> </DT>
190 <DD>Sets the padding on the left
191 and right sides of <I>window</I>. <I>Pad</I> can be a list of one or two numbers. If <I>pad</I>
192 has two elements, the left side of <I>window</I> is padded by the first value
193 and the right side by the second value. If <I>pad</I> has just one value, both
194 the left and right sides are padded evenly by the value. The default is
195 <I>0</I>. </DD>
196
197 <DT><B>-pady <I>pad</I></B> </DT>
198 <DD>Sets the padding above and below <I>window</I>. <I>Pad</I> can be a list of
199 one or two numbers. If <I>pad</I> has two elements, the area above <I>window</I> is padded
200 by the first value and the area below by the second value. If <I>pad</I> is just
201 one number, both the top and bottom are padded by the value. The default
202 is <I>0</I>. </DD>
203
204 <DT><B>-relheight <I>value</I></B> </DT>
205 <DD>Specifies the height of the cavity containing <I>window</I>
206 relative to the height of <I>pathName</I>. <I>Value</I> is real number indicating the
207 ratio of the height of the cavity to the height of <I>pathName</I>. As the height
208 of <I>pathName</I> changes, so will the height of <I>window</I>. If <I>value</I> is 0.0 or less,
209 the height of the cavity is the requested height <I>window</I>. The default is
210 <I>0.0</I>. </DD>
211
212 <DT><B>-relwidth <I>value</I></B> </DT>
213 <DD>Specifies the width of the cavity containing <I>window</I> relative
214 to the width of <I>pathName</I>. <I>Value</I> is real number indicating the ratio of
215 the width of the cavity to the width of IpathName. As the height of <I>pathName</I>
216 changes, so will the height of <I>window</I>. If <I>value</I> is 0.0 or less, the width
217 of the cavity is the requested width of <I>window</I>. The default is <I>0.0</I>. </DD>
218
219 <DT><B>-width
220 <I>value</I></B> </DT>
221 <DD>Species the width of the cavity containing the child window. <I>Value</I>
222 must be in a form accepted by <B>Tk_GetPixels</B>. If <I>value</I> is greater than zero,
223 the cavity is resized to that width. If the requested window width is
224 greater than the cavity's width, the window will be reduced to fit the cavity.
225 By default, the cavity is requested width of the child window. </DD>
226 </DL>
227 </blockquote>
228
229 <DL>
230
231 <DT><I>pathName
232 <B>configure</B></I> ?<I>window</I>? ?<I>option</I>? ?<I>value option value ...</I>? </DT>
233 <DD>Queries or modifies the
234 configuration options of the text widget or one of its embedded widgets.
235 If no <I>window</I> argument is present, the htext widget itself is configured.
236 Otherwise <I>window</I> is the pathname of a widget already embedded into the
237 htext widget. Then this command configure the options for the embedded widget.
238 </DD>
239 </DL>
240 <P>
241 If <I>option</I> isn't specified, a list describing all of the current options
242 for <I>pathName</I> or <I>window</I> is returned. If <I>option</I> is specified, but not <I>value</I>,
243 then a list describing the option <I>option</I> is returned. If one or more <I>option</I>
244 and <I>value</I> pairs are specified, then for each pair, the htext or embedded
245 window option <I>option</I> is set to <I>value</I>. <P>
246 The following options are valid for
247 the htext widget. <blockquote>
248 <DL>
249
250 <DT><B>-background</B> <I>color<I> </I></I></DT>
251 <DD>Sets the background of the htext widget
252 to <I>color</I>. This default is <I>white</I>. </DD>
253
254 <DT><B>-cursor</B> <I>cursor</I> </DT>
255 <DD>Specifies the cursor for
256 the htext widget. The default cursor is <I>pencil</I>. </DD>
257
258 <DT><B>-filename</B> <I>fileName</I> </DT>
259 <DD>Specifies
260 a <B>htext</B> file to be displayed in the window. If the value is the empty string,
261 the <B>-text</B> option is used instead. See the section <FONT SIZE=-1><B>FILE</B></FONT>
262 for a description
263 of the <B>htext</B> file format. </DD>
264
265 <DT><B>-font</B> <I>fontName</I> </DT>
266 <DD>Sets the font of the text in the
267 htext widget to <I>fontName</I>. The default is <I>*-Helvetica-Bold-R-Normal-*-12-120-*</I>. </DD>
268
269 <DT><B>-foreground</B>
270 <I>color</I> </DT>
271 <DD>Sets the foreground of the htext widget to <I>color</I>. This is the color
272 of the text. This default is <I>black</I>. </DD>
273
274 <DT><B>-height</B> <I>pixels</I> </DT>
275 <DD>Specifies the height of
276 the htext widget window. </DD>
277
278 <DT><B>-linespacing</B> <I>pixels</I> </DT>
279 <DD>Specifies the spacing between
280 each line of text. The value must be in a form accepted by <B>Tk_GetPixels</B>.
281 The default value is 1 pixel. </DD>
282
283 <DT><B>-specialchar</B> <I>number</I> </DT>
284 <DD>Specifies the ASCII value
285 of the special double character delimiters. In <B>htext</B> files, the text between
286 these special characters is evaluated as a block of Tcl commands. The default
287 special character is the <I>0x25</I> (percent sign). </DD>
288
289 <DT><B>-text</B> <I>text</I> </DT>
290 <DD>Specifies the
291 text to be displayed in the htext widget. <I>Text</I> can be any valid string
292 of characters. See <FONT SIZE=-1><B>FILE FORMAT</B></FONT>
293 for a description. </DD>
294
295 <DT><B>-xscrollcommand</B> <I>string</I>
296 </DT>
297 <DD>Specifies the prefix for a command used to communicate with horizontal
298 scrollbars. When the view in the htext widget's window changes (or whenever
299 anything else occurs that could change the display in a scrollbar, such
300 as a change in the total size of the widget's contents), the widget invoke
301 <I>string</I> concatenated by two numbers. Each of the numbers is a fraction between
302 0 and 1, which indicates a position in the document. If this option is
303 not specified, then no command will be executed. </DD>
304
305 <DT><B>-yscrollcommand</B> <I>string</I> </DT>
306 <DD>Specifies
307 the prefix for a command used to communicate with vertical scrollbars.
308 When the view in the htext widget's window changes (or whenever anything
309 else occurs that could change the display in a scrollbar, such as a change
310 in the total size of the widget's contents), the widget invoke <I>string</I> concatenated
311 by two numbers. Each of the numbers is a fraction between 0 and 1, which
312 indicates a position in the document. If this option is not specified,
313 then no command will be executed. </DD>
314
315 <DT><B>-width</B> <I>pixels</I> </DT>
316 <DD>Specifies the desired width
317 of the viewport window. If the <I>pixels</I> is less than one, the window will
318 grow to accommodate the widest line of text. </DD>
319
320 <DT><B>-xscrollunits</B> <I>pixels</I> </DT>
321 <DD>Specifies
322 the horizontal scrolling distance. The default is 10 pixels. </DD>
323
324 <DT><B>-yscrollunits</B>
325 <I>pixels</I> </DT>
326 <DD>Specifies the vertical scrolling distance. The default is 10 pixels.
327 </DD>
328 </DL>
329 </blockquote>
330
331 <DL>
332
333 <DT><I>pathName <B>gotoline </B></I>?<I>index</I>? </DT>
334 <DD>Sets the top line of the text to <I>index</I>. <I>Index</I>
335 must be a valid text index (the character offset is ignored). If an <I>index</I>
336 isn't provided, the current line number is returned. </DD>
337
338 <DT><I>pathName <B>scan mark
339 <I>position</I></B></I> </DT>
340 <DD>Records <I>position</I> and the current view in the text window; used
341 in conjunction with later <B>scan dragto</B> commands. <I>Position</I> must be in the
342 form "<I>@x,y</I>, where <I>x</I> and <I>y</I> are window coordinates. Typically this command
343 is associated with a mouse button press in the widget. It returns an empty
344 string. </DD>
345
346 <DT><I>pathName <B>scan dragto <I>position</I></B></I> </DT>
347 <DD>Computes the difference between <I>position</I>
348 and the position registered in the last <B>scan mark</B> command for the widget.
349 The view is then adjusted up or down by 10 times the difference in coordinates.
350 This command is can be associated with mouse motion events to produce
351 the effect of dragging the text at high speed through the window. <I>Position</I>
352 must be in the form "<I>@x,y</I>, where <I>x</I> and <I>y</I> are window coordinates. The command
353 returns an empty string. </DD>
354
355 <DT><I>pathName <B>search <I>pattern</I></B></I> ?<I>from</I>? ?<I>to</I>? </DT>
356 <DD>Returns the
357 number of the next line matching <I>pattern</I>. <I>Pattern</I> is a string which obeys
358 the matching rules of <B>Tcl_StringMatch</B>. <I>From</I> and <I>to</I> are text line numbers
359 (inclusive) which bound the search. If no match for <I>pattern</I> can be found,
360 <B>-1</B> is returned. </DD>
361
362 <DT><I>pathName <B>xview </B></I>?<I>position</I>? </DT>
363 <DD>Moves the viewport horizontally
364 to the new text x-coordinate position. <I>Position</I> is the offset from the
365 left side of the text to the current position and must be in a form accepted
366 by <B>Tk_GetPixels</B>. If <I>position</I> is not present, the current text position is
367 returned. </DD>
368
369 <DT><I>pathName <B>yview </B></I>?<I>position</I>? </DT>
370 <DD>Moves the viewport vertically to the
371 new text y-coordinate position. <I>Position</I> is the offset from the top of
372 the text to the current position and must be in a form accepted by <B>Tk_GetPixels</B>.
373 If <I>position</I> is not present, the current text position is returned. </DD>
374 </DL>
375
376 <H2><A NAME="sect8" HREF="#toc8">Bugs</A></H2>
377 Text
378 with embedded tabs can be obscured by child windows when scrolled horizontally.
379
380 <H2><A NAME="sect9" HREF="#toc9">Keywords</A></H2>
381 hypertext, widget <P>
382
383 <HR><P>
384 <A NAME="toc"><B>Table of Contents</B></A><P>
385 <UL>
386 <LI><A NAME="toc0" HREF="#sect0">Name</A></LI>
387 <LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI>
388 <LI><A NAME="toc2" HREF="#sect2">Description</A></LI>
389 <LI><A NAME="toc3" HREF="#sect3">File Format</A></LI>
390 <LI><A NAME="toc4" HREF="#sect4">Indices</A></LI>
391 <LI><A NAME="toc5" HREF="#sect5">Variables</A></LI>
392 <LI><A NAME="toc6" HREF="#sect6">Syntax</A></LI>
393 <LI><A NAME="toc7" HREF="#sect7">Operations</A></LI>
394 <LI><A NAME="toc8" HREF="#sect8">Bugs</A></LI>
395 <LI><A NAME="toc9" HREF="#sect9">Keywords</A></LI>
396 </UL>
397 </BODY></HTML>