2
3
4
5
6
7
8
13#define _XOPEN_SOURCE_EXTENDED 1
14#define NCURSES_WIDECHAR 1
17#include <ncursesw/ncurses.h>
22#if __STDC_VERSION__
< 202311L
33#define Ctrl(c) ((c) & 0x1f
)
36
37
38
39
40
41
42
43
44
45
46
47
63
64
65
66
67
68
69
70
71
72
73
75
76
77
85
86
87
96
97
98
99
100
101
102
105 __typeof__(x) _a = (x);
111 (__c >= 'A' && __c <= 'Z') ? (__c + ('a' - 'A')) : __c;
116 (__c >= 'a' && __c <= 'z') ? (__c - ('a' - 'A')) : __c;
120
121
167
168
169
170
171
172
173
174
175
176
177
181#define DEFAULTSHELL "/bin/bash"
183#define S_QUIET 0x2000
186
187
188
189
190
191
192
193
197 rc = atexit(end_pgm);
199 fprintf(stderr
, "\nCannot set exit function\n");
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227#define CHYRON_KEY_MAXLEN
229
230#define CHYRON_KEYS 20
234
247extern int xwgetch(WINDOW *, Chyron *,
int);
261
263
295
296
297
298
299
300
301
328extern int win_new(
int,
int,
int,
int,
char *,
int);
336extern bool
mk_dir(
char *dir);
345#define KEY_ALTF0 0x138
347#define XTERM_256COLOR
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
399#define KEY_ALTINS 0x223
400#define KEY_ALTHOME 0x21e
401#define KEY_ALTPGUP 0x232
402#define KEY_ALTDEL 0x20e
403#define KEY_ALTEND 0x219
404#define KEY_ALTPGDN 0x22d
405#define KEY_ALTUP 0x23d
406#define KEY_ALTLEFT 0x228
407#define KEY_ALTDOWN 0x214
408#define KEY_ALTRIGHT 0x237
409#elif defined(XTERM_GHOSTTY)
410#define KEY_ALTINS 0x228
411#define KEY_ALTHOME 0x223
412#define KEY_ALTPGUP 0x237
413#define KEY_ALTDEL 0x213
414#define KEY_ALTEND 0x21e
415#define KEY_ALTPGDN 0x232
416#define KEY_ALTUP 0x242
417#define KEY_ALTLEFT 0x22d
418#define KEY_ALTDOWN 0x219
419#define KEY_ALTRIGHT 0x23c
423#define BW_HO L'\x2500'
424#define BW_VE L'\x2502'
425#define BW_TL L'\x250C'
426#define BW_TR L'\x2510'
427#define BW_BL L'\x2514'
428#define BW_BR L'\x2518'
429#define BW_RTL L'\x256d'
430#define BW_RTR L'\x256e'
431#define BW_RBL L'\x2570'
432#define BW_RBR L'\x256f'
433#define BW_LT L'\x251C'
434#define BW_TT L'\x252C'
435#define BW_RT L'\x2524'
436#define BW_CR L'\x253C'
437#define BW_BT L'\x2534'
441
442
443
444
445
447extern const wchar_t
bw_ho;
448extern const wchar_t
bw_ve;
449extern const wchar_t
bw_tl;
450extern const wchar_t
bw_tr;
451extern const wchar_t
bw_bl;
452extern const wchar_t
bw_br;
453extern const wchar_t
bw_lt;
454extern const wchar_t
bw_tt;
455extern const wchar_t
bw_rt;
456extern const wchar_t
bw_cr;
457extern const wchar_t
bw_bt;
462
464
480
483
486
487
490
491
493
494
497
498
501
502
505
508
510
511
513
514
517
519#define to_uppercase(c)
520 if (c >= 'a' && c <= 'z')
523#define to_lowercase(c)
524 if (c >= 'A' && c <= 'Z')
527
530
534
536
540
542
550
556extern void cbox(WINDOW *);
567
568
574
575
578
582
583
589
590
591
592
598
599
600
601
602
603
604
610#define to_uppercase(c)
611 if (c >= 'a' && c <= 'z')
614
615
616
617
618
619
620
621
622
623
624
625
682extern int a_toi(
char *, bool *);
683extern bool
chrep(
char *,
char,
char);
684extern char *
rep_substring(
const char *,
const char *,
const char *);
693extern bool
strnfill(
char *,
char,
int);
694extern bool
str_subc(
char *,
char *,
char,
char *,
int);
695extern size_t
strnz(
char *, size_t);
696extern size_t
strnlf(
char *, size_t);
698extern size_t
ssnprintf(
char *, size_t,
const char *, ...);
699extern size_t
strnz__cpy(
char *,
const char *, size_t);
700extern size_t
strnz__cat(
char *,
const char *, size_t);
702extern size_t
string_cpy(String *,
const String *);
703extern size_t
string_cat(String *,
const String *);
704extern size_t
string_ncat(String *,
const String *, size_t);
705extern size_t
string_ncpy(String *,
const String *, size_t);
706extern size_t
trim(
char *);
707extern size_t
rtrim(
char *);
723extern int shell(
char *);
737extern void abend(
int,
char *);
740extern int answer_yn(
char *,
char *,
char *,
char *);
744extern bool
lf_find(
const char *,
const char *,
const char *,
int,
int);
751extern bool
dir_name(
char *,
char *);
756extern bool
trim_ext(
char *,
char *);
int cmd_processor(Init *)
int popup_form(Init *, int, char **, int, int)
int popup_menu(Init *, int, char **, int, int)
int popup_view(Init *, int, char **, int, int, int, int)
int parse_opt_args(Init *, int, char **)
int popup_pick(Init *, int, char **, int, int)
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)
void mouse_getch(int *, int *, int *, int *)
int display_ok_message(char *)
void destroy_win(WINDOW *)
struct termios shell_tioctl curses_tioctl
bool verify_dir_q(char *, int)
String mk_string(size_t)
Create a String struct with a dynamically allocated string.
bool construct_file_spec(char *, char *, char *, char *, char *, int)
#define CHYRON_KEY_MAXLEN
bool verify_file_q(char *, int)
void dump_opts_by_use(char *, char *)
void destroy_box(WINDOW *)
bool f_have_curses_tioctl
void w_mouse_getch(WINDOW *, int *, int *, int *, int *)
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
int display_curses_keys()
void display_argv_error_msg(char *, char **)
struct termios shell_in_tioctl curses_in_tioctl
struct termios shell_err_tioctl curses_err_tioctl
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
bool waitpid_with_timeout(pid_t pid, int timeout)
bool action_disposition(char *title, char *action_str)
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
char const colors_text[][10]
void set_chyron_key(Chyron *, int, char *, int)
struct termios shell_tioctl
bool open_curses(SIO *)
Initialize NCurses and color settings.
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.
int win_new(int, int, int, int, char *, int)
Create a new window with optional box and title.
void win_init_attrs()
Initialize window attributes.
WINDOW * win_del()
Delete the current window and its associated box window.
void mvwaddstr_fill(WINDOW *, int, int, char *, int)
For lines shorter than their display area, fill the rest with spaces.
void cbox(WINDOW *)
Draw a box around the specified window.
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.
bool is_set_chyron_key(Chyron *, int)
Check if function key label is set.
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
int get_chyron_key(Chyron *, int)
Get keycode from chyron.
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key.
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
void unset_chyron_key(Chyron *, int)
Unset chyron key.
Chyron * new_chyron()
Create and initialize Chyron structure.
RGB xterm256_idx_to_rgb(int)
Convert XTerm 256 color index to RGB color.
int clr_name_to_idx(char *)
Get color index from color name.
int rgb_to_curses_clr(RGB *)
Get color index for RGB color.
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.
int get_clr_pair(int fg, int bg)
Get color pair index for foreground and background colors.
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
int answer_yn(char *em0, char *em1, char *em2, char *em3)
Accept a single letter answer.
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
int Perror(char *)
Display a simple error message window or print to stderr.
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an 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 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 init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
void destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
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
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
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
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.
bool lf_find(const char *, const char *, const char *, int, int)
Find files in a directory matching a regular expression.
bool strnfill(char *, char, int)
Fills string s with character c n.
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 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.
char * strnz_dup(char *, size_t)
Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
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.
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 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".
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 file_spec_name(char *, char *)
extracts the file name component of a file specification
bool expand_tilde(char *, int)
Replace Leading Tilde With Home Directory.
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.
bool normalize_file_spec(char *)
replace backslashes with forward lashes
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
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.
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.
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.
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 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()
sget 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.
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char text[CHYRON_KEY_MAXLEN]
cchar_t cmplx_buf[MAXLEN]
ChyronKey * key[CHYRON_KEYS]
char ln_bg_clr_x[COLOR_LEN]