NetBSD/dist/cdk/examples/mentry_ex.c
garbled 5940edcfb4 Initial import of CDK 4.9.9. The work to port this was performed by
Charles Hannum, and that is the version being imported:
cdk-4.9.9-20000407-myc3
2001-01-04 19:57:58 +00:00

74 lines
1.6 KiB
C

#include <cdk.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName="mentry_ex";
#endif
int main (int argc GCC_UNUSED, char **argv)
{
/* Declare variables. */
CDKSCREEN *cdkscreen = 0;
CDKMENTRY *filename = 0;
WINDOW *cursesWin = 0;
char *info = 0;
char *label = "</R>Message";
char *title = "<C></5>Enter a message.<!5>";
int exitType;
/* 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, TRUE);
/* Is the object null? */
if (filename == 0)
{
/* 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, 0);
exitType = filename->exitType;
if (exitType == vNORMAL)
{
info = copyChar (filename->info);
}
/* Clean up. */
destroyCDKMentry (filename);
destroyCDKScreen (cdkscreen);
delwin (cursesWin);
endCDK();
/* Spit out the results. */
if (exitType == vESCAPE_HIT)
{
printf ("You pressed escape.\n");
}
else if (exitType == vNORMAL)
{
printf ("Your message was: <%s>\n", info);
}
free(info);
exit (0);
}