aboutsummaryrefslogtreecommitdiff
path: root/libXaw/spec/TextFuncs
blob: ea26068a5e4a924a79d0b29d29c3692004ee76ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
.\" $Xorg: TextFuncs,v 1.3 2000/08/17 19:42:28 cpqbld Exp $
.NH 2
Text Functions
.XS
	Text Functions
.XE
.LP
The following functions are provided as convenience routines for use with
the Text widget.  Although many of these actions can be performed by
modifying resources, these interfaces are frequently more efficient.
.LP
These data structures are defined in the Text widget's public header file,
<X11/Xaw/Text.h>.
.LP
.IN "XawTextPosition" "" "@DEF@"
typedef long XawTextPosition;
.sp
.LP
Character positions in the Text widget begin at 0 and end at n, where
n is the number of characters in the Text source widget.
.LP
.IN "XawTextBlock" "" "@DEF@"
.Ds 0
.TA .5i 1.5i 2.25i
.ta .5i 1.5i 2.25i
typedef struct {
	int \fIfirstPos\fP;
	int \fIlength\fP;
	char *\fIptr\fP;
	unsigned long \fIformat\fP;
} XawTextBlock, *XawTextBlockPtr;
.De
.LP
.IN "XawTextBlockPtr" ""
.IP \fIfirstPos\fP 1.0i
The first position, or index, to use within the \fIptr\fP field.
The value is commonly zero.
.IP \fIlength\fP 1.0i
The number of characters to be used from the \fIptr\fP field.
The number of characters used is commonly the number of characters
in \fIptr\fP, and must not be greater than the length of the string
in \fIptr\fP.
.IP \fIptr\fP 1.0i
Contains the string to be referenced by the Text widget.
.IP \fIformat\fP 1.0i
This flag indicates whether the data pointed to by \fBptr\fP is char
or wchar_t.  When the associated widget has \fBinternational\fP set
to \fBfalse\fP this field must be XawFmt8Bit.  When the associated
widget has \fBinternational\fP set to \fBtrue\fP this field must be
either XawFmt8Bit or XawFmtWide.
.LP
Note: Previous versions of Xaw used
.PN FMT8BIT ,
which has been retained for backwards compatibility. \fBFMT8BIT\fP is
deprecated and will eventually be removed from the implementation.
.NH 3
Selecting Text
.LP
To select a piece of text, use
.PN XawTextSetSelection :
.IN "XawTextSetSelection" "" "@DEF@"
.FD 0
void XawTextSetSelection(\fIw\fP, \fIleft\fP, \fIright\fP)
.br
     Widget \fIw\fP;
.br
     XawTextPosition \fIleft\fP, \fIright\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIleft\fP 1i
Specifies the character position at which the selection begins.
.IP \fIright\fP 1i
Specifies the character position at which the selection ends.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP.
If redisplay is enabled, this function highlights the text and
makes it the \fBPRIMARY\fP selection.  This function does not have any
effect on \fBCUT_BUFFER0\fP.
.LP
.NH 3
Unhighlighting Text
.LP
To unhighlight previously highlighted text in a widget, use
\fBXawTextUnsetSelection\fP:
.IN "XawTextUnsetSelection" "" "@DEF@"
.FD 0
void XawTextUnsetSelection(\fIw\fP)
.br
     Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.NH 3
Getting Current Text Selection
.LP
To retrieve the text that has been selected by this
text widget use \fBXawTextGetSelectionPos\fP:
.IN "XawTextGetSelectionPos" "" "@DEF@"
.FD 0
void XawTextGetSelectionPos(\fIw\fP, \fIbegin_return\fP, \fIend_return\fP)
.br
     Widget \fIw\fP;
.br
     XawTextPosition *\fIbegin_return\fP, *\fIend_return\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIbegin_return\fP 1i
Returns the beginning of the text selection.
.IP \fIend_return\fP 1i
Returns the end of the text selection.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP.
If the returned values are equal, no text is currently selected.
.NH 3
Replacing Text
.LP
To modify the text in an editable Text widget use \fBXawTextReplace\fP:
.IN "XawTextReplace" "" "@DEF@"
.FD 0
int XawTextReplace(\fIw\fP, \fIstart\fP, \fIend\fP, \fItext\fP)
.br
     Widget \fIw\fP;
