C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
form.h File Reference

Form data structures, enums, types, end process declarations. More...

#include <cm.h>
Include dependency graph for form.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Text
 structure for form fields More...
struct  Field
 structure for form fields More...
struct  Form

Macros

#define FIELD_MAXLEN   1024
#define FIELD_MAXCNT   100
#define F_NOMETAS   1
#define F_NOTBLANK   2
#define F_NOECHO   4

Typedefs

typedef struct Init Init

Enumerations

enum  {
  P_CONTINUE , P_ACCEPT , P_HELP , P_CANCEL ,
  P_REFUSE , P_CALC , P_EDIT , P_END
}
enum  FieldFormat {
  FF_STRING , FF_DECIMAL_INT , FF_HEX_INT , FF_FLOAT ,
  FF_DOUBLE , FF_CURRENCY , FF_YYYYMMDD , FF_HHMMSS ,
  FF_APR , FF_INVALID
}

Functions

int field_editor (Form *)
 Accept input for a field.
int form_display_field (Form *)
 Display current field.
int form_display_field_n (Form *, int)
 Display field n.
int field_navigator (Form *)
 Handle user input for field entry, allowing navigation between fields and looping until an exit action is selected.
int form_read_description (Form *)
int form_fmt_field (Form *, char *s)
 Format field according to its format type.
int form_desc_error (int, char *, char *)
 Handle errors encountered while parsing the form description file, providing detailed error messages that include the file name, line number, and the specific error encountered.
void form_help (char *)
int form_yx_to_fidx (Form *, int, int)
void form_display_chyron (Form *)

Variables

char ff_tbl [][26]
Formform

Detailed Description

Form data structures, enums, types, end process declarations.

Author
Bill Waller Copyright (c) 2025 MIT License billx.nosp@m.wall.nosp@m.er@gm.nosp@m.ail..nosp@m.com
Date
2026-02-09

Definition in file form.h.

Macro Definition Documentation

◆ F_NOECHO

#define F_NOECHO   4

flag - do not echo field input on the screen, e.g. for password \ fields

Definition at line 22 of file form.h.

22#define F_NOECHO \
23 4

◆ F_NOMETAS

#define F_NOMETAS   1

flag - no metacharacters allowed in field input

Definition at line 20 of file form.h.

◆ F_NOTBLANK

#define F_NOTBLANK   2

flag - field input cannot be blank

Definition at line 21 of file form.h.

◆ FIELD_MAXCNT

#define FIELD_MAXCNT   100

Definition at line 19 of file form.h.

◆ FIELD_MAXLEN

#define FIELD_MAXLEN   1024

Definition at line 18 of file form.h.

Typedef Documentation

◆ Init

typedef struct Init Init

Definition at line 15 of file form.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Form process types

Enumerator
P_CONTINUE 

continue processing the form, e.g. after accepting a field

P_ACCEPT 

accept the form, e.g. after accepting a field and all fields are valid

P_HELP 

display the help information for the form, e.g. after accepting a field and the user requests help

P_CANCEL 

cancel the form, e.g. after accepting a field and the user cancels the form

P_REFUSE 

refuse the form, e.g. after accepting a field and the field value is invalid

P_CALC 

process the form, e.g. after accepting a field and calculating the values of other fields based on the accepted field value

P_EDIT 

edit the form, e.g. after accepting a field and allowing the user to edit the form fields

P_END 

end the form processing, e.g. after accepting a field and all fields are valid and the form is accepted

Definition at line 27 of file form.h.

30 P_ACCEPT,
32 P_HELP,
34 P_CANCEL,
36 P_REFUSE,
38 P_CALC,
41 P_EDIT,
43 P_END
45};
@ P_HELP
Definition form.h:32
@ P_CALC
Definition form.h:38
@ P_CONTINUE
Definition form.h:28
@ P_END
Definition form.h:43
@ P_ACCEPT
Definition form.h:30
@ P_CANCEL
Definition form.h:34
@ P_EDIT
Definition form.h:41
@ P_REFUSE
Definition form.h:36

◆ FieldFormat

Form field formats

Enumerator
FF_STRING 

a string field format, e.g. for accepting a name or other text input

FF_DECIMAL_INT 

a decimal integer field format, e.g. for accepting an age or other numeric input

FF_HEX_INT 

