1cdk_util(3)                Library Functions Manual                cdk_util(3)
2
3
4

NAME

6       cdk_util - Cdk utility functions
7

SYNOPSIS

9       cc [ flag ... ] file ...  -lcdk [ library ... ]
10
11       #include <cdk.h>
12
13       int CDKgetDirectoryContents (
14                      const char *directory,
15                      char ***list);
16
17       int CDKreadFile (
18                      const char *filename,
19                      char ***info);
20
21       void alignxy ( WINDOW *window,
22                      int *xpos,
23                      int *ypos,
24                      int boxWidth,
25                      int boxHeight);
26
27       chtype *char2Chtype (
28                      const char *string,
29                      int *length,
30                      int *align);
31
32       EDisplayType char2DisplayType (
33                      const char *string);
34
35       int checkForLink (
36                      const char *line,
37                      char *filename);
38
39       char *chtype2String (
40                      const chtype *string);
41
42       void deleteCursesWindow (
43                      WINDOW *window);
44
45       void eraseCursesWindow (
46                      WINDOW *window);
47
48       int getListIndex (
49                      CDKSCREEN *screen,
50                      const char *title,
51                      CDK_CONST char **list,
52                      int listSize,
53                      boolean numbers);
54
55       char *getString (
56                      CDKSCREEN *screen,
57                      const char *title,
58                      const char *label,
59                      const char *init);
60
61       int justifyString (
62                      int fieldWidth,
63                      int mesglen,
64                      int justify);
65
66       int mode2Filetype (
67                      mode_t fileMode);
68
69       void moveCursesWindow (
70                      WINDOW *window,
71                      int xdiff,
72                      int ydiff);
73
74       int popupDialog (
75                      CDKSCREEN *screen,
76                      CDK_CONST char **mesg,
77                      int mesgCount,
78                      CDK_CONST char **buttons,
79                      int buttonCount);
80
81       void popupLabel (
82                      CDKSCREEN *win,
83                      CDK_CONST char **mesg,
84                      int count);
85
86       void popupLabelAttrib (
87                      CDKSCREEN *win,
88                      CDK_CONST char **mesg,
89                      int count,
90                      chtype attribute);
91
92       char *selectFile (
93                      CDKSCREEN *screen,
94                      const char *title);
95
96       int setWidgetDimension (
97                      int parentDim,
98                      int proposedDim,
99                      int adjustment);
100
101       void stripWhiteSpace (
102                      EStripType stripType,
103                      char *string);
104
105       int viewFile ( CDKSCREEN *screen,
106                      const char *title,
107                      const char *filename,
108                      CDK_CONST char **buttons,
109                      int buttonCount);
110
111       int viewInfo ( CDKSCREEN *screen,
112                      const char *title,
113                      CDK_CONST char **info,
114                      int size,
115                      CDK_CONST char **buttons,
116                      int buttonCount,
117                      boolean interpret);
118

DESCRIPTION

120       These  are  utility  functions that one may use to initialize, build or
121       customize widgets.
122

AVAILABLE FUNCTIONS

