2
3
4
5
6
7
8
25char ff_tbl[][26] = {
"string",
"decimal_int",
"hex_int",
"float",
"double",
26 "currency",
"yyyymmdd",
"hhmmss",
"apr",
""};
29
30
31
32
33
34
35
36
37
40
41
42
43
44
45
46
47
49 bool f_insert =
false;
64 char *fstart = accept_s;
65 char *fend = fstart + flen;
67 char *p = fstart = accept_s;
68 char *str_end = p + strlen(p);
91
126 x = fcol + (p - fstart);
130
131
197 if (p < fend && p < str_end) {
214 fend = fstart + flen;
215 str_end = fstart + strlen(fstart);
233
235 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
240
242 if ((in_key >=
'0' && in_key <=
'9') ||
243 (in_key >=
'A' && in_key <=
'F') ||
244 (in_key >=
'a' && in_key <=
'f'))
249
251 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
252 (in_key ==
'-' && p == fstart))
257
259 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
260 (in_key ==
'-' && p == fstart))
265
266
268 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
269 (in_key ==
'-' && p == fstart))
275 if (in_key >=
'0' && in_key <=
'9')
281 if (in_key >=
'0' && in_key <=
'9')
287 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
292 Perror("field_editor() invalid format");
295 if (in_key <
' ' || in_key >
'~') {
300 if (str_end < fend) {
312 if (p == accept_s && in_key ==
' ') {
323 }
else if (p == str_end) {
338
339
340
341
342
343
344
345
346
359
360
361
362
363
364
365
366
367
368
405
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
458 uint decimal_int_n = 0;
461 double double_n = 0.0;
462 double currency_n = 0.0;
478 sscanf(input_s,
"%d", &decimal_int_n);
479 sprintf(accept_s,
"%d", decimal_int_n);
480 sprintf(display_s,
"%d", decimal_int_n);
484 sscanf(input_s,
"%x", &hex_int_n);
485 sprintf(accept_s,
"%d", hex_int_n);
486 sprintf(display_s,
"%x", hex_int_n);
490 sscanf(input_s,
"%f", &float_n);
491 sprintf(accept_s,
"%f", float_n);
492 sprintf(display_s,
"%f", float_n);
496 sscanf(input_s,
"%lf", &double_n);
497 sprintf(accept_s,
"%lf", double_n);
498 sprintf(display_s,
"%lf", double_n);
503 sscanf(field_s,
"%lf", ¤cy_n);
504 sprintf(accept_s,
"%.2lf", currency_n);
505 sprintf(display_s,
"%'.2lf", currency_n);
511 sscanf(field_s,
"%4d%2d%2d", &date
.yyyy, &date
.mm, &date
.dd);
512 sprintf(accept_s,
"%04d%02d%02d", date
.yyyy, date
.mm, date
.dd);
514 sprintf(display_s,
"%04d-%02d-%02d", date
.yyyy, date
.mm, date
.dd);
519 sscanf(field_s,
"%2d%2d%2d", &time
.hh, &time
.mm, &time
.ss);
520 sprintf(accept_s,
"%02d%02d%02d", time
.hh, time
.mm, time
.ss);
522 sprintf(display_s,
"%02d:%02d:%02d", time
.hh, time
.mm, time
.ss);
525 sscanf(input_s,
"%lf", &double_n);
526 sprintf(accept_s,
"%lf", double_n);
527 sprintf(display_s,
"%0.3lf", double_n);
531 Perror("form_fmt_field() invalid format");
539
540
541
542
543
557 if (strpbrk(p,
"*?[]") != 0) {
558 Perror("metacharacters not allowed");
565
566
567
568
569
570
571
574
575
576
577
578
579
580
581
582
583
601
602
603
604
605
606
607
608
609
610
612 if (yyyy < 1 || mm < 1 || mm > 12 || dd < 1)
614 uint days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
615 if ((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0))
616 days_in_month[2] = 29;
617 if (dd > days_in_month[mm])
622
623
624
625
626
627
628
629
630
631
633 if (hh > 23 || mm > 59 || ss > 59)
638
639
640
641
642
643
644
645
646
647
650 if (*s ==
'-' || *s ==
'.' || (*s >=
'0' && *s <=
'9'))
#define min(x, y)
min macro evaluates two expressions, returning least result
int ui_mvwadd_wchstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_cursor_move(UiSurface *s, uint w, uint y, uint x)
int ui_mvwadd_wchnstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
UiSurface * ui_surface[UI_SFC_MAX]
int ui_get_event_multi(UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
int ui_curs_set(int visibility)
void ui_getmaxyx(UiSurface *s, uint w, uint *lines, uint *cols)
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 Perror(char *emsg_str)
Display a simple error message window or print to stderr.
void set_chyron_key_cb(Chyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
Set chyron key with color pair (cp).
void compile_chyron(Chyron *chyron)
construct the chyron string from the chyron structure
int get_chyron_key(Chyron *chyron, uint x)
Get keycode from chyron.
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.
void display_chyron(UiSurface *sfc, uint w, Chyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
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
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]