1cdk_display(3) Library Functions Manual cdk_display(3)
2
3
4
6 cdk_display - Curses Development Kit Display Capabilities.
7
9 Cdk has a number of pre-defined display types. The following are out‐
10 lined in this manual page:
11
12 · How To Use Colors
13
14 · How To Use Different Character Attributes
15
16 · How To Justify Strings
17
18 · How To Use Special Drawing Characters
19
20 · Edit/Display Type Codes (EDisplayType)
21
23 Cdk has special formatting commands which can be included in any string
24 which add highlights, justification, or even colors to a basic string.
25 These attributes, once set, remain in effect until changed explicitly,
26 or until the end of the string.
27
28 This manual page outlines and demonstrates how they work.
29
30 How To Use Colors
31 Cdk has the capability to display colors in almost every string type
32 displayed in a Cdk widget.
33
34 Normally the color pairs are accessed via the COLOR_PAIR macro. You
35 can still do this, but creating a string with multiple colors is
36 tedious. That is why the color commands were created. Use initCDK‐
37 Color to create up to 64 color pairs which you can refer to by number
38 in strings.
39
40 The color settings are stored directly in the string. When the widget
41 is created or activated, the string is converted to take advantage of
42 any color commands in the string.
43
44 · To turn on a color pair insert </XX> into the string; where XX is a
45 numeric value from 0 to the maximum color pair.
46
47 Color pair 0 is the standard default color pair for the screen.
48
49 If you used initCDKColor, the maximum value for XX is 63 for termi‐
50 nals supporting 8 ANSI colors.
51
52 If you created color pairs directly using init_pair, the maximum
53 value for XX is implementation-dependent, e.g., 63 (for Unix sys‐
54 tems) and 255 for ncurses.
55
56 If the terminal does not support color, Cdk uses the bold
57 attribute.
58
59 · To turn off a color pair use the format command <!XX> where XX is a
60 numeric value from 0 to the maximum color pair.
61
62 The following example demonstrates the use of the color commands.
63
64 ----------------------------------------
65 #include <cdk/cdk.h>
66
67 void main()
68 {
69 CDKSCREEN *cdkscreen;
70 CDKLABEL *demo;
71 char *mesg[4];
72
73 cdkscreen = initCDKScreen (NULL);
74
75 /* Start CDK Colors */
76 initCDKColor();
77
78 /* Set the labels up. */
79 mesg[0] = "</31>This line should have a yellow foreground and a cyan background.<!31>";
80 mesg[1] = "</05>This line should have a white foreground and a blue background.<!05>";
81 mesg[2] = "</26>This line should have a yellow foreground and a red background.<!26>";
82 mesg[3] = "<C>This line should be set to whatever the screen default is.";
83
84 /* Declare the labels. */
85 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
86
87 /* Draw the label */
88 drawCDKLabel (demo, TRUE);
89 waitCDKLabel (demo, ' ');
90
91 /* Clean up */
92 destroyCDKLabel (demo);
93 destroyCDKScreen (cdkscreen);
94 endCDK();
95 exit (0);
96 }
97 ----------------------------------------
98
99 How To Use Different Character Attributes
100 Cdk also provides attribute commands which allow different character
101 attributes to be displayed in a Cdk widget. To use a character
102 attribute the format command is </X> where X is one of several command
103 characters. To turn a attribute off use the command <!X>. The follow‐
104 ing table outlines the command characters:
105
106 ┌────────────────────────────────────────────────────────┐
107 │Command Character Character Attribute │
108 ├────────────────────────────────────────────────────────┤
109 │B Bold │
110 │U Underline │
111 │K Blink │
112 │R Reverse │
113 │S Standout │
114 │D Dim │
115 │N Normal │
116 └────────────────────────────────────────────────────────┘
117 The following example demonstrates the use of character display
118 attributes.
119
120
121 ----------------------------------------
122 #include <cdk/cdk.h>
123
124 void main()
125 {
126 CDKSCREEN *cdkscreen;
127 CDKLABEL *demo;
128 char *mesg[4];
129
130 cdkscreen = initCDKScreen (NULL);
131
132 /* Start CDK Colors */
133 initCDKColor();
134
135 /* Set the labels up. */
136 mesg[0] = "</B/31>Bold text yellow foreground / blue background.<!31>";
137 mesg[1] = "</U/05>Underlined text white foreground / blue background.<!05>";
138 mesg[2] = "</K/26>Blinking text yellow foreground / red background.<!26>";
139 mesg[3] = "<C>This line uses the screen default colors.";
140
141 /* Declare the labels. */
142 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
143
144 /* Draw the label */
145 drawCDKLabel (demo, TRUE);
146 waitCDKLabel (demo, ' ');
147
148 /* Clean up */
149 destroyCDKLabel (demo);
150 destroyCDKScreen (cdkscreen);
151 endCDK();
152 exit (0);
153 }
154 ----------------------------------------
155
156 Note that color commands and format commands can be mixed inside the
157 same format marker. The above example underlines the label marker,
158 which also sets color pair number 2.
159
160 How To Justify Strings
161 Justification commands can left justify, right justify, or center a
162 string of text. To use a justification format in a string the command
163 <X> is used. The following table lists the format commands:
164
165 ┌─────────────────────────────────────────────────────────┐
166 │Command Action. │
167 ├─────────────────────────────────────────────────────────┤
168 │<L> Left Justified. Default if not stated. │
169 │<C> Centered text. │
170 │<R> Right justified. │
171 │<I=X> Indent the line X characters. │
172 │<B=X> Bullet. X is the bullet string to use. │
173 │<F=X> Links in a file where X is the file‐ │
174 │ name. This works only with the viewer │
175 │ widget. │
176 └─────────────────────────────────────────────────────────┘
177 The following example demonstrates how to use the justification com‐
178 mands in a Cdk widget.
179 ----------------------------------------
180 #include <cdk/cdk.h>
181
182 void main()
183 {
184 CDKSCREEN *cdkscreen;
185 CDKLABEL *demo;
186 char *mesg[5];
187
188 cdkscreen = initCDKScreen (NULL);
189
190 /* Start CDK Colors */
191 initCDKColor();
192
193 /* Set the labels up. */
194 mesg[0] = "<R></B/31>This line should have a yellow foreground and a blue background.<!31>";
195 mesg[1] = "</U/05>This line should have a white foreground and a blue background.<!05>";
196 mesg[2] = "<B=+>This is a bullet.";
197 mesg[3] = "<I=10>This is indented 10 characters.";
198 mesg[4] = "<C>This line should be set to whatever the screen default is.";
199
200 /* Declare the labels. */
201 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 5, TRUE, TRUE);
202
203 /* Draw the label */
204 drawCDKLabel (demo, TRUE);
205 waitCDKLabel (demo, ' ');
206
207 /* Clean up */
208 destroyCDKLabel (demo);
209 destroyCDKScreen (cdkscreen);
210 endCDK();
211 exit (0);
212 }
213 ----------------------------------------
214
215 The bullet format command can take either a single character or a
216 string. The bullet in the above example would look like
217 + This is a bullet.
218 but if we were to use the following command instead
219 <B=***>This is a bullet.
220 it would look like
221 *** This is a bullet.
222
223 A format command must be at the beginning of the string.
224
225 How To Use Special Drawing Characters
226 Cdk has a set of special drawing characters which can be inserted into
227 any ASCII file. These characters are encoded using the format command
228 “<#XX>” where XX is a two-character name. The char2Chtype and
229 chtype2String functions provide conversion to/from curses chtype data
230 (see cdk_util(3)).
231
232 The following table lists the supported special character commands.
233
234 ┌────────────────────────────────────────────────────────┐
235 │Special_Character Character │
236 ├────────────────────────────────────────────────────────┤
237 │<#UL> Upper Left Corner │
238 │<#UR> Upper Right Corner │
239 │<#LL> Lower Left Corner │
240 │<#LR> Lower Right Corner │
241 ├────────────────────────────────────────────────────────┤
242 │<#LT> Left Tee │
243 │<#RT> Right Tee │
244 │<#TT> Top Tee │
245 │<#BT> Bottom Tee │
246 ├────────────────────────────────────────────────────────┤
247 │<#HL> Horizontal Line │
248 │<#VL> Vertical Line │
249 ├────────────────────────────────────────────────────────┤
250 │<#PL> Plus Sign │
251 │<#PM> Plus or Minus Sign │
252 │<#DG> Degree Sign │
253 │<#CB> Checker Board │
254 │<#DI> Diamond │
255 │<#BU> Bullet │
256 │<#S1> Scan line 1 │
257 │<#S9> Scan line 9 │
258 ├────────────────────────────────────────────────────────┤
259 │<#LA> Left Arrow │
260 │<#RA> Right Arrow │
261 │<#TA> Top Arrow │
262 │<#BA> Bottom Arrow │
263 └────────────────────────────────────────────────────────┘
264 The character formats can be repeated using an optional numeric repeat
265 value. To repeat a character add the repeat count within parentheses
266 to the end of the character format. The following example draws 10
267 horizontal-line characters:
268
269 <#HL(10)>
270
271 The following example draws a box within a label window:
272 ----------------------------------------
273 #include <cdk/cdk.h>
274
275 void main()
276 {
277 /* Declare variables. */
278 CDKSCREEN *cdkscreen;
279 CDKLABEL *demo;
280 char *mesg[4];
281
282 cdkscreen = initCDKScreen (NULL);
283
284 /* Start CDK Colors */
285 initCDKColor();
286
287 /* Set the labels up. */
288 mesg[0] = "<C><#UL><#HL(26)><#UR>";
289 mesg[1] = "<C><#VL></R>This text should be boxed.<!R><#VL>";
290 mesg[2] = "<C><#LL><#HL(26)><#LR>";
291 mesg[3] = "<C>While this is not.";
292
293 /* Declare the labels. */
294 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
295
296 /* Is the label NULL??? */
297 if (demo == (CDKLABEL *)NULL)
298 {
299 /* Clean up the memory. */
300 destroyCDKScreen (cdkscreen);
301
302 /* End curses... */
303 endCDK();
304
305 /* Spit out a message. */
306 printf ("Oops. Can't seem to create the label. Is the window too small?\n");
307 exit (1);
308 }
309
310 /* Draw the CDK screen. */
311 refreshCDKScreen (cdkscreen);
312 waitCDKLabel (demo, ' ');
313
314 /* Clean up */
315 destroyCDKLabel (demo);
316 destroyCDKScreen (cdkscreen);
317 endCDK();
318 exit (0);
319 }
320 ----------------------------------------
321
322 Notice that drawn text can also be justified.
323
324 Edit/Display Type Codes (EDisplayType)
325 ┌────────────────────────────────────────────────────────────────┐
326 │Display_Type Result │
327 ├────────────────────────────────────────────────────────────────┤
328 │vCHAR Only accepts alphabetic characters. │
329 │vLCHAR Only accepts alphabetic characters. Maps the │
330 │ character to lower case when a character has │
331 │ been accepted. │
332 │vUCHAR Only accepts alphabetic characters. Maps the │
333 │ character to upper case when a character has │
334 │ been accepted. │
335 │vHCHAR Only accepts alphabetic characters. Displays │
336 │ a period (.) when a character has been │
337 │ accepted. │
338 │vUHCHAR Only accepts alphabetic characters. Displays │
339 │ a period (.) and maps the character to upper │
340 │ case when a character has been accepted. │
341 │vLHCHAR Only accepts alphabetic characters. Displays │
342 │ a period (.) and maps the character to lower │
343 │ case when a character has been accepted. │
344 │vINT Only accepts numeric characters. │
345 │vHINT Only accepts numeric characters. Displays a │
346 │ period (.) when a character has been │
347 │ accepted. │
348 │vMIXED Accepts any character types. │
349 │vLMIXED Accepts any character types. Maps the char‐ │
350 │ acter to lower case when an alphabetic char‐ │
351 │ acter has been accepted. │
352 │vUMIXED Accepts any character types. Maps the char‐ │
353 │ acter to upper case when an alphabetic char‐ │
354 │ acter has been accepted. │
355 │vHMIXED Accepts any character types. Displays a │
356 │ period (.) when a character has been │
357 │ accepted. │
358 │vLHMIXED Accepts any character types. Displays a │
359 │ period (.) and maps the character to lower │
360 │ case when a character has been accepted. │
361 │vUHMIXED Accepts any character types. Displays a │
362 │ period (.) and maps the character to upper │
363 │ case when a character has been accepted. │
364 │vVIEWONLY Uneditable field. │
365 └────────────────────────────────────────────────────────────────┘
367 cdk(3), cdk_binding(3), cdk_screen(3), cdk_util(3)
368
369
370
371 cdk_display(3)