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
|
'\" t
.\" $Id: cdk_util.3,v 1.10 2016/12/11 01:32:30 tom Exp $
.de bP
.IP \(bu 4
..
.de XX
..
.TH cdk_util 3
.SH NAME
.XX CDKgetDirectoryContents
.XX CDKreadFile
.XX alignxy
.XX char2Chtype
.XX char2DisplayType
.XX checkForLink
.XX chtype2String
.XX deleteCursesWindow
.XX eraseCursesWindow
.XX getListIndex
.XX getString
.XX justifyString
.XX mode2Filetype
.XX moveCursesWindow
.XX popupDialog
.XX popupLabel
.XX popupLabelAttrib
.XX selectFile
.XX setWidgetDimension
.XX stripWhiteSpace
.XX viewFile
.XX viewInfo
cdk_util \- Cdk utility functions
.SH SYNOPSIS
.LP
.B cc
.RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
.B \-lcdk
.RI "[ " "library" " \|.\|.\|. ]"
.LP
#include <cdk.h>
.nf
.TP 15
.B "int CDKgetDirectoryContents ("
.BI "const char *" "directory",
.BI "char ***" "list");
.TP 15
.B "int CDKreadFile ("
.BI "const char *" "filename",
.BI "char ***" "info");
.TP 15
.B "void alignxy ("
.BI "WINDOW *" "window",
.BI "int *" "xpos",
.BI "int *" "ypos",
.BI "int " "boxWidth",
.BI "int " "boxHeight");
.TP 15
.B "chtype *char2Chtype ("
.BI "const char *" "string",
.BI "int *" "length",
.BI "int *" "align");
.TP 15
.B "EDisplayType char2DisplayType ("
.BI "const char *" "string");
.TP 15
.B "int checkForLink ("
.BI "const char *" "line",
.BI "char *" "filename");
.TP 15
.B "char *chtype2String (
.BI "const chtype *" "string");
.TP 15
.B "void deleteCursesWindow ("
.BI "WINDOW *" "window");
.TP 15
.B "void eraseCursesWindow ("
.BI "WINDOW *" "window");
.TP 15
.B "int getListIndex ("
.BI "CDKSCREEN *" "screen",
.BI "const char *" "title",
.BI "CDK_CONST char **" "list",
.BI "int " "listSize",
.BI "boolean " "numbers");
.TP 15
.B char *getString ("
.BI "CDKSCREEN *" "screen",
.BI "const char *" "title",
.BI "const char *" "label",
.BI "const char *" "init");
.TP 15
.B "int justifyString ("
.BI "int " "fieldWidth",
.BI "int " "mesglen",
.BI "int " "justify");
.TP 15
.B "int mode2Filetype ("
.BI "mode_t " "fileMode");
.TP 15
.B "void moveCursesWindow ("
.BI "WINDOW *" "window",
.BI "int " "xdiff",
.BI "int " "ydiff");
.TP 15
.B "int popupDialog ("
.BI "CDKSCREEN *" "screen",
.BI "CDK_CONST char **" "mesg",
.BI "int " "mesgCount",
.BI "CDK_CONST char **" "buttons",
.BI "int " "buttonCount");
.TP 15
.B "void popupLabel ("
.BI "CDKSCREEN *" "win",
.BI "CDK_CONST char **" "mesg",
.BI "int " "count");
.TP 15
.B "void popupLabelAttrib ("
.BI "CDKSCREEN *" "win",
.BI "CDK_CONST char **" "mesg",
.BI "int " "count",
.BI "chtype " "attribute");
.TP 15
.B "char *selectFile ("
.BI "CDKSCREEN *" "screen",
.BI "const char *" "title");
.TP 15
.B "int setWidgetDimension ("
.BI "int " "parentDim",
.BI "int " "proposedDim",
.BI "int " "adjustment");
.TP 15
.B "void stripWhiteSpace ("
.BI "EStripType " "stripType",
.BI "char *" "string");
.TP 15
.B "int viewFile ("
.BI "CDKSCREEN *" "screen",
.BI "const char *" "title",
.BI "const char *" "filename",
.BI "CDK_CONST char **" "buttons",
.BI "int " "buttonCount");
.TP 15
.B "int viewInfo ("
.BI "CDKSCREEN *" "screen",
.BI "const char *" "title",
.BI "CDK_CONST char **" "info",
.BI "int " "size",
.BI "CDK_CONST char **" "buttons",
.BI "int " "buttonCount",
.BI "boolean " "interpret");
.fi
.SH DESCRIPTION
These are utility functions that one may use to initialize,
build or customize widgets.
.
.SH AVAILABLE FUNCTIONS
.TP 5
.B CDKgetDirectoryContents
opens and reads the contents of the given directory, filling
the array \fBlist\fR with the sorted contents of the directory.
If the directory cannot be opened then it returns a value of -1.
.TP 5
.B CDKreadFile
Read the file \fIfilename\fP,
load the contents into a dynamically allocated array,
storing its address via \fIinfo\fP.
It returns the number of lines
read if the file could be opened, -1 otherwise.
.TP 5
.B alignxy
Aligns a box on the given \fIwindow\fP with the height and width given.
See cdk_position (3) for the interpretation of the
\fIxpos\fP,
\fIypos\fP,
\fIboxWidth\fP and
\fIboxHeight\fP,
parameters.
.TP 5
.B char2Chtype
Translate a character \fIstring\fP with embedded format markers
(e.g., "</X/Y>Blah Blah")
to a null-terminated array of chtype's.
.RS
.bP
The length of the array is stored via the \fIlength\fP parameter.
.bP
The \fBalign\fR parameter contains justification information
(LEFT, CENTER, RIGHT).
.IP
The caller is responsible for freeing the result.
.RE
.TP 5
.B char2DisplayType
Lookup the given name in \fIstring\fP and return the equivalent display type.
See also cdk_display (3).
.TP 5
.B checkForLink
Check if the given \fIline\fP is of the form
.RS
<F=\fIfilename\fP>
.RE
.IP
If so, extract the filename from the line, storing it in the \fIfilename\fP
buffer (which must hold at least CDK_PATHMAX characters).
Return nonzero if a filename is extracted.
.TP 5
.B chtype2String
Extract the characters and formatting information
from a null-terminated array of chtype's \fIstring\fP.
A dynamically allocated string is returned.
.TP 5
.B deleteCursesWindow
Safely delete a given window,
i.e., first check if the \fIwindow\fP parameter is nonnull.
.TP 5
.B eraseCursesWindow
Safely erase a given window,
i.e., first check if the \fIwindow\fP parameter is nonnull.
.TP 5
.B getListIndex
Display a scrollable list of strings in a dialog,
allow the user to select one.
Return the index in the list of the value selected.
.RS
.bP
The \fIlist\fP parameter contains the strings to display;
there are \fIlistSize\fP strings in the list.
.bP
If \fInumbers\fP is true, the displayed list items will be numbered.
.RE
.TP 5
.B getString
pops up an entry widget with
.RS
.bP
a title supplied by the value
of the \fBtitle\fR parameter,
.bP
a label supplied by the \fBlabel\fR parameter,
and
.bP
an initial value supplied by the \fBinitialValue\fR parameter.
.RE
.IP
It returns
a pointer to the value typed in or NULL if the widget was exited early.
.TP 5
.B justifyString
Given a string length \fImesglen\fP,
the available field width \fIfieldWidth\fP
and a justification type \fIjustify\fP,
return the number of characters by which to shift the string.
.TP 5
.B mode2Filetype
Given a file protection mode \fIfileMode\fP,
return ignoring the file-type bits,
i.e., ignoring the corresponding permissions data.
.TP 5
.B moveCursesWindow
Move a given \fIwindow\fP by the amounts in \fIxdiff\fP and \fIydiff\fP.
.TP 5
.B popupDialog
creates a quick pop-up dialog box.
Pass in
.RS
.bP
the message in the \fBmesg\fR parameter,
.bP
the size of the message in the \fBmesgCount\fR parameter,
.bP
the button labels in the \fBbuttons\fR parameter and
.bP
the number of buttons in the \fBbuttonCount\fR parameter.
.RE
.IP
The dialog box will be centered on the screen.
.TP 5
.B popupLabel
creates a quick pop-up label widget.
.IP
The message and the size of
the message are passed in via the \fBmesg\fR and \fBcount\fR parameters respectively.
.IP
The label widget waits until the user hits a character and is centered
on the screen.
.TP 5
.B popupLabelAttrib
Display a simple dialog with
a list of \fIcount\fP message strings \fImesg\fP.
Use the given \fIattribute\fP for the background of the dialog.
.TP 5
.B selectFile
Display a file-selection dialog.
Return the selected filename, or null if none is selected.
The caller should free the return-value.
.TP 5
.B setWidgetDimension
This is a helper function used to set the height/width of a widget:
.RS
.bP
If the proposed dimension \fIproposedDim\fP is FULL or zero,
the return value will be \fIparentDim\fP.
.bP
If the proposed dimension \fIproposedDim\fP is positive,
.RS
.bP
and it is larger than \fIparentDim\fP, return \fIproposedDim\fP,
.bP
otherwise return \fIproposedDim\fP plus \fIadjustment\fP.
.RE
.bP
If the proposed dimension \fIproposedDim\fP is negative,
the return value will be \fIparentDim\fP plus \fIproposedDim\fP.
.bP
Otherwise, the return value will be \fIproposedDim\fP.
.RE
.TP 5
.B stripWhiteSpace
Strip whitespace from the front and/or back of the given \fIstring\fP.
.IP
The \fIstripType\fP parameter controls the type of stripping done:
vFRONT, vBACK or vBOTH.
.TP 5
.B viewFile
Read the file specified by \fIfilename\fP and display it in a CDKVIEWER window.
The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the
CDKVIEWER window.
.RS
.bP
The viewer shows
the contents of the file supplied by the \fBfilename\fR value.
.bP
The buttons on
the file viewer are supplied by the \fBbuttons\fR parameter.
.RE
.IP
It returns the index of the button selected,
or -1 if the file does not exist or if the widget was exited early.
.LP
.TS
center tab(/) allbox;
l l
l l
lw15 lw35 .
\fBStrip_Type/Result\fR
=
vFRONT/T{
This tells the function to remove
all of the white space from the
front of the given string.
T}
vBACK/T{
This tells the function to remove
all of the white space from the
back of the given string.
T}
vBOTH/T{
This tells the function to remove
all of the white space from both
the front and the back of the given string.
T}
.TE
.TP 5
.B viewInfo
Display the list of strings in \fIinfo\fP in a CDKVIEWER window.
The number of strings is given by \fIsize\fP.
The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the
CDKVIEWER window.
.
.SH SEE ALSO
cdk_dialog (3),
cdk_display (3),
cdk_position (3),
cdk_misc (3).
|