diff options
author | paul <paul@FreeBSD.org> | 1995-03-26 07:44:33 +0000 |
---|---|---|
committer | paul <paul@FreeBSD.org> | 1995-03-26 07:44:33 +0000 |
commit | e0abbde8cf65bc85c00329f124c29ebadabca1a4 (patch) | |
tree | 74529f2af39672789431bf89b4541f799c86b669 /lib/libforms/examples/example.c | |
parent | 91aac05da2413bf79364520453818b2c52f8650e (diff) | |
download | FreeBSD-src-e0abbde8cf65bc85c00329f124c29ebadabca1a4.zip FreeBSD-src-e0abbde8cf65bc85c00329f124c29ebadabca1a4.tar.gz |
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.
Diffstat (limited to 'lib/libforms/examples/example.c')
-rw-r--r-- | lib/libforms/examples/example.c | 16 |
1 files changed, 10 insertions, 6 deletions
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 <stdio.h> +#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]); |