diff options
| author | Paul Richards <paul@FreeBSD.org> | 1995-05-12 17:20:06 +0000 | 
|---|---|---|
| committer | Paul Richards <paul@FreeBSD.org> | 1995-05-12 17:20:06 +0000 | 
| commit | 89e255f52c667a49e05cd8f4b135bb3f6c9b2df1 (patch) | |
| tree | 6558dacc67a647a255afdab138d04182dc651b44 /lib/libforms/examples/example.c | |
| parent | 97f3a7e6e7b2315a17055166bc138340d6f70017 (diff) | |
Notes
Diffstat (limited to 'lib/libforms/examples/example.c')
| -rw-r--r-- | lib/libforms/examples/example.c | 62 | 
1 files changed, 12 insertions, 50 deletions
| diff --git a/lib/libforms/examples/example.c b/lib/libforms/examples/example.c index 39c4432e15856..b08a4ea6e1f35 100644 --- a/lib/libforms/examples/example.c +++ b/lib/libforms/examples/example.c @@ -33,66 +33,28 @@   */  #include <stdio.h>  #include <strhash.h> +#include <ncurses.h>  #include "../forms.h" -extern hash_table *global_bindings; +void UserRoutine(OBJECT *);  main()  {  	struct Tuple *tuple; -	struct Form *form; +	struct Form *form1, *form2;  	int res; -	initscr(); - - -	if (form_load("example.frm") == FS_ERROR) -		exit(0);; - -	form = form_start("example"); - -	if (!form) { -		err(-1, "No form `example' in example.frm returned"); +	if (load_objects("example.frm") == ST_ERROR)  		exit(0); -	} - -	keypad(form->window, TRUE); -	cbreak(); -	noecho(); - -	tuple = form_get_tuple(global_bindings, "example", FT_FORM); -	if (!tuple) -		err(0, "No such form: example"); -	else -		form = (struct Form *)tuple->addr; -	print_status("This is the status line"); +	bind_tuple(root_table, "User_Routine", TT_FUNC, &UserRoutine); -	form_bind_tuple(form->bindings, "exit_form", FT_FUNC, &exit_form); -	form_bind_tuple(form->bindings, "cancel_form", FT_FUNC, &cancel_form); - -	res = form_show("example"); - -	while (form->status == FS_RUNNING) { -		do_field(form); -		wrefresh(form->window); -	} - -	wclear(form->window); -	wrefresh(form->window); - -	if  (form->status == FS_EXIT) { -		printf("Your entries were:\n\n"); -		tuple = form_get_tuple(form->bindings, "input1", FT_FIELD_INST); -		printf("Input 1 = %s\n", ((struct Field *)tuple->addr)->field.input->input); -		tuple = form_get_tuple(form->bindings, "input2", FT_FIELD_INST); -		printf("Input 2 = %s\n", ((struct Field *)tuple->addr)->field.input->input); -		tuple = form_get_tuple(form->bindings, "menu1", FT_FIELD_INST); -		res = ((struct Field *)tuple->addr)->field.menu->selected; -		printf("Menu selected = %d, %s\n", res, -			 ((struct Field *)tuple->addr)->field.menu->options[res]); -	} else if (form->status == FS_CANCEL) -		printf("You cancelled the form\n"); +	start_object("adduser"); +} -	endwin(); +void +UserRoutine(OBJECT *obj) +{ +	/* Just draw a box and return */ +	exit (1);  } | 
