From 62773adf71f81f85a396213412e55bec1f9c7186 Mon Sep 17 00:00:00 2001 From: Paul Richards 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 ++++++++++------ lib/libforms/examples/example.frm | 9 +++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'lib/libforms/examples') diff --git a/lib/libforms/examples/example.c b/lib/libforms/examples/example.c index f2dad1c9a6a7..447d8468cb1b 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]); diff --git a/lib/libforms/examples/example.frm b/lib/libforms/examples/example.frm index d1f5349237bd..f28b2c65b2c5 100644 --- a/lib/libforms/examples/example.frm +++ b/lib/libforms/examples/example.frm @@ -1,9 +1,14 @@ -field1 { attributes = 0 text = "This text is bold and flashy" } +Colours example_colors { + pair = red, yellow + pair = blue, white +} + +field1 { attributes = 0 text = "\standout This text is \bold bold and \blink flashy" } field2 { height = 2 width = 22 - text = "This is an input field with a default" + text = "This is an input fieldwith a default" } field3 { -- cgit v1.3