C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
common.h File Reference

Headder for C-Menu Menu, Form, Pick, and View components. More...

#include "cm.h"
#include <form.h>
#include <menu.h>
#include <pick.h>
#include <view.h>
#include <stddef.h>
Include dependency graph for common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Init
 Gathers runtime information for C-Menu Menu, Form, Pick, and View components, used for passing common data and state during initialization and processing of these componentsi. More...

Macros

#define _GNU_SOURCE
#define ABOUT   ".about"
#define ACCEPT_PROMPT_CHAR   '_'
#define COLOR_LEN   8
#define DEFAULTEDITOR   "vi"
#define destroy_cmenu()
#define EIGHT   8
#define FORM_HELP_FILE   "form.help"
#define MAPP_DIR   "~/menuapp"
#define MAX_FORMS   10
#define MAX_MENUS   10
#define MAX_PICK_OBJS   1024
#define MAX_PICKS   10
#define MAX_VIEWS   10
#define MAX_WIDE_LEN   1024
#define MAXOPTS   50
#define MENU_HELP_FILE   "menu.help"
#define MIN_COLS   40
#define MINITRC   ".minitrc"
#define NCURSES_WIDECHAR   1
#define new_cmenu()
#define P_READ   0
#define P_WRITE   1
#define PICK_HELP_FILE   "pick.help"
#define PICK_MAX_ARG_LEN   256
#define PRINTCMD   "lp -c -s"
#define TRUE   1
#define USE_PAD   TRUE
#define VIEW_HELP_FILE   "view.help"
#define VIEW_PRT_FILE   "prtout"

Typedefs

typedef Form Form
typedef Menu Menu
typedef Pick Pick
typedef View View

Enumerations

enum  Caller { VIEW , FORM , PICK , MENU }
enum  OptGroup {
  OG_FILES , OG_DIRS , OG_SPECS , OG_MISC ,
  OG_PARMS , OG_FLAGS , OG_COL
}
 option groups More...
enum  OptType { OT_STRING , OT_INT , OT_BOOL , OT_HEX }
 option types More...

Functions

void build_prompt (View *)
 Build Prompt String.
int cmd_processor (Init *)
bool derive_file_spec (char *, char *, char *)
 Derive full file specification from directory and file name.
Formdestroy_form (Init *init)
 Destroy Form structure.
Initdestroy_init (Init *init)
 Destroy Init structure.
void destroy_line_table (View *)
 Destroy Line Table.
Menudestroy_menu (Init *init)
 Destroy Menu structure.
Pickdestroy_pick (Init *init)
 Destroy Pick structure.
Viewdestroy_view (Init *init)
 Destroy View structure.
void destroy_view_win (Init *)
int display_prompt (View *, char *)
 Display Command Line Prompt.
int init_form (Init *, int, char **, uint, uint)
 Initialize form data structure and parse description file.
int init_pick (Init *, int, char **, uint, uint)
 Initializes pick structure and opens pick input file or pipe.
int init_view_boxwin (Init *)
 Initialize the C-Menu View in box window mode.
int init_view_full_screen (Init *)
 Initialize C-Menu View in full screen mode.
void initialize_line_table (View *)
 Initialize Line Table.
void mapp_initialization (Init *, int, char **)
 Main initialization function for MAPP - Menu Application.
unsigned int menu_engine (Init *)
 The main loop of the menu system.
Formnew_form (Init *, int, char **, uint, uint)
 Create and initialize Form structure.
Initnew_init (int, char **)
 Create and initialize Init structure.
Menunew_menu (Init *, int, char **, uint, uint)
 Create and initialize Menu structure.
Picknew_pick (Init *, int, char **, uint, uint)
 Create and initialize Pick structure.
Viewnew_view (Init *)
 Create and initialize View structure.
void next_page (View *)
 Advance to Next Page.
int open_pick_win (Init *)
 Initializes the pick window based on the parameters specified in the Pick structure.
int pad_refresh (View *)
 Refresh Pad and Line Number Window.
unsigned int parse_menu_description (Init *)
 Parse menu description file and create Menu.
int parse_opt_args (Init *, int, char **)
 Parse command-line options and set Init struct values accordingly.
int pick_engine (Init *)
 Initializes pick interface, calculates window size and position, and enters picker loop.
int popup_ckeys ()
int popup_form (Init *, int, char **, uint, uint)
 instantiate a form popup window
int popup_menu (Init *, int, char **, uint, uint)
 instantiate a menu popup window
int popup_pick (Init *, int, char **, uint, uint)
 instantiate a pick popup window
int popup_view (Init *, int, char **, uint, uint, uint, uint)
 instantiate a view popup window
int process_config_file (char *, Init *)
void view_boxwin_resize (Init *)
 Resize the current window and its box.
void view_calc_boxwin_dimensions (Init *)
 Calculate the dimensions and position of the box window for C-Menu View.
void view_calc_full_screen_dimensions (Init *)
 Calculate the dimensions for full screen mode.
int view_cmd_processor (Init *)
 Main Command Processing Loop for View.
int view_file (Init *)
 Start view.
void view_full_screen_resize (Init *)
 Resize the full screen view and its components.
