File: mentry_ex.c

package info (click to toggle)
libcdk 4.9.9-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,876 kB
  • ctags: 2,249
  • sloc: ansic: 28,664; sh: 6,966; makefile: 211; cpp: 42
file content (62 lines) | stat: -rw-r--r-- 1,513 bytes parent folder | download | duplicates (2)
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
#include "cdk.h"

#ifdef HAVE_XCURSES
char *XCursesProgramName="mentry_ex";
#endif

int main (int argc, char **argv)
{
   /* Declare variables. */
   CDKSCREEN *cdkscreen	= (CDKSCREEN *)NULL;
   CDKMENTRY *filename	= (CDKMENTRY *)NULL;
   WINDOW *cursesWin	= (WINDOW *)NULL;
   char *info		= (char *)NULL;
   char *label		= "</R>Message";
   char *title		= "<C></5>Enter a message.<!5>";

   /* Set up CDK. */ 
   cursesWin = initscr();
   cdkscreen = initCDKScreen (cursesWin);

   /* Start CDK Colors.*/
   initCDKColor();

   /* Set up the multi-line entry field. */
   filename	= newCDKMentry (cdkscreen, CENTER, CENTER,
			title, label, A_BOLD, '.', vMIXED,
			20, 5, 20, 0, TRUE, FALSE);

   /* Is the object NULL? */
   if (filename == (CDKMENTRY *)NULL)
   {
      /* Shut down CDK. */
      destroyCDKScreen (cdkscreen);
      endCDK();

      /* Print out a message. */
      printf ("Oops. Can not create CDK object. Is the window too small?\n");
      exit (1);
   }

   /* Draw the CDK screen. */
   refreshCDKScreen (cdkscreen);

   /* Set what ever was given from the command line. */
   setCDKMentry (filename, argv[1], 0, TRUE);

   /* Activate this thing. */
   activateCDKMentry (filename, (chtype *)NULL);
   info	= strdup (filename->info);

   /* Clean up.	*/
   destroyCDKMentry (filename);
   destroyCDKScreen (cdkscreen);
   delwin (cursesWin);
   endCDK();

   /* Spit out the results. */
   printf ("\n\n\n");
   printf ("Your message was : <%s>\n", info);
   free(info);
   exit (0);
}