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 NCURSES_WIDECHAR   1
#define USE_PAD   TRUE
#define MIN_COLS   40
#define MAX_WIDE_LEN   1024
#define COLOR_LEN   8
#define PICK_MAX_ARG_LEN   256
#define MAX_PICK_OBJS   1024
#define ACCEPT_PROMPT_CHAR   '_'
#define MENU_HELP_FILE   "menu.help"
#define FORM_HELP_FILE   "form.help"
#define PICK_HELP_FILE   "pick.help"
#define VIEW_HELP_FILE   "view.help"
#define VIEW_PRT_FILE   "prtout"
#define DEFAULTEDITOR   "vi"
#define MINITRC   ".minitrc"
#define ABOUT   ".about"
#define MAPP_DIR   "~/menuapp"
#define PRINTCMD   "lp -c -s"
#define MAXOPTS   50
#define EIGHT   8
#define F_VIEW   0x01
#define P_READ   0
#define P_WRITE   1
#define TRUE   1
#define new_cmenu()
#define destroy_cmenu()

Typedefs

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

Enumerations

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

Functions

void mapp_initialization (Init *, int, char **)
 Main initialization function for MAPP - Menu Application.
Initnew_init (int, char **)
 Create and initialize Init structure.
Viewnew_view (Init *)
 Create and initialize View structure.
Formnew_form (Init *, int, char **, int, int)
 Create and initialize Form structure.
Picknew_pick (Init *, int, char **, int, int)
 Create and initialize Pick structure.
Menunew_menu (Init *, int, char **, int, int)
 Create and initialize Menu structure.
int popup_menu (Init *, int, char **, int, int)
int popup_form (Init *, int, char **, int, int)
int popup_pick (Init *, int, char **, int, int)
int popup_view (Init *, int, char **, int, int, int, int)
int popup_ckeys ()
 Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description.
Menudestroy_menu (Init *init)
 Destroy Menu structure.
Pickdestroy_pick (Init *init)
 Destroy Pick structure.
Formdestroy_form (Init *init)
 Destroy Form structure.
Viewdestroy_view (Init *init)
 Destroy View structure.
Initdestroy_init (Init *init)
 Destroy Init structure.
int parse_opt_args (Init *, int, char **)
void zero_opt_args (Init *)
 Initialize optional arguments in the Init struct to default values.
int write_config (Init *)
 Write the current configuration to a file specified in init->minitrc.
bool derive_file_spec (char *, char *, char *)
 Derive full file specification from directory and file name.
bool init_menu_files (Init *, int, char **)
 Initialize Menu file specifications.
unsigned int menu_engine (Init *)
 The main loop of the menu system.
unsigned int parse_menu_description (Init *)
 Parse menu description file and create Menu.
int init_form (Init *, int, char **, int, int)
 Initialize form data structure and parse description file.
int init_pick (Init *, int, char **, int, int)
 Initializes pick structure and opens pick input file or pipe.
int open_pick_win (Init *)
 Initializes the pick window based on the parameters specified in the Pick structure.
int pick_engine (Init *)
 Initializes pick interface, calculates window size and position, and enters picker loop.
int view_file (Init *)
 Start view.
int init_view_full_screen (Init *)
 Initialize C-Menu View in full screen mode.
int init_view_boxwin (Init *, char *)
 Initialize the C-Menu View in box window mode.
int view_init_input (View *, char *)
 Initialize the input for a C-Menu View.
int cmd_processor (Init *)

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

Without #define _GNU_SOURCE you may get errors like locale_t undefined in time.h

Definition at line 15 of file common.h.

◆ _XOPEN_SOURCE_EXTENDED

#define _XOPEN_SOURCE_EXTENDED   1

Definition at line 16 of file common.h.

◆ ABOUT

#define ABOUT   ".about"

Definition at line 44 of file common.h.

◆ ACCEPT_PROMPT_CHAR

#define ACCEPT_PROMPT_CHAR   '_'

Definition at line 34 of file common.h.

◆ COLOR_LEN

#define COLOR_LEN   8

Definition at line 31 of file common.h.

◆ DEFAULTEDITOR

#define DEFAULTEDITOR   "vi"

Definition at line 41 of file common.h.

◆ destroy_cmenu

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

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 48 of file common.h.

◆ F_VIEW

#define F_VIEW   0x01

Definition at line 49 of file common.h.

◆ FORM_HELP_FILE

#define FORM_HELP_FILE   "form.help"

Definition at line 37 of file common.h.

◆ MAPP_DIR

#define MAPP_DIR   "~/menuapp"

Definition at line 45 of file common.h.

◆ MAX_PICK_OBJS

