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]

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

354 {
356 ui_mvwadd_wchstr(sfc, WIN, y, x, cmplx_buf);
357}
int ui_mvwadd_wchstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:28
int sfc_ptr
Definition nckeys.c:47
A drawable surface in the NotCurses backend.

References sfc_ptr, ui_mvwadd_wchstr(), ui_surface, and WIN.

Here is the call graph for this function:

◆ form_display_accept_field()

int form_display_accept_field ( Form * form)

Definition at line 387 of file fields.c.

387 {
389 uint y = form->field[form->fidx]->line;
390 uint x = form->field[form->fidx]->col;
391 uint pos = 0;
392 mbstr_to_cellstr(form->field[form->fidx]->filler_cc, form->field[form->fidx]->filler_s, &cell_nt, &pos,
393 form->field[form->fidx]->len + 1);
394 ui_mvwadd_wchnstr(sfc, WIN, y, x, form->field[form->fidx]->filler_cc, form->field[form->fidx]->len);
395 ui_render();
396
397 pos = 0;
398 mbstr_to_cellstr(form->field[form->fidx]->accept_cc, form->field[form->fidx]->accept_s, &cell_nt, &pos,
399 form->field[form->fidx]->len + 1);
400 ui_mvwadd_wchnstr(sfc, WIN, y, x, form->field[form->fidx]->accept_cc, form->field[form->fidx]->len);
401 ui_render();
402 return 0;
403}
void ui_render()
Definition ui_ncurses.c:800
int ui_mvwadd_wchnstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
Form * form
Definition mem.c:37
UiCell cell_nt
Definition dwin.c:94
uint mbstr_to_cellstr(UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *pos, const uint atmost)
Convert multibyte string to complex character array.
Definition dwin.c:480

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, mbstr_to_cellstr(), sfc_ptr, ui_mvwadd_wchnstr(), ui_render(), ui_surface, and WIN.

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
Initial value:
= {"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",
26 "currency", "yyyymmdd", "hhmmss", "apr", ""};

Referenced by form_parse_desc().