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 <ncursesw/ncurses.h>
#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 _XOPEN_SOURCE_EXTENDED   1
#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_PICK_OBJS   1024
#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

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.
Menudestroy_menu (Init *init)
 Destroy Menu structure.
Pickdestroy_pick (Init *init)
 Destroy Pick structure.
Viewdestroy_view (Init *init)
 Destroy View structure.
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 *, char *)
 Initialize the C-Menu View in box window mode.
int init_view_full_screen (Init *)
 Initialize C-Menu View in full screen mode.
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.
int open_pick_win (Init *)
 Initializes the pick window based on the parameters specified in the Pick structure.
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
void view_calc_full_screen_dimensions (Init *)
 Calculate the dimensions for full screen mode.
void view_calc_win_dimensions (Init *, char *title)
 Calculate the dimensions and position of the box window for C-Menu 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 (View *, char *)
 Initialize the input for a C-Menu View.
void view_win_resize (Init *, char *)
 Resize the current window and its box, and update the title.
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

Initinit
int init_cnt
char minitrc [MAXLEN]

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.

◆ _XOPEN_SOURCE_EXTENDED

#define _XOPEN_SOURCE_EXTENDED   1

Definition at line 14 of file common.h.

◆ ABOUT

#define ABOUT   ".about"

Definition at line 42 of file common.h.

◆ ACCEPT_PROMPT_CHAR

#define ACCEPT_PROMPT_CHAR   '_'

Definition at line 32 of file common.h.

◆ COLOR_LEN

#define COLOR_LEN   8

Definition at line 29 of file common.h.

◆ DEFAULTEDITOR

#define DEFAULTEDITOR   "vi"

Definition at line 39 of file common.h.

◆ destroy_cmenu

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

Definition at line 64 of file common.h.

64#define destroy_cmenu() \
65 destroy_init(init); \
66 win_del(); \
67 curs_set(1); \
68 destroy_curses(); \
69 return 0; \
70 }

◆ EIGHT

#define EIGHT   8

Definition at line 46 of file common.h.

◆ FORM_HELP_FILE

#define FORM_HELP_FILE   "form.help"

Definition at line 35 of file common.h.

◆ MAPP_DIR

#define MAPP_DIR   "~/menuapp"

Definition at line 43 of file common.h.

◆ MAX_PICK_OBJS

#define MAX_PICK_OBJS   1024

Definition at line 31 of file common.h.

◆ MAX_WIDE_LEN

#define MAX_WIDE_LEN   1024

Definition at line 28 of file common.h.

◆ MAXOPTS

#define MAXOPTS   50

Definition at line 45 of file common.h.

◆ MENU_HELP_FILE

#define MENU_HELP_FILE   "menu.help"

Definition at line 34 of file common.h.

◆ MIN_COLS

#define MIN_COLS   40

Definition at line 26 of file common.h.

◆ MINITRC

#define MINITRC   ".minitrc"

Definition at line 41 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:230
int main(int argc, char **argv)
Definition amort.c:34
SIO * sio
Definition dwin.c:80
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:70
Gathers runtime information for C-Menu Menu, Form, Pick, and View components, used for passing common...
Definition common.h:104
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:696

Definition at line 51 of file common.h.

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

◆ P_READ

#define P_READ   0

Definition at line 47 of file common.h.

◆ P_WRITE

#define P_WRITE   1

Definition at line 48 of file common.h.

◆ PICK_HELP_FILE

#define PICK_HELP_FILE   "pick.help"

Definition at line 36 of file common.h.

◆ PICK_MAX_ARG_LEN

#define PICK_MAX_ARG_LEN   256

Definition at line 30 of file common.h.

◆ PRINTCMD

#define PRINTCMD   "lp -c -s"

Definition at line 44 of file common.h.

◆ TRUE

#define TRUE   1

Definition at line 49 of file common.h.

◆ USE_PAD

#define USE_PAD   TRUE

Definition at line 25 of file common.h.

◆ VIEW_HELP_FILE

#define VIEW_HELP_FILE   "view.help"

Definition at line 37 of file common.h.

◆ VIEW_PRT_FILE

#define VIEW_PRT_FILE   "prtout"

Definition at line 38 of file common.h.

Typedef Documentation

◆ Form

typedef Form Form

Definition at line 94 of file common.h.

◆ Menu

typedef Menu Menu

Definition at line 93 of file common.h.

◆ Pick

typedef Pick Pick

Definition at line 95 of file common.h.

◆ View

typedef View View

Definition at line 96 of file common.h.

Enumeration Type Documentation

◆ Caller

enum Caller
Enumerator
VIEW 
FORM 
PICK 
MENU 

Definition at line 72 of file common.h.

