2
3
4
5
6
7
8
11
12
13
47int init_form(Init *,
int,
char **, uint, uint);
53
54
55
56
57
58
59
60
61int init_form(Init *init,
int argc,
char **argv, uint begy, uint begx) {
86 strcmp(form
->in_spec,
"/dev/stdin") == 0) {
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
125 if (form ==
nullptr) {
142 form
->chyron->key[2]->active =
false;
143 form
->chyron->key[3]->active =
false;
144 form
->chyron->key[4]->active =
false;
145 form
->chyron->key[5]->active =
false;
146 form
->chyron->key[18]->active =
false;
160 if (form_action == 0 || form_action ==
FA_CONTINUE)
162 form
->chyron->key[18]->active =
false;
163 switch (form_action) {
192 eargv[eargc++] = strdup(
"view");
193 eargv[eargc++] = strdup(
"-Nf");
194 eargv[eargc++] = strdup(tmp_str);
195 eargv[eargc] =
nullptr;
212 if (form_action ==
FA_END)
218
219
220
221
222
242 form
->chyron->key[5]->active =
true;
243 form
->chyron->key[10]->active =
false;
244 form
->chyron->key[18]->active =
false;
252 if (event
.in_win == 1 && event
.y == maxy - 1)
279 form
->chyron->key[5]->active =
false;
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
323 char earg_str[
MAXLEN + 1];
347 form
->chyron->key[10]->active =
false;
348 form
->chyron->key[18]->active =
false;
356 if (event
.in_win == 1 && event
.y == maxy - 1)
369 for (i = 0; i < form
->fcnt; i++) {
376 if (pipe(pipe_fd) == -1) {
381 if ((pid = fork()) == -1) {
388 int dev_null = open(
"/dev/null", O_WRONLY);
389 if (dev_null == -1) {
390 ui_perror(_(
"open(/dev/null) failed in init_pick child process"));
393 dup2(dev_null, STDERR_FILENO);
396 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
399 execvp(eargv[0], eargv);
416 waitpid(pid,
nullptr, 0);
420 form
->chyron->key[2]->active =
false;
421 form
->chyron->key[3]->active =
false;
422 form
->chyron->key[4]->active =
false;
423 form
->chyron->key[5]->active =
true;
424 form
->chyron->key[10]->active =
true;
450 form
->chyron->key[2]->active =
false;
451 form
->chyron->key[3]->active =
false;
452 form
->chyron->key[4]->active =
false;
453 form
->chyron->key[5]->active =
false;
457
458
459
460
461
462
463
464
465
512 for (uint i = 0; i < form
->fcnt; i++) {
522
523
524
525
526
533 for (n = 0; n < form
->dcnt; n++)
536 for (n = 0; n < form
->fcnt; n++)
542 for (n = 0; n < form
->fcnt; n++) {
557 ui_immedok(sfc, WIN,
true);
558 ui_immedok(sfc, BOX,
true);
569 for (n = 0; n < form
->dcnt; n++) {
579
580
581
582
583
584
585
586
599 for (size_t i = 0; i < fl; i++) {
619 ui_mbstr_to_cellstr(sfc, WIN,
638
639
640
641
642
643
644
645
661 if (form_desc_fp ==
nullptr) {
670 form
->field[i] = calloc(1,
sizeof(Field));
672 sprintf(tmp_str,
_(
"FORM: calloc failed for fields"));
677 form
->text[i] = calloc(1,
sizeof(Text));
679 sprintf(tmp_str,
_(
"FORM: calloc failed for text"));
687 while ((fgets(in_buf,
MAXLEN, form_desc_fp)) !=
nullptr) {
696 delim[1] = in_buf[1];
700 if (!(token = strtok(tmp_buf_p, delim))) {
704 switch ((
int)directive) {
717 if (!(token = strtok(
nullptr, delim))) {
719 _(
"FORM: receiver_cmd delimiter"));
725 if (!(token = strtok(
nullptr, delim))) {
727 _(
"FORM: help_spec delimiter"));
733 sprintf(tmp_str,
_(
"FORM: calloc failed for fields"));
736 if (!(token = strtok(
nullptr, delim))) {
738 _(
"FORM: line number delimiter"));
744 _(
"FORM: invalid line number"));
747 if (!(token = strtok(
nullptr, delim))) {
749 _(
"FORM: column number delimiter"));
755 _(
"FORM: invalid column number"));
758 if (!(token = strtok(
nullptr, delim))) {
768 if (!(token = strtok(
nullptr, delim))) {
770 _(
"FORM: validation code delimiter"));
777 if (!strcmp(token,
ff_tbl[i])) {
784 _(
"FORM: invalid format code"));
796 sprintf(tmp_str,
_(
"FORM: calloc failed for text"));
799 if (!(token = strtok(
nullptr, delim))) {
801 _(
"FORM: line number delimiter"));
807 _(
"FORM: invalid line number"));
810 if (!(token = strtok(
nullptr, delim))) {
812 _(
"FORM: column number delimiter"));
818 _(
"FORM: invalid column number"));
821 if (!(token = strtok(
nullptr, delim))) {
839 if ((token = strtok(
nullptr, delim))) {
848 fclose(form_desc_fp);
859
860
861
862
863
864
865
874 if ((lstat(form
->in_spec, &sb) == -1) || (sb.st_size == 0) ||
904
905
906
907
908
910 char earg_str[
MAXLEN + 1];
913 for (i = 0; i < form
->fcnt; i++) {
925
926
927
928
929
930
931
932
933
934
935
940 char tmp_str[
MAXLEN] = {
'\0'};
947 bool f_append_values =
false;
965 for (i = 0; i < form
->fcnt; i++) {
967 if (tmp_str[0] !=
'\0')
972 eargv[eargc++] = strdup(tmp_str);
974 f_append_values =
false;
979 if (strstr(eargv[i],
"%%") !=
nullptr) {
981 f_append_values =
true;
988 for (i = 0; i < form
->fcnt; i++) {
991 if (f_append_values ==
true) {
992 if (tmp_str[0] !=
'\0')
1001 if (f_append_values ==
true) {
1002 if (eargv[eargx] !=
nullptr) {
1004 eargv[eargx] =
nullptr;
1007 if (out_s ==
nullptr || out_s[0] ==
'\0') {
1010 if (eargv[i] !=
nullptr)
1014 ui_perror(_(
"rep_substring() failed in form_exec_objects"));
1018 eargv[eargx] = strdup(out_s);
1019 if (out_s !=
nullptr) {
1026 eargv[eargc] =
nullptr;
1028 if (tmp_str[0] !=
'\0' && (strcmp(tmp_str,
"view") == 0)) {
1030
1035 if (title[0] !=
'\0')
1043 if (eargv[i] !=
nullptr)
1050 if ((pid = fork()) == -1) {
1054 if (eargv[i] !=
nullptr)
1063 int dev_null = open(
"/dev/null", O_WRONLY);
1064 if (dev_null == -1) {
1065 ui_perror(_(
"open(/dev/null) failed in init_form child process"));
1068 dup2(dev_null, STDERR_FILENO);
1071 execvp(eargv[0], eargv);
1073
1080 waitpid(pid,
nullptr, 0);
1087
1088
1089
1090
1091
1092
1093
1097 strcmp(form
->out_spec,
"/dev/stdout") == 0) {
1131 for (n = 0; n < form
->fcnt; n++)
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
int popup_view(Init *, int, char **, uint, uint, uint, uint)
instantiate a view popup window
char stdio_names_str[4096]
char * stdio_fdnames(char *, char *)
char * rep_substring(const char *, const char *, const char *) __attribute__((nonnull(1
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
void ui_render()
Render the UI by updating panels and refreshing the display.
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
int ui_cursor_move(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
int ui_cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
void ui_restore_wins()
Restore the state of all windows in the UI. This function refreshes the standard screen and all surfa...
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
int ui_tracked_sfc_box(uint wlines, uint wcols, uint wbegy, uint wbegx, const char *wtitle)
Create a new surface with a box window.
int ui_wclrtoeol(UiSurface *s, ss_t w)
Clear to the end of the line in a surface window.
int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev, int timeout_ms)
Read input events.
void ui_set_chyron_key(UiChyron *chyron, uint k, char *s, uint kc)
Set chyron key with default color pair (cp_nt_rev).
UiChyron * ui_new_chyron(UiSurface *sfc, ss_t w)
Create new chyron structure.
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).
bool ui_is_set_chyron_key(UiChyron *chyron, uint k)
Check if function key label is set.
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
UiChyron * ui_destroy_chyron(UiChyron *chyron)
Destroy UiChyron structure.
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.
int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x, const char *text)
Draw a text string at a specific position in a surface window.
int ui_mvwadd_wch(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cell)
Draw a complex character at a specific position in a surface window.
void mk_filler(char *, uint)
uint form_yx_to_fidx(Form *, uint, uint)
int shell(char *)
Execute a shell command.
int form_fmt_field(Form *form, char *s)
Format field according to its format type.
int field_editor(Form *)
Accept input for a field.
int form_exec_receiver(Init *)
Execute a command specified by the -R option on the form command line.
int form_desc_error(Form *form, int, char *, char *)
Handle errors encountered while parsing the form description file, providing detailed error messages ...
int form_read_data(Form *)
Read initial data for form fields from a specified input source, such as a file or standard input,...
int form_parse_desc(Form *)
Parse the form description file to populate the Form data structure with field definitions,...
int form_write(Form *)
Write form field values to a specified output destination, such as a file or standard output,...
int form_process(Init *)
Handle integration with a getter program which will provide field data.
int form_exec_cmd(Form *)
Execute a command specified in the form description file, passing form field values as arguments,...
int form_post(Init *)
Handle post-processing after field entry, allowing user to edit data, execute a provider command,...
int form_engine(Init *)
Form main processing loop.
void form_display_fields(Form *)
Display form fields on the screen, populating field values and formatting them according to the form ...
int init_form(Init *, int, char **, uint, uint)
Initialize form data structure and parse description file.
int field_navigator(Form *)
Handle user input for field entry, allowing navigation between fields and looping until an exit actio...
unsigned int display_form(Init *)
Display the form on the screen, including text elements and fields, and set up the form window based ...
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.
bool str_to_lower(char *)
Converts a string to lowercase.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
char * strerror__r(int errnum, char *buf, size_t buflen)
A thread-safe alternative to strerror() that writes the error message corresponding to errnum into th...
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
bool base_name(char *, char *)
Returns the base name of a file specification.
Form * destroy_form(Init *init)
Destroy Form structure.
Form * new_form(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Form structure.
void sig_prog_mode()
Set up signal handlers for interrupt signals.
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
char display_s[FIELD_MAXLEN]
UiCell display_cc[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
UiCell filler_cc[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Text * text[FIELD_MAXCNT]
Field * field[FIELD_MAXCNT]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char mapp_spec[FIELD_MAXLEN]