2
.\" $Id: cdk_util.3,v 1.4 2005/04/24 18:10:50 tom Exp $
2
.\" $Id: cdk_util.3,v 1.6 2005/12/28 18:35:31 tom Exp $
10
CDKgetDirectoryContents,
52
viewInfo \- Cdk utility functions
7
.XX CDKgetDirectoryContents
14
.XX deleteCursesWindow
25
.XX setWidgetDimension
29
cdk_util \- Cdk utility functions
65
.B "unsigned CDKallocStrings("
66
.BI "char ***" "list"/,
68
.BI "unsigned " "length"/,
69
.BI "unsigned " "used"/);
71
.B "unsigned CDKcountStrings("
74
.B "void CDKfreeChtypes("
75
.BI "chtype **" "list");
77
.B "void CDKfreeStrings("
78
.BI "char **" "list");
80
40
.B "int CDKgetDirectoryContents ("
81
41
.BI "char *" "directory",
82
42
.BI "char ***" "list");
114
64
.BI "char *" "line",
115
65
.BI "char *" "filename");
118
.BI "chtype *" "string");
122
.BI "chtype *" "src",
123
.BI "int " "maxcount");
125
.B "char *chtype2Char ("
126
.BI "chtype *" "string");
128
67
.B "char *chtype2String (
129
68
.BI "chtype *" "string");
131
.B "void cleanChar ("
132
.BI "char *" "string",
134
.BI "char " "character");
136
.B "void cleanChtype ("
137
.BI "chtype *" "string",
139
.BI "chtype" "character");
141
.B "int cmpStrChstr("
143
.BI "chtype *" "chstr");
145
.B "char *copyChar ("
146
.BI "char *" "string");
148
.B "chtype *copyChtype ("
149
.BI "chtype *" "string");
151
70
.B "void deleteCursesWindow ("
152
71
.BI "WINDOW *" "window");
155
.BI "char *" "filename");
157
73
.B "void eraseCursesWindow ("
158
74
.BI "WINDOW *" "window");
161
.BI "double " "value");
164
.BI "char *" "string");
166
.B "void freeCharList ("
167
.BI "char **" "list",
168
.BI "unsigned " "size");
170
.B "void freeChtype (
171
.BI "chtype *" "string");
173
.B void freeChtypeList ("
174
.BI "chtype **" "list",
175
.BI "unsigned " "size");
177
76
.B "int getListIndex ("
178
77
.BI "CDKSCREEN *" "screen",
179
78
.BI "char *" "title",
264
147
.BI "boolean " "interpret");
150
These are utility functions that one may use to initialize,
151
build or customize widgets.
268
153
.SH AVAILABLE FUNCTIONS
271
This beeps at the user.
272
The standard curses beep() does not
273
flush the stream, so it will only beep until a force is made.
274
This forces a flush after issuing the beep command.
277
Add a new string \fIitem\fP to a \fIlist\fP.
278
Keep a null pointer on the end so one may use
279
\fBCDKfreeStrings()\fP to deallocate the whole list.
280
The caller is responsible for updating the \fIlength\fP of the list.
281
The return value is the updated number of chars \fIused\fP.
284
Count the number of items in a null-terminated \fIlist\fP of character strings.
288
Free a \fIlist\fP of chtype-strings which is terminated by a null pointer.
291
Free a \fIlist\fP of character strings which is terminated by a null pointer.
293
155
.B CDKgetDirectoryContents
294
Open the given \fIdirectory\fP and reads in the contents.
295
Store result in \fIlist\fP and return the number of elements found.
156
opens and reads the contents of the given directory, filling
157
the array \fBlist\fR with the sorted contents of the directory.
158
If the directory cannot be opened then it returns a value of -1.
298
161
Read the file \fIfilename\fP,
299
162
load the contents into a dynamically allocated array,
300
storing its address via \fIinfo\fP
301
and return the number of lines read.
304
Split the \fIstring\fP at each occurrence of \fIseparator\fP,
305
returning a pointer to a dynamically allocated array of the pieces.
306
The original \fIstring\fP is unmodified.
163
storing its address via \fIinfo\fP.
164
It returns the number of lines
165
read if the file could be opened, -1 otherwise.
309
168
Aligns a box on the given \fIwindow\fP with the height and width given.
318
Return the basename of the given \fIfilename\fP.
319
The result should be freed by the caller.
322
Return an integer like the math library \fBceil()\fP, which returns a double.
325
177
Translate a character \fIstring\fP with embedded format markers
178
(e.g., "</X/Y>Blah Blah")
326
179
to a null-terminated array of chtype's.
327
180
The length of the array is stored via the \fIlength\fP parameter.
328
The alignment (LEFT, CENTER, RIGHT) is stored via the \fIalign\fP parameter.
181
The \fBalign\fR parameter contains justification information
182
(LEFT, CENTER, RIGHT).
183
The caller is responsible for freeing the result.
330
185
.B char2DisplayType
331
186
Lookup the given name in \fIstring\fP and return the equivalent display type.
341
196
buffer (which must hold at least CDK_PATHMAX characters).
342
197
Return nonzero if a filename is extracted.
345
Returns the length of the (null-terminated) \fIstring\fP of chtype's.
348
Extract the characters from a null-terminated array of chtype's \fIsrc\fP.
349
The size of the destination \fIdest\fP is given in \fImaxcount\fP.
352
Extract the characters from a null-terminated array of chtype's \fIstring\fP.
353
A dynamically allocated string is returned.
356
200
Extract the characters and formatting information
357
201
from a null-terminated array of chtype's \fIstring\fP.
358
202
A dynamically allocated string is returned.
361
Set the characters in \fIstring\fP to the given \fIcharacter\fP.
362
The length of \fIstring\fP is given by \fIlength\fP.
365
Set the chtype's in \fIstring\fP to the given \fIcharacter\fP.
366
The length of \fIstring\fP is given by \fIlength\fP.
369
Compare a char string \fIstr\fP to a chtype string \fIchstr\fP.
370
Return -1, 0 or 1 according to whether \fIstr\fP is less than, equal to
371
to greater than \fIchstr\fP.
374
Copy the given character string (like strdup).
377
Copy the given chtype string (analogous to strdup).
379
204
.B deleteCursesWindow
380
205
Safely delete a given window,
381
206
i.e., first check if the \fIwindow\fP parameter is nonnull.
384
Returns the directory for the given \fIfilename\fP,
385
i.e., the part before the * last slash.
386
The return value should be freed by the caller.
388
208
.B eraseCursesWindow
389
209
Safely erase a given window,
390
210
i.e., first check if the \fIwindow\fP parameter is nonnull.
393
Return an integer like the math function floor(), which returns a double.
396
Free the memory used by the given \fIstring\fP.
399
Free the memory used by the given \fIlist\fP of strings.
400
The number of strings to free is given by \fIsize\fP.
403
Free frees the memory used by the given chtype \fIstring\fP.
406
Free the memory used by the given \fIlist\fP of chtype strings.
407
The number of strings to free is given by \fIsize\fP.
410
213
Display a scrollable list of strings in a dialog,
411
214
allow the user to select one.
415
218
If \fInumbers\fP is true, the displayed list items will be numbered.
418
Display a simple dialog containing a prompt \fIlabel\fP and
419
initial value \fIinit\fP for the user's response.
420
Return the response string.
423
Return the number of characters which are required to represent the given
221
pops up an entry widget with a title supplied by the value
222
of the \fBtitle\fR parameter, a label supplied by the \fBlabel\fR parameter,
223
and an initial value supplied by the \fBinitialValue\fR parameter.
225
a pointer to the value typed in or NULL if the widget was exited early.
427
228
Given a string length \fImesglen\fP,
429
230
and a justification type \fIjustify\fP,
430
231
return the number of characters by which to shift the string.
433
Given a file protection mode \fIfileMode\fP,
434
store a printable version of the permissions in \fIstring\fP.
435
Return the corresponding permissions data,
436
i.e., ignoring the file-type bits.
439
234
Given a file protection mode \fIfileMode\fP,
440
235
return ignoring the file-type bits,
444
239
Move a given \fIwindow\fP by the amounts in \fIxdiff\fP and \fIydiff\fP.
447
Display a simple dialog with
448
a list of \fImesgCount\fP message strings \fImesg\fP.
449
At the bottom of the dialog, display \fIbuttonCount\fP buttons.
242
creates a quick pop-up dialog box.
243
Pass in the message in the
244
\fBmesg\fR parameter, the size of the message in the \fBmesgCount\fR parameter,
245
the button labels in the \fBbuttons\fR parameter and the number of buttons in
246
the \fBbuttonCount\fR parameter.
247
The dialog box will be centered on the screen.
452
Display a simple dialog with
453
a list of \fIcount\fP message strings \fImesg\fP.
250
creates a quick pop-up label widget.
251
The message and the size of
252
the message are passed in via the \fBmesg\fR and \fBcount\fR parameters respectively.
253
The label widget waits until the user hits a character and is centered
455
256
.B popupLabelAttrib
456
257
Display a simple dialog with
457
258
a list of \fIcount\fP message strings \fImesg\fP.
458
259
Use the given \fIattribute\fP for the background of the dialog.
461
Search the given \fIlist\fP of \fIlistSize\fP strings
462
for a subset of a word \fIpattern\fP in the given list.
463
Return the index in the list if it is found, or -1 if not found.
466
262
Display a file-selection dialog.
467
263
Return the selected filename, or null if none is selected.
494
290
Otherwise, the return value will be \fIproposedDim\fP.
498
This is a wrapper for qsort,
499
used to sort the \fIlist\fP of strings.
500
The number of strings in \fIlist\fP is given by \fIlength\fP.
502
293
.B stripWhiteSpace
503
294
Strip whitespace from the front and/or back of the given \fIstring\fP.
504
295
The \fIstripType\fP parameter controls the type of stripping done:
508
299
Read the file specified by \fIfilename\fP and display it in a CDKVIEWER window.
509
300
The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the
510
301
CDKVIEWER window.
303
the contents of the file supplied by the \fBfilename\fR value.
305
the file viewer are supplied by the \fBbuttons\fR parameter.
306
It returns the index of the button selected,
307
or -1 if the file does not exist or if the widget was exited early.
310
center tab(/) allbox;
314
\fBStrip_Type/Result\fR
317
This tells the function to remove
318
all of the white space from the
319
front of the given string.
322
This tells the function to remove
323
all of the white space from the
324
back of the given string.
327
This tells the function to remove
328
all of the white space from both
329
the front and the back of the given string.
513
334
Display the list of strings in \fIinfo\fP in a CDKVIEWER window.