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  Field
 structure for form fields More...
struct  Form
struct  Text
 structure for form fields More...

Macros

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

Typedefs

typedef struct Init Init

Enumerations

enum  FieldFormat {
  FF_STRING , FF_DECIMAL_INT , FF_HEX_INT , FF_FLOAT ,
  FF_DOUBLE , FF_CURRENCY , FF_YYYYMMDD , FF_HHMMSS ,
  FF_APR , FF_INVALID
}
enum  FormAction {
  FA_CONTINUE , FA_ACCEPT , FA_HELP , FA_CANCEL ,
  FA_REFUSE , FA_CALC , FA_EDIT , FA_END
}

Functions

void display_field (Form *, cchar_t *, int, int)
int field_editor (Form *)
 Accept input for a field.
int field_navigator (Form *)
 Handle user input for field entry, allowing navigation between fields and looping until an exit action is selected.
int form_desc_error (Form *, 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_display_chyron (Form *)
int form_display_field (Form *)
 Display current field.
int form_display_field_n (Form *, int)
 Display field n.
int form_fmt_field (Form *, char *s)
 Format field according to its format type.
void form_help (char *)
int form_read_description (Form *)
int form_yx_to_fidx (Form *, int, int)

Variables

char ff_tbl [][26]

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.

◆ 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

◆ 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 47 of file form.h.

47 {
48 FF_STRING,
54 FF_FLOAT,
56 FF_DOUBLE,
63 FF_HHMMSS,
65 FF_APR,
FieldFormat
Definition form.h:47
@ FF_DECIMAL_INT
Definition form.h:50
@ FF_STRING
Definition form.h:48
@ FF_HEX_INT
Definition form.h:52
@ FF_YYYYMMDD
Definition form.h:61
@ FF_HHMMSS
Definition form.h:63
@ FF_CURRENCY
Definition form.h:58
@ FF_FLOAT
Definition form.h:54
@ FF_INVALID
Definition form.h:68
@ FF_DOUBLE
Definition form.h:56
@ FF_APR
Definition form.h:65

◆ FormAction

enum FormAction

FormAction Directives

Enumerator
FA_CONTINUE 

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

FA_ACCEPT 

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

FA_HELP 

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

FA_CANCEL 

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

FA_REFUSE 

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

FA_CALC 

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

FA_EDIT 

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

FA_END 

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

Definition at line 26 of file form.h.

26 {
28 302,
29 FA_ACCEPT,
31 FA_HELP,
33 FA_CANCEL,
35 FA_REFUSE,
37 FA_CALC,
40 FA_EDIT,
42 FA_END
FormAction
Definition form.h:26
@ FA_END
Definition form.h:42
@ FA_ACCEPT
Definition form.h:29
@ FA_EDIT
Definition form.h:40
@ FA_CALC
Definition form.h:37
@ FA_HELP
Definition form.h:31
@ FA_REFUSE
Definition form.h:35
@ FA_CANCEL
Definition form.h:33
@ FA_CONTINUE
Definition form.h:27

Function Documentation

◆ display_field()

void display_field ( Form * ,
cchar_t * ,
int ,
int  )
extern

Definition at line 369 of file fields.c.

369 {
370
371 mvwadd_wchstr(form->win, y, x, cmplx_buf);
372}
Form * form
Definition mem.c:48

References Form::win.

◆ 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 509 of file form_engine.c.

509 {
510 for (int i = 0; i < form->fcnt; i++) {
511 if (y == form->field[i]->line && x >= form->field[i]->col &&
512 x < form->field[i]->col + form->field[i]->len) {
513 return i;
514 }
515 }
516 return -1; // No field found at the given coordinates
517}

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 26 of file fields.c.

26 {"string", "decimal_int", "hex_int", "float", "double",
27 "currency", "yyyymmdd", "hhmmss", "apr", ""};

Referenced by form_parse_desc().