C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
init.c
Go to the documentation of this file.
1/** @file init.c
2 @brief Initialization for Menu Application Programs
3 @author Bill Waller
4 Copyright (c) 2025
5 MIT License
6 billxwaller@gmail.com
7 @date 2026-02-09
8 */
9
10/**
11 @defgroup init C-Menu Initialization
12 @brief Capture Data from the Environment, Command Line, and
13 Configuration File and Populate the Init and SIO Data Structures
14 @verbatim
15 SIO Struct for screen I/O settings (colors, gamma, etc.)
16 Init Struct for application settings (file paths, commands, flags, etc.)
17 @endverbatim
18 */
19
20#define _GNU_SOURCE
21#include <argp.h>
22#include <common.h>
23#include <locale.h>
24#include <stddef.h>
25#include <stdlib.h>
26#include <string.h>
27#include <unistd.h>
28#include <wchar.h>
29
30typedef enum {
31 BG = 257,
88} InitVariables;
89
90bool f_write_config = false;
91int write_config(Init *init);
92void display_version();
93
94// Init *init = nullptr;
95void mapp_initialization(Init *, int, char **);
96void zero_opt_args(Init *);
97int process_config_files(Init *);
98int process_config_file(char *, Init *);
99int parse_opt_args(Init *, int, char **);
100void opt_prt_char(const char *o, const char *name, const char *value);
101void opt_prt_str(const char *o, const char *name, const char *value);
102void opt_prt_int(const char *o, const char *name, int value);
103void opt_prt_double(const char *o, const char *name, double value);
104void opt_prt_bool(const char *o, const char *name, bool value);
105
106bool derive_file_spec(char *, char *, char *);
107void print_argp_doc(FILE *, char *, char *);
108int executor = 0;
109
111const char *argp_program_bug_address = "billxwaller@gmail.com";
112static char doc[] = _("C-Menu - User Interface Toolkit");
113static char args_doc[] = _("[INPUT] [OUTPUT] [HELP] [ARG4] [ARG5]");
114// const int opt_doc_col = 33;
115
116static struct argp_option options[] = {
117 {"f_write_config", 'W', 0, OPTION_ARG_OPTIONAL, "write configuration", 0},
118 {"minitrc", 'a', "file_spec", 0, "configuration file spec", 1},
119 {"parent_cmd", 'k', 0, 0, "parent command", 1},
120 {"begx", 'X', "number", 0, "begin on column", 2},
121 {"begy", 'Y', "number", 0, "begin on line", 2},
122 {"cols", 'C', "number", 0, "width in columns", 2},
123 {"lines", 'L', "number", 0, "height in lines", 2},
124 {"title", 'T', "text", 0, "Window title", 2},
125 {"out_spec", 'o', "file_spec", 0, "output file spec", 3},
126 {"cmd", 'c', "file_spec", 0, "view cmd, first file", 3},
127 {"cmd_all", 'A', "file_spec", 0, "view cmd, all files", 3},
128 {"help_spec", 'H', "file_spec", 0, "help file spec", 3},
129 {"in_spec", 'i', "file_spec", 0, "input file spec", 3},
130 {"log_level", 'l', "text", 0, "FATAL, ERROR, WARN, INFO, VERBOSE, DEBUG", 3},
131 {"mapp_spec", 'd', "file_spec", 0, "description file spec", 3},
132 {"provider_cmd", 'S', "file_spec", 0, "execute provider of piped input", 3},
133 {"receiver_cmd", 'R', "file_spec", 0, "execute receiver of piped output", 3},
134 {"select_max", 'n', "number", 0, "number of selections", 5},
135 {"f_erase_remainder", 'e', "bool", OPTION_ARG_OPTIONAL, "erase remainder of line on enter", 5},
136 {"f_strip_ansi", 'j', "bool", OPTION_ARG_OPTIONAL, "always strip ansi when writing", 5},
137 {"f_multiple_cmd_args", 'M', "bool", OPTION_ARG_OPTIONAL, "allow multiple command arguments", 5},
138 {"f_read_theme", 'r', "bool", OPTION_ARG_OPTIONAL, "read and process theme file", 5},
139 {"f_squeeze", 's', "bool", OPTION_ARG_OPTIONAL, "squeeze multiple blank lines", 5},
140 {"f_ignore_case", 'x', "bool", OPTION_ARG_OPTIONAL, "ignore case in search", 5},
141 {"p_view_files", 'v', "bool", OPTION_ARG_OPTIONAL, "File View in Pick", 5},
142 {"wrap", 'w', "bool", OPTION_ARG_OPTIONAL, "view wrap lines", 5},
143 {"f_ln", 'N', "bool", OPTION_ARG_OPTIONAL, "line numbers in view", 5},
144 {"fill_char", 'f', "char", 0, "field fill_char (_,.,empty)", 5},
145 {"brackets", 'u', "text", 0, "brackets around fields ([]{}<>)", 5},
146 {"editor", CM_EDITOR, "text", 0, "default editor", 5},
147 {"tab_stop", 't', "number", 0, "number of spaces per tab (4)", 5},
148 {"timeout_secs", 'Z', "text", 0, "seconds to wait for input", 3},
149 {"h_shift", 'z', "number", 0, "horizontal shift width (16)", 5},
150 {"border", 'b', "text", 0, "single, rounded, double, heavy, none", 5},
151 {"bg", BG, "hex_clr", 0, "Terminal (stdscr) background (#000000)", 6},
152 {"fg", FG, "hex_clr", 0, "Terminal (stdscr) foreground (#d0d0d0)", 6},
153 {"box_fg", BOX_FG, "hex_clr", 0, "box foreground (#d0d0d0)", 6},
154 {"box_bg", BOX_BG, "hex_clr", 0, "box background (#000000)", 6},
155 {"ind_fg", IND_FG, "hex_clr", 0, "indicator foreground (#d0d0d0)", 6},
156 {"ind_bg", IND_BG, "hex_clr", 0, "indicator background (#000000)", 6},
157 {"brackets_fg", BRACKETS_FG, "hex_clr", 0, "brackets foreground (#d0d0d0)", 6},
158 {"brackets_bg", BRACKETS_BG, "hex_clr", 0, "brackets background (#000000)", 6},
159 {"fill_char_fg", FILL_CHAR_FG, "hex_clr", 0, "fill character foreground (#d0d0d0)", 6},
160 {"fill_char_bg", FILL_CHAR_BG, "hex_clr", 0, "fill character background (#000000)", 6},
161 {"nt_fg", NT_FG, "hex_clr", 0, "normal foreground (#d0d0d0)", 6},
162 {"nt_bg", NT_BG, "hex_clr", 0, "normal background (#000000)", 6},
163 {"nt_rev_fg", NT_REV_FG, "hex_clr", 0, "normal reverse foreground (#000000)", 6},
164 {"nt_rev_bg", NT_REV_BG, "hex_clr", 0, "normal reverse background (#d0d0d0)", 6},
165 {"nt_hl_fg", NT_HL_FG, "hex_clr", 0, "normal highlight foreground (#ffffff)", 6},
166 {"nt_hl_bg", NT_HL_BG, "hex_clr", 0, "normal highlight background (#000000)", 6},
167 {"nt_hl_rev_fg", NT_HL_REV_FG, "hex_clr", 0, "normal highlight reverse foreground (#f00000)", 6},
168 {"nt_hl_rev_bg", NT_HL_REV_BG, "hex_clr", 0, "normal highlight reverse background (#d0d0d0)", 6},
169 {"ln_fg", LN_FG, "hex_clr", 0, "line number foreground (#0000b0)", 6},
170 {"ln_bg", LN_BG, "hex_clr", 0, "line number background (#202020)", 6},
171 {"cmdln_fg", CMDLN_FG, "hex_clr", 0, "line number foreground (#0000b0)", 6},
172 {"cmdln_bg", CMDLN_BG, "hex_clr", 0, "line number background (#202020)", 6},
173 {"title_fg", TITLE_FG, "hex_clr", 0, "title foreground (#d0d0d0)", 6},
174 {"title_bg", TITLE_BG, "hex_clr", 0, "title background (#000000)", 6},
175 {"ran_fg", RAN_FG, "hex_clr", 0, "ran foreground (#d0d0d0)", 6},
176 {"ran_bg", RAN_BG, "hex_clr", 0, "ran background (#000000)", 6},
177 {"blue_gamma", GM_BLUE, "float", 0, "blue_gamma (1.2)", 7},
178 {"gray_gamma", GM_GRAY, "float", 0, "gray gamma (1.2)", 7},
179 {"green_gamma", GM_GREEN, "float", 0, "green gamma (1.2)", 7},
180 {"red_gamma", GM_RED, "float", 0, "red gamma (View)", 7},
181 {"black", XBLACK, "hex_clr", 0, "black (#000000)", 8},
182 {"red", XRED, "hex_clr", 0, "red (#bf0000)", 8},
183 {"green", XGREEN, "hex_clr", 0, "green (#00cf00)", 8},
184 {"yellow", XYELLOW, "hex_clr", 0, "yellow (#efbf00)", 8},
185 {"blue", XBLUE, "hex_clr", 0, "blue (#0000FF)", 8},
186 {"magenta", XMAGENTA, "hex_clr", 0, "magenta (#9f009f)", 8},
187 {"cyan", XCYAN, "hex_clr", 0, "cyan (#00dfdf)", 8},
188 {"white", XWHITE, "hex_clr", 0, "white (#d0d0d0)", 8},
189 {"bblack", XBBLACK, "hex_clr", 0, "bright black (#7f7f7f)", 8},
190 {"bred", XBRED, "hex_clr", 0, "bright red (#FF3737)", 8},
191 {"bgreen", XBGREEN, "hex_clr", 0, "bright green (#00FF7f)", 8},
192 {"byellow", XBYELLOW, "hex_clr", 0, "bright yellow (#FFeF00)", 8},
193 {"bblue", XBBLUE, "hex_clr", 0, "bright blue (#00cfFF)", 8},
194 {"bmagenta", XMAGENTA, "hex_clr", 0, "bright magenta (#FF00FF)", 8},
195 {"bcyan", XBCYAN, "hex_clr", 0, "bright cyan (#00FFFF)", 8},
196 {"bwhite", XBWHITE, "hex_clr", 0, "bright white (#FFFFFF)", 8},
197 {"mapp_data", MAPP_DATA, "directory", 0, "data directory", 9},
198 {"mapp_help", MAPP_HELP, "directory", 0, "help directory", 9},
199 {"mapp_home", MAPP_HOME, "directory", 0, "home directory", 9},
200 {"mapp_msrc", MAPP_MSRC, "directory", 0, "source directory", 9},
201 {"mapp_user", MAPP_USER, "directory", 0, "user directory", 9},
202 {"mapp_theme", MAPP_THEME, "file", 0, "default theme file", 9},
203 {0},
204};
205
206static error_t
207parse_opt(int key, char *arg, struct argp_state *state) {
208 Init *init = state->input;
209 SIO *sio = init->sio;
210 switch (key) {
211 case 'W':
212 f_write_config = true;
213 break;
214 case 'a':
216 break;
217 case 'k':
219 break;
220 case 'C':
221 init->cols = atoi(arg);
222 break;
223 case 'L':
224 init->lines = atoi(arg);
225 break;
226 case 'T':
227 strnz__cpy(init->title, arg, MAXLEN - 1);
228 break;
229 case 'X':
230 init->begx = atoi(arg);
231 break;
232 case 'Y':
233 init->begy = atoi(arg);
234 break;
235 case 'A':
237 break;
238 case 'c':
239 strnz__cpy(init->cmd, arg, MAXLEN - 1);
240 break;
241 case 'd':
243 break;
244 case 'H':
246 break;
247 case 'i':
249 break;
250 case 'l':
252 if (!strcmp(arg, "SILENT"))
253 init->log_min_level = SILENT;
254 else if (!strcmp(arg, "DEBUG"))
255 init->log_min_level = DEBUG;
256 else if (!strcmp(arg, "INFO"))
257 init->log_min_level = INFO;
258 else if (!strcmp(arg, "WARN"))
259 init->log_min_level = WARN;
260 else if (!strcmp(arg, "ERROR"))
261 init->log_min_level = ERROR;
262 else if (!strcmp(arg, "FATAL"))
263 init->log_min_level = FATAL;
264 else
265 init->log_min_level = SILENT;
266 break;
267 case 'o':
269 break;
270 case 'R':
272 break;
273 case 'S':
275 break;
276 case 'e':
277 init->f_erase_remainder = true;
278 break;
279 case 'f':
281 break;
282 case 'j':
283 init->f_strip_ansi = true;
284 break;
285 case 'M':
286 init->f_multiple_cmd_args = true;
287 break;
288 case 'n':
289 init->select_max = atoi(arg);
290 break;
291 case 'N':
292 if (arg)
293 init->f_ln = str_to_bool(arg);
294 if (arg && arg[0] == 't')
295 init->f_ln = true;
296 else if (arg && arg[0] == 'f')
297 init->f_ln = false;
298 else
299 init->f_ln = true;
300 break;
301 case 'r':
302 init->f_read_theme = true;
303 break;
304 case 's':
305 init->f_squeeze = true;
306 break;
307 case 't':
308 init->tab_stop = atoi(arg);
309 if (init->tab_stop < 1)
310 init->tab_stop = 1;
311 break;
312 case 'Z':
313 init->timeout_secs = atoi(arg);
314 break;
315 case 'z':
316 init->h_shift = atoi(arg);
317 if (init->h_shift < 1)
318 init->h_shift = 1;
319 break;
320 case 'u':
321 strnz__cpy(init->brackets, arg, 2);
322 break;
323 case 'w':
324 if (arg && arg[0] == 't')
325 init->wrap = true;
326 else if (arg && arg[0] == 'f')
327 init->wrap = false;
328 else
329 init->wrap = true;
330 break;
331 case 'v':
332 init->p_view_files = true;
333 if (arg)
335 break;
336 case BG:
337 sscanf(arg, "#%06x", &sio->bg);
338 break;
339 case FG:
340 sscanf(arg, "#%06x", &sio->fg);
341 break;
342 case BORDER:
343 char c = arg[0];
344 if (c == 'r' || c == 'R')
345 sio->border = 'r';
346 else if (c == 's' || c == 'S')
347 sio->border = 's';
348 else if (c == 'd' || c == 'D')
349 sio->border = 'd';
350 else if (c == 'h' || c == 'H')
351 sio->border = 'h';
352 else
353 sio->border = 'n';
354 break;
355 case BOX_FG:
356 sscanf(arg, "#%06x", &sio->box_fg);
357 break;
358 case BOX_BG:
359 sscanf(arg, "#%06x", &sio->box_bg);
360 break;
361 case IND_FG:
362 sscanf(arg, "#%06x", &sio->ind_fg);
363 break;
364 case IND_BG:
365 sscanf(arg, "#%06x", &sio->ind_bg);
366 break;
367 case BRACKETS_FG:
368 sscanf(arg, "#%06x", &sio->brackets_fg);
369 break;
370 case BRACKETS_BG:
371 sscanf(arg, "#%06x", &sio->brackets_bg);
372 break;
373 case FILL_CHAR_FG:
374 sscanf(arg, "#%06x", &sio->fill_char_fg);
375 break;
376 case FILL_CHAR_BG:
377 sscanf(arg, "#%06x", &sio->fill_char_bg);
378 break;
379 case NT_FG:
380 sscanf(arg, "#%06x", &sio->nt_fg);
381 break;
382 case NT_BG:
383 sscanf(arg, "#%06x", &sio->nt_bg);
384 break;
385 case NT_REV_FG:
386 sscanf(arg, "#%06x", &sio->nt_rev_fg);
387 break;
388 case NT_REV_BG:
389 sscanf(arg, "#%06x", &sio->nt_rev_bg);
390 break;
391 case NT_HL_FG:
392 sscanf(arg, "#%06x", &sio->nt_hl_fg);
393 break;
394 case NT_HL_BG:
395 sscanf(arg, "#%06x", &sio->nt_hl_bg);
396 break;
397 case NT_HL_REV_FG:
398 sscanf(arg, "#%06x", &sio->nt_hl_rev_fg);
399 break;
400 case NT_HL_REV_BG:
401 sscanf(arg, "#%06x", &sio->nt_hl_rev_bg);
402 break;
403 case TITLE_FG:
404 sscanf(arg, "#%06x", &sio->title_fg);
405 break;
406 case TITLE_BG:
407 sscanf(arg, "#%06x", &sio->title_bg);
408 break;
409 case LN_FG:
410 sscanf(arg, "#%06x", &sio->ln_fg);
411 break;
412 case LN_BG:
413 sscanf(arg, "#%06x", &sio->ln_bg);
414 break;
415 case CMDLN_FG:
416 sscanf(arg, "#%06x", &sio->cmdln_fg);
417 break;
418 case CMDLN_BG:
419 sscanf(arg, "#%06x", &sio->cmdln_bg);
420 break;
421 case RAN_FG:
422 sscanf(arg, "#%06x", &sio->ran_fg);
423 break;
424 case RAN_BG:
425 sscanf(arg, "#%06x", &sio->ran_bg);
426 break;
427 case GM_BLUE:
429 break;
430 case GM_GRAY:
432 break;
433 case GM_GREEN:
435 break;
436 case GM_RED:
438 break;
439 case MAPP_USER:
441 break;
442 case MAPP_DATA:
444 break;
445 case MAPP_HELP:
447 break;
448 case MAPP_HOME:
450 break;
451 case MAPP_MSRC:
453 break;
454 case MAPP_SPEC:
456 break;
457 case HELP_SPEC:
459 break;
460 case MAPP_THEME:
462 break;
463 case ARGP_KEY_ARG:
464 if (state->arg_num >= 35)
465 argp_usage(state);
466 init->argv[state->arg_num] = strdup(arg);
467 break;
468 case ARGP_KEY_END:
469 init->argc = state->arg_num;
470 init->argv[state->arg_num + 1] = nullptr;
471 break;
472 default:
473 return ARGP_ERR_UNKNOWN;
474 }
475 return 0;
476}
477
478static struct argp argp = {options, parse_opt, args_doc, doc,
479 nullptr, nullptr, nullptr};
480
481/** @brief Main initialization function for MAPP - Menu Application
482 @ingroup init
483 @param init - pointer to Init struct to be initialized
484 @param argc - argument count from main()
485 @param argv - argument vector from main()
486 @code
487 1. Read environment variables and set defaults
488 2. Parse configuration file
489 3. Parse command-line options
490 4. Set up SIO struct with colors and other settings
491 5. Handle special options like help and version
492 @endcode
493 */
494void mapp_initialization(Init *init, int argc, char **argv) {
495 char term[MAXLEN];
496 char tmp_str[MAXLEN];
497 char *e;
498 setlocale(LC_ALL, "en_US.UTF-8");
499
500 init->sio = (SIO *)calloc(1, sizeof(SIO));
501 if (!init->sio) {
502 ui_perror(_("calloc init->sio failed"));
503 exit(EXIT_FAILURE);
504 }
505 SIO *sio = init->sio;
506 if (!init) {
507 ssnprintf(tmp_str, sizeof(tmp_str), "%s",
508 _("init struct not allocated on entry"));
509 ui_abend(-1, tmp_str);
510 exit(-1);
511 }
512 e = getenv("CMENU_HOME");
513 if (!e || *e == '\0')
514 strnz__cpy(init->mapp_home, "~/menuapp", MAXLEN);
515 else
517
518 if (init->mapp_home[0] != '\0') {
520 if (!verify_dir(init->mapp_home, R_OK))
521 ui_abend(-1, _("MAPP_HOME directory invalid"));
522 }
523 // CMENU_RC should be an absolute path
524 e = getenv("CMENU_RC");
525 if (!e || *e == '\0') {
527 strnz__cat(init->minitrc, "/.minitrc", MAXLEN);
528 } else
530 if (init->mapp_user[0] == '\0') {
532 strnz__cat(init->mapp_user, "/user", MAXLEN - 1);
533 }
534 if (init->mapp_theme[0] == '\0') {
536 strnz__cat(init->mapp_theme, "/themes/default", MAXLEN - 1);
537 }
538 if (init->mapp_msrc[0] == '\0') {
540 strnz__cat(init->mapp_msrc, "/msrc", MAXLEN - 1);
541 }
542 if (init->mapp_data[0] == '\0') {
544 strnz__cat(init->mapp_data, "/data", MAXLEN - 1);
545 }
546 if (init->mapp_help[0] == '\0') {
548 strnz__cat(init->mapp_help, "/help", MAXLEN - 1);
549 }
550 init->mapp_spec[0] = '\0'; /**< menu specification file */
551 // Set default colors and settings in SIO struct
552 // These can be overridden by the config file or command-line options
553 // Included here to ensure SIO has valid defaults even if config parsing fails
554
555 sio->border = 'r'; /**< default border style */
556 sio->bg = 0x000000;
557 sio->fg = 0xc0c0c0;
558 sio->border = 'r';
559 sio->box_fg = 0xf00000;
560 sio->box_bg = 0x000000;
561 sio->ind_fg = 0xf00000;
562 sio->ind_bg = 0x000000;
563 sio->ran_fg = 0xf00000;
564 sio->ran_bg = 0x000000;
565 sio->title_fg = 0xf0f0f0;
566 sio->title_bg = 0x000000;
567 sio->nt_fg = 0xc0c0c0;
568 sio->nt_bg = 0x000000;
569 sio->nt_rev_fg = 0x000000;
570 sio->nt_rev_bg = 0xc0c0c0;
571 sio->nt_hl_fg = 0xf00000;
572 sio->nt_hl_bg = 0x000000;
573 sio->nt_hl_rev_fg = 0x000000;
574 sio->nt_hl_rev_bg = 0xc0c0c0;
575 sio->ln_fg = 0x0070ff;
576 sio->ln_bg = 0x101010;
577 sio->cmdln_fg = 0xd0d0d0;
578 sio->cmdln_bg = 0x000000;
579 init->f_erase_remainder = true; /**< erase remainder on enter */
580 init->brackets[0] = '\0'; /**< field enclosure brackets */
581 strnz__cpy(init->fill_char, " ", MAXLEN - 1); /**< field fill character */
582 e = getenv("TERM");
583 if (e == nullptr || *e == '\0')
584 strnz__cpy(term, "xterm-256color", MAXLEN);
585 else
586 strnz__cpy(term, e, MAXLEN - 1);
587 e = getenv("EDITOR");
588 if (e && *e != '\0')
589 strnz__cpy(init->editor, "vi", MAXLEN - 1);
590 else
595 ui_log(INFO, "mapp_initialization");
596 ui_log(INFO, _("config files processed"));
597 init->mapp_spec[0] = '\0';
598 init->argc = argc;
599 argp_parse(&argp, argc, argv, 0, 0, init);
602 if (f_write_config) {
603 write_config(init);
604 exit(EXIT_SUCCESS);
605 }
606}
607/** @brief Parse command-line options and set Init struct values accordingly
608 @ingroup init
609 @param init - pointer to Init struct to be populated with option values
610 @param argc - argument count from main()
611 @param argv - argument vector from main()
612 @returns 0 on success, -1 on failure
613 @details This function uses the argp library to parse command-line
614 options defined in the options array. It updates the Init struct with
615 values from the options and handles any special flags for dumping or
616 writing configuration.
617 */
618int parse_opt_args(Init *init, int argc, char **argv) {
619 init->argc = destroy_argv(init->argc, init->argv);
620 argp_parse(&argp, argc, argv, 0, 0, init);
621 return 0;
622}
623
624/** @brief Initialize optional arguments in the Init struct to default
625 values
626 @ingroup init
627 @param init - pointer to Init struct to be initialized This function
628 sets all optional argument fields in the Init struct to their default
629 values before parsing command-line options or configuration file. This
630 ensures that any fields not specified by the user will have known default
631 values.
632 */
633void zero_opt_args(Init *init) {
634 init->lines = 0;
635 init->cols = 0;
636 init->begx = 0;
637 init->begy = 0;
638 init->f_mapp_desc = false;
639 init->f_provider_cmd = false;
640 init->f_receiver_cmd = false;
641 init->f_title = false;
642 init->f_mapp_spec = false;
643 init->f_help_spec = false;
644 init->f_in_spec = false;
645 init->f_out_spec = false;
646 init->p_view_files = false;
647 init->h_shift = 0;
648 init->mapp_spec[0] = init->help_spec[0] = '\0';
649 init->provider_cmd[0] = init->receiver_cmd[0] = '\0';
650 init->title[0] = '\0';
651 init->cmd[0] = init->cmd_all[0] = '\0';
652 init->parent_cmd[0] = '\0';
653 init->in_spec[0] = init->out_spec[0] = '\0';
654 init->help_spec[0] = '\0';
655 init->in_spec[0] = '\0';
656 init->out_spec[0] = '\0';
657}
658/** @brief parse the configuration file specified in init->minitrc and set
659 Init struct values accordingly
660 @ingroup init
661 @returns on success, -1 on failure
662 @details Lines beginning with '#" are comments, discard.
663 Copy line to tmp_str removing quotes, spaces, semicolons, and
664 newlines.
665 Record structure is "parse key=value pairs".
666 Skip lines without '='.
667 Set init struct values based on key.
668 Skip unknown keys. */
669int process_config_files(Init *init) {
670 char config_file_name[MAXLEN];
671 int rc;
672 if (!init->minitrc[0]) {
673 char *e = getenv("MINITRC");
674 if (e)
676 else
677 strnz__cpy(init->minitrc, "~/.minitrc", MAXLEN - 1);
678 }
679
681 strnz__cpy(config_file_name, init->minitrc, MAXLEN - 1);
682 rc = process_config_file(config_file_name, init);
683
685 strnz__cpy(config_file_name, init->mapp_theme, MAXLEN - 1);
686 rc = process_config_file(config_file_name, init);
687 return rc;
688}
689
690int process_config_file(char *config_file_name, Init *init) {
691 char include_file_name[MAXLEN];
692 char tmp_str[MAXLEN];
693 char *src_p, *dp;
694 SIO *sio = init->sio;
695 char hex_clr_str[8];
696 char key[MAXLEN];
697 char value[MAXLEN];
698 FILE *config_fp = fopen(config_file_name, "r");
699 char quote_char = '\0';
700 if (!config_fp) {
701 fprintf(stderr, "failed to read file: %s %s\n", config_file_name, strerror(errno));
702 return (-1);
703 }
704 while (fgets(tmp_str, sizeof(tmp_str), config_fp)) {
705 bool inquotes = false;
706 if (tmp_str[0] == '#')
707 continue;
708 src_p = tmp_str;
709 key[0] = '\0';
710 dp = key;
711 // copy delimited by "=" into value
712 while (*src_p != '\0') {
713 if (*src_p == '\n')
714 *dp = *src_p = '\0';
715 if (*src_p == '=') {
716 *dp = '\0';
717 src_p++;
718 break;
719 }
720 if (*src_p == '"' && *src_p == ' ') {
721 src_p++;
722 continue;
723 }
724 *dp++ = *src_p++;
725 }
726 value[0] = '\0';
727 dp = value;
728 // copy delimited by newline or unquoted "#" into value, removing quotes, spaces, semicolons, and newlines, but respecting quotes
729 while (*src_p != '\0') {
730 if ((*src_p == '"' || *src_p == '\'') && (*(src_p + 1) != '\\')) {
731 if (!inquotes) {
732 inquotes = true;
733 quote_char = *src_p++;
734 } else if (*src_p == quote_char) {
735 inquotes = false;
736 quote_char = '\0';
737 }
738 }
739 if (!inquotes) {
740 if (*src_p == '#') {
741 if (unstr_hex_clr(hex_clr_str, src_p)) {
742 strnz__cpy(value, hex_clr_str, MAXLEN - 1);
743 dp = value + strlen(value);
744 }
745 break;
746 }
747 }
748 if (*src_p == ' ' || *src_p == ';') {
749 src_p++;
750 continue;
751 }
752 if (*src_p == '\n') {
753 *src_p = '\0';
754 break;
755 }
756 *dp++ = *src_p++;
757 }
758 *dp = '\0';
759 if (key[0] == '\0')
760 continue;
761 if (value[0] == '\0')
762 continue;
763 if (!strcmp(key, "include")) {
764 strnz__cpy(include_file_name, value, MAXLEN - 1);
765 expand_tilde(include_file_name, MAXLEN - 1);
766 process_config_file(include_file_name, init);
767 continue;
768 }
769 if (!strcmp(key, "minitrc")) {
770 strnz__cpy(init->minitrc, value, MAXLEN - 1);
771 continue;
772 }
773 if (!strcmp(key, "lines")) {
774 init->lines = atoi(value);
775 continue;
776 }
777 if (!strcmp(key, "cols")) {
778 init->cols = atoi(value);
779 continue;
780 }
781 if (!strcmp(key, "begy")) {
782 init->begy = atoi(value);
783 continue;
784 }
785 if (!strcmp(key, "begx")) {
786 init->begx = atoi(value);
787 continue;
788 }
789 if (!strcmp(key, "f_ln")) {
790 init->f_ln = str_to_bool(value);
791 continue;
792 }
793 if (!strcmp(key, "f_at_end_remove")) {
795 continue;
796 }
797 if (!strcmp(key, "f_erase_remainder")) {
799 continue;
800 }
801 if (!strcmp(key, "brackets")) {
802 strnz__cpy(init->brackets, value, 2);
803 continue;
804 }
805 if (!strcmp(key, "fill_char")) {
806 if (strlen(value) > 1)
807 value[1] = '\0';
808 if (wcwidth((int)value[0]) > 1)
809 value[0] = '?';
810 strnz__cpy(init->fill_char, value, 4);
811 continue;
812 }
813 if (!strcmp(key, "f_ignore_case")) {
815 continue;
816 }
817 if (!strcmp(key, "p_view_files")) {
818 init->p_view_files = str_to_bool(value);
819 continue;
820 }
821 if (!strcmp(key, "f_read_theme")) {
822 init->f_read_theme = str_to_bool(value);
823 continue;
824 }
825 if (!strcmp(key, "f_squeeze")) {
826 init->f_squeeze = str_to_bool(value);
827 continue;
828 }
829 if (!strcmp(key, "f_strip_ansi")) {
830 init->f_strip_ansi = str_to_bool(value);
831 continue;
832 }
833 if (!strcmp(key, "f_multiple_cmd_args")) {
835 continue;
836 }
837 if (!strcmp(key, "select_max")) {
838 init->select_max = atoi(value);
839 continue;
840 }
841 if (!strcmp(key, "tab_stop")) {
842 init->tab_stop = atoi(value);
843 continue;
844 }
845 if (!strcmp(key, "timeout_secs")) {
846 init->timeout_secs = atoi(value);
847 continue;
848 }
849 if (!strcmp(key, "h_shift")) {
850 init->h_shift = atoi(value);
851 continue;
852 }
853 if (!strcmp(key, "wrap")) {
854 init->wrap = str_to_bool(value);
855 continue;
856 }
857 if (!strcmp(key, "title")) {
858 strnz__cpy(init->title, value, MAXLEN - 1);
859 continue;
860 }
861 if (!strcmp(key, "cmd")) {
862 strnz__cpy(init->cmd, value, MAXLEN - 1);
863 continue;
864 }
865 if (!strcmp(key, "cmd_all")) {
866 strnz__cpy(init->cmd_all, value, MAXLEN - 1);
867 continue;
868 }
869 if (!strcmp(key, "parent_cmd")) {
871 continue;
872 }
873 if (!strcmp(key, "provider_cmd")) {
875 continue;
876 }
877 if (!strcmp(key, "receiver_cmd")) {
879 continue;
880 }
881 if (!strcmp(key, "editor")) {
882 strnz__cpy(init->editor, value, MAXLEN - 1);
883 continue;
884 }
885 if (!strcmp(key, "border")) {
886 char c = value[0];
887 if (c == 'r' || c == 'R')
888 sio->border = 'r';
889 else if (c == 's' || c == 'S')
890 sio->border = 's';
891 else if (c == 'd' || c == 'D')
892 sio->border = 'd';
893 else if (c == 'h' || c == 'H')
894 sio->border = 'h';
895 else
896 sio->border = 'n';
897 continue;
898 }
899 if (!strcmp(key, "fg")) {
900 sscanf(value, "#%06x", &sio->fg);
901 continue;
902 }
903 if (!strcmp(key, "bg")) {
904 sscanf(value, "#%06x", &sio->bg);
905 continue;
906 }
907 if (!strcmp(key, "box_fg")) {
908 sscanf(value, "#%06x", &sio->fg);
909 continue;
910 }
911 if (!strcmp(key, "box_bg")) {
912 sscanf(value, "#%06x", &sio->box_bg);
913 continue;
914 }
915 if (!strcmp(key, "ind_fg")) {
916 sscanf(value, "#%06x", &sio->ind_fg);
917 continue;
918 }
919 if (!strcmp(key, "ind_bg")) {
920 sscanf(value, "#%06x", &sio->ind_bg);
921 continue;
922 }
923 if (!strcmp(key, "brackets_fg")) {
924 sscanf(value, "#%06x", &sio->brackets_fg);
925 continue;
926 }
927 if (!strcmp(key, "brackets_bg")) {
928 sscanf(value, "#%06x", &sio->brackets_bg);
929 continue;
930 }
931 if (!strcmp(key, "fill_char_fg")) {
932 sscanf(value, "#%06x", &sio->fill_char_fg);
933 continue;
934 }
935 if (!strcmp(key, "fill_char_bg")) {
936 sscanf(value, "#%06x", &sio->fill_char_bg);
937 continue;
938 }
939 if (!strcmp(key, "ln_fg")) {
940 sscanf(value, "#%06x", &sio->ln_fg);
941 continue;
942 }
943 if (!strcmp(key, "ln_bg")) {
944 sscanf(value, "#%06x", &sio->ln_bg);
945 continue;
946 }
947 if (!strcmp(key, "cmdln_fg")) {
948 sscanf(value, "#%06x", &sio->cmdln_fg);
949 continue;
950 }
951 if (!strcmp(key, "cmdln_bg")) {
952 sscanf(value, "#%06x", &sio->cmdln_bg);
953 continue;
954 }
955 if (!strcmp(key, "nt_fg")) {
956 sscanf(value, "#%06x", &sio->nt_fg);
957 continue;
958 }
959 if (!strcmp(key, "nt_bg")) {
960 sscanf(value, "#%06x", &sio->nt_bg);
961 continue;
962 }
963 if (!strcmp(key, "nt_rev_fg")) {
964 sscanf(value, "#%06x", &sio->nt_rev_fg);
965 continue;
966 }
967 if (!strcmp(key, "nt_rev_bg")) {
968 sscanf(value, "#%06x", &sio->nt_rev_bg);
969 continue;
970 }
971 if (!strcmp(key, "nt_hl_fg")) {
972 sscanf(value, "#%06x", &sio->nt_hl_fg);
973 continue;
974 }
975 if (!strcmp(key, "nt_hl_bg")) {
976 sscanf(value, "#%06x", &sio->nt_hl_bg);
977 continue;
978 }
979 if (!strcmp(key, "nt_hl_rev_fg")) {
980 sscanf(value, "#%06x", &sio->nt_hl_rev_fg);
981 continue;
982 }
983 if (!strcmp(key, "nt_hl_rev_bg")) {
984 sscanf(value, "#%06x", &sio->nt_hl_rev_bg);
985 continue;
986 }
987 if (!strcmp(key, "title_fg")) {
988 sscanf(value, "#%06x", &sio->title_fg);
989 continue;
990 }
991 if (!strcmp(key, "title_bg")) {
992 sscanf(value, "#%06x", &sio->title_bg);
993 continue;
994 }
995 if (!strcmp(key, "ran_fg")) {
996 sscanf(value, "#%06x", &sio->ran_fg);
997 continue;
998 }
999 if (!strcmp(key, "ran_bg")) {
1000 sscanf(value, "#%06x", &sio->ran_bg);
1001 continue;
1002 }
1003 if (!strcmp(key, "red_gamma")) {
1004 sio->red_gamma = str_to_double(value);
1005 continue;
1006 }
1007 if (!strcmp(key, "green_gamma")) {
1009 continue;
1010 }
1011 if (!strcmp(key, "blue_gamma")) {
1012 sio->blue_gamma = str_to_double(value);
1013 continue;
1014 }
1015 if (!strcmp(key, "gray_gamma")) {
1016 sio->gray_gamma = str_to_double(value);
1017 continue;
1018 }
1019 if (!strcmp(key, "black")) {
1020 sscanf(value, "#%06x", &sio->black);
1021 continue;
1022 }
1023 if (!strcmp(key, "red")) {
1024 sscanf(value, "#%06x", &sio->red);
1025 continue;
1026 }
1027 if (!strcmp(key, "green")) {
1028 sscanf(value, "#%06x", &sio->green);
1029 continue;
1030 }
1031 if (!strcmp(key, "yellow")) {
1032 sscanf(value, "#%06x", &sio->yellow);
1033 continue;
1034 }
1035 if (!strcmp(key, "blue")) {
1036 sscanf(value, "#%06x", &sio->blue);
1037 continue;
1038 }
1039 if (!strcmp(key, "magenta")) {
1040 sscanf(value, "#%06x", &sio->magenta);
1041 continue;
1042 }
1043 if (!strcmp(key, "cyan")) {
1044 sscanf(value, "#%06x", &sio->cyan);
1045 continue;
1046 }
1047 if (!strcmp(key, "white")) {
1048 sscanf(value, "#%06x", &sio->white);
1049 continue;
1050 }
1051 if (!strcmp(key, "orange")) {
1052 sscanf(value, "#%06x", &sio->orange);
1053 continue;
1054 }
1055 if (!strcmp(key, "bblack")) {
1056 sscanf(value, "#%06x", &sio->bblack);
1057 continue;
1058 }
1059 if (!strcmp(key, "bred")) {
1060 sscanf(value, "#%06x", &sio->bred);
1061 continue;
1062 }
1063 if (!strcmp(key, "bgreen")) {
1064 sscanf(value, "#%06x", &sio->bgreen);
1065 continue;
1066 }
1067 if (!strcmp(key, "byellow")) {
1068 sscanf(value, "#%06x", &sio->byellow);
1069 continue;
1070 }
1071 if (!strcmp(key, "bblue")) {
1072 sscanf(value, "#%06x", &sio->bblue);
1073 continue;
1074 }
1075 if (!strcmp(key, "bmagenta")) {
1076 sscanf(value, "#%06x", &sio->bmagenta);
1077 continue;
1078 }
1079 if (!strcmp(key, "bcyan")) {
1080 sscanf(value, "#%06x", &sio->bcyan);
1081 continue;
1082 }
1083 if (!strcmp(key, "bwhite")) {
1084 sscanf(value, "#%06x", &sio->bwhite);
1085 continue;
1086 }
1087 if (!strcmp(key, "borange")) {
1088 sscanf(value, "#%06x", &sio->borange);
1089 continue;
1090 }
1091 if (!strcmp(key, "mapp_spec")) {
1092 strnz__cpy(init->mapp_spec, value, MAXLEN - 1);
1093 continue;
1094 }
1095 if (!strcmp(key, "mapp_data")) {
1096 strnz__cpy(init->mapp_data, value, MAXLEN - 1);
1097 continue;
1098 }
1099 if (!strcmp(key, "mapp_help")) {
1100 strnz__cpy(init->mapp_help, value, MAXLEN - 1);
1101 continue;
1102 }
1103 if (!strcmp(key, "mapp_home")) {
1104 strnz__cpy(init->mapp_home, value, MAXLEN - 1);
1105 continue;
1106 }
1107 if (!strcmp(key, "mapp_msrc")) {
1108 strnz__cpy(init->mapp_msrc, value, MAXLEN - 1);
1109 continue;
1110 }
1111 if (!strcmp(key, "mapp_user")) {
1112 strnz__cpy(init->mapp_user, value, MAXLEN - 1);
1113 continue;
1114 }
1115 if (!strcmp(key, "mapp_theme")) {
1116 strnz__cpy(init->mapp_theme, value, MAXLEN - 1);
1117 continue;
1118 }
1119 if (!strcmp(key, "log_level")) {
1120 str_to_upper(value);
1121 if (!strcmp(value, "SILENT"))
1122 init->log_min_level = SILENT;
1123 else if (!strcmp(value, "DEBUG"))
1124 init->log_min_level = DEBUG;
1125 else if (!strcmp(value, "INFO"))
1126 init->log_min_level = INFO;
1127 else if (!strcmp(value, "WARN"))
1128 init->log_min_level = WARN;
1129 else if (!strcmp(value, "ERROR"))
1130 init->log_min_level = ERROR;
1131 else if (!strcmp(value, "FATAL"))
1132 init->log_min_level = FATAL;
1133 else
1134 init->log_min_level = SILENT;
1135 continue;
1136 }
1137 }
1138 (void)fclose(config_fp);
1139 return 0;
1140}
1141/** @brief Write the current configuration to a file specified in
1142 init->minitrc
1143 @ingroup init
1144 @param init - pointer to Init struct containing current configuration
1145 @returns 0 on success, -1 on failure
1146 @details The configuration is written in key=value format, one per line.
1147 Lines beginning with '#' are comments and are ignored when reading
1148 the config file.
1149 The file is created if it does not exist, and overwritten if it
1150 does exist
1151 */
1152int write_config(Init *init) {
1153 char *e;
1154 char minitrc_dmp[MAXLEN];
1155 char tmp_str[MAXLEN];
1156 SIO *sio = init->sio;
1157 e = getenv("CMENU_HOME");
1158 minitrc_dmp[0] = '\0';
1159 char config_s[MAXLEN];
1160 if (e) {
1161 strnz__cpy(minitrc_dmp, e, MAXLEN - 1);
1162 strnz__cat(minitrc_dmp, "/", MAXLEN - 1);
1163 }
1164 strnz__cat(minitrc_dmp, "minitrc.dmp", MAXLEN - 1);
1165 ui_log(INFO, _("writing config file to: %s"), minitrc_dmp);
1166 FILE *minitrc_fp = fopen(minitrc_dmp, "w");
1167 if (minitrc_fp == (FILE *)0) {
1168 ssnprintf(em0, MAXLEN - 1, _("failed to open file: %s"), minitrc_dmp);
1169 ui_log(ERROR, "em0");
1170 return (-1);
1171 }
1172 (void)fprintf(minitrc_fp, "# %s\n", minitrc_dmp);
1173 char *doc_tbl[50] = {
1174 _("# C-Menu example configuration file"),
1175 "#",
1176 _("# This file is generated by C-Menu when run with the -W option."),
1177 _("# Copy this file and edit the copy because this file will be"),
1178 _("# overwritten each time C-Menu is run with the - W option."),
1179 "#",
1180 _("# C-Menu processes key value pairs in reading order from its"),
1181 _("# main configuraiton file, ~/ menuapp /.minitrc, and any other"),
1182 _("# configuration files sourced with include statements such as"),
1183 _("# the following:"),
1184 "#",
1185 _("# include = ~/menuapp/theme/default"),
1186 "#",
1187 _("# Assuming your configuration file is in ~/menuapp/theme/Red,"),
1188 _("# you could create a symbolic link named default that points to"),
1189 _("# Red, and then include default in your main configuration file."),
1190 _("# (Actually ~/menuapp/.minitrc already includes default, so you"),
1191 _("# would only need to create the theme file and the symbolic link."),
1192 "#",
1193 _("# ln -s Red default"),
1194 "#",
1195 _("# Key value pairs included from configuration files are"),
1196 _("# processed in reading order as they are included."),
1197 "#",
1198 _("# This is significant in the event that a key is included more"),
1199 _("# than once in the configuration file and / or included files."),
1200 _("# Only the last value read for a key will be used by C-Menu."),
1201 "#",
1202 _("# If you want to override key values in the C-Menu configuration"),
1203 _("# file, you can do so by inserting an include statement for a"),
1204 _("# supplemental configuration file below the keys you want to"),
1205 _("# override in the C-Menu configuration file. Conversely, if you"),
1206 _("# want to use a supplemental configuration as the default,"),
1207 _("# include it first."),
1208 "#",
1209 _("# Parsing: Lines beginning with # are comments and are ignored."),
1210 _("# Lines containing key=value pairs are parsed and the key and"),
1211 _("# value are extracted. Lines without an '=' are ignored. Values"),
1212 _("# are stripped of leading and trailing whitespace and quotes."),
1213 _("# Values can be enclosed in single or double quotes to preserve"),
1214 _("# leading and trailing whitespace. Values can also be specified"),
1215 _("# as hex color codes such as #ff0000 for red. If a value is"),
1216 _("# specified as a hex color code, it is parsed and stored as a"),
1217 _("# hex color code in the configuration. An unquoted '#' that is"),
1218 _("# not part of a six digit hex color code and after key values"),
1219 _("# have been extracted is the beginning of a comment."), ""};
1220 for (int i = 0; doc_tbl[i][0] != '\0'; i++)
1221 (void)fprintf(minitrc_fp, "%s\n", doc_tbl[i]);
1222 (void)fprintf(minitrc_fp, "#\n");
1223 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "parent_cmd", init->parent_cmd);
1224 print_argp_doc(minitrc_fp, config_s, "parent_cmd");
1225 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "cols", init->cols);
1226 print_argp_doc(minitrc_fp, config_s, "cols");
1227 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "lines", init->lines);
1228 print_argp_doc(minitrc_fp, config_s, "lines");
1229 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "title", init->title);
1230 print_argp_doc(minitrc_fp, config_s, "title");
1231 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begx", init->begx);
1232 print_argp_doc(minitrc_fp, config_s, "begx");
1233 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begy", init->begy);
1234 print_argp_doc(minitrc_fp, config_s, "begy");
1235 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd_all", init->cmd_all);
1236 print_argp_doc(minitrc_fp, config_s, "cmd_all");
1237 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd", init->cmd);
1238 print_argp_doc(minitrc_fp, config_s, "cmd");
1239 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_spec", init->mapp_spec);
1240 print_argp_doc(minitrc_fp, config_s, "mapp_spec");
1241 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "help_spec", init->help_spec);
1242 print_argp_doc(minitrc_fp, config_s, "help_spec");
1243 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "in_spec", init->in_spec);
1244 print_argp_doc(minitrc_fp, config_s, "in_spec");
1245 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "out_spec", init->out_spec);
1246 print_argp_doc(minitrc_fp, config_s, "out_spec");
1247
1248 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "log_level", ui_log_ctx.level[init->log_min_level]);
1249 print_argp_doc(minitrc_fp, config_s, "log_level");
1250
1251 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "receiver_cmd", init->receiver_cmd);
1252 print_argp_doc(minitrc_fp, config_s, "receiver_cmd");
1253 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "provider_cmd", init->provider_cmd);
1254 print_argp_doc(minitrc_fp, config_s, "provider_cmd");
1255 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_erase_remainder", init->f_erase_remainder ? "true" : "false");
1256 print_argp_doc(minitrc_fp, config_s, "f_erase_remainder");
1257 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fill_char", init->fill_char);
1258 print_argp_doc(minitrc_fp, config_s, "fill_char");
1259 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_strip_ansi", init->f_strip_ansi ? "true" : "false");
1260 print_argp_doc(minitrc_fp, config_s, "f_strip_ansi");
1261 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_multiple_cmd_args", init->f_multiple_cmd_args ? "true" : "false");
1262 print_argp_doc(minitrc_fp, config_s, "f_multiple_cmd_args");
1263 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "select_max", init->select_max);
1264 print_argp_doc(minitrc_fp, config_s, "select_max");
1265
1266 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ln", init->f_ln ? "true" : "false");
1267 print_argp_doc(minitrc_fp, config_s, "f_ln");
1268
1269 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_squeeze", init->f_squeeze ? "true" : "false");
1270 print_argp_doc(minitrc_fp, config_s, "f_squeeze");
1271 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "tab_stop", init->tab_stop);
1272 print_argp_doc(minitrc_fp, config_s, "tab_stop");
1273
1274 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "timeout_secs", init->timeout_secs);
1275 print_argp_doc(minitrc_fp, config_s, "timeout_secs");
1276
1277 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "h_shift", init->h_shift);
1278 print_argp_doc(minitrc_fp, config_s, "h_shift");
1279 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "brackets", init->brackets);
1280 print_argp_doc(minitrc_fp, config_s, "brackets");
1281
1282 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "wrap", init->wrap ? "true" : "false");
1283 print_argp_doc(minitrc_fp, config_s, "wrap");
1284
1285 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ignore_case", init->f_ignore_case ? "true" : "false");
1286 print_argp_doc(minitrc_fp, config_s, "f_ignore_case");
1287 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "p_view_files", init->p_view_files ? "true" : "false");
1288 print_argp_doc(minitrc_fp, config_s, "p_view_files");
1289 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_read_theme", init->f_read_theme ? "true" : "false");
1290 print_argp_doc(minitrc_fp, config_s, "f_read_theme");
1291 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "editor", init->editor);
1292 print_argp_doc(minitrc_fp, config_s, "editor");
1293 ssnprintf(config_s, MAXLEN - 1, "%s=%c", "border", sio->border);
1294 print_argp_doc(minitrc_fp, config_s, "border");
1295 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bg", sio->bg);
1296 print_argp_doc(minitrc_fp, config_s, "bg");
1297 ssnprintf(config_s, MAXLEN - 1, "%s=#%6x", "fg", sio->fg);
1298 print_argp_doc(minitrc_fp, config_s, "fg");
1299 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "box_fg", sio->box_fg);
1300 print_argp_doc(minitrc_fp, config_s, "box_fg");
1301 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "box_bg", sio->box_bg);
1302 print_argp_doc(minitrc_fp, config_s, "box_bg");
1303 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ind_fg", sio->ind_fg);
1304 print_argp_doc(minitrc_fp, config_s, "ind_fg");
1305 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ind_bg", sio->ind_bg);
1306 print_argp_doc(minitrc_fp, config_s, "ind_bg");
1307 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "brackets_fg", sio->brackets_fg);
1308 print_argp_doc(minitrc_fp, config_s, "brackets_fg");
1309 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "brackets_bg", sio->brackets_bg);
1310 print_argp_doc(minitrc_fp, config_s, "brackets_bg");
1311 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "fill_char_fg", sio->fill_char_fg);
1312 print_argp_doc(minitrc_fp, config_s, "fill_char_fg");
1313 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "fill_char_bg", sio->fill_char_bg);
1314 print_argp_doc(minitrc_fp, config_s, "fill_char_bg");
1315 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ln_bg", sio->ln_bg);
1316 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1317 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ln_fg", sio->ln_fg);
1318 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1319 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cmdln_bg", sio->cmdln_bg);
1320 print_argp_doc(minitrc_fp, config_s, "cmdln_bg");
1321 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cmdln_fg", sio->cmdln_fg);
1322 print_argp_doc(minitrc_fp, config_s, "cmdln_fg");
1323
1324 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_fg", sio->nt_fg);
1325 print_argp_doc(minitrc_fp, config_s, "nt_fg");
1326 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_bg", sio->nt_bg);
1327 print_argp_doc(minitrc_fp, config_s, "nt_bg");
1328 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_fg", sio->nt_hl_fg);
1329 print_argp_doc(minitrc_fp, config_s, "nt_hl_fg");
1330 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_bg", sio->nt_hl_bg);
1331 print_argp_doc(minitrc_fp, config_s, "nt_hl_bg");
1332 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_rev_fg", sio->nt_rev_fg);
1333 print_argp_doc(minitrc_fp, config_s, "nt_rev_fg");
1334 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_rev_bg", sio->nt_rev_bg);
1335 print_argp_doc(minitrc_fp, config_s, "nt_rev_bg");
1336 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_rev_fg", sio->nt_hl_rev_fg);
1337 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_fg");
1338 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_rev_bg", sio->nt_hl_rev_bg);
1339 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_bg");
1340 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "title_fg", sio->title_fg);
1341 print_argp_doc(minitrc_fp, config_s, "title_fg");
1342 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "title_bg", sio->title_bg);
1343 print_argp_doc(minitrc_fp, config_s, "title_bg");
1344 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ran_fg", sio->ran_fg);
1345 print_argp_doc(minitrc_fp, config_s, "ran_fg");
1346 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ran_bg", sio->ran_bg);
1347 print_argp_doc(minitrc_fp, config_s, "ran_bg");
1348 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "blue_gamma", sio->blue_gamma);
1349 print_argp_doc(minitrc_fp, config_s, "blue_gamma");
1350 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "gray_gamma", sio->gray_gamma);
1351 print_argp_doc(minitrc_fp, config_s, "gray_gamma");
1352 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "green_gamma", sio->green_gamma);
1353 print_argp_doc(minitrc_fp, config_s, "green_gamma");
1354 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "red_gamma", sio->red_gamma);
1355 print_argp_doc(minitrc_fp, config_s, "red_gamma");
1356 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "black", sio->black);
1357 print_argp_doc(minitrc_fp, config_s, "black");
1358 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "red", sio->red);
1359 print_argp_doc(minitrc_fp, config_s, "red");
1360 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "green", sio->green);
1361 print_argp_doc(minitrc_fp, config_s, "green");
1362 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "yellow", sio->yellow);
1363 print_argp_doc(minitrc_fp, config_s, "yellow");
1364 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "blue", sio->blue);
1365 print_argp_doc(minitrc_fp, config_s, "blue");
1366 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "magenta", sio->magenta);
1367 print_argp_doc(minitrc_fp, config_s, "magenta");
1368 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cyan", sio->cyan);
1369 print_argp_doc(minitrc_fp, config_s, "cyan");
1370 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "white", sio->white);
1371 print_argp_doc(minitrc_fp, config_s, "white");
1372 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bblack", sio->bblack);
1373 print_argp_doc(minitrc_fp, config_s, "bblack");
1374 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bred", sio->bred);
1375 print_argp_doc(minitrc_fp, config_s, "bred");
1376 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bgreen", sio->bgreen);
1377 print_argp_doc(minitrc_fp, config_s, "bgreen");
1378 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "byellow", sio->byellow);
1379 print_argp_doc(minitrc_fp, config_s, "byellow");
1380 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bblue", sio->bblue);
1381 print_argp_doc(minitrc_fp, config_s, "bblue");
1382 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bmagenta", sio->bmagenta);
1383 print_argp_doc(minitrc_fp, config_s, "bmagenta");
1384 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bcyan", sio->bcyan);
1385 print_argp_doc(minitrc_fp, config_s, "bcyan");
1386 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bwhite", sio->bwhite);
1387 print_argp_doc(minitrc_fp, config_s, "bwhite");
1388 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_data", init->mapp_data);
1389 print_argp_doc(minitrc_fp, config_s, "mapp_data");
1390 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_help", init->mapp_help);
1391 print_argp_doc(minitrc_fp, config_s, "mapp_help");
1392 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_home", init->mapp_home);
1393 print_argp_doc(minitrc_fp, config_s, "mapp_home");
1394 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_msrc", init->mapp_msrc);
1395 print_argp_doc(minitrc_fp, config_s, "mapp_msrc");
1396 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_user", init->mapp_user);
1397 print_argp_doc(minitrc_fp, config_s, "mapp_user");
1398 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_theme", init->mapp_theme);
1399 print_argp_doc(minitrc_fp, config_s, "mapp_theme");
1400 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "include", init->mapp_theme);
1401 (void)fprintf(minitrc_fp, "%-34s # default theme file\n", config_s);
1402 strnz__cpy(tmp_str, "Configuration written to file: ", MAXLEN - 1);
1403 strnz__cat(tmp_str, minitrc_dmp, MAXLEN - 1);
1404 ui_perror(tmp_str);
1405 return 0;
1406}
1407void print_argp_doc(FILE *minitrc_fp, char *config_s, char *key) {
1408 char comment[MAXLEN];
1409 comment[0] = '\0';
1410 if (get_argp_doc_by_name(comment, options, key))
1411 (void)fprintf(minitrc_fp, "%-34s # %s\n", config_s, comment);
1412 else
1413 (void)fprintf(minitrc_fp, "%-34s #\n", config_s);
1414}
1415/** @brief Derive full file specification from directory and file name
1416 @ingroup init
1417 @param file_spec - output full file specification
1418 @param dir - directory path
1419 @param file_name - file name
1420 @returns true if file_spec is derived, false otherwise
1421 @details If dir is nullptr, use MAPP_DIR environment variable or default
1422 directory, ~/menuapp.
1423 file_spec should be a pre-allocated char array of size MAXLEN to
1424 hold the resulting file specification
1425 */
1426bool derive_file_spec(char *file_spec, char *dir, char *file_name) {
1427 char tmp_str[MAXLEN];
1428 char ts2[MAXLEN];
1429 char *e;
1430
1431 if (!file_name || !*file_name) {
1432 *file_spec = '\0';
1433 return false;
1434 }
1435 if (dir) {
1436 strnz__cpy(tmp_str, dir, MAXLEN - 1);
1437 } else {
1438 e = getenv("MAPP_DIR");
1439 if (e) {
1440 strnz__cpy(tmp_str, e, MAXLEN - 1);
1441 } else {
1442 strnz__cpy(tmp_str, "~/menuapp", MAXLEN - 1);
1443 }
1444 }
1445 trim_path(tmp_str);
1446 strnz__cpy(ts2, tmp_str, MAXLEN - 1);
1447 // construct the full file specification
1448 // check that the file exists and is readable
1449 strnz__cpy(file_spec, ts2, MAXLEN - 1);
1450 strnz__cat(file_spec, "/", MAXLEN - 1);
1451 strnz__cat(file_spec, file_name, MAXLEN - 1);
1452 return true;
1453}
1454/** @brief Display the version information of the application
1455 @ingroup init
1456 @details The version information is defined in the mapp_version variable
1457 and is printed to stdout when this function is called. */
1459 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1460 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1461 fprintf(stdout, "C version: %ld\n", __STDC_VERSION__);
1462}
1463/** @brief Print an option and its value in a formatted manner
1464 @ingroup init
1465 @param o - option flag (e.g., "-a:")
1466 @param name - option name (e.g., "--minitrc")
1467 @param value - option value to print
1468 @details This function is used to display the current configuration options
1469 and their values in a readable format. */
1470void opt_prt_char(const char *o, const char *name, const char *value) {
1471 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1472}
1473/** @brief Print an option and its value in a formatted manner for integer
1474 values
1475 @ingroup init
1476 @param o - option flag (e.g., "-C:")
1477 @param name - option name (e.g., "--cols")
1478 @param value - integer option value to print
1479 @details This function is used to display the current configuration options
1480 and their integer values in a readable format. */
1481void opt_prt_str(const char *o, const char *name, const char *value) {
1482 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1483}
1484/** @brief Print an option and its value in a formatted manner for integer
1485 values
1486 @ingroup init
1487 @param o - option flag (e.g., "-C:")
1488 @param name - option name (e.g., "--cols")
1489 @param value - integer option value to print
1490 @details This function is used to display the current configuration options
1491 and their integer values in a readable format. */
1492void opt_prt_int(const char *o, const char *name, int value) {
1493 fprintf(stdout, "%3s %-15s: %d\n", o, name, value);
1494}
1495/** @brief Print an option and its value in a formatted manner for double
1496 values
1497 @ingroup init
1498 @param o - option flag (e.g., "-r:")
1499 @param name - option name (e.g., "red_gamma")
1500 @param value - double option value to print
1501 @details This function is used to display the current configuration options
1502 and their double values in a readable format. */
1503void opt_prt_double(const char *o, const char *name, double value) {
1504 fprintf(stdout, "%3s %-15s: %0.2f\n", o, name, value);
1505}
1506/** @brief Print an option and its value in a formatted manner for boolean
1507 values
1508 @ingroup init
1509 @param o - option flag (e.g., "-z")
1510 @param name - option name (e.g., "f_squeeze")
1511 @param value - boolean option value to print
1512 @details This function is used to display the current configuration options
1513 and their boolean values in a readable format, printing "true" or "false"
1514 based on the value. */
1515void opt_prt_bool(const char *o, const char *name, bool value) {
1516 fprintf(stdout, "%3s %-15s: %s\n", o, name, value ? "true" : "false");
1517}
bool str_to_bool(const char *)
Converts String to boolean true or false.
Definition futil.c:982
#define CM_VERSION
Definition version.h:5
UiLogContext ui_log_ctx
Definition ui_common.c:53
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:404
int ui_open_log()
Open the log file for writing.
Definition ui_common.c:1446
#define MAXLEN
Definition lf.h:38
char em0[MAXLEN]
Definition lf.c:42
const char * argp_program_version
Definition init.c:110
int process_config_file(char *, Init *)
Definition init.c:690
void print_argp_doc(FILE *, char *, char *)
Definition init.c:1407
@ XBBLACK
Definition init.c:58
@ XBCYAN
Definition init.c:60
@ MAPP_THEME
Definition init.c:86
@ IND_BG
Definition init.c:36
@ NT_HL_REV_FG
Definition init.c:47
@ XYELLOW
Definition init.c:74
@ RAN_BG
Definition init.c:56
@ LN_BG
Definition init.c:52
@ XRED
Definition init.c:72
@ MAPP_USER
Definition init.c:83
@ NT_BG
Definition init.c:42
@ XBLACK
Definition init.c:62
@ CMDLN_FG
Definition init.c:53
@ FILL_CHAR_BG
Definition init.c:40
@ XBWHITE
Definition init.c:66
@ XBLUE
Definition init.c:63
@ FILL_CHAR_FG
Definition init.c:39
@ NT_REV_BG
Definition init.c:44
@ BORDER
Definition init.c:57
@ XGREEN
Definition init.c:70
@ NT_HL_FG
Definition init.c:45
@ MAPP_HELP
Definition init.c:80
@ XBBLUE
Definition init.c:59
@ XBYELLOW
Definition init.c:67
@ CMDLN_BG
Definition init.c:54
@ XCYAN
Definition init.c:68
@ TITLE_BG
Definition init.c:50
@ BRACKETS_FG
Definition init.c:37
@ NT_HL_REV_BG
Definition init.c:48
@ NT_FG
Definition init.c:41
@ GM_RED
Definition init.c:78
@ BRACKETS_BG
Definition init.c:38
@ NT_REV_FG
Definition init.c:43
@ HELP_SPEC
Definition init.c:85
@ XBMAGENTA
Definition init.c:64
@ CM_EDITOR
Definition init.c:69
@ FG
Definition init.c:32
@ GM_GRAY
Definition init.c:76
@ BG
Definition init.c:31
@ MAPP_MSRC
Definition init.c:82
@ GM_GREEN
Definition init.c:77
@ XBGREEN
Definition init.c:61
@ IND_FG
Definition init.c:35
@ XWHITE
Definition init.c:73
@ MAPP_HOME
Definition init.c:81
@ RAN_FG
Definition init.c:55
@ BOX_BG
Definition init.c:34
@ XMAGENTA
Definition init.c:71
@ MAPP_DATA
Definition init.c:79
@ NT_HL_BG
Definition init.c:46
@ MAPP_SPEC
Definition init.c:84
@ LN_FG
Definition init.c:51
@ END_INIT_VARS
Definition init.c:87
@ XBRED
Definition init.c:65
@ TITLE_FG
Definition init.c:49
@ BOX_FG
Definition init.c:33
@ GM_BLUE
Definition init.c:75
int executor
Definition init.c:108
bool f_write_config
Definition init.c:90
const char * argp_program_bug_address
Definition init.c:111
#define _(String)
Definition amort.c:23
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition lf.c:2299
bool str_to_upper(char *)
Converts a string to uppercase.
Definition futil.c:502
double str_to_double(char *)
converts string to double
Definition futil.c:970
size_t ssnprintf(char *, size_t, const char *,...)
Custom safe string formatting utility (Variadic version).
Definition futil.c:398
bool expand_tilde(char *, uint)
Expand a tilde (~) in a file path to the user's home directory.
Definition lf.c:2089
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition lf.c:2330
bool get_argp_doc_by_name(char *comment, const struct argp_option *, const char *)
Retrieves the documentation string for a given key name from an argp options array.
Definition futil.c:163
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:474
bool verify_dir(char *, uint)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1220
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:1029
bool unstr_hex_clr(char *, char *)
Validates that a string is a hex color code in the format "#RRGGBB".
Definition futil.c:219
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.
Definition init.c:1481
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
Definition init.c:618
bool derive_file_spec(char *, char *, char *)
Derive full file specification from directory and file name.
Definition init.c:1426
void display_version()
Display the version information of the application.
Definition init.c:1458
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.
Definition init.c:1503
void opt_prt_char(const char *o, const char *name, const char *value)
Print an option and its value in a formatted manner.
Definition init.c:1470
int write_config(Init *init)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:1152
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.
Definition init.c:1515
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.
Definition init.c:1492
int process_config_files(Init *)
parse the configuration file specified in init->minitrc and set Init struct values accordingly
Definition init.c:669
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:494
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:633
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition ui_common.c:1323
char title[MAXLEN]
Definition common.h:132
char mapp_data[MAXLEN]
Definition common.h:151
char minitrc[MAXLEN]
Definition common.h:177
bool f_out_spec
Definition common.h:174
UiLogLevel log_min_level
Definition common.h:183
char mapp_help[MAXLEN]
Definition common.h:152
int begx
Definition common.h:121
bool f_title
Definition common.h:169
SIO * sio
Definition common.h:117
char in_spec[MAXLEN]
Definition common.h:171
char cmd_all[MAXLEN]
Definition common.h:126
int argc
Definition common.h:133
char fill_char[2]
Definition common.h:149
char mapp_msrc[MAXLEN]
Definition common.h:153
int cols
Definition common.h:119
int tab_stop
Definition common.h:185
bool f_erase_remainder
Definition common.h:144
bool f_read_theme
Definition common.h:145
bool f_mapp_desc
Definition common.h:164
char mapp_home[MAXLEN]
Definition common.h:150
bool f_squeeze
Definition common.h:140
int begy
Definition common.h:120
char parent_cmd[MAXLEN]
Definition common.h:127
char mapp_spec[MAXLEN]
Definition common.h:179
char receiver_cmd[MAXLEN]
Definition common.h:124
int h_shift
Definition common.h:186
bool wrap
Definition common.h:147
bool f_multiple_cmd_args
Definition common.h:142
int select_max
Definition common.h:184
bool f_ln
Definition common.h:146
bool f_mapp_spec
Definition common.h:159
char provider_cmd[MAXLEN]
Definition common.h:123
char out_spec[MAXLEN]
Definition common.h:172
bool f_strip_ansi
Definition common.h:139
bool p_view_files
Definition common.h:137
bool f_at_end_remove
Definition common.h:138
char brackets[3]
Definition common.h:148
bool f_ignore_case
Definition common.h:136
char ** argv
Definition common.h:134
int lines
Definition common.h:118
char mapp_user[MAXLEN]
Definition common.h:154
char cmd[MAXLEN]
Definition common.h:125
char mapp_theme[MAXLEN]
Definition common.h:155
uint timeout_secs
Definition common.h:182
bool f_help_spec
Definition common.h:170
bool f_receiver_cmd
Definition common.h:166
bool f_provider_cmd
Definition common.h:165
char help_spec[MAXLEN]
Definition common.h:180
char editor[MAXLEN]
Definition common.h:175
bool f_in_spec
Definition common.h:173
UiLogLevel min_level
Definition ui_backend.h:237
char * level[LOG_LEVEL_COUNT]
Definition ui_backend.h:241
uint32_t ran_bg
Definition ui_backend.h:794
double green_gamma
Definition ui_backend.h:747
uint32_t ln_bg
Definition ui_backend.h:780
double blue_gamma
Definition ui_backend.h:748
char brackets[3]
Definition ui_backend.h:807
uint32_t magenta
Definition ui_backend.h:755
uint32_t cmdln_bg
Definition ui_backend.h:782
uint32_t cmdln_fg
Definition ui_backend.h:781
uint32_t nt_hl_rev_fg
Definition ui_backend.h:789
uint32_t ran_fg
Definition ui_backend.h:793
uint32_t bgreen
Definition ui_backend.h:761
double red_gamma
Definition ui_backend.h:746
uint32_t green
Definition ui_backend.h:752
char fill_char[2]
Definition ui_backend.h:808
uint32_t nt_fg
Definition ui_backend.h:783
uint32_t yellow
Definition ui_backend.h:753
uint32_t fill_char_fg
Definition ui_backend.h:777
uint32_t box_fg
Definition ui_backend.h:771
uint32_t orange
Definition ui_backend.h:758
uint32_t ln_fg
Definition ui_backend.h:779
uint32_t ind_bg
Definition ui_backend.h:774
uint32_t bmagenta
Definition ui_backend.h:764
uint32_t ind_fg
Definition ui_backend.h:773
uint32_t byellow
Definition ui_backend.h:762
uint32_t bblue
Definition ui_backend.h:763
uint32_t borange
Definition ui_backend.h:767
uint32_t title_bg
Definition ui_backend.h:792
uint32_t fg
Definition ui_backend.h:769
uint32_t cyan
Definition ui_backend.h:756
uint32_t bblack
Definition ui_backend.h:759
uint32_t red
Definition ui_backend.h:751
uint32_t nt_hl_rev_bg
Definition ui_backend.h:790
uint32_t title_fg
Definition ui_backend.h:791
uint32_t bred
Definition ui_backend.h:760
uint32_t fill_char_bg
Definition ui_backend.h:778
uint32_t black
Definition ui_backend.h:750
uint32_t nt_rev_bg
Definition ui_backend.h:786
uint32_t brackets_bg
Definition ui_backend.h:776
uint32_t bcyan
Definition ui_backend.h:765
uint32_t nt_bg
Definition ui_backend.h:784
uint32_t blue
Definition ui_backend.h:754
uint32_t brackets_fg
Definition ui_backend.h:775
uint32_t white
Definition ui_backend.h:757
uint32_t box_bg
Definition ui_backend.h:772
uint32_t nt_hl_fg
Definition ui_backend.h:787
uint32_t bwhite
Definition ui_backend.h:766
char border
Definition ui_backend.h:809
uint32_t nt_rev_fg
Definition ui_backend.h:785
double gray_gamma
Definition ui_backend.h:749
uint32_t nt_hl_bg
Definition ui_backend.h:788
uint32_t bg
Definition ui_backend.h:770