summaryrefslogtreecommitdiffstats
path: root/lib/libforms/examples/example.c
diff options
context:
space:
mode:
authorpaul <paul@FreeBSD.org>1995-05-12 17:20:06 +0000
committerpaul <paul@FreeBSD.org>1995-05-12 17:20:06 +0000
commit65e32573aa7d24409456153f596c431cc62fd970 (patch)
tree6558dacc67a647a255afdab138d04182dc651b44 /lib/libforms/examples/example.c
parent8c0e89af78b6c3f0d502b8ea4e44085b6c336102 (diff)
downloadFreeBSD-src-65e32573aa7d24409456153f596c431cc62fd970.zip
FreeBSD-src-65e32573aa7d24409456153f596c431cc62fd970.tar.gz
New libforms.
Bumped major number. Ncurses backend still needs improving. Other back-ends need to be written.
Diffstat (limited to 'lib/libforms/examples/example.c')
-rw-r--r--lib/libforms/examples/example.c62
1 files changed, 12 insertions, 50 deletions
diff --git a/lib/libforms/examples/example.c b/lib/libforms/examples/example.c
index 39c4432..b08a4ea 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);
}
OpenPOWER on IntegriCloud