72{ VIEW, FORM, PICK, MENU } Caller;
Caller
Definition common.h:72
@ FORM
Definition common.h:72
@ MENU
Definition common.h:72
@ VIEW
Definition common.h:72
@ PICK
Definition common.h:72

◆ OptGroup

enum OptGroup

option groups

Enumerator
OG_FILES 
OG_DIRS 
OG_SPECS 
OG_MISC 
OG_PARMS 
OG_FLAGS 
OG_COL 

Definition at line 83 of file common.h.

83 {
85 OG_DIRS,
87 OG_MISC,
90 OG_COL
91} OptGroup;
OptGroup
option groups
Definition common.h:83
@ OG_FILES
Definition common.h:84
@ OG_DIRS
Definition common.h:85
@ OG_SPECS
Definition common.h:86
@ OG_MISC
Definition common.h:87
@ OG_FLAGS
Definition common.h:89
@ OG_PARMS
Definition common.h:88
@ OG_COL
Definition common.h:90

◆ OptType

enum OptType

option types

Enumerator
OT_STRING 
OT_INT 
OT_BOOL 
OT_HEX 

Definition at line 75 of file common.h.

75 {
77 OT_INT,
78 OT_BOOL,
79 OT_HEX,
80} OptType;
OptType
option types
Definition common.h:75
@ OT_INT
Definition common.h:77
@ OT_BOOL
Definition common.h:78
@ OT_HEX
Definition common.h:79
@ OT_STRING
Definition common.h:76

Function Documentation

◆ cmd_processor()

int cmd_processor ( Init * )
extern

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

References box_new(), display_error(), em0, em1, em2, handle_signal(), Perror(), sig_received, strnz__cat(), strnz__cpy(), win_box, 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 begy,
int begx )
extern

instantiate a form popup window

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

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

 begy, and begx 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;
116 parse_opt_args(init, argc, argv);
117 Form *sav_form = init->form;
118 init->form = nullptr;
119 form = nullptr;
120 rc = init_form(init, init->argc, init->argv, begy, begx);
122 init->form = sav_form;
123 return rc;
124}
Form * form
Definition mem.c:47
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:60
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
Definition init.c:427
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:442
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:289
Definition form.h:145

References Init::argc, Init::argv, destroy_form(), 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 begy,
int begx )
extern

instantiate a menu popup window

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

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

 begy, and begx 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;
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, begy, begx);
60 rc = menu_engine(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:148
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:169
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:38
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:90

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 begy,
int begx )
extern

instantiate a pick popup window

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

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

 begy, and begx 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;
86 parse_opt_args(init, argc, argv);
87 Pick *sav_pick = init->pick;
88 init->pick = nullptr;
89 pick = nullptr;
90 rc = init_pick(init, init->argc, init->argv, begy, begx);
92 init->pick = sav_pick;
93 return rc;
94}
Pick * pick
Definition mem.c:46
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:239
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:60
Pick data structure.
Definition pick.h:25

References Init::argc, Init::argv, destroy_pick(), init_pick(), parse_opt_args(), Init::pick, 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 lines,
int cols,
int begy,
int begx )
extern

instantiate a view popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
linesthe number of lines for the view window
colsthe number of columns for the view window
begythe y coordinate for the view window
begxthe x coordinate for the view window

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

 lines, cols, begy, and begx 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 146 of file popups.c.

147 {
148 int rc = 0;
150 parse_opt_args(init, argc, argv);
151 View *sav_view = init->view;
152 init->view = nullptr;
153 view = nullptr;
154 view = new_view(init);
155
156 if (init->lines > 0 && init->cols > 0) {
157 lines = init->lines;
158 cols = init->cols;
159 }
160 if (init->begy > 0 || init->begx > 0) {
161 begy = init->begy;
162 begx = init->begx;
163 }
164 view->lines = lines;
165 view->cols = cols;
166 view->begy = begy;
167 view->begx = begx;
169 view->f_full_screen = false;
170 if (!init_view_boxwin(init, view->title)) {
171 rc = view_file(init);
172 win_del();
173 }
175 init->view = sav_view;
176 return rc;
177}
View * view
Definition mem.c:48
void view_calc_win_dimensions(Init *, char *title)
Calculate the dimensions and position of the box window for C-Menu View.
Definition init_view.c:367
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:172
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:359
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:313
int view_file(Init *)
Start view.
Definition view.h:37

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(), View::title, Init::view, view, view_calc_win_dimensions(), view_file(), win_del(), 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:

Variable Documentation

◆ init

Init* init
extern

Definition at line 74 of file init.c.

Referenced by main().

◆ init_cnt

int init_cnt
extern

Definition at line 43 of file mem.c.

Referenced by destroy_init(), and new_init().

◆ minitrc

char minitrc[MAXLEN]
extern

number of Init data structures allocated