2
3
4
5
6
7
8
26char ff_tbl[][26] = {
"string",
"decimal_int",
"hex_int",
"float",
"double",
27 "currency",
"yyyymmdd",
"hhmmss",
"apr",
""};
36
37
38
39
40
41
42
43
44
47
48
49
50
51
52
53
54
56 bool f_insert =
FALSE;
69 char *fstart = accept_s;
70 char *fend = fstart + flen;
72 char *p = fstart = accept_s;
73 char *str_end = p + strlen(p);
88 wmove(form
->win, flin, x);
98
133 x = fcol + (p - fstart);
137
138
204 if (p < fend && p < str_end) {
221 fend = fstart + flen;
222 str_end = fstart + strlen(fstart);
240
242 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
248
250 if ((in_key >=
'0' && in_key <=
'9') ||
251 (in_key >=
'A' && in_key <=
'F') ||
252 (in_key >=
'a' && in_key <=
'f'))
258
260 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
261 (in_key ==
'-' && p == fstart))
267
269 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
270 (in_key ==
'-' && p == fstart))
276
277
279 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
280 (in_key ==
'-' && p == fstart))
287 if (in_key >=
'0' && in_key <=
'9')
294 if (in_key >=
'0' && in_key <=
'9')
301 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
307 Perror("field_editor() invalid format");
310 if (in_key <
' ' || in_key >
'~') {
315 if (str_end < fend) {
327 if (p == accept_s && in_key ==
' ') {
338 }
else if (p == str_end) {
353
354
355
356
357
358
359
360
361
371 mvwadd_wchstr(form
->win, y, x, cmplx_buf);
374
375
376
377
378
379
380
381
382
383
401
402
403
404
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
454 int decimal_int_n = 0;
457 double double_n = 0.0;
458 double currency_n = 0.0;
474 sscanf(input_s,
"%d", &decimal_int_n);
475 sprintf(accept_s,
"%d", decimal_int_n);
476 sprintf(display_s,
"%d", decimal_int_n);
480 sscanf(input_s,
"%x", &hex_int_n);
481 sprintf(accept_s,
"%d", hex_int_n);
482 sprintf(display_s,
"%x", hex_int_n);
486 sscanf(input_s,
"%f", &float_n);
487 sprintf(accept_s,
"%f", float_n);
488 sprintf(display_s,
"%f", float_n);
492 sscanf(input_s,
"%lf", &double_n);
493 sprintf(accept_s,
"%lf", double_n);
494 sprintf(display_s,
"%lf", double_n);
499 sscanf(field_s,
"%lf", ¤cy_n);
500 sprintf(accept_s,
"%.2lf", currency_n);
501 sprintf(display_s,
"%'.2lf", currency_n);
507 sscanf(field_s,
"%4d%2d%2d", &date
.yyyy, &date
.mm, &date
.dd);
508 sprintf(accept_s,
"%04d%02d%02d", date
.yyyy, date
.mm, date
.dd);
510 sprintf(display_s,
"%04d-%02d-%02d", date
.yyyy, date
.mm, date
.dd);
515 sscanf(field_s,
"%2d%2d%2d", &time
.hh, &time
.mm, &time
.ss);
516 sprintf(accept_s,
"%02d%02d%02d", time
.hh, time
.mm, time
.ss);
518 sprintf(display_s,
"%02d:%02d:%02d", time
.hh, time
.mm, time
.ss);
521 sscanf(input_s,
"%lf", &double_n);
522 sprintf(accept_s,
"%lf", double_n);
523 sprintf(display_s,
"%0.3lf", double_n);
527 Perror("form_fmt_field() invalid format");
535
536
537
538
539
553 if (strpbrk(p,
"*?[]") != 0) {
554 Perror("metacharacters not allowed");
561
562
563
564
565
566
567
570
571
572
573
574
575
576
577
578
579
597
598
599
600
601
602
603
604
605
606
608 if (yyyy < 1 || mm < 1 || mm > 12 || dd < 1)
610 int days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
611 if ((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0))
612 days_in_month[2] = 29;
613 if (dd > days_in_month[mm])
618
619
620
621
622
623
624
625
626
627
629 if (hh < 0 || hh > 23 || mm < 0 || mm > 59 || ss < 0 || ss > 59)
634
635
636
637
638
639
640
641
642
643
646 if (*s ==
'-' || *s ==
'.' || (*s >=
'0' && *s <=
'9'))
int form_yx_to_fidx(Form *, int, int)
void display_field(Form *, cchar_t *, int, int)
#define min(x, y)
min macro evaluates two expressions, returning least result
int form_display_accept_field(Form *)
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
size_t str_to_cc(cchar_t *, const char *, attr_t, int, size_t)
Convert a multibyte string to an array of cchar_t complex characters.
int Perror(char *)
Display a simple error message window or print to stderr.
void display_chyron(WINDOW *, Chyron *, int, int)
Display chyron on window.
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key with color pair (cp).
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
int form_fmt_field(Form *, char *s)
Format field according to its format type.
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_date(int yyyy, int mm, int dd)
Check if a given date is valid, including leap years.
void left_justify(char *s)
Left justify string by removing leading spaces.
bool is_valid_time(int hh, int mm, int ss)
Check if a given time is valid.
int form_display_field_n(Form *, int)
Display field n.
void right_justify(char *, int)
Right justify string by removing trailing spaces and adding leadingspaces.
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
char display_s[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
char input_s[FIELD_MAXLEN]
cchar_t filler_cc[FIELD_MAXLEN]
cchar_t display_cc[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Field * field[FIELD_MAXCNT]