.br
     XawTextPosition \fIstart\fP, \fIend\fP;
.br
     XawTextBlock *\fItext\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIstart\fP 1i
Specifies the starting character position of the text replacement.
.IP \fIend\fP 1i
Specifies the ending character position of the text replacement.
.IP \fItext\fP 1i
Specifies the text to be inserted into the file.
.LP
This function will not
be able to replace text in read-only text widgets.  It will also only
be able to append text to an append-only text widget.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP and
\fBXawTextBlock\fP.
.LP
This function may return the following values:
.IP \fBXawEditDone\fP 1.25i
.IN "XawEditDone" ""
The text replacement was successful.
.IP \fBXawPositionError\fP 1.25i
.IN "XawPositionError" ""
The edit mode is \fBXawtextAppend\fP and \fIstart\fP is not the position of
the last character of the source.
.IP \fBXawEditError\fP 1.25i
.IN "XawEditError" ""
Either the Source was read-only or the range to be deleted is larger
than the length of the Source.

.LP
The \fBXawTextReplace\fP arguments \fIstart\fP and
\fIend\fP represent the text source character positions for the
existing text that is to be replaced by the text in the text block.
The characters from \fIstart\fP up to
but not including \fIend\fP are deleted, and the characters
specified on the text block are inserted in their place.  If
\fIstart\fP and \fIend\fP are equal, no text is deleted and the new
text is inserted after \fIstart\fP.
.NH 3
Searching for Text
.LP
To search for a string in the Text widget, use
\fBXawTextSearch\fP:
.IN "XawTextSearch" "" "@DEF@"
.FD 0
XawTextPosition XawTextSearch(\fIw\fP, \fIdir\fP, \fItext\fP)
.br
      Widget \fIw\fP;
.br
      XawTextScanDirection \fIdir\fP;
.br
      XawTextBlock * \fItext\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIdir\fP 1i
Specifies the direction to search in.  Legal values are
\fBXawsdLeft\fP and \fBXawsdRight\fP.
.IP \fItext\fP 1i
Specifies a text block structure that contains the text to search for.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP and \fBXawTextBlock\fP.
The \fBXawTextSearch\fP function will begin at the insertion point
and search in the
direction specified for a string that matches the one passed in
\fItext\fP.  If the string is found the location of the first
character in the string is returned.  If the string could not be
found then the value \fBXawTextSearchError\fP is returned.
.NH 3
Redisplaying Text
.LP
To redisplay a range of characters, use \fBXawTextInvalidate\fP:
.IN "XawTextInvalidate" "" "@DEF@"
.FD 0
void XawTextInvalidate(\fIw\fP, \fIfrom\fP, \fIto\fP)
.br
      Widget \fIw\fP;
.br
      XawTextPosition \fIfrom\fP, \fIto\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIfrom\fP 1i
Specifies the start of the text to redisplay.
.IP \fIto\fP 1i
Specifies the end of the text to redisplay.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP.
The \fBXawTextInvalidate\fP
function causes the specified range of characters to be redisplayed
immediately if redisplay is enabled or the next time that redisplay is
enabled.
.LP
.sp 1
To enable redisplay, use \fBXawTextEnableRedisplay\fP:
.IN "XawTextEnableRedisplay" "" "@DEF@"
.FD 0
void XawTextEnableRedisplay(\fIw\fP)
.br
      Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.LP
The \fBXawTextEnableRedisplay\fP function flushes any changes due to
batched updates when \fBXawTextDisableRedisplay\fP
was called and allows future changes to be reflected immediately.
.LP
.sp 1
To disable redisplay while making several changes, use
\fBXawTextDisableRedisplay\fP.
.IN "XawTextDisableRedisplay" "" "@DEF@"
.FD 0
void XawTextDisableRedisplay(\fIw\fP)
.br
       Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.LP
