/****************************************************************************
- * Copyright (c) 2003-2018,2019 Free Software Foundation, Inc. *
+ * Copyright 2018-2022,2023 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.56 2019/08/17 21:49:19 tom Exp $
+ * $Id: demo_forms.c,v 1.63 2023/11/11 00:29:53 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>
if (f) {
set_field_buffer(f, 0, label);
- set_field_opts(f, (int) ((unsigned) field_opts(f) & ~O_ACTIVE));
+ set_field_opts(f, (int) ((unsigned) field_opts(f) & (unsigned) ~O_ACTIVE));
}
return (f);
}
#define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
static FIELD *
-another_field(FORM *form, FIELD *field)
+another_field(FORM *form, const FIELD *const field)
{
FIELD **f = form_fields(form);
FIELD *result = 0;
}
static void
-usage(void)
+usage(int ok)
{
static const char *tbl[] =
{
"Usage: demo_forms [options] [data file]"
,""
- ," -d make fields dynamic"
- ," -j value justify (1=left, 2=center, 3=right)"
- ," -m value set maximum size of dynamic fields"
- ," -o value specify number of offscreen rows in new_field()"
- ," -t value specify text to fill fields initially"
+ ,USAGE_COMMON
+ ,"Options:"
+ ," -d make fields dynamic"
+ ," -j NUM justify (1=left, 2=center, 3=right)"
+ ," -m NUM set maximum size of dynamic fields"
+ ," -o NUM specify number of offscreen rows in new_field()"
+ ," -t NUM specify text to fill fields initially"
};
unsigned int j;
for (j = 0; j < SIZEOF(tbl); ++j)
fprintf(stderr, "%s\n", tbl[j]);
- exit(EXIT_FAILURE);
+ ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
int
main(int argc, char *argv[])
setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, "dj:m:o:t:")) != -1) {
+ while ((ch = getopt(argc, argv, OPTS_COMMON "dj:m:o:t:")) != -1) {
switch (ch) {
case 'd':
d_option = TRUE;
j_value = atoi(optarg);
if (j_value < NO_JUSTIFICATION
|| j_value > JUSTIFY_RIGHT)
- usage();
+ usage(FALSE);
break;
case 'm':
m_value = atoi(optarg);
case 't':
t_value = optarg;
break;
+ case OPTS_VERSION:
+ show_version(argv);
+ ExitProgram(EXIT_SUCCESS);
default:
- usage();
-
+ usage(ch == OPTS_USAGE);
+ /* NOTREACHED */
}
}
while (optind < argc) {