2
3
4
5
6
7
8
16typedef struct Init Init;
19#define MAX_MENU_LINES 256
56
60
61
62
63
64
65
67
68
69
70
71
72
75
77
78
80
81
83
84
86
87
90
91
92
93
94
96
97
98
99
103
104
105
108
109
111
112
114
116
118
120
121
123
124
126
127
129
130
132
133
135
136
138
139
141
142
143
144
145
147
148
149
150
152
153
154
155
156
157
160
161
162
163
164
165
167
168
169
170
171
172
174
175
176
177
179
180
181
182
184
185
186
187
188
189
191
192
193
194
195
197
198
199
201
202
203
204
205
207
208
209
210
211
213
214
216
217
218
220
221
222
223
224
int form_yx_to_fidx(Form *, int, int)
int form_read_description(Form *)
void display_field(Form *, cchar_t *, int, int)
void form_display_chyron(Form *)
int cmd_processor(Init *)
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
int process_config_file(char *, Init *)
int popup_form(Init *, int, char **, int, int)
instantiate a form popup window
void destroy_view_win(Init *)
int popup_menu(Init *, int, char **, int, int)
instantiate a menu popup window
int popup_view(Init *, int, char **, int, int, int, int)
instantiate a view popup window
int popup_pick(Init *, int, char **, int, int)
instantiate a pick popup window
void destroy_line_table(View *)
volatile sig_atomic_t sig_received
size_t rtrim(char *)
Trims trailing spaces from string s in place.
bool handle_signal(sig_atomic_t)
void get_rfc3339_s(char *, size_t)
PANEL * panel_win2[MAXWIN]
void mouse_getch(int *, int *, int *, int *)
int display_ok_message(char *)
WINDOW * win_win2[MAXWIN]
void destroy_win(WINDOW *)
void resize_panel(PANEL *, int, int, int, int)
struct termios shell_tioctl curses_tioctl
char * stdio_names(char *, char *)
bool verify_dir_q(char *, int)
String mk_string(size_t)
Create a String struct with a dynamically allocated string.
int border_draw(WINDOW *)
bool construct_file_spec(char *, char *, char *, char *, char *, int)
bool strnfill(char *, char, int)
#define CHYRON_KEY_MAXLEN
bool verify_file_q(char *, int)
int box2_new(int, int, int, int, char *)
void dump_opts_by_use(char *, char *)
PANEL * panel_win[MAXWIN]
char stdio_names_str[MAXLEN]
void destroy_box(WINDOW *)
#define min(x, y)
min macro evaluates two expressions, returning least result
bool f_have_curses_tioctl
PANEL * panel_box[MAXWIN]
void w_mouse_getch(WINDOW *, int *, int *, int *, int *)
char const colors_text[][10]
Color names for .minitrc overrides.
bool str_to_bool(const char *)
Converts String to boolean true or false.
#define __atexit
This macro registers the end_pgm function to be called when the program exits.
struct termios shell_out_tioctl curses_out_tioctl
char * stdio_fdnames(char *, char *)
int display_curses_keys()
char * fill_field(char *, char *, char, int)
void display_argv_error_msg(char *, char **)
struct termios shell_in_tioctl curses_in_tioctl
struct termios shell_err_tioctl curses_err_tioctl
void free_menu_line(Line *)
UiSurface * ui_surface_win[MAXWIN]
UiSurface * ui_surface_box[MAXWIN]
UiSurface * ui_surface_win2[MAXWIN]
int ui_bkgrnd(UiSurface *, const UiStyle *, const char *)
int ui_bkgd_set(UiSurface *, const UiStyle *, const char *)
int cf_accept(WINDOW *win, char *accept_s, int flin, int fcol, int flen)
Accepts input for a field in a C-Menu window.
struct termios shell_tioctl
bool open_curses(SIO *)
Initialize NCurses and color settings.
int border_title(WINDOW *, char *)
Draw a box with a title around the specified window.
int dxwgetch(WINDOW *, WINDOW *, WINDOW *, WINDOW *, WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
void restore_wins()
Restore all windows after a screen resize.
void win_del()
Delete the current window and its associated box window.
void check_panels(int)
Check and display the panels for a given window index.
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
void view_boxwin_resize(Init *)
Resize the current window and its box.
int border_hsplit_text(WINDOW *, char *, int)
Draw a box with a separator line and text around the specified window.
int bare_box_new(int, int, int, int, char *)
Create a new window with optional box and title.
int win_new(int, int)
Create a new window with specified dimensions and position.
int border_hsplit(WINDOW *, int)
Draw a box with a separator line around the specified window.
void win_init_attrs()
Initialize window attributes.
void mvwaddstr_fill(WINDOW *, int, int, char *, int)
For lines shorter than their display area, fill the rest with spaces.
int box_new(int, int, int, int, char *)
Create a new window with optional box and title.
int box_hsplit_new(int, int, int, int, int, char *)
Create a new window with optional box and title, and a second window inside it, split horizontally.
int win2_new(int, int, int, int)
Create a new subwindow (win2) with specified dimensions and position.
int vgetch(WINDOW *, int)
Wrapper for wgetch that handles signals and mouse events, and accepts a single character answer.
void win_resize(int, int, char *)
Resize the current window and its box, and update the title.
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
void win_redraw(WINDOW *)
Redraw the specified window.
int win2_box_new(int, int, int, int, char *)
Create a new window with optional box and title, and a second window inside it.
void initialize_local_colors(SIO *)
Initialize local color variables and color pairs based on SIO settings.
void display_cmplx_str(WINDOW *, cchar_t *, int, int)
Display a complex character string on a window.
RGB xterm256_idx_to_rgb(int)
Convert XTerm 256 color index to RGB.
size_t str_to_cc(cchar_t *, const char *, attr_t, int, size_t)
Convert a multibyte string to an array of cchar_t complex characters.
int clr_name_to_idx(char *)
Get color index from color name.
int rgb_to_curses_clr(RGB *)
Get color index for RGB color.
size_t mk_cmplx_str(cchar_t *, char *, attr_t, int)
Convert a multibyte string to an array of cchar_t complex characters.
bool init_clr_palette(SIO *)
Initialize color palette based on SIO settings.
void apply_gamma(RGB *)
Apply gamma correction to RGB color.
int rgb_to_xterm256_idx(RGB *)
Convert RGB color to XTerm 256 color index.
cchar_t mkcc(int, attr_t, const char *)
Create a cchar_t with the specified color pair index.
int get_clr_pair(int, int)
Get color pair index for foreground and background colors.
WINDOW * message_win(char *)
Display a message in a window or print to stderr if curses is not available.
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
bool waitpid_with_timeout(pid_t, int)
Wait for a process to finish with a timeout and optional user cancellation.
bool action_disposition(char *eitle, char *action_str)
Display a simple action disposition message window or print to stderr.
int answer_yn(char *, char *, char *, char *)
Accept a single letter answer.
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
int Perror(char *)
Display a simple error message window or print to stderr.
void abend(int, char *)
Abnormal program termination.
Chyron * wait_mk_chyron()
Create a Chyron struct for the waiting message.
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
bool is_set_chyron_key(Chyron *, int)
Check if function key label is set.
void set_chyron_key(Chyron *, int, char *, int)
Set chyron key with default color pair (cp_nt_rev).
void display_chyron(WINDOW *, Chyron *, int, int)
Display chyron on window.
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
void activate_chyron_key(Chyron *, int)
Activate chyron key.
int get_chyron_key(Chyron *, int)
Get keycode from chyron.
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key with color pair (cp).
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
void activate_all_chyron_keys(Chyron *)
Deactivate chyron key.
void unset_chyron_key(Chyron *, int)
Unset chyron key.
void deactivate_all_chyron_keys(Chyron *)
Deactivate all chyron keys.
void deactivate_chyron_key(Chyron *, int)
Deactivate chyron key.
Chyron * new_chyron()
Create and initialize Chyron structure.
int fork_exec(char **)
Fork and exec a command.
int shell(char *)
Execute a shell command.
int full_screen_fork_exec(char **)
Execute a command in full screen mode.
int full_screen_shell(char *)
Execute a shell command in full screen mode.
int fork_detach_execvp(char **)
Fork, set new session ID, close files, and execute detached command.
int form_fmt_field(Form *, char *s)
Format field according to its format type.
int field_editor(Form *)
Accept input for a field.
void numeric(char *d, char *s)
Extract numeric characters from source string to destination string.
bool is_valid_date(int yyyy, int mm, int dd)
Check if a given date is valid, including leap years.
void left_justify(char *s)
Left justify string by removing leading spaces.
bool is_valid_time(int hh, int mm, int ss)
Check if a given time is valid.
int form_display_field_n(Form *, int)
Display field n.
void right_justify(char *, int)
Right justify string by removing trailing spaces and adding leadingspaces.
int form_display_field(Form *)
Display current field.
int form_desc_error(Form *, 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.
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.
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
bool parse_local_timestamp(const char *, time_t *)
Parses an ISO 8601 timestamp string in local time and converts it to time_t.
bool trim_ext(char *, char *)
trims the file extension from "filename" and copies the result to "buf"
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
void write_cmenu_log(char *)
Write message to C-Menu log file with timestamp.
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
char * get_local_timestamp()
Returns the current local time as an ISO 8601 formatted string.
bool is_directory(const char *)
Checks if the given path is a directory.
bool file_spec_path(char *, char *)
extracts the path component of a file specification
bool str_to_upper(char *)
Converts a string to uppercase.
bool dir_name(char *, char *)
Returns the directory name of a file specification.
double str_to_double(char *)
converts string to double
bool str_to_lower(char *)
Converts a string to lowercase.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
bool strip_quotes(char *)
removes leading and trailing double quotes if present
bool is_valid_regex(const char *)
Checks if the given regular expression pattern is valid.
void open_cmenu_log()
Open new C-Menu log file.
char * strnz_dup(char *, size_t)
Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
bool file_spec_name(char *, char *)
extracts the file name component of a file specification
size_t strip_ansi(char *, char *)
Strips ANSI SGR escape sequences (ending in 'm') from string s to d.
bool mk_dir(char *dir)
If directory doesn't exist, make it.
int wccp_to_str(wchar_t, uint8_t *)
Converts a Unicode code point to a UTF-8 encoded string.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
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...
bool get_argp_doc_by_name(char *comment, const struct argp_option *, const char *)
Retrieves the documentation string for a given key name from an argp options array.
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
char * rep_substring(const char *, const char *, const char *)
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
bool is_symlink_to_dir(const char *)
Checks if the given path is a symbolic link to a directory.
size_t strnlf(char *, size_t)
terminates string with line feed
int a_toi(char *, bool *)
a safer alternative to atoi() for converting ASCII strings to integers.
bool is_hex_str(char *, int)
Validates that a string consists of exactly len hexadecimal digits.
void write_cmenu_log_nt(char *)
Write message to C-Menu log file without timestamp.
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
bool chrep(char *, char, char)
Replaces all occurrences of old_chr in s with new_chr in place.
bool base_name(char *, char *)
Returns the base name of a file specification.
char * get_ip_addresses(char *, int)
Retrieves the IP addresses of the local machine and formats them into a string.
bool normalize_file_spec(char *)
replace backslashes with forward lashes
char * format_local_timestamp(time_t, char *, size_t)
Formats a time_t as an ISO 8601 string in local time.
bool is_newer(char *, char *)
Checks if the file specified by "fut" is newer than the file specified by "control".
char * fdname(int, char *)
Retrieves the file path associated with a given file descriptor.
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
char * get_user_str(char *, size_t)
Retrieves the current user's name and UID, and formats it into a string.
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
unsigned long a_to_ul(const char *)
Converts a string to an unsigned long long integer, with support for suffixes K, M,...
bool unstr_hex_clr(char *, char *)
Validates that a string is a hex color code in the format "#RRGGBB".
char * iso8601_time(char *, int, time_t *, bool)
Formats a struct tm as an ISO 8601 string.
size_t string_cpy(String *, const String *)
Copy src String to dest String, allocating additional memory for dest String if necessary.
String to_string(const char *)
String functions provide a simple string library to facilitate string manipulation in C,...
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...
size_t string_cat(String *, const String *)
Concatenates src String to dest String, allocating additional memory for dest String if necessary.
String free_string(String)
Free the dynamically allocated String.
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...
int segmentation_fault()
Function to intentionally cause a segmentation fault for testing purposes.
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
bool derive_file_spec(char *, char *, char *)
Derive full file specification from directory and file name.
int write_config(Init *)
Write the current configuration to a file specified in init->minitrc.
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
void view_calc_boxwin_dimensions(Init *)
Calculate the dimensions and position of the box window for C-Menu View.
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
int init_view_boxwin(Init *)
Initialize the C-Menu View in box window mode.
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
int view_init_input(Init *, char *)
Initialize the input for the C-Menu View.
View * destroy_view(Init *init)
Destroy View structure.
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
bool init_menu_files(Init *, int, char **)
Initialize Menu file specifications.
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Init * new_init(int, char **)
Create and initialize Init structure.
Menu * new_menu(Init *, int, char **, int, int)
Create and initialize Menu structure.
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Form * destroy_form(Init *init)
Destroy Form structure.
View * new_view(Init *)
Create and initialize View structure.
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Init * destroy_init(Init *init)
Destroy Init structure.
Pick * destroy_pick(Init *init)
Destroy Pick structure.
unsigned int menu_engine(Init *)
The main loop of the menu system.
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.
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
char di_getch()
get single character from terminal in raw mode
bool restore_curses_tioctl()
restore_curses_tioctl() - restore curses terminal settings
bool capture_curses_tioctl()
capture_curses_tioctl() - capture curses terminal settings
bool mk_raw_tioctl(struct termios *)
mk_raw_tioctl() - set terminal to raw mode
bool set_sane_tioctl(struct termios *)
set_sane_tioctl() - set terminal to sane settings for C-MENU
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
void sig_dfl_mode()
Set signal handlers to default behavior.
void signal_handler(int)
Signal handler for interrupt signals.
void sig_prog_mode()
Set up signal handlers for interrupt signals.
int view_file(Init *)
Start view.
bool view_stack_pop(ViewStack *, View *)
Pop Item from View Stack.
bool view_stack_peek(const ViewStack *, View *)
Peek at Top Item of View Stack.
void view_stack_free(ViewStack *)
Free View Stack.
int view_cmd_processor(Init *)
Main Command Processing Loop for View.
bool view_stack_init(ViewStack *, size_t)
Initialize View Stack.
void build_prompt(View *)
Build Prompt String.
bool view_stack_push(ViewStack *, View)
Push Item onto View Stack.
void initialize_line_table(View *)
Initialize Line Table.
void next_page(View *)
Advance to Next Page.
int pad_refresh(View *)
Refresh Pad and Line Number Window.
int display_prompt(View *, char *)
Display Command Line Prompt.
int ui_draw_vline(UiSurface *s, int y, int x, int len, const UiStyle *style)
Draw a vertical line on a UiSurface.This function uses the ncurses mvwvline function to draw a vertic...
UiSurface * ui_surface_new(UiRuntime *ui, UiSurface *parent, UiRect rect)
Create a new UI surface.
int ui_surface_hide(UiSurface *s)
Hide a UI surface.
int ui_surface_clear(UiSurface *s)
Clear the contents of a UI surface.
int ui_draw_border(UiSurface *s, UiBorderKind kind, const UiStyle *style)
Draw a border around a UiSurface.This function draws a border around the UiSurface's window based on ...
void ui_get_screen_size(UiRuntime *ui, int *rows, int *cols)
Get the current screen size.
int ui_render(UiRuntime *ui)
Render the UI by updating panels and refreshing the screen.
void ui_surface_destroy(UiSurface *s)
Destroy a UI surface and free its resources.
int ui_surface_show(UiSurface *s)
Show a UI surface.
void ui_shutdown(UiRuntime *ui)
Shutdown the UI runtime and free its resources.
int ui_clear_screen(UiRuntime *ui)
Clear the entire screen.
int ui_surface_erase(UiSurface *s)
Erase the contents of a UI surface.
UiRuntime * ui_init(const UiConfig *cfg)
Initialize NCUrses.
int ui_surface_set_base(UiSurface *s, const UiStyle *style, uint32_t fill_ch)
Set the base fill character and style for a UiSurface.This function sets the background fill characte...
int ui_cursor_move(UiSurface *s, int y, int x)
Move the cursor within a UI surface.
int ui_suspend(UiRuntime *ui)
Suspend the UI, restoring the terminal to its normal state.
int ui_draw_box_title(UiSurface *s, int x, const UiStyle *style, const char *title)
Draw a title on the top border of a UiSurface.This function draws the provided title string at the sp...
int ui_draw_text_n(UiSurface *s, int y, int x, const UiStyle *style, const char *text, size_t n)
Draw a specified number of characters from a string on a UiSurface.This function is similar to ui_dra...
int ui_draw_text(UiSurface *s, int y, int x, const UiStyle *style, const char *text)
Draw text on a UiSurface at a specified position with a given style.This function uses the ncurses mv...
int ui_surface_set_style(UiSurface *s, const UiStyle *style)
Set the style for a UiSurface.This function applies the given UiStyle to the ncurses window associate...
int ui_resume(UiRuntime *ui)
Resume the UI after being suspended, reinitializing the screen.
int ui_surface_move(UiSurface *s, int y, int x)
Move a UI surface to a new position.
int ui_surface_resize(UiSurface *s, int rows, int cols)
Resize a UI surface to new dimensions.
int ui_get_event(UiRuntime *ui, UiSurface *target, UiEvent *ev, int timeout_ms)
Retrieves an input event from the specified UI surface.
int ui_draw_hline(UiSurface *s, int y, int x, int len, const UiStyle *style)
Draw a horizontal line on a UiSurface.This function uses the ncurses mvwhline function to draw a hori...
int ui_cursor_enable(UiRuntime *ui, bool visible)
Enable or disable the cursor visibility.
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char text[CHYRON_KEY_MAXLEN]
cchar_t cmplx_buf[MAXLEN]
ChyronKey * key[CHYRON_KEYS]
char nt_hl_rev_bg[COLOR_LEN]
char nt_rev_bg[COLOR_LEN]
char nt_rev_fg[COLOR_LEN]
char brackets_fg[COLOR_LEN]
char fill_char_fg[COLOR_LEN]
char brackets_bg[COLOR_LEN]
char fill_char_bg[COLOR_LEN]
char nt_hl_rev_fg[COLOR_LEN]
char display_s[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
char input_s[FIELD_MAXLEN]
cchar_t filler_cc[FIELD_MAXLEN]
cchar_t display_cc[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Text * text[FIELD_MAXCNT]
Field * field[FIELD_MAXCNT]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char mapp_spec[FIELD_MAXLEN]
unsigned int command_type
char provider_cmd[MAXLEN]
Line * line[MAX_MENU_LINES]
char receiver_cmd[MAXLEN]
UiMouseAction mouse_action
Opaque structure representing the UI runtime environment.
Opaque structure representing a drawable surface in the UI.