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