a hexadecimal integer field format, e.g. for accepting a color code or other hexadecimal input

FF_FLOAT 

a floating point field format, e.g. for accepting a price or other decimal input

FF_DOUBLE 

a double precision floating point field format, e.g. for accepting a more precise decimal input

FF_CURRENCY 

a currency field format, e.g. for accepting a price or other monetary input, formatted as a decimal number with two decimal places and a currency symbol

FF_YYYYMMDD 

a date field format, e.g. for accepting a date input, formatted as a string in the format "YYYY-MM-DD"

FF_HHMMSS 

a time field format, e.g. for accepting a time input, formatted as a string in the format "HH:MM:SS"

FF_APR 

an APR field format, e.g. for accepting an annual percentage rate input, formatted as a decimal number with two decimal places and a percent symbol

FF_INVALID 

an invalid field format, used for error handling and validation purposes Future Implementation of Additional Field Formats FF_EMAIL - an email field format, e.g. for accepting an email address input, formatted as a string that matches a regular expression for valid email addresses FF_PHONE - a phone number field format, e.g. for accepting a phone number input, formatted as a string that matches a regular expression for valid phone numbers FF_URL - a URL field format, e.g. for accepting a URL input, formatted as a string that matches a regular expression for valid

Definition at line 48 of file form.h.

48 {
49 FF_STRING,
55 FF_FLOAT,
57 FF_DOUBLE,
64 FF_HHMMSS,
66 FF_APR,
81};
@ FF_DECIMAL_INT
Definition form.h:51
@ FF_STRING
Definition form.h:49
@ FF_HEX_INT
Definition form.h:53
@ FF_YYYYMMDD
Definition form.h:62
@ FF_HHMMSS
Definition form.h:64
@ FF_CURRENCY
Definition form.h:59
@ FF_FLOAT
Definition form.h:55
@ FF_INVALID
Definition form.h:69
@ FF_DOUBLE
Definition form.h:57
@ FF_APR
Definition form.h:66

Function Documentation

◆ form_display_chyron()

void form_display_chyron ( Form * )
extern

◆ form_help()

void form_help ( char * )
extern

◆ form_read_description()

int form_read_description ( Form * )
extern

◆ form_yx_to_fidx()

int form_yx_to_fidx ( Form * form,
int y,
int x )
extern

Definition at line 444 of file form_engine.c.

444 {
445 for (int i = 0; i < form->fcnt; i++) {
446 if (y == form->field[i]->line && x >= form->field[i]->col &&
447 x < form->field[i]->col + form->field[i]->len) {
448 return i;
449 }
450 }
451 return -1; // No field found at the given coordinates
452}
Form * form
Definition mem.c:47

References Field::col, Form::fcnt, Form::field, Field::len, and Field::line.

Referenced by field_editor().

Here is the caller graph for this function:

Variable Documentation

◆ ff_tbl

char ff_tbl[][26]
extern

ff_tbl - a table of field format strings used in the Form description file to identify field data types the index of the field format in this table corresponds to the FieldFormat enum values, e.g. ff_tbl[FF_STRING] = "string", ff_tbl[F_DECIMAL_INT] = "decimal_int", etc. a table of field format strings used in the Form description file to identify field data types, e.g. "string", "decimal_int", "hex_int", etc. The index of the field format in this table corresponds to the FieldFormat enum values, e.g. ff_tbl[FF_STRING] = "string", ff_tbl[FF_DECIMAL_INT] = "decimal_int", etc. This table is used for parsing the form description file and determining the field formats for each field in the form.

Definition at line 40 of file fields.c.

40 {"string", "decimal_int", "hex_int", "float", "double",
41 "currency", "yyyymmdd", "hhmmss", "apr", ""};

Referenced by form_parse_desc().

◆ form

Form* form
extern

a pointer to the current form structure, used for managing and processing the form during form processing. This pointer can be updated to point to different form structures as needed, allowing for dynamic handling of multiple forms within the same application or session. The form pointer provides access to all the properties and data of the current form, enabling efficient management and processing of the form fields and text during user interactions and other events during form processing.

Definition at line 47 of file mem.c.

Referenced by form_desc_error(), form_display_screen(), form_engine(), form_post(), form_process(), init_form(), init_form_files(), mk_filler(), and new_form().