#define MAX_PICK_OBJS   1024

Definition at line 33 of file common.h.

◆ MAX_WIDE_LEN

#define MAX_WIDE_LEN   1024

Definition at line 30 of file common.h.

◆ MAXOPTS

#define MAXOPTS   50

Definition at line 47 of file common.h.

◆ MENU_HELP_FILE

#define MENU_HELP_FILE   "menu.help"

Definition at line 36 of file common.h.

◆ MIN_COLS

#define MIN_COLS   40

Definition at line 28 of file common.h.

◆ MINITRC

#define MINITRC   ".minitrc"

Definition at line 43 of file common.h.

◆ NCURSES_WIDECHAR

#define NCURSES_WIDECHAR   1

Definition at line 17 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:194
int main(int argc, char **argv)
Capture the current terminal settings for later restoration.
Definition enterchr.c:38
SIO * sio
Definition dwin.c:77
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:107
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:626

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 38 of file common.h.

◆ PICK_MAX_ARG_LEN

#define PICK_MAX_ARG_LEN   256

Definition at line 32 of file common.h.

◆ PRINTCMD

#define PRINTCMD   "lp -c -s"

Definition at line 46 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 27 of file common.h.

◆ VIEW_HELP_FILE

#define VIEW_HELP_FILE   "view.help"

Definition at line 39 of file common.h.

◆ VIEW_PRT_FILE

#define VIEW_PRT_FILE   "prtout"

Definition at line 40 of file common.h.

Typedef Documentation

◆ Form

typedef Form Form

Definition at line 97 of file common.h.

◆ Menu

typedef Menu Menu

Definition at line 96 of file common.h.

◆ Pick

typedef Pick Pick

Definition at line 98 of file common.h.

◆ View

typedef View View

Definition at line 99 of file common.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IC_MENU 
IC_PICK 
IC_FORM 
IC_VIEW 

Definition at line 184 of file common.h.

@ IC_MENU
Definition common.h:184
@ IC_VIEW
Definition common.h:184
@ IC_FORM
Definition common.h:184
@ IC_PICK
Definition common.h:184

◆ Caller

enum Caller
Enumerator
VIEW 
FORM 
PICK 
MENU 

Definition at line 75 of file common.h.

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

◆ OptGroup

enum OptGroup

option groups

Enumerator
OG_FILES 
OG_DIRS 
OG_SPECS 
OG_MISC 
OG_PARMS 
OG_FLAGS 
OG_COL 

Definition at line 86 of file common.h.

86 {
88 OG_DIRS,
90 OG_MISC,
93 OG_COL
94};
@ OG_FILES
Definition common.h:87
@ OG_DIRS
Definition common.h:88
@ OG_SPECS
Definition common.h:89
@ OG_MISC
Definition common.h:90
@ OG_FLAGS
Definition common.h:92
@ OG_PARMS
Definition common.h:91
@ OG_COL
Definition common.h:93

◆ OptType

enum OptType

option types

Enumerator
OT_STRING 
OT_INT 
OT_BOOL 
OT_HEX 

Definition at line 78 of file common.h.

78 {
80 OT_INT,
81 OT_BOOL,
82 OT_HEX,
83};
@ OT_INT
Definition common.h:80
@ OT_BOOL
Definition common.h:81
@ OT_HEX
Definition common.h:82
@ OT_STRING
Definition common.h:79

Function Documentation

◆ cmd_processor()

int cmd_processor ( Init * )
extern

◆ parse_opt_args()

int parse_opt_args ( Init * init,
int argc,
char ** argv )
extern

Definition at line 393 of file init.c.

393 {
394 init->argc = 0;
395 argp_parse(&argp, argc, argv, 0, 0, init);
396 return 0;
397}

References Init::argc.

Referenced by menu_cmd_processor(), popup_form(), popup_menu(), popup_pick(), and popup_view().

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
41 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT |
42 BUTTON_CTRL | BUTTON_ALT,
43 NULL);
44 if (win_new(lines, cols, begy, begx, Title, 0)) {
45 strnz__cpy(tmp, "win_new failed: ", MAXLEN - 1);
46 strnz__cat(tmp, Title, MAXLEN - 1);
47 Perror(tmp);
48 return 0;
49 }
51 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:403
#define KEY_ALTLEFT
Definition cm.h:406
#define KEY_ALTDOWN
Definition cm.h:407
#define KEY_ALTHOME
Definition cm.h:400
int cols
#define KEY_ALTPGDN
Definition cm.h:404
#define KEY_ALTRIGHT
Definition cm.h:408
int lines
#define KEY_ALTDEL
Definition cm.h:402
int begx
#define KEY_ALTUP
Definition cm.h:405
#define KEY_ALTPGUP
Definition cm.h:401
#define KEY_ALTF(n)
Definition cm.h:346
#define KEY_ALTINS
Definition cm.h:399
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:113
WINDOW * win_win[MAXWIN]
Definition dwin.c:114
char em1[MAXLEN]
Definition dwin.c:133
int win_ptr
Definition dwin.c:121
char em0[MAXLEN]
Definition dwin.c:132
WINDOW * win_box[MAXWIN]
Definition dwin.c:115
char em2[MAXLEN]
Definition dwin.c:134
int win_new(int, int, int, int, char *, int)
Create a new window with optional box and title.
Definition dwin.c:783
WINDOW * win_del()
Delete the current window and its associated box window.
Definition dwin.c:902
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1110
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
Definition dwin.c:1054
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:269
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:298

