2
3
4
5
6
7
8
25char ff_tbl[][26] = {
_(
"string"),
_(
"decimal_int"),
_(
"hex_int"),
_(
"float"),
_(
"double"),
_(
"currency"),
_(
"yyyymmdd"),
_(
"hhmmss"),
_(
"apr"),
""};
28
29
30
31
32
33
34
35
36
39
40
41
42
43
44
45
46
48 bool f_insert =
false;
63 char *fstart = accept_s;
64 char *fend = fstart + flen;
66 char *p = fstart = accept_s;
67 char *str_end = p + strlen(p);
88 if (event
.in_win == WIN && event
.y == maxy - 1)
94
127 x = fcol + (p - fstart);
131
132
198 if (p < fend && p < str_end) {
215 fend = fstart + flen;
216 str_end = fstart + strlen(fstart);
234
236 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
241
243 if ((in_key >=
'0' && in_key <=
'9') ||
244 (in_key >=
'A' && in_key <=
'F') ||
245 (in_key >=
'a' && in_key <=
'f'))
250
252 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
253 (in_key ==
'-' && p == fstart))
258
260 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
261 (in_key ==
'-' && p == fstart))
266
267
269 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
270 (in_key ==
'-' && p == fstart))
276 if (in_key >=
'0' && in_key <=
'9')
282 if (in_key >=
'0' && in_key <=
'9')
288 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
296 if (in_key <
' ' || in_key >
'~') {
301 if (str_end < fend) {
313 if (p == accept_s && in_key ==
' ') {
324 }
else if (p == str_end) {
339
340
341
342
343
344
345
346
347
360
361
362
363
364
365
366
367
368
369
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
459 uint decimal_int_n = 0;
462 double double_n = 0.0;
463 double currency_n = 0.0;
479 sscanf(input_s,
"%d", &decimal_int_n);
480 sprintf(accept_s,
"%d", decimal_int_n);
481 sprintf(display_s,
"%d", decimal_int_n);
485 sscanf(input_s,
"%x", &hex_int_n);
486 sprintf(accept_s,
"%d", hex_int_n);
487 sprintf(display_s,
"%x", hex_int_n);
491 sscanf(input_s,
"%f", &float_n);
492 sprintf(accept_s,
"%f", float_n);
493 sprintf(display_s,
"%f", float_n);
497 sscanf(input_s,
"%lf", &double_n);
498 sprintf(accept_s,
"%lf", double_n);
499 sprintf(display_s,
"%lf", double_n);
504 sscanf(field_s,
"%lf", ¤cy_n);
505 sprintf(accept_s,
"%.2lf", currency_n);
506 sprintf(display_s,
"%'.2lf", currency_n);
512 sscanf(field_s,
"%4d%2d%2d", &date
.yyyy, &date
.mm, &date
.dd);
513 sprintf(accept_s,
"%04d%02d%02d", date
.yyyy, date
.mm, date
.dd);
515 sprintf(display_s,
"%04d-%02d-%02d", date
.yyyy, date
.mm, date
.dd);
520 sscanf(field_s,
"%2d%2d%2d", &time
.hh, &time
.mm, &time
.ss);
521 sprintf(accept_s,
"%02d%02d%02d", time
.hh, time
.mm, time
.ss);
523 sprintf(display_s,
"%02d:%02d:%02d", time
.hh, time
.mm, time
.ss);
526 sscanf(input_s,
"%lf", &double_n);
527 sprintf(accept_s,
"%lf", double_n);
528 sprintf(display_s,
"%0.3lf", double_n);
540
541
542
543
544
558 if (strpbrk(p,
"*?[]") != 0) {
566
567
568
569
570
571
572
575
576
577
578
579
580
581
582
583
584
602
603
604
605
606
607
608
609
610
611
613 if (yyyy < 1 || mm < 1 || mm > 12 || dd < 1)
615 uint days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
616 if ((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0))
617 days_in_month[2] = 29;
618 if (dd > days_in_month[mm])
623
624
625
626
627
628
629
630
631
632
634 if (hh > 23 || mm > 59 || ss > 59)
639
640
641
642
643
644
645
646
647
648
651 if (*s ==
'-' || *s ==
'.' || (*s >=
'0' && *s <=
'9'))
#define min(x, y)
min macro evaluates two expressions, returning least result
void ui_render()
Render the UI by updating panels and refreshing the display.
int ui_cursor_enable_yx(UiSurface *s, ss_t w, uint y, uint x, bool visible)
Enable or disable the cursor at a specific position within a UiSurface.
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
int ui_curs_set(int visibility)
Set the visibility of the cursor.
int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev, int timeout_ms)
Read input events.
void ui_display_chyron(UiSurface *sfc, ss_t w, UiChyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
void ui_set_chyron_key_cb(UiChyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
Set chyron key with color pair (cp).
int ui_get_chyron_key(UiChyron *chyron, uint x)
Get keycode from chyron.
void ui_compile_chyron(UiChyron *chyron)
construct the chyron string from the chyron structure
UiSurface * ui_surface[UI_SFC_MAX]
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.
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.
uint form_yx_to_fidx(Form *, uint, uint)
void display_field(UiCell *cmplx_buf, uint y, uint x)
int form_display_accept_field(Form *)
int form_fmt_field(Form *form, char *s)
Format field according to its format type.
bool is_valid_date(uint yyyy, uint mm, uint dd)
Check if a given date is valid, including leap years.
int field_editor(Form *)
Accept input for a field.
void numeric(char *d, char *s)
Extract numeric characters from source string to destination string.
bool is_valid_time(uint hh, uint mm, uint ss)
Check if a given time is valid.
void right_justify(char *, uint)
Right justify string by removing trailing spaces and adding leadingspaces.
void left_justify(char *s)
Left justify string by removing leading spaces.
int form_display_field_n(Form *, uint)
Display field n.
int form_display_field(Form *)
Display current field.
int form_validate_field(Form *)
Validate current field based on flags.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
UiCell accept_cc[FIELD_MAXLEN]
char display_s[FIELD_MAXLEN]
UiCell display_cc[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
char input_s[FIELD_MAXLEN]
UiCell filler_cc[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Field * field[FIELD_MAXCNT]