int view_init_input (Init *, char *)
 Initialize the input for the C-Menu View.
void view_stack_free (ViewStack *)
bool view_stack_init (ViewStack *, size_t)
bool view_stack_peek (const ViewStack *, View *)
bool view_stack_pop (ViewStack *, View *)
bool view_stack_push (ViewStack *, View)
int write_config (Init *)
 Write the current configuration to a file specified in init->minitrc.
void zero_opt_args (Init *)
 Initialize optional arguments in the Init struct to default values.

Variables

int init_cnt
char minitrc [MAXLEN]
ViewStack view_stack

Detailed Description

Headder for C-Menu Menu, Form, Pick, and View components.

Author
Bill Waller Copyright (c) 2025 MIT License billx.nosp@m.wall.nosp@m.er@gm.nosp@m.ail..nosp@m.com
Date
2026-02-09

Definition in file common.h.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 13 of file common.h.

◆ ABOUT

#define ABOUT   ".about"

Definition at line 45 of file common.h.

◆ ACCEPT_PROMPT_CHAR

#define ACCEPT_PROMPT_CHAR   '_'

Definition at line 30 of file common.h.

◆ COLOR_LEN

#define COLOR_LEN   8

Definition at line 27 of file common.h.

◆ DEFAULTEDITOR

#define DEFAULTEDITOR   "vi"

Definition at line 37 of file common.h.

◆ destroy_cmenu

#define destroy_cmenu ( )
Value:
destroy_init(init); \
win_del(); \
curs_set(1); \
destroy_curses(); \
return 0; \
}
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:95

Definition at line 67 of file common.h.

67#define destroy_cmenu() \
68 destroy_init(init); \
69 win_del(); \
70 curs_set(1); \
71 destroy_curses(); \
72 return 0; \
73 }

◆ EIGHT

#define EIGHT   8

Definition at line 49 of file common.h.

◆ FORM_HELP_FILE

#define FORM_HELP_FILE   "form.help"

Definition at line 33 of file common.h.

◆ MAPP_DIR

#define MAPP_DIR   "~/menuapp"

Definition at line 46 of file common.h.

◆ MAX_FORMS

#define MAX_FORMS   10

Definition at line 40 of file common.h.

◆ MAX_MENUS

#define MAX_MENUS   10

Definition at line 41 of file common.h.

◆ MAX_PICK_OBJS

#define MAX_PICK_OBJS   1024

Definition at line 29 of file common.h.

◆ MAX_PICKS

#define MAX_PICKS   10

Definition at line 42 of file common.h.

◆ MAX_VIEWS

#define MAX_VIEWS   10

Definition at line 39 of file common.h.

◆ MAX_WIDE_LEN

#define MAX_WIDE_LEN   1024

Definition at line 26 of file common.h.

◆ MAXOPTS

#define MAXOPTS   50

Definition at line 48 of file common.h.

◆ MENU_HELP_FILE

#define MENU_HELP_FILE   "menu.help"

Definition at line 32 of file common.h.

◆ MIN_COLS

#define MIN_COLS   40

Definition at line 24 of file common.h.

◆ MINITRC

#define MINITRC   ".minitrc"

Definition at line 44 of file common.h.

◆ NCURSES_WIDECHAR

#define NCURSES_WIDECHAR   1

Definition at line 15 of file common.h.

◆ new_cmenu