References display_error(), em0, em1, em2, handle_signal(), Perror(), sig_received, strnz__cat(), strnz__cpy(), win_box, win_del(), win_new(), 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

Definition at line 34 of file popups.c.

34 {
35 int rc;
37 parse_opt_args(init, argc, argv);
38 Form *sav_form = init->form;
39 init->form = NULL;
40 new_form(init, init->argc, init->argv, begy, begx);
41 rc = init_form(init, init->argc, init->argv, begy, begx);
43 init->form = sav_form;
44 return rc;
45}
int parse_opt_args(Init *, int, char **)
Definition init.c:393
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:59
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:408
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:253
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:276
Definition form.h:145

References Init::argc, Init::argv, destroy_form(), Init::form, init_form(), new_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

Definition at line 8 of file popups.c.

8 {
9 int rc;
11 parse_opt_args(init, argc, argv);
12 Menu *sav_menu = init->menu;
13 init->menu = NULL;
14 new_menu(init, init->argc, init->argv, begy, begx);
15 rc = menu_engine(init);
17 init->menu = sav_menu;
18 return rc;
19}
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:37
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:81

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

Here is the call graph for this function:

◆ popup_pick()

int popup_pick ( Init * init,
int argc,
char ** argv,
int begy,
int begx )
extern

Definition at line 21 of file popups.c.

21 {
22 int rc;
24 parse_opt_args(init, argc, argv);
25 Pick *sav_pick = init->pick;
26 init->pick = NULL;
27 new_pick(init, init->argc, init->argv, begy, begx);
28 rc = init_pick(init, init->argc, init->argv, begy, begx);
30 init->pick = sav_pick;
31 return rc;
32}
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Definition mem.c:200
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:230
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:59
Pick data structure.
Definition pick.h:25

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

Definition at line 47 of file popups.c.

48 {
49 int rc = 0;
51 parse_opt_args(init, argc, argv);
52 View *sav_view = init->view;
53 init->view = NULL;
54 view = NULL;
55 if (!view)
57 else
58 view = init->view;
59 if (lines > 0)
60 view->lines = lines;
61 if (cols > 0)
62 view->cols = cols;
63 if (begy > 0)
64 view->begy = begy;
65 if (begx > 0)
66 view->begx = begx;
67 if (init->lines != 0 && view->lines == 0)
68 view->lines = init->lines;
69 if (view->lines == 0)
70 view->lines = LINES * 3 / 4;
71 if (view->lines > LINES - 3)
72 view->lines = LINES - 3;
73 if (init->cols != 0 && view->lines == 0)
74 view->cols = init->cols;
75 if (view->cols == 0)
76 view->cols = COLS * 3 / 4;
77 if (view->cols > COLS - 3)
78 view->cols = COLS - 3;
79 if (init->begy != 0 && view->begy == 0)
80 view->begy = init->begy;
81 if (view->begy == 0)
82 view->begy = (LINES - view->lines) / 5;
83 if (view->begy + view->lines > LINES - 2)
84 view->begy = LINES - view->lines - 2;
85 if (init->begx != 0 && view->begx == 0)
86 view->begx = init->begx;
87 if (view->begx == 0)
88 view->begx = (COLS - view->cols) / 5;
89 if (view->begx + view->cols > COLS - 1)
90 view->begx = COLS - view->cols - 1;
91 view->f_full_screen = false;
92 if (!init_view_boxwin(init, init->title)) {
93 rc = view_file(init);
94 win_del();
95 }
97 init->view = sav_view;
98 return rc;
99}
View * view
Definition mem.c:48
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:123
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:346
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:300
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(), Init::title, Init::view, view, view_file(), win_del(), and zero_opt_args().

Referenced by display_pick_help(), exec_objects(), form_engine(), 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 186 of file common.h.

◆ 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