|
C-Menu 0.2.9
A User Interface Toolkit
|
Parses Form Descriptions, Handles User Input, and Integrates with External Commands for Calculations and Data Processing. More...
Functions | |
| unsigned int | display_form (Init *init) |
| Display the form on the screen, including text elements and fields, and set up the form window based on the form configuration. | |
| int | field_navigator (Form *form) |
| Handle user input for field entry, allowing navigation between fields and looping until an exit action is selected. | |
| int | form_desc_error (int in_line_num, char *in_buf, char *em) |
| Handle errors encountered while parsing the form description file, providing detailed error messages that include the file name, line number, and the specific error encountered. | |
| void | form_display_fields (Form *form) |
| Display form fields on the screen, populating field values and formatting them according to the form configuration. | |
| int | form_engine (Init *init) |
| Form main processing loop. | |
| int | form_exec_cmd (Form *form) |
| Execute a command specified in the form description file, passing form field values as arguments, and optionally redirecting output to a file. | |
| int | form_exec_receiver (Init *init) |
| Execute a command specified by the -R option on the form command line. | |
| int | form_parse_desc (Form *form) |
| Parse the form description file to populate the Form data structure with field definitions, text elements, and other configuration specified in the description file. | |
| int | form_post (Init *init) |
| Handle post-processing after field entry, allowing user to edit data, execute a provider command, or write data to an output file. | |
| int | form_process (Init *init) |
| Handle integration with a getter program which will provide field data. | |
| int | form_read_data (Form *form) |
| Read initial data for form fields from a specified input source, such as a file or standard input, and populate the form fields with the data. | |
| int | form_write (Form *form) |
| Write form field values to a specified output destination, such as a file or standard output, based on the form configuration and user input. | |
| int | init_form (Init *init, int argc, char **argv, int begy, int begx) |
| Initialize form data structure and parse description file. | |
Parses Form Descriptions, Handles User Input, and Integrates with External Commands for Calculations and Data Processing.
| unsigned int display_form | ( | Init * | init | ) |
Display the form on the screen, including text elements and fields, and set up the form window based on the form configuration.
| init | A pointer to the Init structure containing form data and state. |
Definition at line 486 of file form_engine.c.
References Form::begx, Form::begy, Form::box, box_new(), Form::brackets, Field::col, Text::col, Form::cols, Form::dcnt, Form::fcnt, Form::fidx, Form::field, form, Init::form, form_display_fields(), Field::len, Field::line, Text::line, Form::lines, Perror(), Text::str, strnz(), strnz__cat(), strnz__cpy(), Form::text, Form::title, Form::win, win_box, win_ptr, and win_win.
Referenced by form_engine().
| int field_navigator | ( | Form * | form | ) |
Handle user input for field entry, allowing navigation between fields and looping until an exit action is selected.
| form | A pointer to the Form structure containing form data and state. |
This function manages user input for field entry, including navigation between fields and handling of special keys for accepting, canceling, requesting help, or performing calculations. The function loops until the user selects an exit action (e.g., accept or cancel).
Definition at line 426 of file form_engine.c.
References cmd_key, Form::f_process, FA_ACCEPT, FA_CALC, FA_CANCEL, FA_HELP, Form::fcnt, Form::fidx, and field_editor().
Referenced by form_engine().
| int form_desc_error | ( | int | in_line_num, |
| char * | in_buf, | ||
| char * | em ) |
Handle errors encountered while parsing the form description file, providing detailed error messages that include the file name, line number, and the specific error encountered.
| in_line_num | The line number in the description file where the error occurred. |
| in_buf | The content of the line that caused the error, for context. |
| em | A specific error message describing the nature of the error. |
Definition at line 1086 of file form_engine.c.
References display_error(), em0, em1, em2, form, Form::mapp_spec, ssnprintf(), and strnz__cpy().
Referenced by form_parse_desc().
| void form_display_fields | ( | Form * | form | ) |
Display form fields on the screen, populating field values and formatting them according to the form configuration.
| form | A pointer to the Form structure containing form data and state. |
This function iterates through the defined form fields, formats their display values based on the specified fill character and field length, and renders them on the form window. It also updates the chyron with available commands for user interaction.
Definition at line 551 of file form_engine.c.
References Field::col, Form::cols, Field::display_s, Form::fcnt, Form::fidx, Form::field, Form::fill_char, Field::filler_s, Field::len, Field::line, strnfill(), strnz(), and Form::win.
Referenced by display_form(), and form_process().
| int form_engine | ( | Init * | init | ) |
Form main processing loop.
| init | A pointer to the Init structure containing form data and state. |
Definition at line 120 of file form_engine.c.
References Form::begx, Init::begx, Form::begy, Init::begy, Form::chyron, Init::cols, compile_chyron(), destroy_argv(), display_chyron(), display_form(), Form::f_calculate, Form::f_help_spec, Form::f_out_spec, Form::f_process, Form::f_query, Form::f_receiver_cmd, FA_ACCEPT, FA_CANCEL, FA_CONTINUE, FA_END, FA_HELP, Form::fidx, field_navigator(), form, Init::form, form_exec_receiver(), form_parse_desc(), form_post(), form_process(), form_read_data(), form_write(), Form::help_spec, Chyron::l, Form::lines, Init::lines, Init::mapp_help, new_chyron(), Form::out_spec, Perror(), popup_view(), Form::receiver_cmd, set_chyron_key(), strnz__cat(), strnz__cpy(), Init::title, and Form::win.
Referenced by init_form().
| int form_exec_cmd | ( | Form * | form | ) |
Execute a command specified in the form description file, passing form field values as arguments, and optionally redirecting output to a file.
| form | A pointer to the Form structure containing form data and state. |
Definition at line 848 of file form_engine.c.
References Field::accept_s, Form::f_out_spec, Form::f_process, Form::fcnt, Form::field, Form::out_spec, Form::receiver_cmd, shell(), strnz__cat(), and strnz__cpy().
| int form_exec_receiver | ( | Init * | init | ) |
Execute a command specified by the -R option on the form command line.
| init | A pointer to the Init structure |
This function constructs a command by taking the receiver_cmd appending field values as arguments, and handling special cases such as multiple command arguments or placeholder substitution. It then executes the command, either displaying the output in a popup view if the command is "view", or executing it directly in a child process for other commands. The function also handles error cases and ensures that resources are properly freed.
This is the line that gets the selected objects
initialize popup_view arguments and execute popup_view to display command output within form interface
fork failed, free eargv and return error
Prevent child process from writing to terminal
Child process to execute command
If execvp returns, it means execution failed, so free eargv and print error message before exiting
Definition at line 875 of file form_engine.c.
References Field::accept_s, base_name(), Form::begx, Init::begx, Form::begy, Init::begy, Init::cols, destroy_argv(), Form::f_multiple_cmd_args, Form::fcnt, Form::field, form, Init::lines, Perror(), popup_view(), Form::receiver_cmd, rep_substring(), restore_curses_tioctl(), restore_wins(), sig_prog_mode(), str_to_args(), strnz__cat(), strnz__cpy(), and Init::title.
Referenced by form_engine().
| int form_parse_desc | ( | Form * | form | ) |
Parse the form description file to populate the Form data structure with field definitions, text elements, and other configuration specified in the description file.
| form | A pointer to the Form structure containing form data and state. |
Definition at line 579 of file form_engine.c.
References abend(), Field::col, Text::col, Form::cols, Form::dcnt, Form::didx, display_error(), em0, em1, em2, Form::f_calculate, Form::f_process, Form::f_query, Form::fcnt, Field::ff, FF_INVALID, ff_tbl, Form::fidx, Form::field, form_desc_error(), Form::help_spec, Field::len, Text::len, Field::line, Text::line, Form::mapp_spec, Form::receiver_cmd, ssnprintf(), Text::str, str_to_lower(), strnz__cat(), strnz__cpy(), Form::text, Form::title, and trim().
Referenced by form_engine().
| int form_post | ( | Init * | init | ) |
Handle post-processing after field entry, allowing user to edit data, execute a provider command, or write data to an output file.
| init | A pointer to the Init structure containing form data and state. |
Definition at line 207 of file form_engine.c.
References Form::box, Form::chyron, click_x, click_y, compile_chyron(), display_chyron(), FA_ACCEPT, FA_CANCEL, FA_CONTINUE, FA_HELP, form, Init::form, is_set_chyron_key(), Chyron::l, Form::lines, set_chyron_key(), unset_chyron_key(), Form::win, and xwgetch().
Referenced by form_engine().
| int form_process | ( | Init * | init | ) |
Handle integration with a getter program which will provide field data.
| init | A pointer to the Init structure containing form data and state. |
This function provides integration with getter programs. The requirements are:
The sequence of operations is as follows: 1. The 'C', 'Q', or 'G' option causes Form to pause and display anKEY_F(5) Calculate, Query, or Getter. option on the chyron.
This function forks and executes the getter executable as a child process, creates a pipe to read the output from the provider command, reads the output, and updates the Form fields.
Prevent child process from writing to terminal
Definition at line 292 of file form_engine.c.
References Field::accept_s, base_name(), Form::box, Form::chyron, click_x, click_y, compile_chyron(), cp_nt_hl_rev, destroy_argv(), display_chyron(), display_error(), em0, em1, em2, Form::f_calculate, Form::f_in_pipe, Form::f_out_spec, Form::f_process, Form::f_provider_cmd, Form::f_query, FA_ACCEPT, FA_CANCEL, FA_CONTINUE, FA_HELP, Form::fcnt, Form::field, form, Init::form, form_display_fields(), form_read_data(), form_write(), Form::in_fp, is_set_chyron_key(), Chyron::l, Form::lines, Perror(), Form::provider_cmd, set_chyron_key(), set_chyron_key_cp(), ssnprintf(), str_to_args(), strnz__cat(), strnz__cpy(), unset_chyron_key(), wait_timeout, waitpid_with_timeout(), Form::win, and xwgetch().
Referenced by form_engine().
| int form_read_data | ( | Form * | form | ) |
Read initial data for form fields from a specified input source, such as a file or standard input, and populate the form fields with the data.
| form | A pointer to the Form structure containing form data and state. |
Definition at line 806 of file form_engine.c.
References cmd_key, display_error(), em0, em1, em2, Form::f_in_pipe, Form::f_in_spec, Form::fidx, form_fmt_field(), Form::in_fp, Form::in_spec, strnz__cat(), and strnz__cpy().
Referenced by form_engine(), and form_process().
| int form_write | ( | Form * | form | ) |
Write form field values to a specified output destination, such as a file or standard output, based on the form configuration and user input.
| form | A pointer to the Form structure containing form data and state. |
Definition at line 1034 of file form_engine.c.
References Field::accept_s, display_error(), em0, em1, em2, Form::f_out_pipe, Form::f_out_spec, Form::fcnt, Form::field, Form::out_fd, Form::out_fp, Form::out_spec, ssnprintf(), strnz__cat(), and strnz__cpy().
Referenced by form_engine(), and form_process().
| int init_form | ( | Init * | init, |
| int | argc, | ||
| char ** | argv, | ||
| int | begy, | ||
| int | begx ) |
Initialize form data structure and parse description file.
| init | A pointer to the Init structure containing form data and state. |
| argc | The number of command line arguments passed to the form. |
| argv | The array of command line arguments passed to the form. |
| begy | The y-coordinate for the top-left corner of the form window. |
| begx | The x-coordinate for the top-left corner of the form window. |
Definition at line 60 of file form_engine.c.
References Form::begx, Form::begy, Form::chyron, destroy_chyron(), destroy_form(), Form::f_in_pipe, Form::f_in_spec, Form::f_mapp_spec, form, Init::form, form_engine(), Form::in_spec, Form::mapp_spec, new_form(), Perror(), strnz__cat(), strnz__cpy(), Form::title, Form::win, and win_del().
Referenced by main(), and popup_form().