From e0abbde8cf65bc85c00329f124c29ebadabca1a4 Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 26 Mar 1995 07:44:33 +0000 Subject: Use a hash table to hold all the bindings info rather than a linked list. Forms now have their own local bindings table so that anything declared within a form is local to that form. This means you can have fields of the same name in different forms. Added inlined attribute setting for strings e.g. "This is \bold bold" Added entry and exit functions for fields. --- lib/libforms/examples/example.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/libforms/examples/example.c') diff --git a/lib/libforms/examples/example.c b/lib/libforms/examples/example.c index f2dad1c..447d846 100644 --- a/lib/libforms/examples/example.c +++ b/lib/libforms/examples/example.c @@ -32,8 +32,11 @@ * */ #include +#include "../hash.h" #include "../forms.h" +extern hash_table *global_bindings; + main() { struct Tuple *tuple; @@ -42,8 +45,6 @@ main() initscr(); - form_bind_tuple("exit_form", FT_FUNC, &exit_form); - form_bind_tuple("cancel_form", FT_FUNC, &cancel_form); if (form_load("example.frm") == FS_ERROR) exit(0);; @@ -59,7 +60,7 @@ main() cbreak(); noecho(); - tuple = form_get_tuple("example", FT_FORM); + tuple = form_get_tuple(global_bindings, "example", FT_FORM); if (!tuple) err(0, "No such form"); else @@ -67,6 +68,9 @@ main() print_status("This is the status line"); + 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) { @@ -79,11 +83,11 @@ main() if (form->status == FS_EXIT) { printf("You're entries were:\n\n"); - tuple = form_get_tuple("input1", FT_FIELD_INST); + 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("input2", FT_FIELD_INST); + 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("menu1", FT_FIELD_INST); + 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]); -- cgit v1.1