File: mentry_ex2.c

package info (click to toggle)
libcdk5 5.0.20260119-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,552 kB
  • sloc: ansic: 32,727; sh: 5,317; makefile: 1,205; awk: 55; sed: 49; cpp: 41
file content (80 lines) | stat: -rw-r--r-- 1,895 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* $Id: mentry_ex2.c,v 1.3 2025/01/09 00:20:21 tom Exp $ */

#include <cdk_test.h>

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

int main (int argc, char **argv)
{
   /* *INDENT-EQLS* */
   CDKSCREEN *cdkscreen = NULL;
   CDKMENTRY *widget    = NULL;
   char *info           = NULL;
   const char *label    = "</R>Message";
   const char *title    =
   "<C></5>Enter a message (\".\" to exit).<!5>\n"
   "<C>It can be </3>multi<!3>-line!";
   int boxWidth;

   CDK_PARAMS params;

   CDKparseParams (argc, argv, &params, "w:h:l:" CDK_MIN_PARAMS);

   cdkscreen = initCDKScreen (NULL);

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

   /* Set up the multi-line entry field. */
   boxWidth = CDKparamValue (&params, 'w', 40);
   widget = newCDKMentry (cdkscreen,
			  CDKparamValue (&params, 'X', CENTER),
			  CDKparamValue (&params, 'Y', CENTER),
			  title, label, A_BOLD, '.', vMIXED,
			  boxWidth,
			  CDKparamValue (&params, 'h', 5),
			  CDKparamValue (&params, 'l', 20),
			  0,
			  CDKparamValue (&params, 'N', TRUE),
			  CDKparamValue (&params, 'S', FALSE));

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

      printf ("Cannot create CDK object. Is the window too small?\n");
      ExitProgram (EXIT_FAILURE);
   }

   refreshCDKScreen (cdkscreen);

   for (;;)
   {
      info = getCdkTitle (ObjOf (widget));
      setCDKMentry (widget, info, 0, TRUE);
      free (info);

      activateCDKMentry (widget, NULL);
      if (strlen (widget->info) > 1)
      {
	 setCdkTitle (ObjOf (widget), widget->info, getmaxx (widget->win));
	 eraseCDKScreen (ScreenOf (widget));
	 drawCDKScreen (ScreenOf (widget));
      }
      else
      {
	 break;
      }
   }

   destroyCDKMentry (widget);
   destroyCDKScreen (cdkscreen);
   endCDK ();

   ExitProgram (EXIT_SUCCESS);
}