C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
menu.h
Go to the documentation of this file.
1/** @file menu.h
2 * @brief Menu data structures, enums, types, end external declarations
3 * @author Bill Waller
4 * Copyright (c) 2025
5 * MIT License
6 * billxwaller@gmail.com
7 * @date 2026-02-09
8 */
9
10#ifndef _MENU_H
11#define _MENU_H 1
12
13#include <cm.h>
14
15#ifndef _COMMON_H
16typedef struct Init Init;
17#endif
18
19#define MAX_MENU_LINES 256 /** Maximum number of menu lines in a menu */
20
21/**< Menu line types */
22typedef enum { MT_NULL = 0x320,
24 MT_CHOICE } MenuLineType;
25
26/**< Menu Actions */
27typedef enum {
28 MA_NEW = 350,
33} MenuAction;
34
35/**< Menu command types */
36typedef enum {
37 CT_NULL = 0x396,
53} MenuCommandType;
54
55/** @struct Line
56 @brief The Line strutures are attached to the Menu main structure */
57typedef struct {
58 unsigned int type; /**< The type of menu line, e.g. MT_TEXT for a text line,
59 MT_CHOICE for a choice line */
60 char *raw_text; /**< The raw text of the menu line, as read from the menu
61 description file, before processing any variables or
62 formatting */
63 char *choice_text; /**< The formatted text of the menu line, after
64 processing any variables and formatting, used for
65 display purposes */
66 char choice_letter; /**< The letter that the user can press to select this
67 menu line, if it is a choice line, used for selection
68 purposes */
69 int letter_pos; /**< The position of the choice letter in the text, for
70 highlighting purposes, used to determine where to
71 highlight the choice letter in the menu display */
72 unsigned int
73 command_type; /**< The type of command associated with this menu line,
74 e.g. CT_RETURNMAIN for a command that returns to the
75 main menu, CT_EXEC for a command that executes a
76 program, CT_HELP for a command that displays help
77 information, etc., used to determine what action to
78 take when this menu line is selected */
79 char *command_str; /**< The command string associated with this menu line,
80 which may be a command to execute, a menu to display,
81 a form to show, etc., depending on the command type,
82 used to determine the specific action to take when
83 this menu line is selected */
84} Line;
85
86/** @struct Menu
87 @brief The Menu structure is the main data structure for the menu
88 application, containing all the information about the menu, its lines, and
89 its display properties */
90typedef struct {
91 int fg_clr_idx; /**< The foreground color for the menu display, used to
92 determine the color of the text and other elements in the
93 menu display */
94 int bg_clr_idx; /** <The background color for the menu display, used to
95 determine the color of the background in the menu display
96 */
97 int bo_clr_idx; /**< The color for the box around the menu, used to
98 determine the color of the box in the menu display */
99 int lines; /**< The number of lines for the menu window size, used to
100 determine the height of the menu display */
101 int cols; /**< The number of columns for the menu window size, used to
102 determine the width of the menu display */
103 int begy; /**< The screen line for the upper left corner of the menu window,
104 used to determine the vertical position of the menu display on
105 the screen */
106 int begx; /**< The screen column for the upper left corner of the menu
107 window, used to determine the horizontal position of the menu
108 display on the screen */
109 WINDOW *win; /**< The ncurses window structure for the menu display, used to
110 manage the display of the menu on the screen and handle user
111 input */
112 WINDOW *box; /**< The ncurses window structure for the box around the menu,
113 used to manage the display of the box around the menu on the
114 screen */
115 char title[MAXLEN]; /**< The title to display on the top line of the box
116 window, used to provide a title or header for the
117 menu display */
118 int argc; /**< The number of arguments on the command line, used to
119 determine how many arguments were passed to the menu
120 application when it was executed */
121 char **argv; /**< The argument vector from the command line, used to access
122 the specific arguments passed to the menu application when
123 it was executed */
124 char mapp_spec[MAXLEN]; /**< The menu application description file spec,
125 which may be a file name or a fully qualified
126 path to a file, used to specify the location of
127 the menu description file that contains the
128 information about the menu lines and their
129 properties */
130 char help_spec[MAXLEN]; /**< The menu application help file spec, which may
131 be a file name or a fully qualified path to a
132 file, used to specify the location of the help
133 file that contains the information about the menu
134 application and how to use it */
135 char provider_cmd[MAXLEN]; /**< The provider command, which can be executed
136 in the background to provide dynamic content
137 for a program called by the menu application,
138 used to specify a command that can be run in
139 the background to generate dynamic content for
140 the menu display or for a program that is
141 called by the menu application */
143 [MAXLEN]; /**< The receiver command, which can be executed in the
144 background to process the output of a program called by the
145 menu application, used to specify a command that can be run
146 in the background to process the output of a program that
147 is called by the menu application, such as parsing the
148 output and updating the menu display or performing some
149 other action based on the output */
150 char cmd[MAXLEN]; /**< A command that can be executed in the foreground,
151 possibly taking control of the screen, by the menu
152 application, such as an editor or other program that is
153 called by the menu application, used to specify a
154 command that can be run in the foreground when selected
155 from the menu, which may take control of the screen and
156 require user interaction */
157 bool f_mapp_spec; /**< A flag to indicate whether the menu application
158 description file has been verified, used to indicate
159 whether the menu description file specified by
160 mapp_spec has been successfully verified and can be
161 used to populate the menu lines and their properties */
162 bool f_help_spec; /**< A flag to indicate whether the menu application help
163 file has been verified, used to indicate whether the
164 help file specified by help_spec has been successfully
165 verified and can be used to provide help information
166 for the menu application */
167 bool f_provider_cmd; /**< A flag to indicate whether the provider command
168 has been verified, used to indicate whether the
169 provider command specified by provider_cmd has been
170 successfully verified and can be executed in the
171 background to provide dynamic content for the menu
172 display or for a program called by the menu
173 application */
174 bool f_receiver_cmd; /**< A flag to indicate whether the receiver command
175 has been verified, used to indicate whether the
176 receiver command specified by receiver_cmd has been
177 successfully verified and can be executed in the
178 background to process the output of a program called
179 by the menu application */
180 bool f_cmd; /**< A flag to indicate whether the foreground command has been
181 verified, used to indicate whether the command specified by
182 cmd has been successfully verified and can be executed in the
183 foreground when selected from the menu */
184 int choice_max_len; /**< The longest choice text string of all menu lines,
185 used to determine the width of the menu window,
186 calculated based on the length of the choice_text for
187 all menu lines and used to ensure that the menu
188 window is wide enough to accommodate the longest
189 choice text without truncation or wrapping */
190 int text_max_len; /**< The longest text string of all menu lines, used to
191 determine the width of the menu window, calculated
192 based on the length of the raw_text for all menu lines
193 and used to ensure that the menu window is wide enough
194 to accommodate the longest text without truncation or
195 wrapping */
196 int item_count; /**< The number of menu lines in this menu, used to
197 determine how many lines are currently defined in the
198 menu and to manage the array of menu lines */
199 int line_idx; /**< The index of the currently selected menu line, used for
200 highlighting and selection purposes, updated based on user
201 input to indicate which menu line is currently selected and
202 should be highlighted in the menu display */
203 Line *line[MAX_MENU_LINES]; /**< An array of pointers to the menu line
204 structures in this menu, used to store the
205 information about each menu line, including
206 its type, text, choice letter, command type,
207 and command string, and to manage the menu
208 lines in the menu display */
209} Menu;
210extern Menu *menu;
211
212extern unsigned int get_command_type(char *);
213extern void free_menu_line(Line *);
214#endif
void form_help(char *)
int form_yx_to_fidx(Form *, int, int)
#define FIELD_MAXLEN
Definition form.h:18
@ FF_DECIMAL_INT
Definition form.h:51
@ FF_STRING
Definition form.h:49
@ FF_HEX_INT
Definition form.h:53
@ FF_YYYYMMDD
Definition form.h:62
@ FF_HHMMSS
Definition form.h:64
@ FF_CURRENCY
Definition form.h:59
@ FF_FLOAT
Definition form.h:55
@ FF_INVALID
Definition form.h:69
@ FF_DOUBLE
Definition form.h:57
@ FF_APR
Definition form.h:66
@ FA_END
Definition form.h:43
@ FA_ACCEPT
Definition form.h:30
@ FA_EDIT
Definition form.h:41
@ FA_CALC
Definition form.h:38
@ FA_HELP
Definition form.h:32
@ FA_REFUSE
Definition form.h:36
@ FA_CANCEL
Definition form.h:34
@ FA_CONTINUE
Definition form.h:28
int form_read_description(Form *)
Form * form
Definition mem.c:47
void form_display_chyron(Form *)
#define FIELD_MAXCNT
Definition form.h:19
int cmd_processor(Init *)
@ OT_INT
Definition common.h:77
@ OT_BOOL
Definition common.h:78
@ OT_HEX
Definition common.h:79
@ OT_STRING
Definition common.h:76
Init * init
Definition init.c:74
@ FORM
Definition common.h:72
@ MENU
Definition common.h:72
@ VIEW
Definition common.h:72
@ PICK
Definition common.h:72
int popup_form(Init *, int, char **, int, int)
instantiate a form popup window
Definition popups.c:113
@ 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
int popup_menu(Init *, int, char **, int, int)
instantiate a menu popup window
Definition popups.c:53
int popup_view(Init *, int, char **, int, int, int, int)
instantiate a view popup window
Definition popups.c:146
int popup_pick(Init *, int, char **, int, int)
instantiate a pick popup window
Definition popups.c:83
char minitrc[MAXLEN]
int init_cnt
Definition mem.c:43
volatile sig_atomic_t sig_received
Definition sig.c:31
size_t rtrim(char *)
Trims trailing spaces from string s in place.
Definition futil.c:229
bool handle_signal(sig_atomic_t)
void win_Toggle_Attrs()
#define MAXWIN
Definition cm.h:542
int n_cols
#define KEY_ALTEND
Definition cm.h:460
int mbegx
#define KEY_ALTLEFT
Definition cm.h:463
void curskeys(WINDOW *)
#define KEY_ALTDOWN
Definition cm.h:464
void sig_shell_mode()
int cmenu_log_fd
Definition futil.c:48
void get_rfc3339_s(char *, size_t)
bool f_have_shell_tioctl
Definition scriou.c:24
void init_stdscr()
#define KEY_ALTHOME
Definition cm.h:457
int dbgfd
void mouse_getch(int *, int *, int *, int *)
int display_ok_message(char *)
int cp_title
#define KEY_ALTF0
Definition cm.h:402
int cp_default
void destroy_win(WINDOW *)
int cols
bool f_curses_open
Definition sig.c:33
int enter_option()
#define CHYRON_KEYS
Definition cm.h:266
struct termios shell_tioctl curses_tioctl
Definition scriou.c:34
void dump_opts()
int mg_line
const wchar_t bw_tt
void write_log(char *)
unsigned char uchar
Definition cm.h:543
int cp_bold
bool verify_dir_q(char *, int)
String mk_string(size_t)
Create a String struct with a dynamically allocated string.
Definition futil.c:1404
bool construct_file_spec(char *, char *, char *, char *, char *, int)
int mcols
bool win_pair
const wchar_t bw_cr
#define KEY_ALTPGDN
Definition cm.h:461
int mg_action
FILE * cmenu_log_fp
#define XTERM_256COLOR
Definition cm.h:404
const wchar_t bw_bt
#define KEY_ALTRIGHT
Definition cm.h:465
#define CHYRON_KEY_MAXLEN
Definition cm.h:263
bool verify_file_q(char *, int)
bool f_debug
int lines
#define KEY_ALTDEL
Definition cm.h:459
#define SCR_COLS
Definition cm.h:31
int cp_highlight
void dump_opts_by_use(char *, char *)
int open_log(char *)
int begx
int wait_timeout
Definition futil.c:144
int win_attr_even
char errmsg[]
Definition futil.c:130
#define KEY_ALTUP
Definition cm.h:462
@ LF_EXC_REGEX
Definition cm.h:161
@ LF_HIDE
Definition cm.h:159
@ LF_ISUID
Definition cm.h:171
@ LF_IRUSR
Definition cm.h:169
@ LF_ICASE
Definition cm.h:160
@ LF_ISGID
Definition cm.h:170
@ LF_EXEC
Definition cm.h:163
@ LF_REGEX
Definition cm.h:162
@ LF_USER
Definition cm.h:164
@ LF_IXUSR
Definition cm.h:167
@ LF_IWUSR
Definition cm.h:168
int mlines
@ CLR_FG
Definition cm.h:141
@ CLR_RED
Definition cm.h:125
@ CLR_NT_FG
Definition cm.h:146
@ CLR_YELLOW
Definition cm.h:127
@ CLR_BCYAN
Definition cm.h:138
@ CLR_WHITE
Definition cm.h:131
@ CLR_MAGENTA
Definition cm.h:129
@ CLR_NT_REV_BG
Definition cm.h:149
@ CLR_BLACK
Definition cm.h:124
@ CLR_BWHITE
Definition cm.h:139
@ CLR_LN_BG
Definition cm.h:145
@ CLR_NT_HL_REV_BG
Definition cm.h:153
@ CLR_BO
Definition cm.h:143
@ CLR_BBLACK
Definition cm.h:132
@ CLR_NT_HL_FG
Definition cm.h:150
@ CLR_BBLUE
Definition cm.h:136
@ CLR_LN
Definition cm.h:144
@ CLR_BGREEN
Definition cm.h:134
@ CLR_BYELLOW
Definition cm.h:135
@ CLR_BMAGENTA
Definition cm.h:137
@ CLR_BORANGE
Definition cm.h:140
@ CLR_NT_HL_BG
Definition cm.h:151
@ CLR_NT_HL_REV_FG
Definition cm.h:152
@ CLR_BG
Definition cm.h:142
@ CLR_NT_BG
Definition cm.h:147
@ CLR_BRED
Definition cm.h:133
@ CLR_NCOLORS
Definition cm.h:154
@ CLR_BLUE
Definition cm.h:128
@ CLR_GREEN
Definition cm.h:126
@ CLR_NT_REV_FG
Definition cm.h:148
@ CLR_CYAN
Definition cm.h:130
#define KEY_ALTPGUP
Definition cm.h:458
void destroy_box(WINDOW *)
bool f_restore_screen
@ LF_FIFO
Definition cm.h:176
@ LF_DIR
Definition cm.h:178
@ LF_UNKNOWN
Definition cm.h:183
@ LF_SOCK
Definition cm.h:182
@ LF_BLK
Definition cm.h:179
@ LF_LNK
Definition cm.h:181
@ LF_REG
Definition cm.h:180
@ LF_CHR
Definition cm.h:177
#define COLOR_LEN
Definition cm.h:216
int win_attr_odd
int n_lines
int mg_col
bool f_have_curses_tioctl
Definition scriou.c:25
#define KEY_ALTF(n)
Definition cm.h:403
void w_mouse_getch(WINDOW *, int *, int *, int *, int *)
int mbegy
bool str_to_bool(const char *)
Converts String to boolean true or false.
Definition futil.c:875
int rgb_clr_to_cube(int)
#define __atexit
This macro registers the end_pgm function to be called when the program exits.
Definition cm.h:230
struct termios shell_out_tioctl curses_out_tioctl
Definition scriou.c:36
cchar_t CCC_REVERSE
void user_end()
int display_curses_keys()
#define KEY_ALTINS
Definition cm.h:456
int begy
void display_argv_error_msg(char *, char **)
struct termios shell_in_tioctl curses_in_tioctl
Definition scriou.c:35
int cp_ln_bg
struct termios shell_err_tioctl curses_err_tioctl
Definition scriou.c:37
int clr_idx
Menu * menu
Definition mem.c:45
@ MT_TEXT
Definition menu.h:23
@ MT_CHOICE
Definition menu.h:24
@ MT_NULL
Definition menu.h:22
@ CT_PICK
Definition menu.h:46
@ CT_FORM
Definition menu.h:42
@ CT_UNDEFINED
Definition menu.h:52
@ CT_MENU
Definition menu.h:45
@ CT_RETURN
Definition menu.h:49
@ CT_TOGGLE
Definition menu.h:50
@ CT_HELP
Definition menu.h:40
@ CT_WRITE_CONFIG
Definition menu.h:51
@ CT_FORM_WRITE
Definition menu.h:44
@ CT_EXEC
Definition menu.h:39
@ CT_VIEW
Definition menu.h:47
@ CT_NULL
Definition menu.h:37
@ CT_ABOUT
Definition menu.h:41
@ CT_FORM_EXEC
Definition menu.h:43
@ CT_DMON
Definition menu.h:38
@ CT_CKEYS
Definition menu.h:48
void free_menu_line(Line *)
@ MA_RETURN
Definition menu.h:29
@ MA_DISPLAY_MENU
Definition menu.h:30
@ MA_RESET_MENU
Definition menu.h:31
@ MA_NEW
Definition menu.h:28
@ MA_CONTINUE
Definition menu.h:32
#define MAX_MENU_LINES
Definition menu.h:19
#define TRUE
Definition iloan.c:19
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
Definition curskeys.c:23
#define KSTRLEN
Definition curskeys.c:14
#define MAXLEN
Definition curskeys.c:15
int cp_box
Definition dwin.c:147
unsigned int cmd_key
Definition dwin.c:126
WINDOW * win
Definition dwin.c:121
const wchar_t bw_rt
Definition dwin.c:103
const wchar_t bw_ho
Definition dwin.c:96
int cp_nt
Definition dwin.c:148
int cp_nt_hl
Definition dwin.c:150
cchar_t CCC_LN
Definition dwin.c:164
int cp_win
Definition dwin.c:146
int clr_pair_cnt
Definition dwin.c:155
WINDOW * win_win[MAXWIN]
Definition dwin.c:122
const wchar_t bw_tl
Definition dwin.c:98
const wchar_t bw_ua
Definition dwin.c:107
char em1[MAXLEN]
Definition dwin.c:142
int tty_fd
Definition dwin.c:168
WINDOW * win_win2[MAXWIN]
Definition dwin.c:123
cchar_t CCC_WIN
Definition dwin.c:157
int clr_cnt
Definition dwin.c:153
const wchar_t bw_lan
Definition dwin.c:110
WINDOW * mouse_win
Definition dwin.c:77
const wchar_t bw_tr
Definition dwin.c:99
int clr_pair_idx
Definition dwin.c:154
const wchar_t bw_ran
Definition dwin.c:109
const wchar_t bw_sp
Definition dwin.c:104
const wchar_t bw_ra
Definition dwin.c:105
int dxwgetch(WINDOW *win, WINDOW *win2, Chyron *chyron, int n)
Definition dwin.c:1723
int cp_ln
Definition dwin.c:152
const wchar_t bw_da
Definition dwin.c:108
const wchar_t bw_lt
Definition dwin.c:102
const wchar_t bw_la
Definition dwin.c:106
int click_x
Definition dwin.c:49
int cp_nt_hl_rev
Definition dwin.c:151
int src_line
Definition dwin.c:138
char * src_name
Definition dwin.c:139
cchar_t CCC_BOX
Definition dwin.c:159
cchar_t CCC_NT_HL_REV
Definition dwin.c:162
const wchar_t bw_bl
Definition dwin.c:100
int win_ptr
Definition dwin.c:130
int exit_code
Definition dwin.c:125
int click_y
Definition dwin.c:48
char em0[MAXLEN]
Definition dwin.c:141
cchar_t CCC_NT_HL
Definition dwin.c:163
char em3[MAXLEN]
Definition dwin.c:144
char const colors_text[][10]
Color names for .minitrc overrides.
Definition dwin.c:91
const wchar_t bw_ve
Definition dwin.c:97
int cp_nt_rev
Definition dwin.c:149
cchar_t CCC_BRKTR
Definition dwin.c:166
cchar_t CCC_NORM
Definition dwin.c:156
int win_attr
Definition dwin.c:128
WINDOW * win_box[MAXWIN]
Definition dwin.c:124
char fn[MAXLEN]
Definition dwin.c:140
cchar_t CCC_NT_REV
Definition dwin.c:161
char em2[MAXLEN]
Definition dwin.c:143
int cp_norm
Definition dwin.c:145
cchar_t CCC_NT
Definition dwin.c:160
const wchar_t bw_br
Definition dwin.c:101
cchar_t CCC_BRKTL
Definition dwin.c:165
char ff_tbl[][26]
Definition fields.c:26
struct termios shell_tioctl
Definition scriou.c:22
bool open_curses(SIO *)
Initialize NCurses and color settings.
Definition dwin.c:192
void view_win_resize(Init *, char *)
Resize the current window and its box, and update the title.
Definition init_view.c:265
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
Definition dwin.c:1651
int box_new(int, int, int, int, char *, bool)
Create a new window with optional box and title.
Definition dwin.c:745
int box2_new(int, int, int, int, char *, bool)
Create a new window with optional box and title.
Definition dwin.c:697
void restore_wins()
Restore all windows after a screen resize.
Definition dwin.c:933
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
Definition init_view.c:115
void win_init_attrs()
Initialize window attributes.
Definition dwin.c:176
WINDOW * win_del()
Delete the current window and its associated box window.
Definition dwin.c:893
void mvwaddstr_fill(WINDOW *, int, int, char *, int)
For lines shorter than their display area, fill the rest with spaces.
Definition dwin.c:1515
int win2_new(int wlines, int wcols, int wbegy, int wbegx)
Create a new window with specified dimensions and position.
Definition dwin.c:814
void cbox(WINDOW *)
Draw a box around the specified window.
Definition dwin.c:957
int win_new(int, int, int, int)
Create a new window with specified dimensions and position.
Definition dwin.c:788
void win_resize(int, int, char *)
Resize the current window and its box, and update the title.
Definition dwin.c:841
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
Definition dwin.c:540
void win_redraw(WINDOW *)
Redraw the specified window.
Definition dwin.c:881
RGB xterm256_idx_to_rgb(int)
Convert XTerm 256 color index to RGB color.
Definition dwin.c:366
int clr_name_to_idx(char *)
Get color index from color name.
Definition dwin.c:1536
int rgb_to_curses_clr(RGB *)
Get color index for RGB color.
Definition dwin.c:315
bool init_clr_palette(SIO *)
Initialize color palette based on SIO settings.
Definition dwin.c:429
void apply_gamma(RGB *)
Apply gamma correction to RGB color.
Definition dwin.c:401
int rgb_to_xterm256_idx(RGB *)
Convert RGB color to XTerm 256 color index.
Definition dwin.c:344
cchar_t mkccc(int, attr_t, char *)
Create a cchar_t with the specified color pair index.
Definition dwin.c:625
int get_clr_pair(int fg, int bg)
Get color pair index for foreground and background colors.
Definition dwin.c:284
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
Definition dwin.c:1258
bool waitpid_with_timeout(pid_t pid, int timeout)
Wait for a process to finish with a timeout and optional user cancellation.
Definition dwin.c:1603
bool action_disposition(char *title, char *action_str)
Display a simple action disposition message window or print to stderr.
Definition dwin.c:1286
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
Definition dwin.c:1271
int answer_yn(char *em0, char *em1, char *em2, char *em3)
Accept a single letter answer.
Definition dwin.c:1041
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
Definition dwin.c:1226
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
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:1588
Chyron * wait_mk_chyron()
Create a Chyron struct for the waiting message.
Definition dwin.c:1214
bool is_set_chyron_key(Chyron *, int)
Check if function key label is set.
Definition dwin.c:1372
void set_chyron_key(Chyron *, int, char *, int)
Set chyron key with default color pair (cp_nt_rev).
Definition dwin.c:1411
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
Display chyron on window.
Definition dwin.c:1476
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
Definition dwin.c:1352
int get_chyron_key(Chyron *, int)
Get keycode from chyron.
Definition dwin.c:1499
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key with color pair (cp).
Definition dwin.c:1388
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
Definition dwin.c:1436
void unset_chyron_key(Chyron *, int)
Unset chyron key.
Definition dwin.c:1425
Chyron * new_chyron()
Create and initialize Chyron structure.
Definition dwin.c:1336
int fork_exec(char **)
Fork and exec a command.
Definition exec.c:130
int shell(char *)
Execute a shell command.
Definition exec.c:82
int dmon(char **)
Fork and execute a command as a daemon.
Definition exec.c:226
int full_screen_fork_exec(char **)
Execute a command in full screen mode.
Definition exec.c:46
int full_screen_shell(char *)
Execute a shell command in full screen mode.
Definition exec.c:62
int form_fmt_field(Form *, char *)
Format field according to its format type.
Definition fields.c:417
int field_editor(Form *)
Accept input for a field.
Definition fields.c:55
int form_display_field_n(Form *, int)
Display field n.
Definition fields.c:348
int form_display_field(Form *)
Display current field.
Definition fields.c:366
int form_desc_error(int, char *, char *)
Handle errors encountered while parsing the form description file, providing detailed error messages ...
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:60
int field_navigator(Form *)
Handle user input for field entry, allowing navigation between fields and looping until an exit actio...
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:1148
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1202
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:435
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:385
bool parse_local_timestamp(const char *, time_t *)
Parses an ISO 8601 timestamp string in local time and converts it to time_t.
Definition futil.c:171
bool trim_ext(char *, char *)
trims the file extension from "filename" and copies the result to "buf"
Definition futil.c:950
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:635
void write_cmenu_log(char *)
Write message to C-Menu log file with timestamp.
Definition futil.c:1546
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
Definition futil.c:282
char * get_local_timestamp()
Returns the current local time as an ISO 8601 formatted string.
Definition futil.c:205
bool is_directory(const char *)
Checks if the given path is a directory.
Definition futil.c:1233
bool file_spec_path(char *, char *)
extracts the path component of a file specification
Definition futil.c:804
bool str_to_upper(char *)
Converts a string to uppercase.
Definition futil.c:413
bool dir_name(char *, char *)
Returns the directory name of a file specification.
Definition futil.c:1010
double str_to_double(char *)
converts string to double
Definition futil.c:863
bool str_to_lower(char *)
Converts a string to lowercase.
Definition futil.c:399
bool strnfill(char *, char, int)
Fills string s with character c n.
Definition futil.c:606
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
Definition futil.c:506
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:311
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
Definition futil.c:904
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:620
bool is_valid_regex(const char *)
Checks if the given regular expression pattern is valid.
Definition futil.c:1261
void open_cmenu_log()
Open new C-Menu log file.
Definition futil.c:1528
char * strnz_dup(char *, size_t)
Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
Definition futil.c:545
size_t strip_ansi(char *, char *)
Strips ANSI SGR escape sequences (ending in 'm') from string s to d.
Definition futil.c:763
bool mk_dir(char *dir)
If directory doesn't exist, make it.
Definition futil.c:1181
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:464
bool str_subc(char *, char *, char, char *, int)
Replaces "ReplaceChr" in "s" with "Withstr" in "d" won't copy more than "l" bytes to "d" Replaces all...
Definition futil.c:581
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:1101
char * rep_substring(const char *, const char *, const char *)
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
Definition futil.c:1301
bool is_symlink_to_dir(const char *)
Checks if the given path is a symbolic link to a directory.
Definition futil.c:1246
size_t strnlf(char *, size_t)
terminates string with line feed
Definition futil.c:524
int a_toi(char *, bool *)
a safer alternative to atoi() for converting ASCII strings to integers.
Definition futil.c:671
bool file_spec_name(char *, char *)
extracts the file name component of a file specification
Definition futil.c:831
void write_cmenu_log_nt(char *)
Write message to C-Menu log file without timestamp.
Definition futil.c:1562
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1050
bool chrep(char *, char, char)
Replaces all occurrences of old_chr in s with new_chr in place.
Definition futil.c:652
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:984
char * get_ip_addresses(char *, int)
Retrieves the IP addresses of the local machine and formats them into a string.
Definition futil.c:245
bool normalize_file_spec(char *)
replace backslashes with forward lashes
Definition futil.c:787
char * format_local_timestamp(time_t, char *, size_t)
Formats a time_t as an ISO 8601 string in local time.
Definition futil.c:194
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
Definition futil.c:331
char * get_user_str(char *, size_t)
Retrieves the current user's name and UID, and formats it into a string.
Definition futil.c:218
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:922
unsigned long a_to_ul(const char *)
Converts a string to an unsigned long long integer, with support for suffixes K, M,...
Definition futil.c:695
char * iso8601_time(char *, int, time_t *, bool)
Formats a struct tm as an ISO 8601 string.
Definition futil.c:155
size_t string_cpy(String *, const String *)
Copy src String to dest String, allocating additional memory for dest String if necessary.
Definition futil.c:1438
String to_string(const char *)
String functions provide a simple string library to facilitate string manipulation in C,...
Definition futil.c:1384
size_t string_ncpy(String *, const String *, size_t)
copies up to n characters from src String to dest String, allocating additional memory for dest Strin...
Definition futil.c:1495
size_t string_cat(String *, const String *)
Concatenates src String to dest String, allocating additional memory for dest String if necessary.
Definition futil.c:1455
String free_string(String)
Free the dynamically allocated String.
Definition futil.c:1423
size_t string_ncat(String *, const String *, size_t)
Concatenates up to n characters from src String to dest String, allocating additional memory for dest...
Definition futil.c:1474
int segmentation_fault()
Function to intentionally cause a segmentation fault for testing purposes.
Definition futil.c:1520
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
Definition init.c:427
bool derive_file_spec(char *, char *, char *)
Derive full file specification from directory and file name.
Definition init.c:907
int write_config(Init *)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:797
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:328
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:442
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_full_screen(Init *)
Initialize C-Menu View in full screen mode.
Definition init_view.c:45
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:172
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
Definition init_view.c:140
int view_init_input(View *, char *)
Initialize the input for a C-Menu View.
Definition init_view.c:443
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:359
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:266
bool init_menu_files(Init *, int, char **)
Initialize Menu file specifications.
Definition mem.c:528
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Definition mem.c:406
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:70
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
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:289
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:313
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Definition mem.c:200
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:105
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:239
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:38
unsigned int get_command_type(char *)
Get command type from command string.
unsigned int parse_menu_description(Init *)
Parse menu description file and create Menu.
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:60
int pick_engine(Init *)
Initializes pick interface, calculates window size and position, and enters picker loop.
int open_pick_win(Init *)
Initializes the pick window based on the parameters specified in the Pick structure.
bool capture_shell_tioctl()
capture_shell_tioctl() - capture shell terminal settings
Definition scriou.c:43
char di_getch()
get single character from terminal in raw mode
Definition scriou.c:148
bool restore_curses_tioctl()
restore_curses_tioctl() - restore curses terminal settings
Definition scriou.c:81
bool capture_curses_tioctl()
capture_curses_tioctl() - capture curses terminal settings
Definition scriou.c:68
bool mk_raw_tioctl(struct termios *)
mk_raw_tioctl() - set terminal to raw mode
Definition scriou.c:126
bool set_sane_tioctl(struct termios *)
set_sane_tioctl() - set terminal to sane settings for C-MENU
Definition scriou.c:95
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
Definition scriou.c:56
void sig_dfl_mode()
Set signal handlers to default behavior.
Definition sig.c:42
void signal_handler(int)
Signal handler for interrupt signals.
Definition sig.c:95
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition sig.c:62
int view_file(Init *)
Start view.
char title[MAXLEN]
Definition common.h:120
char mapp_data[MAXLEN]
Definition common.h:136
char minitrc[MAXLEN]
Definition common.h:161
bool f_out_spec
Definition common.h:158
char mapp_help[MAXLEN]
Definition common.h:137
int begx
Definition common.h:109
bool f_title
Definition common.h:153
char chyron_s[MAXLEN]
Definition common.h:119
SIO * sio
Definition common.h:105
int pick_cnt
Definition common.h:174
bool f_cmd_all
Definition common.h:152
Form * form
Definition common.h:171
char in_spec[MAXLEN]
Definition common.h:155
char cmd_all[MAXLEN]
Definition common.h:114
bool f_mapp_help
Definition common.h:144
bool f_mapp_msrc
Definition common.h:145
int argc
Definition common.h:121
char fill_char[2]
Definition common.h:134
bool f_cmd
Definition common.h:151
int prompt_type
Definition common.h:117
char about_fn[MAXLEN]
Definition common.h:162
char mapp_msrc[MAXLEN]
Definition common.h:138
int cols
Definition common.h:107
int menu_cnt
Definition common.h:170
int tab_stop
Definition common.h:168
bool f_mapp_home
Definition common.h:141
bool f_erase_remainder
Definition common.h:131
bool f_mapp_data
Definition common.h:142
bool f_mapp_desc
Definition common.h:148
char mapp_home[MAXLEN]
Definition common.h:135
bool f_mapp_user
Definition common.h:146
char prompt_str[MAXLEN]
Definition common.h:116
bool f_squeeze
Definition common.h:127
int begy
Definition common.h:108
char parent_cmd[MAXLEN]
Definition common.h:115
char mapp_spec[MAXLEN]
Definition common.h:163
char receiver_cmd[MAXLEN]
Definition common.h:112
bool f_multiple_cmd_args
Definition common.h:129
int select_max
Definition common.h:166
bool f_ln
Definition common.h:132
bool f_mapp_spec
Definition common.h:143
char provider_cmd[MAXLEN]
Definition common.h:111
char out_spec[MAXLEN]
Definition common.h:156
bool f_strip_ansi
Definition common.h:126
View * view
Definition common.h:175
Menu * menu
Definition common.h:169
bool f_at_end_remove
Definition common.h:125
int view_cnt
Definition common.h:176
char brackets[3]
Definition common.h:133
bool f_ignore_case
Definition common.h:124
char ** argv
Definition common.h:122
int lines
Definition common.h:106
char mapp_user[MAXLEN]
Definition common.h:139
char cmd[MAXLEN]
Definition common.h:113
int optind
Definition common.h:123
bool f_help_spec
Definition common.h:154
bool f_receiver_cmd
Definition common.h:150
bool f_provider_cmd
Definition common.h:149
int form_cnt
Definition common.h:172
char help_spec[MAXLEN]
Definition common.h:164
char editor[MAXLEN]
Definition common.h:159
Pick * pick
Definition common.h:173
bool f_in_spec
Definition common.h:157
char menuapp[MAXLEN]
Definition common.h:160
char text[CHYRON_KEY_MAXLEN]
Definition cm.h:269
int end_pos
Definition cm.h:272
int cp
Definition cm.h:273
int keycode
Definition cm.h:271
int l
Definition cm.h:280
cchar_t cmplx_buf[MAXLEN]
Definition cm.h:279
char s[MAXLEN]
Definition cm.h:278
ChyronKey * key[CHYRON_KEYS]
Definition cm.h:277
int r
Definition cm.h:305
int b
Definition cm.h:307
int g
Definition cm.h:306
int pair_id
Definition cm.h:346
int fg
Definition cm.h:344
int bg
Definition cm.h:345
char * s
Definition cm.h:639
size_t l
Definition cm.h:640
Arg ** v
Definition cm.h:646
size_t n
Definition cm.h:648
size_t l
Definition cm.h:655
char * s
Definition cm.h:654
size_t l
allocated length
Definition cm.h:664
wchar_t * s
Definition cm.h:663
size_t l
Definition cm.h:676
cchar_t * s
Definition cm.h:675
char nt_hl_rev_bg[COLOR_LEN]
Definition cm.h:735
double green_gamma
Definition cm.h:698
char nt_rev_bg[COLOR_LEN]
Definition cm.h:729
int cp_nt_hl_rev
Definition cm.h:754
char black[COLOR_LEN]
Definition cm.h:701
FILE * stdout_fp
Definition cm.h:738
char bg_clr_x[COLOR_LEN]
Definition cm.h:722
char fg_clr_x[COLOR_LEN]
Definition cm.h:721
double blue_gamma
Definition cm.h:699
int clr_idx
Definition cm.h:747
char bred[COLOR_LEN]
Definition cm.h:711
char yellow[COLOR_LEN]
Definition cm.h:704
int cp_ln_bg
Definition cm.h:760
int clr_cnt
Definition cm.h:745
char nt_hl_bg[COLOR_LEN]
Definition cm.h:731
int stdout_fd
Definition cm.h:742
char nt_hl_fg[COLOR_LEN]
Definition cm.h:730
char bo_clr_x[COLOR_LEN]
Definition cm.h:723
char abg[COLOR_LEN]
Definition cm.h:720
int stderr_fd
Definition cm.h:743
int cp_ln
Definition cm.h:759
int cp_box
Definition cm.h:755
FILE * stdin_fp
Definition cm.h:737
char bcyan[COLOR_LEN]
Definition cm.h:716
char borange[COLOR_LEN]
Definition cm.h:718
double red_gamma
Definition cm.h:697
char red[COLOR_LEN]
Definition cm.h:702
char nt_fg[COLOR_LEN]
Definition cm.h:726
FILE * tty_fp
Definition cm.h:740
char magenta[COLOR_LEN]
Definition cm.h:706
char bgreen[COLOR_LEN]
Definition cm.h:712
char nt_rev_fg[COLOR_LEN]
Definition cm.h:728
int cp_bold
Definition cm.h:756
char ln_clr_x[COLOR_LEN]
Definition cm.h:724
char byellow[COLOR_LEN]
Definition cm.h:713
char bwhite[COLOR_LEN]
Definition cm.h:717
char ln_bg_clr_x[COLOR_LEN]
Definition cm.h:725
char cyan[COLOR_LEN]
Definition cm.h:707
int cp_default
Definition cm.h:749
FILE * stderr_fp
Definition cm.h:739
char tty_name[MAXLEN]
Definition cm.h:736
int cp_highlight
Definition cm.h:758
int cp_title
Definition cm.h:757
char orange[COLOR_LEN]
Definition cm.h:709
int clr_pair_cnt
Definition cm.h:746
char green[COLOR_LEN]
Definition cm.h:703
char white[COLOR_LEN]
Definition cm.h:708
char bg[COLOR_LEN]
Definition cm.h:719
char bblue[COLOR_LEN]
Definition cm.h:714
int tty_fd
Definition cm.h:744
int cp_norm
Definition cm.h:750
char bmagenta[COLOR_LEN]
Definition cm.h:715
char blue[COLOR_LEN]
Definition cm.h:705
int cp_win
Definition cm.h:751
int cp_nt_rev
Definition cm.h:752
char nt_hl_rev_fg[COLOR_LEN]
Definition cm.h:733
int stdin_fd
Definition cm.h:741
double gray_gamma
Definition cm.h:700
char bblack[COLOR_LEN]
Definition cm.h:710
int clr_pair_idx
Definition cm.h:748
int cp_nt_hl
Definition cm.h:753
char nt_bg[COLOR_LEN]
Definition cm.h:727
int len
Definition form.h:108
int col
Definition form.h:104
char str[SCR_COLS]
Definition form.h:106
int line
Definition form.h:102
int line
Definition form.h:115
char display_s[FIELD_MAXLEN]
Definition form.h:132
char accept_s[FIELD_MAXLEN]
Definition form.h:128
int ff
Definition form.h:121
int col
Definition form.h:117
char input_s[FIELD_MAXLEN]
Definition form.h:125
int len
Definition form.h:119
char filler_s[FIELD_MAXLEN]
Definition form.h:137
cchar_t brktr
Definition form.h:294
FILE * out_fp
Definition form.h:161
Text * text[FIELD_MAXCNT]
Definition form.h:338
bool f_in_pipe
Definition form.h:221
bool f_mapp_spec
Definition form.h:192
bool f_erase_remainder
Definition form.h:235
WINDOW * box
Definition form.h:156
Field * field[FIELD_MAXCNT]
Definition form.h:351
char receiver_cmd[MAXLEN]
Definition form.h:178
bool f_process
Definition form.h:246
int didx
Definition form.h:323
int begy
Definition form.h:151
char provider_cmd[MAXLEN]
Definition form.h:170
bool f_query
Definition form.h:248
int out_fd
Definition form.h:165
int cols
Definition form.h:150
int lines
Definition form.h:149
int fcnt
Definition form.h:316
int begx
Definition form.h:153
bool f_out_pipe
Definition form.h:226
int fidx
Definition form.h:308
bool f_provider_cmd
Definition form.h:256
bool f_calculate
Definition form.h:244
int bg_clr_idx
Definition form.h:147
char fill_char[2]
Definition form.h:297
bool help
Definition form.h:250
bool f_cmd
Definition form.h:271
cchar_t brktl
Definition form.h:291
bool f_help_spec
Definition form.h:231
FILE * in_fp
Definition form.h:159
char out_spec[MAXLEN]
Definition form.h:208
Chyron * chyron
Definition form.h:363
int bo_clr_idx
Definition form.h:148
bool f_receiver_cmd
Definition form.h:263
bool f_multiple_cmd_args
Definition form.h:243
char in_spec[MAXLEN]
Definition form.h:201
char mapp_spec[FIELD_MAXLEN]
Definition form.h:167
char cmd[MAXLEN]
Definition form.h:185
char title[MAXLEN]
Definition form.h:157
char brackets[3]
Definition form.h:279
int dcnt
Definition form.h:330
int fg_clr_idx
Definition form.h:146
bool f_out_spec
Definition form.h:218
WINDOW * win
Definition form.h:155
bool f_in_spec
Definition form.h:215
int in_fd
Definition form.h:163
char help_spec[MAXLEN]
Definition form.h:194
char * choice_text
Definition menu.h:63
char * raw_text
Definition menu.h:60
char * command_str
Definition menu.h:79
unsigned int type
Definition menu.h:58
int letter_pos
Definition menu.h:69
unsigned int command_type
Definition menu.h:73
char choice_letter
Definition menu.h:66
char provider_cmd[MAXLEN]
Definition menu.h:135
int cols
Definition menu.h:101
char mapp_spec[MAXLEN]
Definition menu.h:124
int argc
Definition menu.h:118
Line * line[MAX_MENU_LINES]
Definition menu.h:203
bool f_help_spec
Definition menu.h:162
WINDOW * win
Definition menu.h:109
WINDOW * box
Definition menu.h:112
char cmd[MAXLEN]
Definition menu.h:150
bool f_provider_cmd
Definition menu.h:167
int bo_clr_idx
Definition menu.h:97
int fg_clr_idx
Definition menu.h:91
int begy
Definition menu.h:103
int text_max_len
Definition menu.h:190
bool f_mapp_spec
Definition menu.h:157
char receiver_cmd[MAXLEN]
Definition menu.h:143
int item_count
Definition menu.h:196
bool f_receiver_cmd
Definition menu.h:174
int choice_max_len
Definition menu.h:184
int bg_clr_idx
Definition menu.h:94
bool f_cmd
Definition menu.h:180
int line_idx
Definition menu.h:199
char help_spec[MAXLEN]
Definition menu.h:130
int lines
Definition menu.h:99
char ** argv
Definition menu.h:121
char title[MAXLEN]
Definition menu.h:115
int begx
Definition menu.h:106