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

NAME

6       cdk_display - Curses Development Kit Display Capabilities.
7

SYNOPSIS

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

DESCRIPTION

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

SEE ALSO

362       cdk(3), cdk_binding(3), cdk_screen(3)
363
364
365
366                                                                cdk_display(3)
Impressum