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

Field Edit and Entry for C-Menu Form. More...

#include "common.h"
#include <monetary.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
Include dependency graph for fields.c:

Go to the source code of this file.

Functions

void display_field (UiCell *cmplx_buf, uint y, uint x)
int field_editor (Form *form)
 Accept input for a field.
int form_display_accept_field (Form *)
int form_display_field (Form *form)
 Display current field.
int form_display_field_n (Form *form, uint n)
 Display field n.
int form_fmt_field (Form *form, char *s)
 Format field according to its format type.
int form_validate_field (Form *form)
 Validate current field based on flags.
bool is_valid_date (uint yyyy, uint mm, uint dd)
 Check if a given date is valid, including leap years.
bool is_valid_time (uint hh, uint mm, uint ss)
 Check if a given time is valid.
void left_justify (char *s)
 Left justify string by removing leading spaces.
void numeric (char *d, char *s)
 Extract numeric characters from source string to destination string.
void right_justify (char *, uint)
 Right justify string by removing trailing spaces and adding leadingspaces.

Variables

char ff_tbl [][26] = {_("string"), _("decimal_int"), _("hex_int"), _("float"), _("double"), _("currency"), _("yyyymmdd"), _("hhmmss"), _("apr"), ""}

Detailed Description

Field Edit and Entry for 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 fields.c.

Function Documentation

◆ display_field()

void display_field ( UiCell * cmplx_buf,
uint y,
uint x )

Definition at line 355 of file fields.c.

355 {
357 ui_mvwadd_wchstr(sfc, WIN, y, x, cmplx_buf);
358}
int sfc_ptr
Definition ui_ncurses.c:42
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:40
int ui_mvwadd_wchstr(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cmplx_buf)
Draw a complex character string at a specific position in a surface window.

References sfc_ptr, ui_mvwadd_wchstr(), and ui_surface.

Here is the call graph for this function:

◆ form_display_accept_field()

int form_display_accept_field ( Form * form)

Definition at line 388 of file fields.c.

388 {
390 uint y = form->field[form->fidx]->line;
391 uint x = form->field[form->fidx]->col;
392 uint pos = 0;
393 ui_mbstr_to_cellstr(sfc, WIN, form->field[form->fidx]->filler_cc, form->field[form->fidx]->filler_s, &cell_nt, &pos,
394 form->field[form->fidx]->len + 1);
395 ui_mvwadd_wchnstr(sfc, WIN, y, x, form->field[form->fidx]->filler_cc, form->field[form->fidx]->len);
396 ui_render();
397
398 pos = 0;
399 ui_mbstr_to_cellstr(sfc, WIN, form->field[form->fidx]->accept_cc, form->field[form->fidx]->accept_s, &cell_nt, &pos,
400 form->field[form->fidx]->len + 1);
401 ui_mvwadd_wchnstr(sfc, WIN, y, x, form->field[form->fidx]->accept_cc, form->field[form->fidx]->len);
402 ui_render();
403 return 0;
404}
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:884
UiCell cell_nt
Definition ui_common.c:106
uint ui_mbstr_to_cellstr(UiSurface *sfc, ss_t w, UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost)
Convert multibyte string to complex character array (Notcurses version).
int ui_mvwadd_wchnstr(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cmplx_buf, uint n)
Draw a complex character string at a specific position in a surface window, with a maximum length.
Form * form
Definition mem.c:37

References Field::accept_cc, Field::accept_s, cell_nt, Field::col, Form::fidx, Form::field, Field::filler_cc, Field::filler_s, Field::len, Field::line, sfc_ptr, ui_mvwadd_wchnstr(), ui_render(), and ui_surface.

Referenced by field_editor().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ff_tbl

char ff_tbl = {_("string"), _("decimal_int"), _("hex_int"), _("float"), _("double"), _("currency"), _("yyyymmdd"), _("hhmmss"), _("apr"), ""}

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

25{_("string"), _("decimal_int"), _("hex_int"), _("float"), _("double"), _("currency"), _("yyyymmdd"), _("hhmmss"), _("apr"), ""};
#define _(String)
Definition amort.c:23

Referenced by form_parse_desc().