#define new_cmenu ( )
Value:
__end_pgm; \
int main(int argc, char **argv) { \
capture_shell_tioctl(); \
Init *init = new_init(argc, argv); \
SIO *sio = init->sio; \
mapp_initialization(init); \
ui_init(sio); \
sig_prog_mode(); \
capture_curses_tioctl(); \
win_init_attrs();
#define __atexit
This macro registers the end_pgm function to be called when the program exits.
Definition cm.h:339
int main()
Definition hello.c:19
Init * new_init(int argc, char **argv)
Create and initialize Init structure.
Definition mem.c:60
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:688
Gathers runtime information for C-Menu Menu, Form, Pick, and View components, used for passing common...
Definition common.h:113
SIO * sio
Definition common.h:114

Definition at line 54 of file common.h.

54#define new_cmenu() \
55 __end_pgm; \
56 int main(int argc, char **argv) { \
57 __atexit; \
58 capture_shell_tioctl(); \
59 Init *init = new_init(argc, argv); \
60 SIO *sio = init->sio; \
61 mapp_initialization(init); \
62 ui_init(sio); \
63 sig_prog_mode(); \
64 capture_curses_tioctl(); \
65 win_init_attrs();

◆ P_READ

#define P_READ   0

Definition at line 50 of file common.h.

◆ P_WRITE

#define P_WRITE   1

Definition at line 51 of file common.h.

◆ PICK_HELP_FILE

#define PICK_HELP_FILE   "pick.help"

Definition at line 34 of file common.h.

◆ PICK_MAX_ARG_LEN

#define PICK_MAX_ARG_LEN   256

Definition at line 28 of file common.h.

◆ PRINTCMD

#define PRINTCMD   "lp -c -s"

Definition at line 47 of file common.h.

◆ TRUE

#define TRUE   1

Definition at line 52 of file common.h.

◆ USE_PAD

#define USE_PAD   TRUE

Definition at line 23 of file common.h.

◆ VIEW_HELP_FILE

#define VIEW_HELP_FILE   "view.help"

Definition at line 35 of file common.h.

◆ VIEW_PRT_FILE

#define VIEW_PRT_FILE   "prtout"

Definition at line 36 of file common.h.

Typedef Documentation

◆ Form

typedef Form Form

Definition at line 102 of file common.h.

◆ Menu

typedef Menu Menu

Definition at line 101 of file common.h.

◆ Pick

typedef Pick Pick

Definition at line 103 of file common.h.

◆ View

typedef View View

Definition at line 104 of file common.h.

Enumeration Type Documentation

◆ Caller

enum Caller
Enumerator
VIEW 
FORM 
PICK 
MENU 

Definition at line 75 of file common.h.

75 {
76 VIEW,
77 FORM,
78 PICK,
79 MENU
80} Caller;
Caller
Definition common.h:75
@ FORM
Definition common.h:77
@ MENU
Definition common.h:79
@ VIEW
Definition common.h:76
@ PICK
Definition common.h:78

◆ OptGroup

enum OptGroup

option groups

Enumerator
OG_FILES 
OG_DIRS 
OG_SPECS 
OG_MISC 
OG_PARMS 
OG_FLAGS 
OG_COL 

Definition at line 91 of file common.h.

91 {
93 OG_DIRS,
95 OG_MISC,
98 OG_COL
99} OptGroup;
OptGroup
option groups
Definition common.h:91
@ OG_FILES
Definition common.h:92
@ OG_DIRS
Definition common.h:93
@ OG_SPECS
Definition common.h:94
@ OG_MISC
Definition common.h:95
@ OG_FLAGS
Definition common.h:97
@ OG_PARMS
Definition common.h:96
@ OG_COL
Definition common.h:98

◆ OptType

enum OptType

option types

Enumerator
OT_STRING 
OT_INT 
OT_BOOL 
OT_HEX 

Definition at line 83 of file common.h.

83 {
85 OT_INT,
86 OT_BOOL,
87 OT_HEX,
88} OptType;
OptType
option types
Definition common.h:83
@ OT_INT
Definition common.h:85
@ OT_BOOL
Definition common.h:86
@ OT_HEX
Definition common.h:87
@ OT_STRING
Definition common.h:84

Function Documentation

◆ cmd_processor()

int cmd_processor ( Init * )
extern

◆ destroy_view_win()

void destroy_view_win ( Init * )
extern

◆ popup_ckeys()

int popup_ckeys ( )
extern

Definition at line 31 of file curskeys.c.

31 {
32 char Title[] = "TEST CURSES KEYS";
33 unsigned lines = 10;
34 unsigned cols = 55;
35 char tmp[MAXLEN];
36 uint maxy, maxx;
37 ui_get_screen_size(&maxy, &maxx);
38 uint begy = (maxy - lines) / 3;
39 uint begx = (maxx - cols) / 2;
40 if (surface_box_win_new(lines, cols, begy, begx, Title)) {
41 strnz__cpy(tmp, "surface_box_win_new failed: ", MAXLEN - 1);
42 strnz__cat(tmp, Title, MAXLEN - 1);
43 Perror(tmp);
44 exit(EXIT_FAILURE);
45 }
47 ui_keypad(sfc, WIN, true);
49 ui_mvwaddstr(sfc, WIN, lines - 1, 0, " <ALT>END to exit ");
50 ui_bkgdset(sfc, WIN, &cell_nt);
51 ui_mvwaddstr(sfc, WIN, 1, 4, "Press a key or activate the mouse:");
52#ifdef UAL_UI
53 ncurses_input(sfc, WIN);
54#else
55 notcurses_input(sfc, WIN);
56#endif
58 return 0;
59}
int ui_bkgdset(UiSurface *s, uint w, const UiCell *cell)
Definition ui_ncurses.c:760
int ui_mvwaddstr(UiSurface *s, uint w, uint y, uint x, const char *text)
void ui_surface_destroy(UiSurface *s)
Definition ui_ncurses.c:377
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:28
void ui_get_screen_size(uint *lines, uint *cols)
Definition ui_ncurses.c:692
int sfc_ptr
Definition nckeys.c:47
int ui_keypad(UiSurface *s, uint w, bool enable)
Definition ui_ncurses.c:635
int notcurses_input(UiSurface *s, uint w)
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
Definition curskeys.c:584
#define MAXLEN
Definition curskeys.c:15
int surface_box_win_new(uint wlines, uint wcols, uint wbegy, uint wbegx, char *wtitle)
Definition dwin.c:521
UiCell cell_nt
Definition dwin.c:94
UiCell cell_nt_rev
Definition dwin.c:95
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition dwin.c:841
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:537
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:566
A drawable surface in the NotCurses backend.

References cell_nt, cell_nt_rev, notcurses_input(), Perror(), sfc_ptr, strnz__cat(), strnz__cpy(), surface_box_win_new(), ui_bkgdset(), ui_get_screen_size(), ui_keypad(), ui_mvwaddstr(), ui_surface, ui_surface_destroy(), and WIN.

Referenced by main(), and menu_cmd_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popup_form()

int popup_form ( Init * init,
int argc,
char ** argv,
uint by,
uint bx )
extern

instantiate a form popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
bythe y coordinate for the form window
bxthe x coordinate for the form window

by and bx may be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 by, and bx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 113 of file popups.c.

113 {
114 int rc;
115 zero_opt_args(init);
116 parse_opt_args(init, argc, argv);
117 Form *sav_form = init->form;
118 init->form = nullptr;
119 rc = init_form(init, init->argc, init->argv, by, bx);
120 destroy_form(init);
121 init->form = sav_form;
122 return rc;
123}
int init_form(Init *, int, char **, uint, uint)
Initialize form data structure and parse description file.
Definition form_engine.c:61
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
Definition init.c:591
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:606
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:275
Form * form
Definition common.h:185
int argc
Definition common.h:130
char ** argv
Definition common.h:131
Definition form.h:146

References Init::argc, Init::argv, destroy_form(), Init::form, init_form(), parse_opt_args(), and zero_opt_args().

Referenced by enter_file_spec(), and menu_cmd_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popup_menu()

int popup_menu ( Init * init,
int argc,
char ** argv,
uint by,
uint bx )
extern

instantiate a menu popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
bythe y coordinate for the menu window
bxthe x coordinate for the menu window

by and bx may be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 by, and bx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 53 of file popups.c.

53 {
54 int rc;
55 zero_opt_args(init);
56 parse_opt_args(init, argc, argv);
57 Menu *sav_menu = init->menu;
58 init->menu = nullptr;
59 init->menu = new_menu(init, init->argc, init->argv, by, bx);
60 rc = menu_engine(init);
61 destroy_menu(init);
62 init->menu = sav_menu;
63 return rc;
64}
Menu * new_menu(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Menu structure.
Definition mem.c:134
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:155
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:36
Menu * menu
Definition common.h:183
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:105

References Init::argc, Init::argv, destroy_menu(), Init::menu, menu_engine(), new_menu(), parse_opt_args(), and zero_opt_args().

Referenced by menu_cmd_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popup_pick()

int popup_pick ( Init * init,
int argc,
char ** argv,
uint by,
uint bx )
extern

instantiate a pick popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
bythe y coordinate for the pick window
bxthe x coordinate for the pick window

by and bx may be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 by, and bx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 83 of file popups.c.

83 {
84 int rc;
85 zero_opt_args(init);
86 parse_opt_args(init, argc, argv);
87 Pick *sav_pick = init->pick;
88 init->pick = nullptr;
89
90 rc = init_pick(init, init->argc, init->argv, by, bx);
91 destroy_pick(init);
92 init->pick = sav_pick;
93 return rc;
94}
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:225
int init_pick(Init *, int, char **, uint, uint)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:66
Pick * pick
Definition common.h:187
Pick data structure.
Definition pick.h:25

References Init::argc, Init::argv, destroy_pick(), init_pick(), parse_opt_args(), Init::pick, and zero_opt_args().

Referenced by menu_cmd_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popup_view()

int popup_view ( Init * init,
int argc,
char ** argv,
uint ilines,
uint icols,
uint by,
uint bx )
extern

instantiate a view popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
ilinesthe number of lines for the view window
icolsthe number of columns for the view window
bythe y coordinate for the view window
bxthe x coordinate for the view window

ilines, cols, by, and bx may also be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 ilines, cols, by, and bx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 145 of file popups.c.

146 {
147 int rc = 0;
148 zero_opt_args(init);
149 parse_opt_args(init, argc, argv);
150 // view_stack_push(&view_stack, *init->view);
151 View *view_sav = init->view;
152 init->view = nullptr;
153 View *view = nullptr;
154 view = nullptr;
155 view = new_view(init);
156
157 if (init->lines > 0 && init->cols > 0) {
158 ilines = init->lines;
159 icols = init->cols;
160 }
161 if (init->begy > 0 || init->begx > 0) {
162 by = init->begy;
163 bx = init->begx;
164 }
165 view->begy = by;
166 view->begx = bx;
167 view->lines = ilines;
168 view->cols = icols;
169 view->f_full_screen = false;
170 if (!init_view_boxwin(init))
171 rc = view_file(init);
172 destroy_view(init);
173 init->view = view_sav;
174 // view_stack_pop(&view_stack, init->view);
175 return rc;
176}
View * view
Definition mem.c:38
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
Definition init_view.c:147
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:345
View * new_view(Init *init)
Create and initialize View structure.
Definition mem.c:299
int view_file(Init *)
Start view.
int begx
Definition common.h:118
int cols
Definition common.h:116
int begy
Definition common.h:117
View * view
Definition common.h:189
int lines
Definition common.h:115
Definition view.h:61

References Init::begx, View::begx, Init::begy, View::begy, Init::cols, View::cols, destroy_view(), View::f_full_screen, init_view_boxwin(), Init::lines, View::lines, new_view(), parse_opt_args(), Init::view, view_file(), and zero_opt_args().

Referenced by display_pick_help(), exec_objects(), form_engine(), form_exec_receiver(), menu_cmd_processor(), and view_display_help().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_config_file()

int process_config_file ( char * ,
Init *  )
extern

Definition at line 663 of file init.c.

663 {
664 char include_file_name[MAXLEN];
665 char tmp_str[MAXLEN];
666 char *src_p, *dp;
667 SIO *sio = init->sio;
668 char hex_clr_str[8];
669 char key[MAXLEN];
670 char value[MAXLEN];
671 FILE *config_fp = fopen(config_file_name, "r");
672 char quote_char = '\0';
673 if (!config_fp) {
674 fprintf(stderr, "failed to read file: %s %s\n", config_file_name, strerror(errno));
675 return (-1);
676 }
677 while (fgets(tmp_str, sizeof(tmp_str), config_fp)) {
678 bool inquotes = false;
679 if (tmp_str[0] == '#')
680 continue;
681 src_p = tmp_str;
682 key[0] = '\0';
683 dp = key;
684 // copy delimited by "=" into value
685 while (*src_p != '\0') {
686 if (*src_p == '\n')
687 *dp = *src_p = '\0';
688 if (*src_p == '=') {
689 *dp = '\0';
690 src_p++;
691 break;
692 }
693 if (*src_p == '"' && *src_p == ' ') {
694 src_p++;
695 continue;
696 }
697 *dp++ = *src_p++;
698 }
699 value[0] = '\0';
700 dp = value;
701 // copy delimited by newline or unquoted "#" into value, removing quotes, spaces, semicolons, and newlines, but respecting quotes
702 while (*src_p != '\0') {
703 if ((*src_p == '"' || *src_p == '\'') && (*(src_p + 1) != '\\')) {
704 if (!inquotes) {
705 inquotes = true;
706 quote_char = *src_p++;
707 } else if (*src_p == quote_char) {
708 inquotes = false;
709 quote_char = '\0';
710 }
711 }
712 if (!inquotes) {
713 if (*src_p == '#') {
714 if (unstr_hex_clr(hex_clr_str, src_p)) {
715 strnz__cpy(value, hex_clr_str, MAXLEN - 1);
716 dp = value + strlen(value);
717 }
718 break;
719 }
720 }
721 if (*src_p == ' ' || *src_p == ';') {
722 src_p++;
723 continue;
724 }
725 if (*src_p == '\n') {
726 *src_p = '\0';
727 break;
728 }
729 *dp++ = *src_p++;
730 }
731 *dp = '\0';
732 if (key[0] == '\0')
733 continue;
734 if (value[0] == '\0')
735 continue;
736 if (!strcmp(key, "include")) {
737 strnz__cpy(include_file_name, value, MAXLEN - 1);
738 expand_tilde(include_file_name, MAXLEN - 1);
739 process_config_file(include_file_name, init);
740 continue;
741 }
742 if (!strcmp(key, "minitrc")) {
743 strnz__cpy(init->minitrc, value, MAXLEN - 1);
744 continue;
745 }
746 if (!strcmp(key, "lines")) {
747 init->lines = atoi(value);
748 continue;
749 }
750 if (!strcmp(key, "cols")) {
751 init->cols = atoi(value);
752 continue;
753 }
754 if (!strcmp(key, "begy")) {
755 init->begy = atoi(value);
756 continue;
757 }
758 if (!strcmp(key, "begx")) {
759 init->begx = atoi(value);
760 continue;
761 }
762 if (!strcmp(key, "f_ln")) {
763 init->f_ln = str_to_bool(value);
764 continue;
765 }
766 if (!strcmp(key, "f_at_end_remove")) {
767 init->f_at_end_remove = str_to_bool(value);
768 continue;
769 }
770 if (!strcmp(key, "f_erase_remainder")) {
771 init->f_erase_remainder = str_to_bool(value);
772 continue;
773 }
774 if (!strcmp(key, "brackets")) {
775 strnz__cpy(init->brackets, value, 2);
776 continue;
777 }
778 if (!strcmp(key, "fill_char")) {
779 if (strlen(value) > 1)
780 value[1] = '\0';
781 if (wcwidth((int)value[0]) > 1)
782 value[0] = '?';
783 strnz__cpy(init->fill_char, value, 4);
784 continue;
785 }
786 if (!strcmp(key, "f_ignore_case")) {
787 init->f_ignore_case = str_to_bool(value);
788 continue;
789 }
790 if (!strcmp(key, "p_view_files")) {
791 init->p_view_files = str_to_bool(value);
792 continue;
793 }
794 if (!strcmp(key, "f_read_theme")) {
795 init->f_read_theme = str_to_bool(value);
796 continue;
797 }
798 if (!strcmp(key, "f_squeeze")) {
799 init->f_squeeze = str_to_bool(value);
800 continue;
801 }
802 if (!strcmp(key, "f_strip_ansi")) {
803 init->f_strip_ansi = str_to_bool(value);
804 continue;
805 }
806 if (!strcmp(key, "f_multiple_cmd_args")) {
807 init->f_multiple_cmd_args = str_to_bool(value);
808 continue;
809 }
810 if (!strcmp(key, "select_max")) {
811 init->select_max = atoi(value);
812 continue;
813 }
814 if (!strcmp(key, "tab_stop")) {
815 init->tab_stop = atoi(value);
816 continue;
817 }
818 if (!strcmp(key, "h_shift")) {
819 init->h_shift = atoi(value);
820 continue;
821 }
822 if (!strcmp(key, "wrap")) {
823 init->wrap = str_to_bool(value);
824 continue;
825 }
826 if (!strcmp(key, "title")) {
827 strnz__cpy(init->title, value, MAXLEN - 1);
828 continue;
829 }
830 if (!strcmp(key, "cmd")) {
831 strnz__cpy(init->cmd, value, MAXLEN - 1);
832 continue;
833 }
834 if (!strcmp(key, "cmd_all")) {
835 strnz__cpy(init->cmd_all, value, MAXLEN - 1);
836 continue;
837 }
838 if (!strcmp(key, "parent_cmd")) {
839 strnz__cpy(init->parent_cmd, value, MAXLEN - 1);
840 continue;
841 }
842 if (!strcmp(key, "provider_cmd")) {
843 strnz__cpy(init->provider_cmd, value, MAXLEN - 1);
844 continue;
845 }
846 if (!strcmp(key, "receiver_cmd")) {
847 strnz__cpy(init->receiver_cmd, value, MAXLEN - 1);
848 continue;
849 }
850 if (!strcmp(key, "editor")) {
851 strnz__cpy(init->editor, value, MAXLEN - 1);
852 continue;
853 }
854 if (!strcmp(key, "border")) {
855 char c = value[0];
856 if (c == 'r' || c == 'R')
857 sio->border = 'r';
858 else if (c == 's' || c == 'S')
859 sio->border = 's';
860 else if (c == 'd' || c == 'D')
861 sio->border = 'd';
862 else if (c == 'h' || c == 'H')
863 sio->border = 'h';
864 else
865 sio->border = 'n';
866 continue;
867 }
868 if (!strcmp(key, "fg")) {
869 sscanf(value, "#%06x", &sio->fg);
870 continue;
871 }
872 if (!strcmp(key, "bg")) {
873 sscanf(value, "#%06x", &sio->bg);
874 continue;
875 }
876 if (!strcmp(key, "box_fg")) {
877 sscanf(value, "#%06x", &sio->fg);
878 continue;
879 }
880 if (!strcmp(key, "box_bg")) {
881 sscanf(value, "#%06x", &sio->box_bg);
882 continue;
883 }
884 if (!strcmp(key, "ind_fg")) {
885 sscanf(value, "#%06x", &sio->ind_fg);
886 continue;
887 }
888 if (!strcmp(key, "ind_bg")) {
889 sscanf(value, "#%06x", &sio->ind_bg);
890 continue;
891 }
892 if (!strcmp(key, "brackets_fg")) {
893 sscanf(value, "#%06x", &sio->brackets_fg);
894 continue;
895 }
896 if (!strcmp(key, "brackets_bg")) {
897 sscanf(value, "#%06x", &sio->brackets_bg);
898 continue;
899 }
900 if (!strcmp(key, "fill_char_fg")) {
901 sscanf(value, "#%06x", &sio->fill_char_fg);
902 continue;
903 }
904 if (!strcmp(key, "fill_char_bg")) {
905 sscanf(value, "#%06x", &sio->fill_char_bg);
906 continue;
907 }
908 if (!strcmp(key, "ln_fg")) {
909 sscanf(value, "#%06x", &sio->ln_fg);
910 continue;
911 }
912 if (!strcmp(key, "ln_bg")) {
913 sscanf(value, "#%06x", &sio->ln_bg);
914 continue;
915 }
916 if (!strcmp(key, "cmdln_fg")) {
917 sscanf(value, "#%06x", &sio->cmdln_fg);
918 continue;
919 }
920 if (!strcmp(key, "cmdln_bg")) {
921 sscanf(value, "#%06x", &sio->cmdln_bg);
922 continue;
923 }
924 if (!strcmp(key, "nt_fg")) {
925 sscanf(value, "#%06x", &sio->nt_fg);
926 continue;
927 }
928 if (!strcmp(key, "nt_bg")) {
929 sscanf(value, "#%06x", &sio->nt_bg);
930 continue;
931 }
932 if (!strcmp(key, "nt_rev_fg")) {
933 sscanf(value, "#%06x", &sio->nt_rev_fg);
934 continue;
935 }
936 if (!strcmp(key, "nt_rev_bg")) {
937 sscanf(value, "#%06x", &sio->nt_rev_bg);
938 continue;
939 }
940 if (!strcmp(key, "nt_hl_fg")) {
941 sscanf(value, "#%06x", &sio->nt_hl_fg);
942 continue;
943 }
944 if (!strcmp(key, "nt_hl_bg")) {
945 sscanf(value, "#%06x", &sio->nt_hl_bg);
946 continue;
947 }
948 if (!strcmp(key, "nt_hl_rev_fg")) {
949 sscanf(value, "#%06x", &sio->nt_hl_rev_fg);
950 continue;
951 }
952 if (!strcmp(key, "nt_hl_rev_bg")) {
953 sscanf(value, "#%06x", &sio->nt_hl_rev_bg);
954 continue;
955 }
956 if (!strcmp(key, "title_fg")) {
957 sscanf(value, "#%06x", &sio->title_fg);
958 continue;
959 }
960 if (!strcmp(key, "title_bg")) {
961 sscanf(value, "#%06x", &sio->title_bg);
962 continue;
963 }
964 if (!strcmp(key, "ran_fg")) {
965 sscanf(value, "#%06x", &sio->ran_fg);
966 continue;
967 }
968 if (!strcmp(key, "ran_bg")) {
969 sscanf(value, "#%06x", &sio->ran_bg);
970 continue;
971 }
972 if (!strcmp(key, "red_gamma")) {
973 sio->red_gamma = str_to_double(value);
974 continue;
975 }
976 if (!strcmp(key, "green_gamma")) {
977 sio->green_gamma = str_to_double(value);
978 continue;
979 }
980 if (!strcmp(key, "blue_gamma")) {
981 sio->blue_gamma = str_to_double(value);
982 continue;
983 }
984 if (!strcmp(key, "gray_gamma")) {
985 sio->gray_gamma = str_to_double(value);
986 continue;
987 }
988 if (!strcmp(key, "black")) {
989 sscanf(value, "#%06x", &sio->black);
990 continue;
991 }
992 if (!strcmp(key, "red")) {
993 sscanf(value, "#%06x", &sio->red);
994 continue;
995 }
996 if (!strcmp(key, "green")) {
997 sscanf(value, "#%06x", &sio->green);
998 continue;
999 }
1000 if (!strcmp(key, "yellow")) {
1001 sscanf(value, "#%06x", &sio->yellow);
1002 continue;
1003 }
1004 if (!strcmp(key, "blue")) {
1005 sscanf(value, "#%06x", &sio->blue);
1006 continue;
1007 }
1008 if (!strcmp(key, "magenta")) {
1009 sscanf(value, "#%06x", &sio->magenta);
1010 continue;
1011 }
1012 if (!strcmp(key, "cyan")) {
1013 sscanf(value, "#%06x", &sio->cyan);
1014 continue;
1015 }
1016 if (!strcmp(key, "white")) {
1017 sscanf(value, "#%06x", &sio->white);
1018 continue;
1019 }
1020 if (!strcmp(key, "orange")) {
1021 sscanf(value, "#%06x", &sio->orange);
1022 continue;
1023 }
1024 if (!strcmp(key, "bblack")) {
1025 sscanf(value, "#%06x", &sio->bblack);
1026 continue;
1027 }
1028 if (!strcmp(key, "bred")) {
1029 sscanf(value, "#%06x", &sio->bred);
1030 continue;
1031 }
1032 if (!strcmp(key, "bgreen")) {
1033 sscanf(value, "#%06x", &sio->bgreen);
1034 continue;
1035 }
1036 if (!strcmp(key, "byellow")) {
1037 sscanf(value, "#%06x", &sio->byellow);
1038 continue;
1039 }
1040 if (!strcmp(key, "bblue")) {
1041 sscanf(value, "#%06x", &sio->bblue);
1042 continue;
1043 }
1044 if (!strcmp(key, "bmagenta")) {
1045 sscanf(value, "#%06x", &sio->bmagenta);
1046 continue;
1047 }
1048 if (!strcmp(key, "bcyan")) {
1049 sscanf(value, "#%06x", &sio->bcyan);
1050 continue;
1051 }
1052 if (!strcmp(key, "bwhite")) {
1053 sscanf(value, "#%06x", &sio->bwhite);
1054 continue;
1055 }
1056 if (!strcmp(key, "borange")) {
1057 sscanf(value, "#%06x", &sio->borange);
1058 continue;
1059 }
1060 if (!strcmp(key, "mapp_spec")) {
1061 strnz__cpy(init->mapp_spec, value, MAXLEN - 1);
1062 continue;
1063 }
1064 if (!strcmp(key, "mapp_data")) {
1065 strnz__cpy(init->mapp_data, value, MAXLEN - 1);
1066 continue;
1067 }
1068 if (!strcmp(key, "mapp_help")) {
1069 strnz__cpy(init->mapp_help, value, MAXLEN - 1);
1070 continue;
1071 }
1072 if (!strcmp(key, "mapp_home")) {
1073 strnz__cpy(init->mapp_home, value, MAXLEN - 1);
1074 continue;
1075 }
1076 if (!strcmp(key, "mapp_msrc")) {
1077 strnz__cpy(init->mapp_msrc, value, MAXLEN - 1);
1078 continue;
1079 }
1080 if (!strcmp(key, "mapp_user")) {
1081 strnz__cpy(init->mapp_user, value, MAXLEN - 1);
1082 continue;
1083 }
1084 if (!strcmp(key, "mapp_theme")) {
1085 strnz__cpy(init->mapp_theme, value, MAXLEN - 1);
1086 continue;
1087 }
1088 }
1089 (void)fclose(config_fp);
1090 return 0;
1091}
bool str_to_bool(const char *)
Converts String to boolean true or false.
Definition futil.c:934
int process_config_file(char *, Init *)
Definition init.c:663
double str_to_double(char *)
converts string to double
Definition futil.c:922
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
Definition futil.c:963
bool unstr_hex_clr(char *, char *)
Validates that a string is a hex color code in the format "#RRGGBB".
Definition futil.c:225
uint32_t ran_bg
Definition cm.h:737
double green_gamma
Definition cm.h:690
uint32_t ln_bg
Definition cm.h:723
double blue_gamma
Definition cm.h:691
uint32_t magenta
Definition cm.h:698
uint32_t cmdln_bg
Definition cm.h:725
uint32_t cmdln_fg
Definition cm.h:724
uint32_t nt_hl_rev_fg
Definition cm.h:732
uint32_t ran_fg
Definition cm.h:736
uint32_t bgreen
Definition cm.h:704
double red_gamma
Definition cm.h:689
uint32_t green
Definition cm.h:695
uint32_t nt_fg
Definition cm.h:726
uint32_t yellow
Definition cm.h:696
uint32_t fill_char_fg
Definition cm.h:720
uint32_t orange
Definition cm.h:701
uint32_t ln_fg
Definition cm.h:722
uint32_t ind_bg
Definition cm.h:717
uint32_t bmagenta
Definition cm.h:707
uint32_t ind_fg
Definition cm.h:716
uint32_t byellow
Definition cm.h:705
uint32_t bblue
Definition cm.h:706
uint32_t borange
Definition cm.h:710
uint32_t title_bg
Definition cm.h:735
uint32_t fg
Definition cm.h:712
uint32_t cyan
Definition cm.h:699
uint32_t bblack
Definition cm.h:702
uint32_t red
Definition cm.h:694
uint32_t nt_hl_rev_bg
Definition cm.h:733
uint32_t title_fg
Definition cm.h:734
uint32_t bred
Definition cm.h:703
uint32_t fill_char_bg
Definition cm.h:721
uint32_t black
Definition cm.h:693
uint32_t nt_rev_bg
Definition cm.h:729
uint32_t brackets_bg
Definition cm.h:719
uint32_t bcyan
Definition cm.h:708
uint32_t nt_bg
Definition cm.h:727
uint32_t blue
Definition cm.h:697
uint32_t brackets_fg
Definition cm.h:718
uint32_t white
Definition cm.h:700
uint32_t box_bg
Definition cm.h:715
uint32_t nt_hl_fg
Definition cm.h:730
uint32_t bwhite
Definition cm.h:709
char border
Definition cm.h:752
uint32_t nt_rev_fg
Definition cm.h:728
double gray_gamma
Definition cm.h:692
uint32_t nt_hl_bg
Definition cm.h:731
uint32_t bg
Definition cm.h:713

References SIO::bblack, SIO::bblue, SIO::bcyan, Init::begx, Init::begy, SIO::bg, SIO::bgreen, SIO::black, SIO::blue, SIO::blue_gamma, SIO::bmagenta, SIO::borange, SIO::border, SIO::box_bg, Init::brackets, SIO::brackets_bg, SIO::brackets_fg, SIO::bred, SIO::bwhite, SIO::byellow, Init::cmd, Init::cmd_all, SIO::cmdln_bg, SIO::cmdln_fg, Init::cols, SIO::cyan, Init::editor, expand_tilde(), Init::f_at_end_remove, Init::f_erase_remainder, Init::f_ignore_case, Init::f_ln, Init::f_multiple_cmd_args, Init::f_read_theme, Init::f_squeeze, Init::f_strip_ansi, SIO::fg, Init::fill_char, SIO::fill_char_bg, SIO::fill_char_fg, SIO::gray_gamma, SIO::green, SIO::green_gamma, Init::h_shift, SIO::ind_bg, SIO::ind_fg, Init::lines, SIO::ln_bg, SIO::ln_fg, SIO::magenta, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_theme, Init::mapp_user, Init::minitrc, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, SIO::orange, Init::p_view_files, Init::parent_cmd, process_config_file(), Init::provider_cmd, SIO::ran_bg, SIO::ran_fg, Init::receiver_cmd, SIO::red, SIO::red_gamma, Init::select_max, Init::sio, str_to_bool(), str_to_double(), strnz__cpy(), Init::tab_stop, Init::title, SIO::title_bg, SIO::title_fg, unstr_hex_clr(), SIO::white, Init::wrap, and SIO::yellow.

Referenced by process_config_file(), process_config_files(), and read_theme().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ view_stack_free()

void view_stack_free ( ViewStack * )
extern

◆ view_stack_init()

bool view_stack_init ( ViewStack * ,
size_t  )
extern

◆ view_stack_peek()

bool view_stack_peek ( const ViewStack * ,
View *  )
extern

◆ view_stack_pop()

bool view_stack_pop ( ViewStack * ,
View *  )
extern

◆ view_stack_push()

bool view_stack_push ( ViewStack * ,
View  )
extern

Variable Documentation

◆ init_cnt

int init_cnt
extern

Definition at line 28 of file mem.c.

Referenced by destroy_init(), and new_init().

◆ minitrc

char minitrc[MAXLEN]
extern

number of Init data structures allocated

◆ view_stack

ViewStack view_stack
extern

Definition at line 32 of file init_view.c.