The \fBXawTextDisableRedisplay\fP function causes all changes to be
batched until either \fBXawTextDisplay\fP or \fBXawTextEnableRedisplay\fP
is called.
.LP
.sp 1
To display batched updates, use \fBXawTextDisplay\fP:
.IN "XawTextDisplay" "" "@DEF@"
.FD 0
void XawTextDisplay(\fIw\fP)
.br
     Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.LP
The \fBXawTextDisplay\fP function forces any accumulated updates to be
displayed.
.NH 3
Resources Convenience Routines
.LP
To obtain the character position of the left-most character on the
first line displayed in the widget (the value of the
\fBdisplayPosition\fP resource), use \fBXawTextTopPosition\fP.
.IN "XawTextTopPosition" "" @DEF@"
.FD 0
XawTextPosition XawTextTopPosition(\fIw\fP)
.br
      Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.LP
.sp 1
To assign a new selection array to a text widget use
\fBXawTextSetSelectionArray\fP:
.IN "XawTextSetSelectionArray" "" "@DEF@"
.FD 0
void XawTextSetSelectionArray(\fIw\fP, \fIsarray\fP)
.br
      Widget \fIw\fP;
.br
      XawTextSelectType * \fIsarray\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIsarray\fP 1i
Specifies a selection array as defined in the section called \fBText
Selections for Application Programmers\fP.
.LP
Calling this function is equivalent to setting the value of the
\fBselectionTypes\fP resource.
.LP
.sp 1
To move the insertion point to the specified source position, use
\fBXawTextSetInsertionPoint\fP:
.IN "XawTextSetInsertionPoint" "" "@DEF@"
.FD 0
void XawTextSetInsertionPoint(\fIw\fP, \fIposition\fP)
.br
      Widget \fIw\fP;
.br
      XawTextPosition \fIposition\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIposition\fP 1i
Specifies the new position for the insertion point.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP.
The text will be scrolled vertically if necessary to make the line
containing the insertion point visible.  Calling this function is
equivalent to setting the \fBinsertPosition\fP resource.
.LP
.sp 1
To obtain the current position of the insertion point, use
\fBXawTextGetInsertionPoint\fP:
.IN "XawTextGetInsertionPoint" "" "@DEF@"
.FD 0
XawTextPosition XawTextGetInsertionPoint(\fIw\fP)
.br
      Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP.
The result is equivalent to retrieving the value of the
\fBinsertPosition\fP resource.
.LP
.sp 1
To replace the text source in the specified widget, use
\fBXawTextSetSource\fP:
.IN "XawTextSetSource" "" "@DEF@"
.FD 0
void XawTextSetSource(\fIw\fP, \fIsource\fP, \fIposition\fP)
.br
      Widget \fIw\fP;
.br
      Widget \fIsource\fP;
.br
      XawTextPosition \fIposition\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIsource\fP 1i
Specifies the text source object.
.IP \fIposition\fP 1i
Specifies character position that will become the upper left hand corner
of the displayed text.  This is usually set to zero.
.LP
See section 5.4 for a description of \fBXawTextPosition\fP.
A display update will be performed if redisplay is enabled.
.LP
.sp 1
To obtain the current text source for the specified widget, use
\fBXawTextGetSource\fP:
.IN "XawTextGetSource" "" "@DEF@"
.FD 0
Widget XawTextGetSource(\fIw\fP)
.br
      Widget \fIw\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.LP
This function returns the text source that this Text widget is currently
using.
.LP
.sp
To enable and disable the insertion point, use
\fBXawTextDisplayCaret\fP:
.IN "XawTextDisplayCaret" "" "@DEF@"
.FD 0
void XawTextDisplayCaret(\fIw\fP, \fIvisible\fP)
.br
      Widget \fIw\fP;
.br
      Boolean \fIvisible\fP;
.FN
.IP \fIw\fP 1i
Specifies the Text widget.
.IP \fIvisible\fP 1i
Specifies whether or not the caret should be displayed.
.LP
If \fIvisible\fP is \fBFalse\fP the insertion point will be disabled.
The marker is re-enabled either by setting \fIvisible\fP to \fBTrue\fP, by
calling \fBXtSetValues\fP, or by executing the \fIdisplay-caret\fP
action routine.