|
C-Menu 0.2.9
A User Interface Toolkit
|
Capture Data from the Environment, Command Line, and Configuration File and Populate the Init and SIO Data Structures. More...
Functions | |
| bool | derive_file_spec (char *file_spec, char *dir, char *file_name) |
| Derive full file specification from directory and file name. | |
| void | display_version () |
| Display the version information of the application. | |
| void | dump_config (Init *init, char *msg) |
| Dump the current configuration to stdout for debugging purposes. | |
| void | mapp_initialization (Init *init, int argc, char **argv) |
| Main initialization function for MAPP - Menu Application. | |
| void | opt_prt_bool (const char *o, const char *name, bool value) |
| Print an option and its value in a formatted manner for boolean values. | |
| void | opt_prt_char (const char *o, const char *name, const char *value) |
| Print an option and its value in a formatted manner. | |
| void | opt_prt_double (const char *o, const char *name, double value) |
| Print an option and its value in a formatted manner for double values. | |
| void | opt_prt_int (const char *o, const char *name, int value) |
| Print an option and its value in a formatted manner for integer values. | |
| void | opt_prt_str (const char *o, const char *name, const char *value) |
| Print an option and its value in a formatted manner for integer values. | |
| int | parse_config (Init *init) |
| parse the configuration file specified in init->minitrc and set Init struct values accordingly | |
| int | parse_opt_args (Init *init, int argc, char **argv) |
| Parse command-line options and set Init struct values accordingly. | |
| int | write_config (Init *init) |
| Write the current configuration to a file specified in init->minitrc. | |
| void | zero_opt_args (Init *init) |
| Initialize optional arguments in the Init struct to default values. | |
Capture Data from the Environment, Command Line, and Configuration File and Populate the Init and SIO Data Structures.
SIO Struct for screen I/O settings (colors, gamma, etc.)
Init Struct for application settings (file paths, commands, flags, etc.)
| bool derive_file_spec | ( | char * | file_spec, |
| char * | dir, | ||
| char * | file_name ) |
Derive full file specification from directory and file name.
| file_spec | - output full file specification |
| dir | - directory path |
| file_name | - file name |
If dir is nullptr, use MAPP_DIR environment variable or default directory, ~/menuapp. file_spec should be a pre-allocated char array of size MAXLEN to hold the resulting file specification
Definition at line 907 of file init.c.
References strnz__cat(), strnz__cpy(), and trim_path().
| void display_version | ( | ) |
| void dump_config | ( | Init * | init, |
| char * | msg ) |
Dump the current configuration to stdout for debugging purposes.
| init | - pointer to Init struct containing the current configuration |
| msg | - string to print before dumping the configuration to stdout in a readable format, prefixed by the provided title string. |
Definition at line 1005 of file init.c.
References SIO::bblack, SIO::bblue, SIO::bcyan, Init::begx, Init::begy, SIO::bg_clr_x, SIO::bgreen, SIO::black, SIO::blue, SIO::blue_gamma, SIO::bmagenta, SIO::bo_clr_x, SIO::borange, Init::brackets, SIO::bred, SIO::bwhite, SIO::byellow, Init::cmd, Init::cmd_all, Init::cols, SIO::cyan, Init::editor, Init::f_erase_remainder, Init::f_ignore_case, Init::f_ln, Init::f_squeeze, Init::f_strip_ansi, SIO::fg_clr_x, Init::fill_char, SIO::gray_gamma, SIO::green, SIO::green_gamma, Init::help_spec, Init::in_spec, Init::lines, SIO::ln_bg_clr_x, SIO::ln_clr_x, SIO::magenta, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_user, Init::minitrc, opt_prt_bool(), opt_prt_double(), opt_prt_int(), opt_prt_str(), SIO::orange, Init::out_spec, Init::parent_cmd, Init::provider_cmd, Init::receiver_cmd, SIO::red, SIO::red_gamma, Init::select_max, Init::sio, Init::tab_stop, Init::title, wait_timeout, SIO::white, and SIO::yellow.
Referenced by mapp_initialization().
| void mapp_initialization | ( | Init * | init, |
| int | argc, | ||
| char ** | argv ) |
Main initialization function for MAPP - Menu Application.
| init | - pointer to Init struct to be initialized |
| argc | - argument count from main() |
| argv | - argument vector from main() 1. Read environment variables and set defaults
2. Parse configuration file
3. Parse command-line options
4. Set up SIO struct with colors and other settings
5. Handle special options like help and version
|
< menu specification file
< background color
< foreground color
< bold color
< line number olor
< line number background
< erase remainder on enter
< field enclosure brackets
< field fill character
Definition at line 328 of file init.c.
References abend(), Init::argc, SIO::bg_clr_x, SIO::bo_clr_x, Init::brackets, dump_config(), Init::editor, expand_tilde(), f_dump_config, Init::f_erase_remainder, f_write_config, SIO::fg_clr_x, Init::fill_char, SIO::ln_bg_clr_x, SIO::ln_clr_x, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_user, Init::minitrc, parse_config(), Init::sio, ssnprintf(), strnz__cat(), strnz__cpy(), verify_dir(), and write_config().
Referenced by main().
| void opt_prt_bool | ( | const char * | o, |
| const char * | name, | ||
| bool | value ) |
Print an option and its value in a formatted manner for boolean values.
| o | - option flag (e.g., "-z") |
| name | - option name (e.g., "f_squeeze") |
| value | - boolean option value to print |
This function is used to display the current configuration options and their boolean values in a readable format, printing "true" or "false" based on the value.
Definition at line 996 of file init.c.
Referenced by dump_config().
| void opt_prt_char | ( | const char * | o, |
| const char * | name, | ||
| const char * | value ) |
Print an option and its value in a formatted manner.
| o | - option flag (e.g., "-a:") |
| name | - option name (e.g., "--minitrc") |
| value | - option value to print |
This function is used to display the current configuration options and their values in a readable format.
Definition at line 951 of file init.c.
| void opt_prt_double | ( | const char * | o, |
| const char * | name, | ||
| double | value ) |
Print an option and its value in a formatted manner for double values.
| o | - option flag (e.g., "-r:") |
| name | - option name (e.g., "red_gamma") |
| value | - double option value to print |
This function is used to display the current configuration options and their double values in a readable format.
Definition at line 984 of file init.c.
Referenced by dump_config().
| void opt_prt_int | ( | const char * | o, |
| const char * | name, | ||
| int | value ) |
Print an option and its value in a formatted manner for integer values.
| o | - option flag (e.g., "-C:") |
| name | - option name (e.g., "--cols") |
| value | - integer option value to print |
This function is used to display the current configuration options and their integer values in a readable format.
Definition at line 973 of file init.c.
Referenced by dump_config().
| void opt_prt_str | ( | const char * | o, |
| const char * | name, | ||
| const char * | value ) |
Print an option and its value in a formatted manner for integer values.
| o | - option flag (e.g., "-C:") |
| name | - option name (e.g., "--cols") |
| value | - integer option value to print |
This function is used to display the current configuration options and their integer values in a readable format.
Definition at line 962 of file init.c.
Referenced by dump_config().
| int parse_config | ( | Init * | init | ) |
parse the configuration file specified in init->minitrc and set Init struct values accordingly
Lines beginning with '#" are comments, discard. Copy line to tmp_str removing quotes, spaces, semicolons, and newlines. Record structure is "parse key=value pairs". Skip lines without '='. Set init struct values based on key. Skip unknown keys.
Definition at line 476 of file init.c.
References SIO::bblack, SIO::bblue, SIO::bcyan, Init::begx, Init::begy, SIO::bg, SIO::bg_clr_x, SIO::bgreen, SIO::black, SIO::blue, SIO::blue_gamma, SIO::bmagenta, SIO::bo_clr_x, SIO::borange, Init::brackets, SIO::bred, SIO::bwhite, SIO::byellow, Init::cmd, Init::cmd_all, Init::cols, SIO::cyan, Init::editor, expand_tilde(), Init::f_at_end_remove, Init::f_erase_remainder, Init::f_ignore_case, Init::f_ln, Init::f_squeeze, Init::f_strip_ansi, SIO::fg_clr_x, Init::fill_char, SIO::gray_gamma, SIO::green, SIO::green_gamma, Init::lines, SIO::ln_bg_clr_x, SIO::ln_clr_x, SIO::magenta, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_user, Init::minitrc, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, SIO::orange, Init::parent_cmd, Init::provider_cmd, Init::receiver_cmd, SIO::red, SIO::red_gamma, Init::select_max, Init::sio, str_to_bool(), str_to_double(), strnz__cpy(), Init::tab_stop, Init::title, wait_timeout, SIO::white, and SIO::yellow.
Referenced by mapp_initialization().
| int parse_opt_args | ( | Init * | init, |
| int | argc, | ||
| char ** | argv ) |
Parse command-line options and set Init struct values accordingly.
| init | - pointer to Init struct to be populated with option values |
| argc | - argument count from main() |
| argv | - argument vector from main() |
This function uses the argp library to parse command-line options defined in the options array. It updates the Init struct with values from the options and handles any special flags for dumping or writing configuration.
Definition at line 427 of file init.c.
References Init::argc, Init::argv, and destroy_argv().
Referenced by popup_form(), popup_menu(), popup_pick(), and popup_view().
| int write_config | ( | Init * | init | ) |
Write the current configuration to a file specified in init->minitrc.
| init | - pointer to Init struct containing current configuration |
The configuration is written in key=value format, one per line. Lines beginning with '#' are comments and are ignored when reading the config file. The file is created if it does not exist, and overwritten if it does exist
Definition at line 797 of file init.c.
References SIO::bblack, SIO::bblue, SIO::bcyan, Init::begx, Init::begy, SIO::bg_clr_x, SIO::bgreen, SIO::black, SIO::blue, SIO::blue_gamma, SIO::bmagenta, SIO::bo_clr_x, Init::brackets, SIO::bred, SIO::bwhite, SIO::byellow, Init::cmd, Init::cmd_all, Init::cols, SIO::cyan, Init::editor, Init::f_erase_remainder, Init::f_ignore_case, Init::f_ln, Init::f_squeeze, Init::f_strip_ansi, SIO::fg_clr_x, Init::fill_char, SIO::gray_gamma, SIO::green, SIO::green_gamma, Init::help_spec, Init::in_spec, Init::lines, SIO::ln_bg_clr_x, SIO::ln_clr_x, SIO::magenta, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_user, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, Init::out_spec, Init::parent_cmd, Perror(), Init::provider_cmd, Init::receiver_cmd, SIO::red, SIO::red_gamma, Init::select_max, Init::sio, strnz__cat(), strnz__cpy(), Init::tab_stop, Init::title, wait_timeout, SIO::white, and SIO::yellow.
Referenced by mapp_initialization(), and menu_cmd_processor().
| void zero_opt_args | ( | Init * | init | ) |
Initialize optional arguments in the Init struct to default values.
| init | - pointer to Init struct to be initialized This function sets all optional argument fields in the Init struct to their default values before parsing command-line options or configuration file. This ensures that any fields not specified by the user will have known default values. |
Definition at line 442 of file init.c.
References Init::begx, Init::begy, Init::cmd, Init::cmd_all, Init::cols, Init::f_help_spec, Init::f_in_spec, Init::f_mapp_desc, Init::f_mapp_spec, Init::f_out_spec, Init::f_provider_cmd, Init::f_receiver_cmd, Init::f_title, Init::help_spec, Init::in_spec, Init::lines, Init::mapp_spec, Init::out_spec, Init::parent_cmd, Init::provider_cmd, Init::receiver_cmd, and Init::title.
Referenced by popup_form(), popup_menu(), popup_pick(), and popup_view().