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