C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
form_engine.c File Reference

The working part of C-Menu Form. More...

#include <common.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
#include <wait.h>
Include dependency graph for form_engine.c:

Go to the source code of this file.

Macros

#define D_COMMENT   '#'
#define D_CMD   '!'
#define D_FIELD   'F'
#define D_TEXT   'T'
#define D_HELP   '?'
#define D_HEADER   'H'
#define D_CALC   'C'
#define D_QUERY   'Q'
#define D_GETTER   'G'

Functions

unsigned int form_display_screen (Init *init)
 Display the form on the screen, including text elements and fields, and set up the form window based on the form configuration.
void form_display_fields (Form *form)
 Display form fields on the screen, populating field values and formatting them according to the form configuration.
int field_navigator (Form *form)
 Handle user input for field entry, allowing navigation between fields and looping until an exit action is selected.
int form_parse_desc (Form *form)
 Parse the form description file to populate the Form data structure with field definitions, text elements, and other configuration specified in the description file.
int form_read_data (Form *form)
 Read initial data for form fields from a specified input source, such as a file or standard input, and populate the form fields with the data.
int form_write (Form *form)
 Write form field values to a specified output destination, such as a file or standard output, based on the form configuration and user input.
void form_usage ()
int form_desc_error (int in_line_num, char *in_buf, char *em)
 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.
int form_exec_cmd (Form *form)
 Execute a provider command specified in the form description file, passing form field values as arguments, and optionally redirecting output to a file.
int form_process (Init *init)
 Handle integration with a getter program which will provide field data.
int form_post (Init *init)
 Handle post-processing after field entry, allowing user to edit data, execute a provider command, or write data to an output file.
int init_form (Init *init, int argc, char **argv, int begy, int begx)
 Initialize form data structure and parse description file.
int form_engine (Init *init)
 Form main processing loop.
int form_yx_to_fidx (Form *, int, int)

Detailed Description

The working part of C-Menu Form.

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_engine.c.

Macro Definition Documentation

◆ D_CALC

#define D_CALC   'C'

Definition at line 31 of file form_engine.c.

◆ D_CMD

#define D_CMD   '!'

Definition at line 26 of file form_engine.c.

◆ D_COMMENT

#define D_COMMENT   '#'

Definition at line 25 of file form_engine.c.

◆ D_FIELD

#define D_FIELD   'F'

Definition at line 27 of file form_engine.c.

◆ D_GETTER

#define D_GETTER   'G'

Definition at line 33 of file form_engine.c.

◆ D_HEADER

#define D_HEADER   'H'

Definition at line 30 of file form_engine.c.

◆ D_HELP

#define D_HELP   '?'

Definition at line 29 of file form_engine.c.

◆ D_QUERY

#define D_QUERY   'Q'

Definition at line 32 of file form_engine.c.

◆ D_TEXT

#define D_TEXT   'T'

Definition at line 28 of file form_engine.c.

Function Documentation

◆ form_usage()

void form_usage ( )

◆ form_yx_to_fidx()

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

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: