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 *)
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 **, int, int)
 Initialize form data structure and parse description file.
bool init_menu_files (Init *, int, char **)
 Initialize Menu file specifications.
int init_pick (Init *, int, char **, int, int)
 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 initialize_local_colors (SIO *)
 Initialize local color variables and color pairs based on SIO settings.
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 **, int, int)
 Create and initialize Form structure.
Initnew_init (int, char **)
 Create and initialize Init structure.
Menunew_menu (Init *, int, char **, int, int)
 Create and initialize Menu structure.
Picknew_pick (Init *, int, char **, int, int)
 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 ()
 Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description.
int popup_form (Init *, int, char **, int, int)
 instantiate a form popup window
int popup_menu (Init *, int, char **, int, int)
 instantiate a menu popup window
int popup_pick (Init *, int, char **, int, int)
 instantiate a pick popup window
int popup_view (Init *, int, char **, int, int, int, int)
 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 *)
 Free View Stack.
bool view_stack_init (ViewStack *, size_t)
 Initialize View Stack.
bool view_stack_peek (const ViewStack *, View *)
 Peek at Top Item of View Stack.
bool view_stack_pop (ViewStack *, View *)
 Pop Item from View Stack.
bool view_stack_push (ViewStack *, View)
 Push Item onto View Stack.
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:106

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); \
open_curses(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:297
int main(int argc, char **argv)
Definition amort.c:30
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:71
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
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:805

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 open_curses(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_line_table()

void destroy_line_table ( View * view)
extern

Definition at line 1653 of file view_engine.c.

1653 {
1654 if (view->ln_tbl == nullptr)
1655 return;
1656 free(view->ln_tbl);
1657 view->ln_tbl = nullptr;
1658 view->ln_tbl_size = 0;
1659 view->ln_max_pos = 0;
1660 view->ln = 0;
1661}
View * view
Definition mem.c:49

References View::ln, View::ln_max_pos, View::ln_tbl, and View::ln_tbl_size.

Referenced by destroy_pick_view(), new_view_file(), and view_file().

Here is the caller graph for this function:

◆ destroy_view_win()

void destroy_view_win ( Init * init)
extern

Definition at line 318 of file init_view.c.

318 {
319 View *view = init->view;
320 if (!view)
321 return;
322 view_win_del(view->pad_view_pan, view->pad_view_win);
323 delwin(view->pad);
324 view_win_del(view->cmdln_pan, view->cmdln_win);
325 view_win_del(view->lnno_pan, view->lnno_win);
326 view_win_del(view->win_pan, view->win_win);
327 view_win_del(view->box_pan, view->box_win);
328 wnoutrefresh(stdscr);
329 update_panels();
330 doupdate();
331}
void view_win_del(PANEL *, WINDOW *)
Definition init_view.c:332
View * view
Definition common.h:188
Definition view.h:42

References View::box_pan, View::box_win, View::cmdln_pan, View::cmdln_win, View::lnno_pan, View::lnno_win, View::pad, View::pad_view_pan, View::pad_view_win, Init::view, view_win_del(), View::win_pan, and View::win_win.

Referenced by destroy_pick_view(), view_boxwin_resize(), and view_file().

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

◆ popup_ckeys()

int popup_ckeys ( )
extern

Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description.

Returns
0 on success, non-zero on failure

Definition at line 23 of file curskeys.c.

23 {
24 WINDOW *win;
25 // WINDOW *box;
26 char Title[] = "TEST CURSES KEYS";
27 int lines = 10;
28 int cols = 55;
29 char kstr[KSTRLEN];
30 int c;
31 char action[MAXLEN];
32 char tmp[MAXLEN];
33 MEVENT event;
34 char *s;
35 int maxy, maxx;
36
37 getmaxyx(stdscr, maxy, maxx);
38 int begy = (maxy - lines) / 3;
39 int begx = (maxx - cols) / 2;
40 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT |
41 BUTTON_CTRL | BUTTON_ALT,
42 NULL);
43 if (box_new(lines, cols, begy, begx, Title)) {
44 strnz__cpy(tmp, "box_new failed: ", MAXLEN - 1);
45 strnz__cat(tmp, Title, MAXLEN - 1);
46 Perror(tmp);
47 exit(EXIT_FAILURE);
48 }
49 // box = win_box[win_ptr];
50 win = win_win[win_ptr];
51 keypad(win, TRUE);
52 wbkgrndset(win, &CC_NT_REV);
53 mvwaddstr(win, lines - 1, 0, " <ALT>END to exit ");
54 wbkgrndset(win, &CC_NT);
55 // wnoutrefresh(box);
56 mvwaddstr(win, 1, 4, "Press a key or activate the mouse:");
57 c = '\0';
58 halfdelay(1);
59 while (!c) {
60 kstr[0] = '\0';
61 wmove(win, 1, 39);
62 do {
63 update_panels();
64 doupdate();
65 c = wgetch(win);
66 if (sig_received != 0) {
68 c = display_error(em0, em1, em2, NULL);
69 if (c == 'q' || c == KEY_F(9))
70 exit(EXIT_FAILURE);
71 continue;
72 }
73 } while (c == ERR);
74 s = keybound(c, 0);
75 switch (c) {
76 case '\0':
77 break;
78 case KEY_CODE_YES:
79 strnz__cpy(kstr, "KEY_CODE_YES A wchar_t contains a key code",
80 KSTRLEN - 1);
81 break;
82 case KEY_BREAK:
83 strnz__cpy(kstr, "KEY_BREAK Break key(unreliable)", KSTRLEN - 1);
84 break;
85 case KEY_DOWN:
86 strnz__cpy(kstr, "KEY_DOWN down - arrow key", KSTRLEN - 1);
87 break;
88 case KEY_UP:
89 strnz__cpy(kstr, "KEY_UP up - arrow key", KSTRLEN - 1);
90 break;
91 case KEY_LEFT:
92 strnz__cpy(kstr, "KEY_LEFT left - arrow key", KSTRLEN - 1);
93 break;
94 case KEY_RIGHT:
95 strnz__cpy(kstr, "KEY_RIGHT right - arrow key", KSTRLEN - 1);
96 break;
97 case KEY_HOME:
98 strnz__cpy(kstr, "KEY_HOME home key", KSTRLEN - 1);
99 break;
100 case KEY_BACKSPACE:
101 strnz__cpy(kstr, "KEY_BACKSPACE backspace key", KSTRLEN - 1);
102 break;
103 case KEY_F(1):
104 strnz__cpy(kstr, "KEY_F(1) KEY_F(1)", KSTRLEN - 1);
105 break;
106 case KEY_F(2):
107 strnz__cpy(kstr, "KEY_F2 KEY_F2", KSTRLEN - 1);
108 break;
109 case KEY_F(3):
110 strnz__cpy(kstr, "KEY_F3 KEY_F3", KSTRLEN - 1);
111 break;
112 case KEY_F(4):
113 strnz__cpy(kstr, "KEY_F4 KEY_F4", KSTRLEN - 1);
114 break;
115 case KEY_F(5):
116 strnz__cpy(kstr, "KEY_F5 KEY_F5", KSTRLEN - 1);
117 break;
118 case KEY_F(6):
119 strnz__cpy(kstr, "KEY_F6 KEY_F6", KSTRLEN - 1);
120 break;
121 case KEY_F(7):
122 strnz__cpy(kstr, "KEY_F7 KEY_F7", KSTRLEN - 1);
123 break;
124 case KEY_F(8):
125 strnz__cpy(kstr, "KEY_F8 KEY_F8", KSTRLEN - 1);
126 break;
127 case KEY_F(9):
128 strnz__cpy(kstr, "KEY_F9 KEY_F9", KSTRLEN - 1);
129 break;
130 case KEY_F(10):
131 strnz__cpy(kstr, "KEY_F10 KEY_F10", KSTRLEN - 1);
132 break;
133 case KEY_F(11):
134 strnz__cpy(kstr, "KEY_F11 KEY_F11", KSTRLEN - 1);
135 break;
136 case KEY_F(12):
137 strnz__cpy(kstr, "KEY_F12 KEY_F12", KSTRLEN - 1);
138 break;
139 case KEY_DL:
140 strnz__cpy(kstr, "KEY_DL delete - line key", KSTRLEN - 1);
141 break;
142 case KEY_IL:
143 strnz__cpy(kstr, "KEY_IL insert - line key", KSTRLEN - 1);
144 break;
145 case KEY_DC:
146 strnz__cpy(kstr, "KEY_DC delete - character key", KSTRLEN - 1);
147 break;
148 case KEY_IC:
149 strnz__cpy(kstr, "KEY_IC insert - character key", KSTRLEN - 1);
150 break;
151 case KEY_EIC:
152 strnz__cpy(kstr, "KEY_EIC sent by rmir or smir in insert mode",
153 KSTRLEN - 1);
154 break;
155 case KEY_CLEAR:
156 strnz__cpy(kstr, "KEY_CLEAR clear - screen or erase key",
157 KSTRLEN - 1);
158 break;
159 case KEY_EOS:
160 strnz__cpy(kstr, "KEY_EOS clear - to - end - of - screen key",
161 KSTRLEN - 1);
162 break;
163 case KEY_EOL:
164 strnz__cpy(kstr, "KEY_EOL clear - to - end - of - line key",
165 KSTRLEN - 1);
166 break;
167 case KEY_SF:
168 strnz__cpy(kstr, "KEY_SF scroll - forward key", KSTRLEN - 1);
169 break;
170 case KEY_SR:
171 strnz__cpy(kstr, "KEY_SR scroll - backward key", KSTRLEN - 1);
172 break;
173 case KEY_NPAGE:
174 strnz__cpy(kstr, "KEY_NPAGE next - page key", KSTRLEN - 1);
175 break;
176 case KEY_PPAGE:
177 strnz__cpy(kstr, "KEY_PPAGE previous - page key", KSTRLEN - 1);
178 break;
179 case KEY_STAB:
180 strnz__cpy(kstr, "KEY_STAB set - tab key", KSTRLEN - 1);
181 break;
182 case KEY_CTAB:
183 strnz__cpy(kstr, "KEY_CTAB clear - tab key", KSTRLEN - 1);
184 break;
185 case KEY_CATAB:
186 strnz__cpy(kstr, "KEY_CATAB clear - all - tabs key", KSTRLEN - 1);
187 break;
188 case '\n':
189 strnz__cpy(kstr, "KEY_ENTER newline key", KSTRLEN - 1);
190 break;
191 case KEY_ENTER:
192 strnz__cpy(kstr, "KEY_ENTER enter / send key", KSTRLEN - 1);
193 break;
194 case KEY_SRESET:
195 strnz__cpy(kstr, "KEY_SRESET Soft(partial) reset(unreliable)",
196 KSTRLEN - 1);
197 break;
198 case KEY_RESET:
199 strnz__cpy(kstr, "KEY_RESET Reset or hard reset(unreliable)",
200 KSTRLEN - 1);
201 break;
202 case KEY_PRINT:
203 strnz__cpy(kstr, "KEY_PRINT print key", KSTRLEN - 1);
204 break;
205 case KEY_LL:
206 strnz__cpy(kstr, "KEY_LL lower - left key(home down)", KSTRLEN - 1);
207 break;
208 case KEY_A1:
209 strnz__cpy(kstr, "KEY_A1 upper left of keypad", KSTRLEN - 1);
210 break;
211 case KEY_A3:
212 strnz__cpy(kstr, "KEY_A3 upper right of keypad", KSTRLEN - 1);
213 break;
214 case KEY_B2:
215 strnz__cpy(kstr, "KEY_B2 center of keypad", KSTRLEN - 1);
216 break;
217 case KEY_C1:
218 strnz__cpy(kstr, "KEY_C1 lower left of keypad", KSTRLEN - 1);
219 break;
220 case KEY_C3:
221 strnz__cpy(kstr, "KEY_C3 lower right of keypad", KSTRLEN - 1);
222 break;
223 case KEY_BTAB:
224 strnz__cpy(kstr, "KEY_BTAB back - tab key", KSTRLEN - 1);
225 break;
226 case KEY_BEG:
227 strnz__cpy(kstr, "KEY_BEG begin key", KSTRLEN - 1);
228 break;
229 case KEY_CANCEL:
230 strnz__cpy(kstr, "KEY_CANCEL cancel key", KSTRLEN - 1);
231 break;
232 case KEY_CLOSE:
233 strnz__cpy(kstr, "KEY_CLOSE close key", KSTRLEN - 1);
234 break;
235 case KEY_COMMAND:
236 strnz__cpy(kstr, "KEY_COMMAND command key", KSTRLEN - 1);
237 break;
238 case KEY_COPY:
239 strnz__cpy(kstr, "KEY_COPY copy key", KSTRLEN - 1);
240 break;
241 case KEY_CREATE:
242 strnz__cpy(kstr, "KEY_CREATE create key", KSTRLEN - 1);
243 break;
244 case KEY_END:
245 strnz__cpy(kstr, "KEY_END end key", KSTRLEN - 1);
246 break;
247 case KEY_EXIT:
248 strnz__cpy(kstr, "KEY_EXIT exit key", KSTRLEN - 1);
249 break;
250 case KEY_FIND:
251 strnz__cpy(kstr, "KEY_FIND find key", KSTRLEN - 1);
252 break;
253 case KEY_HELP:
254 strnz__cpy(kstr, "KEY_HELP help key", KSTRLEN - 1);
255 break;
256 case KEY_MARK:
257 strnz__cpy(kstr, "KEY_MARK mark key", KSTRLEN - 1);
258 break;
259 case KEY_MESSAGE:
260 strnz__cpy(kstr, "KEY_MESSAGE message key", KSTRLEN - 1);
261 break;
262 case KEY_MOVE:
263 strnz__cpy(kstr, "KEY_MOVE move key", KSTRLEN - 1);
264 break;
265 case KEY_NEXT:
266 strnz__cpy(kstr, "KEY_NEXT next key", KSTRLEN - 1);
267 break;
268 case KEY_OPEN:
269 strnz__cpy(kstr, "KEY_OPEN open key", KSTRLEN - 1);
270 break;
271 case KEY_OPTIONS:
272 strnz__cpy(kstr, "KEY_OPTIONS options key", KSTRLEN - 1);
273 break;
274 case KEY_PREVIOUS:
275 strnz__cpy(kstr, "KEY_PREVIOUS previous key", KSTRLEN - 1);
276 break;
277 case KEY_REDO:
278 strnz__cpy(kstr, "KEY_REDO redo key", KSTRLEN - 1);
279 break;
280 case KEY_REFERENCE:
281 strnz__cpy(kstr, "KEY_REFERENCE reference key", KSTRLEN - 1);
282 break;
283 case KEY_REFRESH:
284 strnz__cpy(kstr, "KEY_REFRESH refresh key", KSTRLEN - 1);
285 break;
286 case KEY_REPLACE:
287 strnz__cpy(kstr, "KEY_REPLACE replace key", KSTRLEN - 1);
288 break;
289 case KEY_RESTART:
290 strnz__cpy(kstr, "KEY_RESTART restart key", KSTRLEN - 1);
291 break;
292 case KEY_RESUME:
293 strnz__cpy(kstr, "KEY_RESUME resume key", KSTRLEN - 1);
294 break;
295 case KEY_SAVE:
296 strnz__cpy(kstr, "KEY_SAVE save key", KSTRLEN - 1);
297 break;
298 case KEY_SBEG:
299 strnz__cpy(kstr, "KEY_SBEG shifted begin key", KSTRLEN - 1);
300 break;
301 case KEY_SCANCEL:
302 strnz__cpy(kstr, "KEY_SCANCEL shifted cancel key", KSTRLEN - 1);
303 break;
304 case KEY_SCOMMAND:
305 strnz__cpy(kstr, "KEY_SCOMMAND shifted command key", KSTRLEN - 1);
306 break;
307 case KEY_SCOPY:
308 strnz__cpy(kstr, "KEY_SCOPY shifted copy key", KSTRLEN - 1);
309 break;
310 case KEY_SCREATE:
311 strnz__cpy(kstr, "KEY_SCREATE shifted create key", KSTRLEN - 1);
312 break;
313 case KEY_SDC:
314 strnz__cpy(kstr, "KEY_SDC shifted delete - character key",
315 KSTRLEN - 1);
316 break;
317 case KEY_SDL:
318 strnz__cpy(kstr, "KEY_SDL shifted delete - line key", KSTRLEN - 1);
319 break;
320 case KEY_SELECT:
321 strnz__cpy(kstr, "KEY_SELECT select key", KSTRLEN - 1);
322 break;
323 case KEY_SEND:
324 strnz__cpy(kstr, "KEY_SEND shifted end key", KSTRLEN - 1);
325 break;
326 case KEY_SEOL:
327 strnz__cpy(kstr,
328 "KEY_SEOL shifted clear - to - end - of - line key",
329 KSTRLEN - 1);
330 break;
331 case KEY_SEXIT:
332 strnz__cpy(kstr, "KEY_SEXIT shifted exit key", KSTRLEN - 1);
333 break;
334 case KEY_SFIND:
335 strnz__cpy(kstr, "KEY_SFIND shifted find key", KSTRLEN - 1);
336 break;
337 case KEY_SHELP:
338 strnz__cpy(kstr, "KEY_SHELP shifted help key", KSTRLEN - 1);
339 break;
340 case KEY_SHOME:
341 strnz__cpy(kstr, "KEY_SHOME shifted home key", KSTRLEN - 1);
342 break;
343 case KEY_SIC:
344 strnz__cpy(kstr, "KEY_SIC shifted insert - character key",
345 KSTRLEN - 1);
346 break;
347 case KEY_SLEFT:
348 strnz__cpy(kstr, "KEY_SLEFT shifted left - arrow key", KSTRLEN - 1);
349 break;
350 case KEY_SMESSAGE:
351 strnz__cpy(kstr, "KEY_SMESSAGE shifted message key", KSTRLEN - 1);
352 break;
353 case KEY_SMOVE:
354 strnz__cpy(kstr, "KEY_SMOVE shifted move key", KSTRLEN - 1);
355 break;
356 case KEY_SNEXT:
357 strnz__cpy(kstr, "KEY_SNEXT shifted next key", KSTRLEN - 1);
358 break;
359 case KEY_SOPTIONS:
360 strnz__cpy(kstr, "KEY_SOPTIONS shifted options key", KSTRLEN - 1);
361 break;
362 case KEY_SPREVIOUS:
363 strnz__cpy(kstr, "KEY_SPREVIOUS shifted previous key", KSTRLEN - 1);
364 break;
365 case KEY_SPRINT:
366 strnz__cpy(kstr, "KEY_SPRINT shifted print key", KSTRLEN - 1);
367 break;
368 case KEY_SREDO:
369 strnz__cpy(kstr, "KEY_SREDO shifted redo key", KSTRLEN - 1);
370 break;
371 case KEY_SREPLACE:
372 strnz__cpy(kstr, "KEY_SREPLACE shifted replace key", KSTRLEN - 1);
373 break;
374 case KEY_SRIGHT:
375 strnz__cpy(kstr, "KEY_SRIGHT shifted right - arrow key",
376 KSTRLEN - 1);
377 break;
378 case KEY_SRSUME:
379 strnz__cpy(kstr, "KEY_SRSUME shifted resume key", KSTRLEN - 1);
380 break;
381 case KEY_SSAVE:
382 strnz__cpy(kstr, "KEY_SSAVE shifted save key", KSTRLEN - 1);
383 break;
384 case KEY_SSUSPEND:
385 strnz__cpy(kstr, "KEY_SSUSPEND shifted suspend key", KSTRLEN - 1);
386 break;
387 case KEY_SUNDO:
388 strnz__cpy(kstr, "KEY_SUNDO shifted undo key", KSTRLEN - 1);
389 break;
390 case KEY_SUSPEND:
391 strnz__cpy(kstr, "KEY_SUSPEND suspend key", KSTRLEN - 1);
392 break;
393 case KEY_UNDO:
394 strnz__cpy(kstr, "KEY_UNDO undo key", KSTRLEN - 1);
395 break;
396 case KEY_ALTDEL:
397 strnz__cpy(kstr, "KEY_ALTDEL alt+delete", KSTRLEN - 1);
398 break;
399 case KEY_ALTDOWN:
400 strnz__cpy(kstr, "KEY_ALTDOWN alt+down", KSTRLEN - 1);
401 break;
402 case KEY_ALTEND:
403 strnz__cpy(kstr, "KEY_ALTEND alt+end", KSTRLEN - 1);
404 break;
405 case KEY_ALTHOME:
406 strnz__cpy(kstr, "KEY_ALTHOME alt+home", KSTRLEN - 1);
407 break;
408 case KEY_ALTINS:
409 strnz__cpy(kstr, "KEY_ALTINS alt+ins", KSTRLEN - 1);
410 break;
411 case KEY_ALTLEFT:
412 strnz__cpy(kstr, "KEY_ALTLEFT alt+left", KSTRLEN - 1);
413 break;
414 case KEY_ALTPGDN:
415 strnz__cpy(kstr, "KEY_ALTPGDN alt+pgdn", KSTRLEN - 1);
416 break;
417 case KEY_ALTPGUP:
418 strnz__cpy(kstr, "KEY_ALTPGUP alt+pgup", KSTRLEN - 1);
419 break;
420 case KEY_ALTRIGHT:
421 strnz__cpy(kstr, "KEY_ALTRIGHT alt+right", KSTRLEN - 1);
422 break;
423 case KEY_ALTUP:
424 strnz__cpy(kstr, "KEY_ALTUP alt+up", KSTRLEN - 1);
425 break;
426 case KEY_ALTF(1):
427 strnz__cpy(kstr, "KEY_ALTF1 alt+F1", KSTRLEN - 1);
428 break;
429 case KEY_ALTF(2):
430 strnz__cpy(kstr, "KEY_ALTF1 alt+F2", KSTRLEN - 1);
431 break;
432 case KEY_ALTF(3):
433 strnz__cpy(kstr, "KEY_ALTF3 alt+F3", KSTRLEN - 1);
434 break;
435 case KEY_ALTF(4):
436 strnz__cpy(kstr, "KEY_ALTF4 alt+F4", KSTRLEN - 1);
437 break;
438 case KEY_ALTF(5):
439 strnz__cpy(kstr, "KEY_ALTF5 alt+F5", KSTRLEN - 1);
440 break;
441 case KEY_ALTF(6):
442 strnz__cpy(kstr, "KEY_ALTF6 alt+F6", KSTRLEN - 1);
443 break;
444 case KEY_ALTF(7):
445 strnz__cpy(kstr, "KEY_ALTF7 alt+F7", KSTRLEN - 1);
446 break;
447 case KEY_ALTF(8):
448 strnz__cpy(kstr, "KEY_ALTF8 alt+F8", KSTRLEN - 1);
449 break;
450 case KEY_ALTF(9):
451 strnz__cpy(kstr, "KEY_ALTF9 alt+F9", KSTRLEN - 1);
452 break;
453 case KEY_ALTF(10):
454 strnz__cpy(kstr, "KEY_ALTF10 alt+F10", KSTRLEN - 1);
455 break;
456 case KEY_ALTF(11):
457 strnz__cpy(kstr, "KEY_ALTF11 alt+F11", KSTRLEN - 1);
458 break;
459 case KEY_ALTF(12):
460 strnz__cpy(kstr, "KEY_ALTF12 alt+F12", KSTRLEN - 1);
461 break;
462 case KEY_MOUSE:
463 action[0] = '\0';
464 if (getmouse(&event) == OK) {
465 switch (event.bstate) {
466 case BUTTON1_PRESSED:
467 strnz__cpy(action, "Button 1 pressed", KSTRLEN - 1);
468 break;
469 case BUTTON1_RELEASED:
470 strnz__cpy(action, "Button 1 released", KSTRLEN - 1);
471 break;
472 case BUTTON1_CLICKED:
473 strnz__cpy(action, "Button 1 clicked", KSTRLEN - 1);
474 break;
475 case BUTTON1_DOUBLE_CLICKED:
476 strnz__cpy(action, "Button 1 double-clicked", KSTRLEN - 1);
477 break;
478 case BUTTON2_PRESSED:
479 strnz__cpy(action, "Button 2 pressed", KSTRLEN - 1);
480 break;
481 case BUTTON2_RELEASED:
482 strnz__cpy(action, "Button 2 released", KSTRLEN - 1);
483 break;
484 case BUTTON2_CLICKED:
485 strnz__cpy(action, "Button 2 clicked", KSTRLEN - 1);
486 break;
487 case BUTTON2_DOUBLE_CLICKED:
488 strnz__cpy(action, "Button 2 double-clicked", KSTRLEN - 1);
489 break;
490 case BUTTON3_PRESSED:
491 strnz__cpy(action, "Button 3 pressed", KSTRLEN - 1);
492 break;
493 case BUTTON3_RELEASED:
494 strnz__cpy(action, "Button 3 released", KSTRLEN - 1);
495 break;
496 case BUTTON3_CLICKED:
497 strnz__cpy(action, "Button 3 clicked", KSTRLEN - 1);
498 break;
499 case BUTTON3_DOUBLE_CLICKED:
500 strnz__cpy(action, "Button 3 double-clicked", KSTRLEN - 1);
501 break;
502 case BUTTON4_PRESSED:
503 strnz__cpy(action, "Button 4 pressed", KSTRLEN - 1);
504 break;
505 case BUTTON4_RELEASED:
506 strnz__cpy(action, "Button 4 released", KSTRLEN - 1);
507 break;
508 case BUTTON4_CLICKED:
509 strnz__cpy(action, "Button 4 clicked", KSTRLEN - 1);
510 break;
511 case BUTTON4_DOUBLE_CLICKED:
512 strnz__cpy(action, "Button 4 double-clicked", KSTRLEN - 1);
513 break;
514 case BUTTON5_PRESSED:
515 strnz__cpy(action, "Scroll Up", KSTRLEN - 1);
516 break;
517 default:
518 break;
519 }
520 mvwaddstr(win, 6, 3, " Action:");
521 mvwaddstr(win, 6, 16, action);
522 wclrtoeol(win);
523
524 strnz__cpy(tmp, " With Key:", MAXLEN - 1);
525 if (event.bstate & BUTTON_SHIFT)
526 strnz__cat(tmp, " Shift", MAXLEN - 1);
527 if (event.bstate & BUTTON_CTRL)
528 strnz__cat(tmp, " Ctrl", MAXLEN - 1);
529 if (event.bstate & BUTTON_ALT)
530 strnz__cat(tmp, " Alt", MAXLEN - 1);
531 mvwaddstr(win, 3, 4, tmp);
532 wclrtoeol(win);
533 if (wenclose(win, event.y, event.x)) {
534 sprintf(tmp, " Inside Win: y: %3d, x: %3d",
535 event.y - begy, event.x - begx);
536 } else {
537 sprintf(tmp, " Outside Win: y: %3d, x: %3d",
538 event.y - begy, event.x - begx);
539 }
540 mvwaddstr(win, 4, 4, tmp);
541 wclrtoeol(win);
542 wmove(win, 5, 0);
543 wclrtoeol(win);
544 wmove(win, 7, 0);
545 wclrtoeol(win);
546 }
547 break;
548 default:
549 break;
550 }
551 if (c != KEY_MOUSE) {
552
553 sprintf(tmp, " Octal: %3o", c);
554 mvwaddstr(win, 3, 4, tmp);
555 wclrtoeol(win);
556
557 sprintf(tmp, " Decimal: %3d", c);
558 mvwaddstr(win, 4, 4, tmp);
559 wclrtoeol(win);
560
561 sprintf(tmp, " Hex: %3x", c);
562 mvwaddstr(win, 5, 4, tmp);
563 wclrtoeol(win);
564
565 if (kstr[0]) {
566 sprintf(tmp, "Description: %s", kstr);
567 } else {
568 sprintf(tmp, " ASCII: %c", c);
569 }
570 mvwaddstr(win, 6, 3, tmp);
571 wclrtoeol(win);
572 mvwaddstr(win, 7, 2, "Key bound To: ");
573 wclrtoeol(win);
574 mvwaddstr(win, 7, 16, s ? s : "Not Bound");
575 // wrefresh(win);
576 update_panels();
577 doupdate();
578 }
579 if (c == KEY_ALTEND) {
580 usleep(100000);
581 break;
582 }
583 c = '\0';
584 }
585 win_del();
586 return 0;
587}
volatile sig_atomic_t sig_received
Definition sig.c:31
bool handle_signal(sig_atomic_t)
#define KEY_ALTEND
Definition cm.h:560
#define KEY_ALTLEFT
Definition cm.h:563
#define KEY_ALTDOWN
Definition cm.h:564
WINDOW * win_win[MAXWIN]
Definition dwin.c:52
#define KEY_ALTHOME
Definition cm.h:557
char em1[MAXLEN]
Definition dwin.c:176
cchar_t CC_NT
Definition dwin.c:204
#define KEY_ALTPGDN
Definition cm.h:561
#define KEY_ALTRIGHT
Definition cm.h:565
#define KEY_ALTDEL
Definition cm.h:559
#define KEY_ALTUP
Definition cm.h:562
int win_ptr
Definition dwin.c:164
#define KEY_ALTPGUP
Definition cm.h:558
char em0[MAXLEN]
Definition dwin.c:175
#define KEY_ALTF(n)
Definition cm.h:503
cchar_t CC_NT_REV
Definition dwin.c:205
#define KEY_ALTINS
Definition cm.h:556
char em2[MAXLEN]
Definition dwin.c:177
#define TRUE
Definition iloan.c:19
#define KSTRLEN
Definition curskeys.c:14
#define MAXLEN
Definition curskeys.c:15
void win_del()
Delete the current window and its associated box window.
Definition dwin.c:1179
int box_new(int, int, int, int, char *)
Create a new window with optional box and title.
Definition dwin.c:967
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1526
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
Definition dwin.c:1467
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:544
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:573

References box_new(), CC_NT, CC_NT_REV, display_error(), em0, em1, em2, handle_signal(), Perror(), sig_received, strnz__cat(), strnz__cpy(), win_del(), win_ptr, and win_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,
int by,
int 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 112 of file popups.c.

112 {
113 int rc;
114 zero_opt_args(init);
115 parse_opt_args(init, argc, argv);
116 Form *sav_form = init->form;
117 init->form = nullptr;
118 rc = init_form(init, init->argc, init->argv, by, bx);
119 destroy_form(init);
120 init->form = sav_form;
121 return rc;
122}
int init_form(Init *, int, char **, int, int)
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:559
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:574
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:286
Form * form
Definition common.h:184
int argc
Definition common.h:130
char ** argv
Definition common.h:131
Definition form.h:145

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,
int by,
int 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 *, int, char **, int, int)
Create and initialize Menu structure.
Definition mem.c:145
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:166
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:38
Menu * menu
Definition common.h:182
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:106

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,
int by,
int 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 rc = init_pick(init, init->argc, init->argv, by, bx);
90 destroy_pick(init);
91 init->pick = sav_pick;
92 return rc;
93}
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:236
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:66
Pick * pick
Definition common.h:186
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,
int ilines,
int icols,
int by,
int 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 144 of file popups.c.

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

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 * config_file_name,
Init * init )
extern

Definition at line 631 of file init.c.

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

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::box_bg, SIO::box_fg, Init::brackets, SIO::brackets_bg, SIO::brackets_fg, SIO::bred, SIO::bwhite, SIO::byellow, Init::cmd, Init::cmd_all, Init::cols, SIO::cyan, Init::editor, expand_tilde(), Init::f_at_end_remove, Init::f_erase_remainder, Init::f_ignore_case, Init::f_ln, Init::f_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, 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(), wait_timeout, SIO::white, 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:

Variable Documentation

◆ init_cnt

int init_cnt
extern

Definition at line 44 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 34 of file init_view.c.