+static FIELD **
+copy_fields(FIELD **source, FIELD *extra, size_t length)
+{
+ FIELD **target = typeCalloc(FIELD *, length + 1);
+ memcpy(target, source, length * sizeof(FIELD *));
+ target[length] = extra;
+ return target;
+}
+
+static void
+do_demo(FORM *form)
+{
+ int count = field_count(form);
+ FIELD *my_field = current_field(form);
+ FIELD **old_fields = form_fields(form);
+
+ if (count > 0 && old_fields != NULL && my_field != NULL) {
+ FIELD **new_fields = copy_fields(old_fields,
+ dup_field(my_field,
+ form_field_row(my_field)
+ + 1,
+ form_field_col(my_field)),
+ (size_t) count);
+ if (new_fields != NULL)
+ set_form_fields(form, new_fields);
+ }
+}
+
+static int
+my_form_driver(FORM *form, int c)
+{
+ switch (c) {
+ case MY_QUIT:
+ if (form_driver(form, REQ_VALIDATION) == E_OK)
+ return (TRUE);
+ break;
+ case MY_HELP:
+ my_help_edit_field();
+ break;
+ case MY_DEMO:
+ do_demo(form);
+ break;
+ default:
+ beep();
+ break;
+ }
+ return (FALSE);
+}
+