124       CDKgetDirectoryContents
125            opens and reads the contents of the given directory,  filling  the
126            array  list  with  the  sorted  contents of the directory.  If the
127            directory cannot be opened then it returns a value of -1.
128
129       CDKreadFile
130            Read the file filename, load the contents into a dynamically allo‐
131            cated  array, storing its address via info.  It returns the number
132            of lines read if the file could be opened, -1 otherwise.
133
134       alignxy
135            Aligns a box on the given window with the height and width  given.
136            See  cdk_position  (3)  for  the interpretation of the xpos, ypos,
137            boxWidth and boxHeight, parameters.
138
139       char2Chtype
140            Translate a character string with embedded format  markers  (e.g.,
141            “</X/Y>Blah Blah”) to a null-terminated array of chtype's.
142
143            ·   The length of the array is stored via the length parameter.
144
145            ·   The  align parameter contains justification information (LEFT,
146                CENTER, RIGHT).
147
148                The caller is responsible for freeing the result.
149
150            See cdk_display(3) for details on formatting.
151
152       char2DisplayType
153            Lookup the given name in string and return the equivalent  display
154            type.  See also cdk_display (3).
155
156       checkForLink
157            Check if the given line is of the form
158            <F=filename>
159
160            If so, extract the filename from the line, storing it in the file‐
161            name buffer (which must hold  at  least  CDK_PATHMAX  characters).
162            Return nonzero if a filename is extracted.
163
164       chtype2String
165            Extract the characters and formatting information from a null-ter‐
166            minated array of chtype's string.  A dynamically allocated  string
167            is returned.
168
169            See cdk_display(3) for details on Cdk's formatting.
170
171            In  addition, this function supports a feature needed to represent
172            multi-line   title   strings   returned   by   getCdkTitle    (see
173            cdk_objs(3)).   Each newline separating lines in the title is rep‐
174            resented by “<#10>” to allow Cdk to display the string in  a  text
175            field.
176
177       deleteCursesWindow
178            Safely  delete  a  given  window,  i.e., first check if the window
179            parameter is nonnull.
180
181       eraseCursesWindow
182            Safely erase a given window,  i.e.,  first  check  if  the  window
183            parameter is nonnull.
184
185       getListIndex
186            Display  a  scrollable list of strings in a dialog, allow the user
187            to select one.   Return  the  index  in  the  list  of  the  value
188            selected.
189
190            ·   The  list parameter contains the strings to display; there are
191                listSize strings in the list.
192
193            ·   If numbers is true, the displayed list items will be numbered.
194
195       getString
196            pops up an entry widget with
197
198            ·   a title supplied by the value of the title parameter,
199
200            ·   a label supplied by the label parameter, and
201
202            ·   an initial value supplied by the initialValue parameter.
203
204            It returns a pointer to the value typed in or NULL if  the  widget
205            was exited early.
206
207       justifyString
208            Given  a  string  length mesglen, the available field width field‐
209            Width and a justification type justify, return the number of char‐
210            acters by which to shift the string.
211
212       mode2Filetype
213            Given  a  file protection mode fileMode, return ignoring the file-
214            type bits, i.e., ignoring the corresponding permissions data.
215
216       moveCursesWindow
217            Move a given window by the amounts in xdiff and ydiff.
218
219       popupDialog
220            creates a quick pop-up dialog box.  Pass in
221
222            ·   the message in the mesg parameter,
223
224            ·   the size of the message in the mesgCount parameter,
225
226            ·   the button labels in the buttons parameter and
227
228            ·   the number of buttons in the buttonCount parameter.
229
230            The dialog box will be centered on the screen.
231
232       popupLabel
233            creates a quick pop-up label widget.
234
235            The message and the size of the message are passed in via the mesg
236            and count parameters respectively.
237
238            The label widget waits until the user hits a character and is cen‐
239            tered on the screen.
240
241       popupLabelAttrib
242            Display a simple dialog with a list of count message strings mesg.
243            Use the given attribute for the background of the dialog.
244
245       selectFile
246            Display a file-selection dialog.  Return the selected filename, or
247            null if none is selected.  The  caller  should  free  the  return-
248            value.
249
250       setWidgetDimension
251            This  is  a helper function used to set the height/width of a wid‐
252            get:
253
254            ·   If the proposed dimension proposedDim is  FULL  or  zero,  the
255                return value will be parentDim.
256
257            ·   If the proposed dimension proposedDim is positive,
258
259                ·   and it is larger than parentDim, return proposedDim,
260
261                ·   otherwise return proposedDim plus adjustment.
262
263            ·   If  the proposed dimension proposedDim is negative, the return
264                value will be parentDim plus proposedDim.
265
266            ·   Otherwise, the return value will be proposedDim.
267
268       stripWhiteSpace
269            Strip whitespace from the front and/or back of the given string.
270
271            The stripType parameter  controls  the  type  of  stripping  done:
272            vFRONT, vBACK or vBOTH.
273
274       viewFile
275            Read  the file specified by filename and display it in a CDKVIEWER
276            window.  The title, buttons and buttonCount  are  applied  to  the
277            CDKVIEWER window.
278
279            ·   The  viewer  shows  the  contents  of the file supplied by the
280                filename value.
281
282            ·   The buttons on the file viewer are  supplied  by  the  buttons
283                parameter.
284
285            It  returns  the  index  of the button selected, or -1 if the file
286            does not exist or if the widget was exited early.
287
288               ┌────────────────┬─────────────────────────────────────┐
289Strip_Type      Result                              
290               ├────────────────┼─────────────────────────────────────┤
291               ├────────────────┼─────────────────────────────────────┤
292               │vFRONT          │ This tells the function  to  remove │
293               │                │ all  of  the  white  space from the │
294               │                │ front of the given string.          │
295               ├────────────────┼─────────────────────────────────────┤
296               │vBACK           │ This tells the function  to  remove │
297               │                │ all  of  the  white  space from the │
298               │                │ back of the given string.           │
299               ├────────────────┼─────────────────────────────────────┤
300               │vBOTH           │ This tells the function  to  remove │
301               │                │ all  of  the  white space from both │
302               │                │ the front and the back of the given │
303               │                │ string.                             │
304               └────────────────┴─────────────────────────────────────┘
305       viewInfo
306            Display  the  list  of strings in info in a CDKVIEWER window.  The
307            number of strings is given by size.  The title, buttons  and  but‐
308            tonCount are applied to the CDKVIEWER window.
309

SEE ALSO

311       cdk_dialog(3),   cdk_display(3),  cdk_misc(3),  cdk_objs(3),  cdk_posi‐
312       tion(3).
313
314
315
316                                                                   cdk_util(3)
Impressum