diff options
author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1996-01-01 03:45:32 +0000 |
---|---|---|
committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1996-01-01 03:45:32 +0000 |
commit | cd5e85eb474d524f6dd5c9809b8cfd504960a901 (patch) | |
tree | fc308bcf491e4a33c7b438e945a226b6cbecb29a /gnu/lib/libdialog | |
parent | 738c371d22563551af2ff0936fed8e09fa5f8c19 (diff) | |
download | src-cd5e85eb474d524f6dd5c9809b8cfd504960a901.tar.gz src-cd5e85eb474d524f6dd5c9809b8cfd504960a901.zip |
Create individual tests for each dialog feature.
Notes
Notes:
svn path=/head/; revision=13136
Diffstat (limited to 'gnu/lib/libdialog')
-rw-r--r-- | gnu/lib/libdialog/TESTS/Makefile | 66 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/check1.c | 82 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/check2.c | 104 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/check3.c | 91 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/dselect.c | 40 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/fselect.c | 43 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/gauge.c | 40 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/input1.c | 44 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/menu1.c | 116 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/menu2.c | 119 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/menu3.c | 110 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/msg.c | 41 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/prgbox.c | 40 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/radio1.c | 70 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/radio2.c | 88 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/radio3.c | 97 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/test1.c | 330 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/text.c | 40 | ||||
-rw-r--r-- | gnu/lib/libdialog/TESTS/yesno.c | 41 |
19 files changed, 1266 insertions, 336 deletions
diff --git a/gnu/lib/libdialog/TESTS/Makefile b/gnu/lib/libdialog/TESTS/Makefile index 990f4970ab63..49ef6db60a75 100644 --- a/gnu/lib/libdialog/TESTS/Makefile +++ b/gnu/lib/libdialog/TESTS/Makefile @@ -1,11 +1,65 @@ -# Makefile for dialog -# $Id: Makefile,v 1.4 1994/10/28 03:12:45 ache Exp $ +# Really quick and evil Makefile for building all the tests. I wish that bmake was friendlier to +# the concept of multiple progs/libs in the same directory. +# $Id$ -PROG= test1 +PROGS= msg yesno prgbox gauge dselect fselect text menu1 menu2 menu3 \ + input1 check1 check2 check3 radio1 radio2 radio3 CFLAGS+= -Wall -Wstrict-prototypes +LDFLAGS += -ldialog -lncurses -lmytinfo -DPADD+= $(LIBDIALOG) $(LIBNCURSES) $(LIBMYTINFO) -LDADD+= -ldialog -lncurses -lmytinfo +all: ${PROGS} -.include <bsd.prog.mk> +clean: + rm -f ${PROGS} + +msg: msg.c + ${CC} msg.c -o msg ${LDFLAGS} + +yesno: yesno.c + ${CC} yesno.c -o yesno ${LDFLAGS} + +prgbox: prgbox.c + ${CC} prgbox.c -o prgbox ${LDFLAGS} + +gauge: gauge.c + ${CC} gauge.c -o gauge ${LDFLAGS} + +dselect: dselect.c + ${CC} dselect.c -o dselect ${LDFLAGS} + +fselect: fselect.c + ${CC} fselect.c -o fselect ${LDFLAGS} + +text: text.c + ${CC} text.c -o text ${LDFLAGS} + +menu1: menu1.c + ${CC} menu1.c -o menu1 ${LDFLAGS} + +menu2: menu2.c + ${CC} menu2.c -o menu2 ${LDFLAGS} + +menu3: menu3.c + ${CC} menu3.c -o menu3 ${LDFLAGS} + +input1: input1.c + ${CC} input1.c -o input1 ${LDFLAGS} + +check1: check1.c + ${CC} check1.c -o check1 ${LDFLAGS} + +check2: check2.c + ${CC} check2.c -o check2 ${LDFLAGS} + +check3: check3.c + ${CC} check3.c -o check3 ${LDFLAGS} + +radio1: radio1.c + ${CC} radio1.c -o radio1 ${LDFLAGS} + +radio2: radio2.c + ${CC} radio2.c -o radio2 ${LDFLAGS} + +radio3: radio3.c + ${CC} radio3.c -o radio3 ${LDFLAGS} diff --git a/gnu/lib/libdialog/TESTS/check1.c b/gnu/lib/libdialog/TESTS/check1.c new file mode 100644 index 000000000000..4e83014d4f22 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/check1.c @@ -0,0 +1,82 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static int +getBool(dialogMenuItem *self) +{ + if (self->data && *((int *)self->data)) + return TRUE; + return FALSE; +} + +static int +setBool(dialogMenuItem *self) +{ + if (self->data) { + *((int *)self->data) = !*((int *)self->data); + return DITEM_SUCCESS; + } + return DITEM_FAILURE; +} + +static int german_book, italian_book, slang_book; + +static int +clearBooks(dialogMenuItem *self) +{ + german_book = italian_book = slang_book = FALSE; + return DITEM_REDRAW; +} + +/* menu2 - A more advanced way of using checked and fire hooks to manipulate the backing-variables directly */ + /* prompt title checked fire sel data */ +static dialogMenuItem menu2[] = { + { "German", "Buy book on learning German", getBool, setBool, NULL, &german_book}, + { "Italian", "Buy book on learning Italian", getBool, setBool, NULL, &italian_book }, + { "Slang", "Buy book on commonly used insults", getBool, setBool, NULL, &slang_book }, + { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_checklist("this is a dialog_checklist() in action, test #1", + "this checklist menu shows off some of the straight-forward features\n" + "of the new menu system's check & fire dispatch hooks", -1, -1, 4, -4, &menu2, NULL); + dialog_clear(); + fprintf(stderr, "returned value for dialog_checklist was %d (%d %d %d)\n", retval, german_book, italian_book, slang_book); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/check2.c b/gnu/lib/libdialog/TESTS/check2.c new file mode 100644 index 000000000000..c28222a43be5 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/check2.c @@ -0,0 +1,104 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static int +getBool(dialogMenuItem *self) +{ + if (self->data && *((int *)self->data)) + return TRUE; + return FALSE; +} + +static int +setBool(dialogMenuItem *self) +{ + if (self->data) { + *((int *)self->data) = !*((int *)self->data); + return DITEM_SUCCESS; + } + return DITEM_FAILURE; +} + +static int german_book, italian_book, slang_book; + +static int +clearBooks(dialogMenuItem *self) +{ + german_book = italian_book = slang_book = FALSE; + return DITEM_REDRAW; +} + +static int +buyBooks(dialogMenuItem *self) +{ + char foo[256]; + + if (german_book || italian_book || slang_book) { + strcpy(foo, "Ok, you're buying books on"); + if (german_book) + strcat(foo, " german"); + if (italian_book) + strcat(foo, " italian"); + if (slang_book) + strcat(foo, " slang"); + } + else + strcpy(foo, "You're not buying any books?"); + dialog_mesgbox("This is a direct callback for the `Buy' button", foo, -1, -1); + return DITEM_SUCCESS; +} + +/* menu3 - Look mom! We can finally use our own OK and Cancel buttons! */ + /* prompt title checked fire sel data */ +static dialogMenuItem menu3[] = { + { "Buy!", NULL, NULL, buyBooks }, /* New "OK" button */ + { "No Way!", NULL, NULL, NULL }, /* New "Cancel" button */ + { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book }, + { "Italian", "Buy books on learning Italian", getBool, setBool, NULL, &italian_book }, + { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book }, + { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_checklist("this is dialog_checklist() in action, test #2", + "Same as before, but now we relabel the buttons and override the OK action.", + -1, -1, 4, -4, menu3 + 2, (char *)TRUE); + dialog_clear(); + fprintf(stderr, "returned value for dialog_checklist was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/check3.c b/gnu/lib/libdialog/TESTS/check3.c new file mode 100644 index 000000000000..ecd4275d58ee --- /dev/null +++ b/gnu/lib/libdialog/TESTS/check3.c @@ -0,0 +1,91 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id$ + * + */ + +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static int +getBool(dialogMenuItem *self) +{ + if (self->data && *((int *)self->data)) + return TRUE; + return FALSE; +} + +static int +setBool(dialogMenuItem *self) +{ + if (self->data) { + *((int *)self->data) = !*((int *)self->data); + return DITEM_SUCCESS; + } + return DITEM_FAILURE; +} + +static int german_book, italian_book, slang_book; +static int spending; + +static int +check(dialogMenuItem *self) +{ + return ((int)self->data == spending); +} + +static int +spend(dialogMenuItem *self) +{ + spending = (int)self->data; + return DITEM_REDRAW; +} + +/* menu4 - Show off a simulated compound menu (group at top is checklist, group at bottom radio) */ + /* prompt title checked fire sel, data lbra mark rbra */ +static dialogMenuItem menu4[] = { + { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book }, + { "Italian", "Buy books on learning Italian", getBool, setBool, NULL, &italian_book }, + { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book }, + { "-----", "----------------------------------", NULL, NULL, NULL, NULL, ' ', ' ', ' ' }, + { "1000", "Spend $1,000", check, spend, NULL, (void *)1000, '(', '*', ')' }, + { "500", "Spend $500", check, spend, NULL, (void *)500, '(', '*', ')' }, + { "100", "Spend $100", check, spend, NULL, (void *)100, '(', '*', ')' }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + + retval = dialog_checklist("this is dialog_checklist() in action, test #3", + "Now we show off some of the button 'styles' one can create.", + -1, -1, 7, -7, menu4, NULL); + dialog_clear(); + fprintf(stderr, "spent $%d on %s%s%s books\n", spending, german_book ? " german" : "", + italian_book ? " italian" : "", slang_book ? " slang" : ""); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/dselect.c b/gnu/lib/libdialog/TESTS/dselect.c new file mode 100644 index 000000000000..8b673f62bbcc --- /dev/null +++ b/gnu/lib/libdialog/TESTS/dselect.c @@ -0,0 +1,40 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_dselect(".", "*"); + dialog_clear(); + fprintf(stderr, "returned value for dialog_dselect was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/fselect.c b/gnu/lib/libdialog/TESTS/fselect.c new file mode 100644 index 000000000000..d07d726ec856 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/fselect.c @@ -0,0 +1,43 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + char *retval; + + init_dialog(); + + retval = dialog_fselect(".", "*.[ch]"); + dialog_clear(); + if (retval) + fprintf(stderr, "returned value for dialog_fselect was %s\n", retval); + else + fprintf(stderr, "returned value for dialog_fselect was NULL\n"); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/gauge.c b/gnu/lib/libdialog/TESTS/gauge.c new file mode 100644 index 000000000000..fe2dfbf917e9 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/gauge.c @@ -0,0 +1,40 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int i; + + init_dialog(); + + for (i = 0; i < 100; i++) { + dialog_gauge("Gas tank", "When this gets 100% full, you'd better yank out the nozzle!", 10, 1, 7, 70, i); + usleep(30000); + } + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/input1.c b/gnu/lib/libdialog/TESTS/input1.c new file mode 100644 index 000000000000..edb45f583fc9 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/input1.c @@ -0,0 +1,44 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + unsigned char result[128]; + + init_dialog(); + + strcpy(result, "not this!"); + retval = dialog_inputbox("this is dialog_inputbox() in action, test #1", + "Enter something really profound below, please.", + -1, -1, result); + dialog_clear(); + fprintf(stderr, "returned value for dialog_inputbox was %d (%s)\n", retval, result); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/menu1.c b/gnu/lib/libdialog/TESTS/menu1.c new file mode 100644 index 000000000000..2868e321c14d --- /dev/null +++ b/gnu/lib/libdialog/TESTS/menu1.c @@ -0,0 +1,116 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Start of hook functions */ +static enum { nowhere, berlin, rome, ny } where; + +static int +_menu1_berlin_action(dialogMenuItem *self) +{ + WINDOW *w; + int st = DITEM_FAILURE; + + w = dupwin(newscr); + if (where == berlin) { + dialog_mesgbox("excuse me?", "But you're already *in* Berlin!", -1, -1); + } + else { + where = berlin; + dialog_mesgbox("whoosh!", "Welcome to Berlin! Have a beer!", -1, -1); + } + touchwin(w); + wrefresh(w); + delwin(w); + return st; +} + +static int +_menu1_rome_action(dialogMenuItem *self) +{ + WINDOW *w; + int st = DITEM_FAILURE; + + w = dupwin(newscr); + if (where == rome) { + dialog_mesgbox("The wine must be getting to you..", "You're already in Rome!", -1, -1); + } + else { + where = rome; + dialog_mesgbox("whoosh!", "Welcome to Rome! Have a coffee!", -1, -1); + } + touchwin(w); + wrefresh(w); + delwin(w); + return st; +} + +static int +_menu1_ny_action(dialogMenuItem *self) +{ + WINDOW *w; + int st = DITEM_FAILURE; + + w = dupwin(newscr); + if (where == ny) { + dialog_mesgbox("Say what?", "You're already there!", -1, -1); + } + else { + where = ny; + dialog_mesgbox("whoosh!", "Welcome to New York! Now go someplace else!", -1, -1); + } + touchwin(w); + wrefresh(w); + delwin(w); + return st; +} + +/* menu1 - show off the "fire" action hook */ + /* prompt title checked fire */ +static dialogMenuItem menu1[] = { + { "Berlin", "Go visit Germany's new capitol", NULL, _menu1_berlin_action }, + { "Rome", "Go visit the Roman ruins", NULL, _menu1_rome_action }, + { "New York", "Go visit the streets of New York", NULL, _menu1_ny_action }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_menu("this is dialog_menu() in action, test #1", + "this simple menu shows off some of the straight-forward features\n" + "of the new menu system's action dispatch hooks. Select Cancel to leave", + -1, -1, 3, -3, &menu1, NULL, NULL, NULL); + dialog_clear(); + fprintf(stderr, "returned value for dialog_menu was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/menu2.c b/gnu/lib/libdialog/TESTS/menu2.c new file mode 100644 index 000000000000..b4e510b01ec6 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/menu2.c @@ -0,0 +1,119 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Start of hook functions */ +static enum { nowhere, berlin, rome, ny } where; + +static int +_menu1_berlin_action(dialogMenuItem *self) +{ + WINDOW *w; + int st = DITEM_FAILURE; + + w = dupwin(newscr); + if (where == berlin) { + dialog_mesgbox("excuse me?", "But you're already *in* Berlin!", -1, -1); + } + else { + where = berlin; + dialog_mesgbox("whoosh!", "Welcome to Berlin! Have a beer!", -1, -1); + } + touchwin(w); + wrefresh(w); + delwin(w); + return st; +} + +static int +_menu1_rome_action(dialogMenuItem *self) +{ + WINDOW *w; + int st = DITEM_FAILURE; + + w = dupwin(newscr); + if (where == rome) { + dialog_mesgbox("The wine must be getting to you..", "You're already in Rome!", -1, -1); + } + else { + where = rome; + dialog_mesgbox("whoosh!", "Welcome to Rome! Have a coffee!", -1, -1); + } + touchwin(w); + wrefresh(w); + delwin(w); + return st; +} + +static int +_menu1_ny_action(dialogMenuItem *self) +{ + WINDOW *w; + int st = DITEM_FAILURE; + + w = dupwin(newscr); + if (where == ny) { + dialog_mesgbox("Say what?", "You're already there!", -1, -1); + } + else { + where = ny; + dialog_mesgbox("whoosh!", "Welcome to New York! Now go someplace else!", -1, -1); + } + touchwin(w); + wrefresh(w); + delwin(w); + return st; +} + +/* menu1 - show off the "fire" action hook */ + /* prompt title checked fire */ +static dialogMenuItem menu1[] = { + { "Berlin", "Go visit Germany's new capitol", NULL, _menu1_berlin_action }, + { "Rome", "Go visit the Roman ruins", NULL, _menu1_rome_action }, + { "New York", "Go visit the streets of New York", NULL, _menu1_ny_action }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + use_helpfile("menu2.c"); + use_helpline("Type F1 to view the source for this demo"); + retval = dialog_menu("this is dialog_menu() in action, test #2", + "this simple menu shows off some of the straight-forward features\n" + "of the new menu system's action dispatch hooks as well as a helpline\n" + "and a helpfile. Select Cancel to leave", + -1, -1, 3, -3, &menu1, NULL, NULL, NULL); + dialog_clear(); + fprintf(stderr, "returned value for dialog_menu was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/menu3.c b/gnu/lib/libdialog/TESTS/menu3.c new file mode 100644 index 000000000000..66a3e7aff8df --- /dev/null +++ b/gnu/lib/libdialog/TESTS/menu3.c @@ -0,0 +1,110 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static int +stop(dialogMenuItem *self) +{ + dialog_mesgbox("!", "I'm no idiot!", -1, -1); + return DITEM_SUCCESS; +} + +static int +maybe(dialogMenuItem *self) +{ + WINDOW *w; + + w = dupwin(newscr); + dialog_mesgbox("!", "I said don't rush me! I'm THINKING!", -1, -1); + touchwin(w); + wrefresh(w); + delwin(w); + return DITEM_FAILURE; +} + +/* Dummy menu just to show of the ability */ +static char *insurance[] = { + "1,000,000", "Mondo insurance policy", "Off", + "5,000,000", "Mega insurance policy", "Off", + "10,000,000", "Friend! Most Favored customer!" +}; + +static void +preinsure(dialogMenuItem *self, int is_selected) +{ + if (is_selected) { + static WINDOW *w; + + /* This has to be here first if you want to see selection traverse properly in the invoking menu */ + refresh(); + + w = dupwin(newscr); + DialogX = 1; + DialogY = 13; + dialog_radiolist("How much insurance would you like to take out?", + "If you're really going to do this, we recommend some insurance\n" + "first! What kind of life insurance policy would you like?", + -1, -1, 3, 3, insurance, NULL); + touchwin(w); + wrefresh(w); + delwin(w); + } +} + +/* + * Show a simple menu that puts up a sub menu when a certain item is traversed to + */ + + /* prompt title checked fire sel */ +static dialogMenuItem doit[] = { + { "Stop", "No, I'm not going to do that!", NULL, stop, NULL }, + { "Maybe", "I'm still thinking about it, don't rush me!", NULL, maybe, NULL, }, + { "Go", "Yes! Yes! I want to do it!", NULL, NULL, preinsure }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + + DialogX = 5; + DialogY = 1; + retval = dialog_menu("Do you have the GUTS?", + "C'mon, macho man! Do you have what it takes to do something REALLY\n" + "dangerous and stupid? WHAT ARE YOU WAITING FOR?!", + -1, -1, 3, -3, &doit, NULL, NULL, NULL); + dialog_clear(); + fprintf(stderr, "returned value for dialog_menu was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/msg.c b/gnu/lib/libdialog/TESTS/msg.c new file mode 100644 index 000000000000..9c2edc417c9d --- /dev/null +++ b/gnu/lib/libdialog/TESTS/msg.c @@ -0,0 +1,41 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_msgbox("This is dialog_msgbox() in action with pause on", "Hi there. Please press return now.", + -1, -1, 1); + dialog_clear(); + fprintf(stderr, "returned value for dialog_msgbox was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/prgbox.c b/gnu/lib/libdialog/TESTS/prgbox.c new file mode 100644 index 000000000000..6a751c32687d --- /dev/null +++ b/gnu/lib/libdialog/TESTS/prgbox.c @@ -0,0 +1,40 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_prgbox("This is dialog_prgbox() in action with cal(1)", "cal", 14, 50, TRUE, TRUE); + dialog_clear(); + fprintf(stderr, "returned value for dialog_prgbox was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/radio1.c b/gnu/lib/libdialog/TESTS/radio1.c new file mode 100644 index 000000000000..514b26448981 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/radio1.c @@ -0,0 +1,70 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static int spending; + +static int +check(dialogMenuItem *self) +{ + return ((int)self->data == spending); +} + +static int +spend(dialogMenuItem *self) +{ + spending = (int)self->data; + return DITEM_REDRAW; +} + +/* menu5 - Show a simple radiolist menu that inherits the radio appearance by default */ + /* prompt title checked fire sel data */ +static dialogMenuItem menu5[] = { + { "1000", "Spend $1,000", check, spend, NULL, (void *)1000 }, + { "500", "Spend $500", check, spend, NULL, (void *)500 }, + { "100", "Spend $100", check, spend, NULL, (void *)100 }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + + retval = dialog_radiolist("this is dialog_radiolist() in action, test #1", + "this radio menu shows off some of the straight-forward features\n" + "of the new menu system's check & fire dispatch hooks", -1, -1, 3, -3, &menu5, NULL); + dialog_clear(); + fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/radio2.c b/gnu/lib/libdialog/TESTS/radio2.c new file mode 100644 index 000000000000..54d24756124a --- /dev/null +++ b/gnu/lib/libdialog/TESTS/radio2.c @@ -0,0 +1,88 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static char bachelor[10], bachelette[10]; + +static int +getBachelor(dialogMenuItem *self) +{ + return !strcmp(bachelor, self->prompt); +} + +static int +setBachelor(dialogMenuItem *self) +{ + strcpy(bachelor, self->prompt); + return DITEM_REDRAW; +} + +static int +getBachelette(dialogMenuItem *self) +{ + return !strcmp(bachelette, self->prompt); +} + +static int +setBachelette(dialogMenuItem *self) +{ + strcpy(bachelette, self->prompt); + return DITEM_REDRAW; +} + +/* menu6- More complex radiolist menu that creates two groups in a single menu */ + /* prompt title checked fire */ +static dialogMenuItem menu6[] = { + { "Tom", "Tom's a dynamic shoe salesman from Tulsa, OK!", getBachelor, setBachelor }, + { "Dick", "Dick's a retired engine inspector from McDonnell-Douglas!", getBachelor, setBachelor }, + { "Harry", "Harry's a professional female impersonator from Las Vegas!", getBachelor, setBachelor }, + { "-----", "----------------------------------", NULL, NULL, NULL, NULL, ' ', ' ', ' ' }, + { "Jane", "Jane's a twice-divorced housewife from Moose, Oregon!", getBachelette, setBachelette }, + { "Sally", "Sally's a shy Human Resources Manager for IBM!", getBachelette, setBachelette }, + { "Mary", "Mary's an energetic serial killer on the lam!", getBachelette, setBachelette }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_radiolist("this is dialog_radiolist() in action, test #2", + "Welcome to \"The Love Blender!\" - America's favorite game show\n" + "where YOU, the contestant, get to choose which of these two\n" + "fine specimens of humanity will go home together, whether they\n" + "like it or not!", -1, -1, 7, -7, &menu6, NULL); + dialog_clear(); + fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/radio3.c b/gnu/lib/libdialog/TESTS/radio3.c new file mode 100644 index 000000000000..87e889b7fc45 --- /dev/null +++ b/gnu/lib/libdialog/TESTS/radio3.c @@ -0,0 +1,97 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Hook functions */ + +static int spending; + +static int +check(dialogMenuItem *self) +{ + return ((int)self->data == spending); +} + +static int +spend(dialogMenuItem *self) +{ + spending = (int)self->data; + return DITEM_REDRAW; +} + +static void +ask(dialogMenuItem *self, int is_selected) +{ + if (is_selected) { + char *str; + + if (!strcmp(self->prompt, "1000")) + str = "You'd better ask both your parents first! "; + else if (!strcmp(self->prompt, "500")) + str = "You'd better at least ask your Dad! "; + else + str = "Yes, being frugal is probably a good idea!"; + DialogX = 15; + DialogY = 17; + dialog_msgbox("Free Advice", str, -1, -1, 0); + } +} + +/* + * menu5 - Show a simple radiolist menu that inherits the radio appearance by default and appears at + * a different location, leaving room for a msg box below it. This shows off the DialogX/DialogY extensions. + */ + + /* prompt title checked fire sel data */ +static dialogMenuItem menu5[] = { + { "1000", "Spend $1,000", check, spend, ask, (void *)1000 }, + { "500", "Spend $500", check, spend, ask, (void *)500 }, + { "100", "Spend $100", check, spend, ask, (void *)100 }, +}; + +/* End of hook functions */ + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + + DialogX = 5; + DialogY = 1; + retval = dialog_radiolist("this is dialog_radiolist() in action, test #3", + "This radio menu shows off the ability to put dialog menus and other\n" + "controls at different locations, as well as the `selected' hook which\n" + "lets you follow the traversal of the selection bar as well as what's\n" + "selected.", + -1, -1, 3, -3, &menu5, NULL); + dialog_clear(); + fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/test1.c b/gnu/lib/libdialog/TESTS/test1.c deleted file mode 100644 index 3f8eaf6f1f9b..000000000000 --- a/gnu/lib/libdialog/TESTS/test1.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * small test-driver for new dialog functionality - * - * Copyright (c) 1995, Jordan Hubbard - * - * All rights reserved. - * - * This manual page may be used, modified, copied, distributed, and - * sold, in both source and binary form provided that the above - * copyright and these terms are retained, verbatim, as the first - * lines of this file. Under no circumstances is the author - * responsible for the proper functioning of the software described herein - * nor does the author assume any responsibility for damages incurred with - * its use. - * - * $Id: test1.c,v 1.1 1995/12/23 01:10:32 jkh Exp $ - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/wait.h> -#include <dialog.h> - -#define IVAL 0 /* Time so sleep between stages */ - - -/* Private routines and the menu declarations that use them reside in this section */ - -/* Callbacks for menu1 */ -static enum { nowhere, berlin, rome, ny } where; - -static int -_menu1_berlin_action(dialogMenuItem *self) -{ - WINDOW *w; - int st = DITEM_FAILURE; - - w = dupwin(newscr); - if (where == berlin) { - dialog_mesgbox("excuse me?", "But you're already *in* Berlin!", -1, -1); - } - else { - where = berlin; - dialog_mesgbox("whoosh!", "Welcome to Berlin! Have a beer!", -1, -1); - } - touchwin(w); - wrefresh(w); - delwin(w); - return st; -} - -static int -_menu1_rome_action(dialogMenuItem *self) -{ - WINDOW *w; - int st = DITEM_FAILURE; - - w = dupwin(newscr); - if (where == rome) { - dialog_mesgbox("The wine must be getting to you..", "You're already in Rome!", -1, -1); - } - else { - where = rome; - dialog_mesgbox("whoosh!", "Welcome to Rome! Have a coffee!", -1, -1); - } - touchwin(w); - wrefresh(w); - delwin(w); - return st; -} - -static int -_menu1_ny_action(dialogMenuItem *self) -{ - WINDOW *w; - int st = DITEM_FAILURE; - - w = dupwin(newscr); - if (where == ny) { - dialog_mesgbox("Say what?", "You're already there!", -1, -1); - } - else { - where = ny; - dialog_mesgbox("whoosh!", "Welcome to New York! Now go someplace else!", -1, -1); - } - touchwin(w); - wrefresh(w); - delwin(w); - return st; -} - -/* menu1 - show off the "fire" action hook */ -static dialogMenuItem menu1[] = { - { "Berlin", "Go visit Germany's new capitol", NULL, _menu1_berlin_action }, - { "Rome", "Go visit the Roman ruins", NULL, _menu1_rome_action }, - { "New York", "Go visit the streets of New York", NULL, _menu1_ny_action }, -}; - - -/* Callbacks for menu2 */ -static int -getBool(dialogMenuItem *self) -{ - if (self->data && *((int *)self->data)) - return TRUE; - return FALSE; -} - -static int -setBool(dialogMenuItem *self) -{ - if (self->data) { - *((int *)self->data) = !*((int *)self->data); - return DITEM_SUCCESS; - } - return DITEM_FAILURE; -} - -static int german_book, italian_book, slang_book; -static int spending; - -static int -clearBooks(dialogMenuItem *self) -{ - german_book = italian_book = slang_book = FALSE; - return DITEM_REDRAW; -} - -/* menu2 - A more advanced way of using checked and fire hooks to manipulate the backing-variables directly */ -static dialogMenuItem menu2[] = { - { "German", "Buy book on learning German", getBool, setBool, &german_book}, - { "Italian", "Buy book on learning Italian", getBool, setBool, &italian_book }, - { "Slang", "Buy book on commonly used insults", getBool, setBool, &slang_book }, - { "Clear", "Clear book list", NULL, clearBooks, NULL, ' ', ' ', ' ' }, -}; - - -/* Callbacks for menu3 */ -static int -buyBooks(dialogMenuItem *self) -{ - char foo[256]; - - strcpy(foo, "Ok, you're buying books on"); - if (german_book) - strcat(foo, " german"); - if (italian_book) - strcat(foo, " italian"); - if (slang_book) - strcat(foo, " slang"); - dialog_mesgbox("Cash Register", foo, -1, -1); - return DITEM_SUCCESS; -} - -/* menu3 - Look mom! We can finally use our own OK and Cancel buttons! */ -static dialogMenuItem menu3[] = { - { "Buy!", NULL, NULL, buyBooks }, /* This is the new "OK" button with own fire action */ - { "No Way!", NULL, NULL, NULL }, /* This is the new "Cancel" button with defaults */ - { "German", "Buy books on learning German", getBool, setBool, &german_book}, /* Actual items start here */ - { "Italian", "Buy books on learning Italian", getBool, setBool, &italian_book }, - { "Slang", "Buy books on commonly used insults", getBool, setBool, &slang_book }, - { "Clear", "Clear book list", NULL, clearBooks, NULL }, -}; - - -/* Callbacks for menu4 and menu5 */ -static int -check(dialogMenuItem *self) -{ - return ((int)self->data == spending); -} - -static int -spend(dialogMenuItem *self) -{ - spending = (int)self->data; - return DITEM_REDRAW; -} - -/* menu4 - Show off a simulated compound menu (group at top is checklist, group at bottom radio) */ -static dialogMenuItem menu4[] = { - { "German", "Buy books on learning German", getBool, setBool, &german_book}, - { "Italian", "Buy books on learning Italian", getBool, setBool, &italian_book }, - { "Slang", "Buy books on commonly used insults", getBool, setBool, &slang_book }, - { "-----", "----------------------------------", NULL, NULL, NULL, ' ', ' ', ' ' }, - { "1000", "Spend $1,000", check, spend, (void *)1000, '(', '*', ')' }, - { "500", "Spend $500", check, spend, (void *)500, '(', '*', ')' }, - { "100", "Spend $100", check, spend, (void *)100, '(', '*', ')' }, -}; - -/* menu5 - Show a simple radiolist menu that inherits the radio appearance by default */ -static dialogMenuItem menu5[] = { - { "1000", "Spend $1,000", check, spend, (void *)1000 }, - { "500", "Spend $500", check, spend, (void *)500 }, - { "100", "Spend $100", check, spend, (void *)100 }, -}; - - -/* Callbacks for menu6 */ -static char bachelor[10], bachelette[10]; - -static int -getBachelor(dialogMenuItem *self) -{ - return !strcmp(bachelor, self->prompt); -} - -static int -setBachelor(dialogMenuItem *self) -{ - strcpy(bachelor, self->prompt); - return DITEM_REDRAW; -} - -static int -getBachelette(dialogMenuItem *self) -{ - return !strcmp(bachelette, self->prompt); -} - -static int -setBachelette(dialogMenuItem *self) -{ - strcpy(bachelette, self->prompt); - return DITEM_REDRAW; -} - -/* menu6- More complex radiolist menu that creates two groups in a single menu */ -static dialogMenuItem menu6[] = { - { "Tom", "Tom's a dynamic shoe salesman from Tulsa, OK!", getBachelor, setBachelor }, - { "Dick", "Dick's a retired engine inspector from McDonnell-Douglas!", getBachelor, setBachelor }, - { "Harry", "Harry's a professional female impersonator from Las Vegas!", getBachelor, setBachelor }, - { "-----", "----------------------------------", NULL, NULL, NULL, ' ', ' ', ' ' }, - { "Jane", "Jane's a twice-divorced housewife from Moose, Oregon!", getBachelette, setBachelette }, - { "Sally", "Sally's a shy Human Resources Manager for IBM!", getBachelette, setBachelette }, - { "Mary", "Mary's an energetic serial killer on the lam!", getBachelette, setBachelette }, -}; - -/* End of hook functions */ - -/* Kick it off, James! */ -int -main(int argc, unsigned char *argv[]) -{ - int retval; - - init_dialog(); - - /* Do the yes/no first */ - retval = dialog_yesno("This is dialog_yesno() in action", - "Have you stopped deliberately putting bugs into your code?", -1, -1); - dialog_clear(); - fprintf(stderr, "returned value for dialog_yesno was %d\n", retval); - sleep(IVAL); - - retval = dialog_msgbox("This is dialog_msgbox() in action with pause on", "Hi there. Please press return now.", - -1, -1, 1); - dialog_clear(); - fprintf(stderr, "returned value for dialog_msgbox was %d\n", retval); - sleep(IVAL); - - retval = dialog_msgbox("This is dialog_msgbox() in action with pause off", - "It also contains\n" - "a multiple line\n" - "message.", - -1, -1, 0); - dialog_clear(); - fprintf(stderr, "returned value for dialog_msgbox was %d\n", retval); - sleep(IVAL); - - retval = dialog_prgbox("This is dialog_prgbox() in action with cal(1)", "cal", 14, 50, TRUE, TRUE); - dialog_clear(); - fprintf(stderr, "returned value for dialog_prgbox was %d\n", retval); - sleep(IVAL); - - retval = dialog_textbox("This is dialog_textbox() in action with /etc/passwd", "/etc/passwd", 10, 60); - dialog_clear(); - fprintf(stderr, "returned value for dialog_textbox was %d\n", retval); - sleep(IVAL); - - retval = dialog_menu("this is dialog_menu() in action, trial #1", - "this simple menu shows off some of the straight-forward features\n" - "of the new menu system's action dispatch hooks", -1, -1, 3, -3, &menu1, NULL, NULL, NULL); - dialog_clear(); - fprintf(stderr, "returned value for dialog_menu was %d\n", retval); - sleep(IVAL); - - retval = dialog_checklist("this is dialog_checklist() in action, trial #1", - "this checklist menu shows off some of the straight-forward features\n" - "of the new menu system's check & fire dispatch hooks", -1, -1, 4, -4, &menu2, NULL); - dialog_clear(); - fprintf(stderr, "returned value for dialog_checklist was %d (%d %d %d)\n", retval, german_book, italian_book, slang_book); - sleep(IVAL); - - retval = dialog_checklist("this is dialog_checklist() in action, trial #2", - "Same as before, but now we relabel the buttons and override the OK action.", - -1, -1, 4, -4, menu3 + 2, (char *)TRUE); - dialog_clear(); - fprintf(stderr, "returned value for dialog_checklist was %d\n", retval); - sleep(IVAL); - - retval = dialog_checklist("this is dialog_checklist() in action, trial #3", - "Now we show off some of the button 'styles' one can create.", - -1, -1, 7, -7, menu4, NULL); - dialog_clear(); - fprintf(stderr, "spent $%d on %s%s%s books\n", spending, german_book ? " german" : "", - italian_book ? " italian" : "", slang_book ? " slang" : ""); - sleep(IVAL); - - retval = dialog_radiolist("this is dialog_radiolist() in action, trial #1", - "this radio menu shows off some of the straight-forward features\n" - "of the new menu system's check & fire dispatch hooks", -1, -1, 3, -3, &menu5, NULL); - dialog_clear(); - fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending); - sleep(IVAL); - - retval = dialog_radiolist("this is dialog_radiolist() in action, trial #2", - "Welcome to \"The Love Blender!\" - America's favorite game show\n" - "where YOU, the contestant, get to choose which of these two\n" - "fine specimens of humanity will go home together, whether they\n" - "like it or not!", -1, -1, 7, -7, &menu6, NULL); - dialog_clear(); - fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette); - sleep(IVAL); - - end_dialog(); - return 0; -} diff --git a/gnu/lib/libdialog/TESTS/text.c b/gnu/lib/libdialog/TESTS/text.c new file mode 100644 index 000000000000..f63b5334b21d --- /dev/null +++ b/gnu/lib/libdialog/TESTS/text.c @@ -0,0 +1,40 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_textbox("This is dialog_textbox() in action with /etc/passwd", "/etc/passwd", 10, 60); + dialog_clear(); + fprintf(stderr, "returned value for dialog_textbox was %d\n", retval); + + end_dialog(); + return 0; +} diff --git a/gnu/lib/libdialog/TESTS/yesno.c b/gnu/lib/libdialog/TESTS/yesno.c new file mode 100644 index 000000000000..841451a8c06f --- /dev/null +++ b/gnu/lib/libdialog/TESTS/yesno.c @@ -0,0 +1,41 @@ +/* + * small test-driver for new dialog functionality + * + * Copyright (c) 1995, Jordan Hubbard + * + * All rights reserved. + * + * This source code may be used, modified, copied, distributed, and + * sold, in both source and binary form provided that the above + * copyright and these terms are retained, verbatim, as the first + * lines of this file. Under no circumstances is the author + * responsible for the proper functioning of the software nor does + * the author assume any responsibility for damages incurred with + * its use. + * + * $Id: test1.c,v 1.2 1995/12/23 14:53:07 jkh Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <dialog.h> + +/* Kick it off, James! */ +int +main(int argc, unsigned char *argv[]) +{ + int retval; + + init_dialog(); + + retval = dialog_yesno("This is dialog_yesno() in action", + "Have you stopped deliberately putting bugs into your code?", -1, -1); + dialog_clear(); + fprintf(stderr, "returned value for dialog_yesno was %d\n", retval); + + end_dialog(); + return 0; +} |