ncurses 6.2 - patch 20200321
[ncurses.git] / test / demo_forms.c
index b0a388e4b895661d2efba6f3fa41d998ca2cbd77..ea0426d0fa00a8dc52c3c2a00eb9e02675fe723c 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2017,2018 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2003-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_forms.c,v 1.55 2018/07/14 23:26:02 tom Exp $
+ * $Id: demo_forms.c,v 1.58 2020/03/21 15:57:59 tom Exp $
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
  */
-/*
-dup_field                      -
-field_init                     -
-field_just                     -
-field_term                     -
-form_init                      -
-form_opts                      -
-form_opts_off                  -
-form_opts_on                   -
-form_request_by_name           -
-form_term                      -
-form_userptr                   -
-free_fieldtype                 -
-link_field                     -
-link_fieldtype                 -
-move_field                     -
-new_page                       -
-pos_form_cursor                        -
-set_field_init                 -
-set_field_term                 -
-set_fieldtype_arg              -
-set_fieldtype_choice           -
-set_form_fields                        -
-set_form_init                  -
-set_form_opts                  -
-set_form_page                  -
-set_form_term                  -
-set_form_userptr               -
-set_max_field                  -
-*/
 
 #include <test.priv.h>
 
@@ -338,9 +309,6 @@ static void
 show_current_field(WINDOW *win, FORM *form)
 {
     FIELD *field;
-    FIELDTYPE *type;
-    char *buffer;
-    int nbuf;
     int field_rows, field_cols, field_max;
     int currow, curcol;
 
@@ -355,7 +323,11 @@ show_current_field(WINDOW *win, FORM *form)
     if (data_behind(form))
        waddstr(win, " behind");
     waddch(win, '\n');
+
     if ((field = current_field(form)) != 0) {
+       FIELDTYPE *type;
+       int nbuf;
+
        wprintw(win, "Page %d%s, Field %d/%d%s:",
                form_page(form),
                new_page(field) ? "*" : "",
@@ -411,6 +383,7 @@ show_current_field(WINDOW *win, FORM *form)
 
        waddstr(win, "\n");
        for (nbuf = 0; nbuf <= 2; ++nbuf) {
+           char *buffer;
            if ((buffer = field_buffer(field, nbuf)) != 0) {
                wprintw(win, "buffer %d:", nbuf);
                (void) wattrset(win, A_REVERSE);
@@ -430,13 +403,11 @@ show_current_field(WINDOW *win, FORM *form)
 static void
 demo_forms(void)
 {
-    WINDOW *w;
     FORM *form;
     FIELD *f[100];             /* will memset to zero */
-    int finished = 0, c;
+    int c;
     unsigned n = 0;
     int pg;
-    WINDOW *also;
     const char *fname;
     static const char *my_enum[] =
     {"first", "second", "third", 0};
@@ -544,6 +515,9 @@ demo_forms(void)
     f[n] = (FIELD *) 0;
 
     if ((form = new_form(f)) != 0) {
+       WINDOW *w;
+       WINDOW *also;
+       int finished = 0;
 
        display_form(form);