C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
cm.h
Go to the documentation of this file.
1/** @file cm.h
2 * @brief Headder for C-Menu API library, libcm.so
3 * @author Bill Waller
4 * Copyright (c) 2025
5 * MIT License
6 * billxwaller@gmail.com
7 * @date 2026-02-09
8 */
9
10#ifndef _CM_H
11#define _CM_H 1
12
13#define _XOPEN_SOURCE_EXTENDED 1 /**< Enable wide character support */
14#define NCURSES_WIDECHAR 1 /**< Enable wide character support */
15#define _GNU_SOURCE
16#include "version.h"
17#include <ncursesw/ncurses.h>
18#include <signal.h>
19#include <stddef.h>
20#include <stdlib.h>
21
22extern int cmenu_log_fd;
23
24#if __STDC_VERSION__ < 202311L
25#define nullptr NULL
26#endif
27
28#define MAX_ARGS 64 /**< maximum number of arguments for external commands */
29#define MAXLEN 256 /**< maximum length for strings and buffers */
30#define MAXARGS 64 /**< maximum number of arguments */
31#define SCR_COLS 1024 /**< maximum number of columns in the terminal screen */
32#define MAX_DEPTH 3 /**< default depth for recursive file searching */
33#define SCREEN_MAX_LINES 100
34#define Ctrl(c) ((c) & 0x1f)
35
36/** @brief max macro evaluates two expressions, returning greatest result.
37 @details These macros use compound statements to create local scopes for the
38 temporary variables _x and _y, which store the values of x and y,
39 respectively. This ensures that if x or y have side effects (such as being
40 incremented), they will only be evaluated once when the macro is expanded.
41 The use of typeof allows the macro to work with any data type.
42 The line (void)(&_x == &_y) is a compile-time check to ensure that the
43 types of the arguments are compatible.
44 This implementation of the min and max macros provides a safer and
45 more robust way to determine the minimum and maximum values between two
46 expressions without risking unintended consequences from multiple
47 evaluations.
48 */
49#define max(a, b)
50 ({
51 typeof(a) _a = (a);
52 typeof(b) _b = (b);
53 _a > _b ? _a : _b;
54 })
55/** @brief min macro evaluates two expressions, returning least result */
56#define min(x, y)
57 ({
58 typeof(x) _x = (x);
59 typeof(y) _y = (y);
60 (void)(&_x == &_y);
61 _x < _y ? _x : _y;
62 })
63/**
64 */
65/** @brief MIN macro for compatibility with code that uses the same name,
66 while avoiding multiple evaluations of the arguments.
67 @details /usr/include/sys/param.h contains implementations of the MIN and MAX
68 macros, which are simple but can lead to issues with multiple evaluations of
69 the arguments if they have side effects. These macros provides a safer
70 alternative to param.h Here are the macros from /usr/include/sys/param.h. You
71 may comment out the macros defined herein and use the macros in param.h if
72 you prefer.
73 @code
74 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
75 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
76 @endcode
77 @note The following macro provides a safer alternative to param.h
78 */
79#define MAX(a, b)
80 ({
81 typeof(a) _a = (a);
82 typeof(b) _b = (b);
83 _a > _b ? _a : _b;
84 })
85/** @brief MAX macro for compatibility with code that uses the same name,
86 while avoiding multiple evaluations of the arguments.
87 @note The following macro provides a safer alternative to param.h
88 */
89#define MIN(x, y)
90 ({
91 typeof(x) _x = (x);
92 typeof(y) _y = (y);
93 (void)(&_x == &_y);
94 _x < _y ? _x : _y;
95 })
96/** @brief ABS macro for absolute value, which evaluates the expression once and
97 returns the absolute value.
98 @details This macro uses a compound statement to create a local scope for
99 the temporary variable _a, which stores the value of x. This ensures that if
100 x has side effects (such as being incremented), it will only be evaluated
101 once when the macro is expanded. The use of typeof allows the macro to work
102 with any data type that supports comparison with zero and negation.
103 */
104#define ABS(x)
105 ({
106 __typeof__(x) _a = (x);
107 _a < 0 ? -_a : _a;
108 })
109#define S_TOLOWER(c)
110 ({
111 int __c = (c);
112 (__c >= 'A' && __c <= 'Z') ? (__c + ('a' - 'A')) : __c;
113 })
114#define S_TOUPPER(c)
115 ({
116 int __c = (c);
117 (__c >= 'a' && __c <= 'z') ? (__c - ('a' - 'A')) : __c;
118 })
119
120/**
121 @brief Used for xterm256 color conversions
122 */
123typedef enum {
155} ColorsEnum;
156
157typedef enum {
158 /** byte 0 - bits 0-7 Selection Flags*/
159 LF_HIDE = 0b00000001, /**< 1 Don't list hidden files */
160 LF_ICASE = 0b00000010, /**< 2 Ignore case in search */
161 LF_EXC_REGEX = 0b00000100, /**< 4 Exclude files matching regex */
162 LF_REGEX = 0b00001000, /**< 8 Include files matching regex */
163 LF_EXEC = 0b00010000, /**< 16 Execute command each file */
164 LF_USER = 0b00100000, /**< 32 Select User Name */
165 /** << 16 */
166 /** byte 1 - bits 8-15 */
167 LF_IXUSR = 0b00000001, /**< 1 Select Files with Execute Permission */
168 LF_IWUSR = 0b00000010, /**< 2 Select Files with Write Permission */
169 LF_IRUSR = 0b00000100, /**< 4 Select Files with Read Permission */
170 LF_ISGID = 0b00010000, /**< 16 Select Setgid Files */
171 LF_ISUID = 0b00100000, /**< 32 Select Setuid Files */
172} LFFlags;
173
174/** byte 2 - bits 16-23 File types*/
175typedef enum {
176 LF_FIFO = 0b00000001, /**< 1 named pipe */
177 LF_CHR = 0b00000010, /**< 2 character device */
178 LF_DIR = 0b00000100, /**< 4 directory */
179 LF_BLK = 0b00001000, /**< 8 block */
180 LF_REG = 0b00010000, /**< 16 regular file */
181 LF_LNK = 0b00100000, /**< 32 link */
182 LF_SOCK = 0b01000000, /**< 64 socket */
183 LF_UNKNOWN = 0b10000000 /**< 128 unknown */
184} LFTypes;
185
186/*
187 * dirent d_type to lf_type for reference
188------------------------ --------------------
189d_type binary dec lf_type binary dec ordinal
190--------- -------- --- ----------- -------- --- -------
191DT_FIFO: 00000001 1 LF_FIFO: 00000001 1 1
192DT_CHR: 00000010 2 LF_CHR: 00000010 2 2
193DT_DIR: 00000100 4 LF_DIR: 00000100 4 3
194DT_BLK: 00000110 6 LF_BLK: 00001000 8 4
195DT_REG: 00001000 8 LF_REG: 00010000 16 5
196DT_LNK: 00001010 10 LF_LNK: 00100000 32 6
197DT_SOCK: 00001100 12 LF_SOCK: 01000000 64 7
198DT_UNKNOWN: 00001110 14 LF_UNKNOWN: 10000000 128 8
199 */
200
201#define F_NO_STDERR 1
202
203/**
204 Include Exclude
205 ---------- ----------
206 LF_FIFO 1 0 00000001 7 11111110 named pipe
207 LF_CHR 2 1 00000010 6 11111101 character device
208 LF_DIR 4 2 00000100 5 11111011 directory
209 LF_BLK 8 3 00001000 4 11110111 block device
210 LF_REG 16 4 00010000 3 11101111 regular file
211 LF_LNK 32 5 00100000 2 11011111 link
212 LF_SOCK 64 6 01000000 1 10111111 socket
213 LF_UNKNOWN 128 7 10000000 0 01111111 unknown
214*/
215
216#define COLOR_LEN 8 /**< length of color code strings */
217#define DEFAULTSHELL "/bin/bash"
218#define S_WCOK 0x1000 /**< write or create permitted */
219#define S_QUIET 0x2000 /**< quiet mode flag for file validation */
220
221/** @brief This macro registers the end_pgm function to be called when the
222 program exits.
223 @details It checks the return value of atexit() to ensure that the
224 registration was successful, and if not, it prints an error message and
225 exits with a failure status. Programs using libcm should call __atexit in
226 their main function to ensure that the end_pgm function is registered to be
227 called on program exit. This will help ensure that the terminal is properly
228 restored to its original state, even if the program encounters an error or
229 is terminated unexpectedly. */
230#define __atexit
231 {
232 int rc;
233 rc = atexit(end_pgm);
234 if (rc != 0) {
235 fprintf(stderr, "\nCannot set exit function\n");
236 exit(EXIT_FAILURE);
237 }
238 }
239
240/** @struct Chyron
241 @details The Chyron structure represents a key binding for a command in the
242 chyron, which is a status line or message area in the terminal interface.
243 The ChyronKey structure includes fields for displayable text,
244 the key code, and the end position of the command text in the chyron.
245 This structure allows xwgetch to map mouse clicks to key codes
246 as defined by NCursesw and the C-Menu program.
247 The text field holds the displayable text associated with the command.
248 xwgetch() translates a mouse click on the chyron with a particular key code
249 stored in this table.
250 The use case is when the developer wants a dynamic chyron that can be
251 easily changed depending on the context of the program without having to
252 worry about translating mouse click positions to key codes.
253 While many key codes are defined by NCursesw, the developer is free to
254 define their own key codes for custom commands in the chyron. However,
255 xwgetch() will translate mouse clicks to the key codes defined in this table,
256 even if they interfere with standard NCurses key codes, Unicode code points,
257 or ASCII characters. Just use common sense.
258 In addition to returning the key code associated with mouse clicks on
259 the chyron, xwgetch() also returns the key codes for standard keyboard input,
260 and sets the global variables cliek_y and click_x to the coordinates of the
261 mouse click.
262 */
263#define CHYRON_KEY_MAXLEN
264 64 /**< maximum length of the command text for a key \
265 binding in the chyron */
266#define CHYRON_KEYS 20 /**< maximum number of key bindings for the chyron */
267
268typedef struct {
269 char text[CHYRON_KEY_MAXLEN]; /**< command text associated with the key code
270 */
271 int keycode; /**< key code associated with the command */
272 int end_pos; /**< end position of the command text in the chyron */
273 int cp; /**< color pair index for the command text in the chyron */
274} ChyronKey;
275
276typedef struct {
277 ChyronKey *key[CHYRON_KEYS]; /**< array of key bindings for the chyron */
278 char s[MAXLEN]; /**< the chyron string, for displaying messages in */
279 cchar_t cmplx_buf[MAXLEN]; /**< the chyron wide character string */
280 int l; /**< length of the chyron string, for display purposes */
281} Chyron;
282
283extern int xwgetch(WINDOW *, Chyron *, int);
284extern int dxwgetch(WINDOW *, WINDOW *, Chyron *, int);
285
286extern int click_y; /**< the y coordinate of a mouse click */
287extern int click_x; /**< the x coordinate of a mouse click */
288extern WINDOW *mouse_win; /**< input from window n */
289
290extern Chyron *wait_mk_chyron();
291extern WINDOW *wait_mk_win(Chyron *, char *);
292extern int wait_continue(WINDOW *, Chyron *, int);
293extern bool wait_destroy(Chyron *);
294extern bool waitpid_with_timeout(pid_t, int);
295extern int wait_timeout;
296extern bool action_disposition(char *title, char *action_str);
297extern int dmon(char **);
298
299extern bool f_debug; /**< a flag to indicate whether debug
300 output should be printed, for debugging purposes */
301extern unsigned int cmd_key; /**< the command key for the current command, for
302 error messages and other output */
303/** @struct RGB */
304typedef struct {
305 int r; /**< red component (0-255) */
306 int g; /**< green component (0-255) */
307 int b; /**< blue component (0-255) */
308} RGB;
309
310#define FG_COLOR 2 /**< default foreground color */
311#define BG_COLOR 0 /**< default background color */
312#define BO_COLOR 1 /**< default bold foreground color */
313#define LN_COLOR 4 /**< default line number color */
314#define LN_BG_COLOR 7 /**< default line number background */
315
316extern int cp_default; /**< default color pair index */
317extern int cp_norm; /**< normal color pair index */
318extern int cp_win; /**< window color pair index */
319extern int cp_box; /**< box color pair index */
320extern int cp_bold; /**< bold color pair index */
321extern int cp_title; /**< title color pair index */
322extern int cp_highlight; /**< highlight color pair index */
323extern int cp_nt; /**< normal color pair index */
324extern int cp_nt_rev; /**< reverse color pair index */
325extern int cp_nt_hl; /**< highlight color pair index */
326extern int cp_nt_hl_rev; /**< highlight reverse color pair index */
327extern int cp_ln; /**< line number color pair index */
328extern int cp_ln_bg; /** line number background color pair index */
329extern int clr_idx; /**< current color index */
330extern int clr_cnt; /**< number of colors used */
331extern int clr_pair_idx; /**< current color pair index */
332extern int clr_pair_cnt; /**< number of color pairs supported by the terminal */
333extern char const colors_text[][10]; /**< color codes for the 16 basic colors */
334
335/** @struct ColorPair
336 @details The ColorPair structure is a simple structure that holds information
337 about a color pair, including the foreground color index, background color
338 index, and the color pair index. This structure can be used to manage and
339 apply color pairs in the ncurses library, allowing for easy customization of
340 the terminal's appearance. By using this structure, you can easily keep track
341 of the different color pairs you have defined and apply them to various
342 elements in your terminal interface. */
343typedef struct {
344 int fg; /**< foreground color index */
345 int bg; /**< background color index */
346 int pair_id; /**< color pair index */
347} ColorPair;
348
349/**< see termios.h */
350extern struct termios shell_tioctl, curses_tioctl;
351extern struct termios shell_in_tioctl, curses_in_tioctl;
352extern struct termios shell_out_tioctl, curses_out_tioctl;
353extern struct termios shell_err_tioctl, curses_err_tioctl;
354
355extern bool f_have_shell_tioctl; /**< shell tioctl captured */
356extern bool f_have_curses_tioctl; /**< curses tioctl captured */
357extern bool f_curses_open; /**< curses mode is active */
358extern bool f_restore_screen; /**< whether to restore the screen */
359
360extern void dump_opts(); /**< dump options to stdout */
361
362extern void dump_opts_by_use(char *, char *); /**< dump options to stdout */
363extern bool capture_shell_tioctl();
364extern bool restore_shell_tioctl();
365extern bool capture_curses_tioctl();
366extern bool restore_curses_tioctl();
367extern bool mk_raw_tioctl(struct termios *);
368extern bool set_sane_tioctl(struct termios *);
369extern int box_new(int, int, int, int, char *, bool);
370extern int box2_new(int, int, int, int, char *, bool);
371extern int win_new(int, int, int, int);
372extern int win2_new(int, int, int, int);
373extern void win_redraw(WINDOW *);
374extern void win_resize(int, int, char *);
375extern void signal_handler(int);
376extern bool handle_signal(sig_atomic_t);
377extern volatile sig_atomic_t sig_received;
378extern void sig_prog_mode();
379extern void sig_dfl_mode();
380extern bool mk_dir(char *dir);
381extern int segmentation_fault();
382extern cchar_t mkccc(int, attr_t, char *);
383extern char *iso8601_time(char *, int, time_t *, bool);
384extern bool parse_local_timestamp(const char *, time_t *);
385extern char *format_local_timestamp(time_t, char *, size_t);
386extern char *get_local_timestamp();
387extern char *get_user_str(char *, size_t);
388extern char *get_ip_addresses(char *, int);
389
390extern cchar_t CCC_NORM; /**< curses default */
391extern cchar_t CCC_REVERSE; /**< curses default reverse */
392extern cchar_t CCC_NT; /**< C-Menu normal text */
393extern cchar_t CCC_NT_REV; /**< reverse */
394extern cchar_t CCC_NT_HL; /**< highlight */
395extern cchar_t CCC_NT_HL_REV; /**< highlight reverse */
396extern cchar_t CCC_WIN; /**< curses default */
397extern cchar_t CCC_BOX; /**< box colors */
398extern cchar_t CCC_LN; /* line numbers */
399extern cchar_t CCC_BRKTL; /* left field bracket */
400extern cchar_t CCC_BRKTR; /* right field bracket */
401
402#define KEY_ALTF0 0x138
403#define KEY_ALTF(n) (KEY_ALTF0 + (n)) /**< define alt function keys */
404#define XTERM_256COLOR /**< use xterm-256color terminfo for altkey bindings */
405/**
406 EXTENDED NCURSES KEYS
407
408 Key code bindings are customarily defined in terminfo.
409 xterm-256color tends to be the most complete, and indeed, it seems to
410 work with Ghostty, Kitty, and Alacritty. If you want to use the
411 altkey bindings, you may need to set your terminal's TERM environment
412 variable to xterm-256color. Here's why:
413
414 Ghostty, Kitty, and Alacritty all come with their own terminfo files:
415
416 Ghostty with xterm-ghostty,
417 Kitty with xterm-kitty, and
418 Alacritty with alacritty
419
420 None of the three produced the correct extended altkey bindings when
421 paired with the terminfo provided in their distribution, yet all
422 three worked with xterm-256color.
423
424 The extended altkeys were not defined in any of the terminfo files, not
425 even xterm-256color. Yet, xterm-256color produced consistent keycode
426 bindings with all three emulators. The standard key bindings, ins, delete,
427 up, down arrows, etc., were the same for all three terminfos, and all
428 three emulators produced the correct key bindings for those keys.
429
430 The fact that xterm-256color produced consistent keycode bindings for the
431 altkeys, while the other three terminfos did not, is likely due to the fact
432 that xterm-256color is more widely used and has better support for extended
433 key bindings, even if they are not explicitly defined in the terminfo file.
434 It's possible that xterm-256color has some default behavior or fallback
435 mechanism that allows it to recognize and produce key codes for the altkeys,
436 while the other terminfos do not have such a mechanism in place. This could
437 explain why xterm-256color produced consistent keycode bindings for the
438 altkeys across all three emulators, while the other terminfos did not.
439 @code
440 mapped altkey ncurses
441 2nd fld - 1 name binding keycode
442 ------------- --------- -------- -------
443 kIC=\E[2;2~, key_ins \E[2;3~, 223
444 kHOM=\E[1;2H, key_home \E[1;3H, 21e
445 kPRV=\E[5;2~, key_pgup \E[5;3~, 232
446 kDC=\E[3;2~, key_del \E[3;3~, 20e
447 kEND=\E[1;2F, key_end \E[1;3F, 219
448 kNXT=\E[6;2~, key_pgdn \E[6;3~, 22d
449 kri=\E[1;2A, key_up \E[1;3A, 23d
450 kind=\E[1;2B, key_down \E[1;3B, 214
451 kRIT=\E[1;2C, key_right \E[1;3C, 237
452 kLFT=\E[1;2D, key_left \E[1;3D, 228
453 @endcode
454 */
455#if defined(XTERM_256COLOR)
456#define KEY_ALTINS 0x223
457#define KEY_ALTHOME 0x21e
458#define KEY_ALTPGUP 0x232
459#define KEY_ALTDEL 0x20e
460#define KEY_ALTEND 0x219
461#define KEY_ALTPGDN 0x22d
462#define KEY_ALTUP 0x23d
463#define KEY_ALTLEFT 0x228
464#define KEY_ALTDOWN 0x214
465#define KEY_ALTRIGHT 0x237
466#elif defined(XTERM_GHOSTTY)
467#define KEY_ALTINS 0x228
468#define KEY_ALTHOME 0x223
469#define KEY_ALTPGUP 0x237
470#define KEY_ALTDEL 0x213
471#define KEY_ALTEND 0x21e
472#define KEY_ALTPGDN 0x232
473#define KEY_ALTUP 0x242
474#define KEY_ALTLEFT 0x22d
475#define KEY_ALTDOWN 0x219
476#define KEY_ALTRIGHT 0x23c
477#endif
478
479/** UNICODE BOX DRAWING SYMBOLS */
480#define BW_HO L'\x2500' /**< horizontal line */
481#define BW_VE L'\x2502' /**< vertical line */
482#define BW_TL L'\x250C' /**< top left */
483#define BW_TR L'\x2510' /**< top right */
484#define BW_BL L'\x2514' /**< bottom left */
485#define BW_BR L'\x2518' /**< bottom right */
486#define BW_RTL L'\x256d' /**< rounded left tee */
487#define BW_RTR L'\x256e' /**< rounded right tee */
488#define BW_RBL L'\x2570' /**< rounded bottom left */
489#define BW_RBR L'\x256f' /**< rounded bottom right */
490#define BW_LT L'\x251C' /**< left tee */
491#define BW_TT L'\x252C' /**< top tee */
492#define BW_RT L'\x2524' /**< right tee */
493#define BW_CR L'\x253C' /**< cross */
494#define BW_BT L'\x2534' /**< bottom tee */
495#define BW_SP L'\x20' /**< space */
496#define BW_RA L'\x2192' /**< large right arrow */
497#define BW_LA L'\x2190' /**< large left arrow */
498#define BW_UA L'\x2191' /**< large up arrow */
499#define BW_DA L'\x2193' /**< large down arrow */
500#define BW_RAN L'\x276F' /**< right_angle */
501#define BW_LAN L'\x276E' /**< left_angle */
502
503/** The following are the actual wchar_t variables that will hold the box
504 drawing characters. These correspond to the above Unicode code points. By
505 defining them as wchar_t, we can use them in the ncurses library to draw
506 boxes and lines in the terminal. The variables are named with a "bw_" prefix
507 to indicate that they are box (wide) drawing characters, and they will be
508 initialized with the corresponding Unicode characters defined above. */
509
510extern const wchar_t bw_ho; /**< horizontal line */
511extern const wchar_t bw_ve; /**< vertical line */
512extern const wchar_t bw_tl; /**< top left corner */
513extern const wchar_t bw_tr; /**< top right corner */
514extern const wchar_t bw_bl; /**< bottom left corner */
515extern const wchar_t bw_br; /**< bottom right corner */
516extern const wchar_t bw_lt; /**< left tee */
517extern const wchar_t bw_tt; /**< top tee */
518extern const wchar_t bw_rt; /**< right tee */
519extern const wchar_t bw_cr; /**< cross */
520extern const wchar_t bw_bt; /**< bottom tee */
521extern const wchar_t bw_sp; /**< space */
522extern const wchar_t bw_ra; /**< right arrow */
523extern const wchar_t bw_la; /**< left arrow */
524extern const wchar_t bw_ua; /**< up arrow */
525extern const wchar_t bw_da; /**< down arrow */
526extern const wchar_t bw_ran; /**< right piointing angle */
527extern const wchar_t bw_lan; /**< left piointing angle */
528
529extern void write_cmenu_log_nt(char *);
530extern void write_cmenu_log(char *);
531extern void open_cmenu_log();
532extern FILE *cmenu_log_fp;
533extern int n_lines; /**< number of lines in the terminal */
534extern int n_cols; /**< number of columns in the terminal */
535extern int lines; /**< current number of lines (may be less than n_lines if the
536 terminal is resized) */
537extern int cols; /**< current number of columns (may be less than n_cols if the
538 terminal is resized) */
539extern int begx; /**< beginning x coordinate of the terminal */
540extern int begy; /**< beginning y coordinate of the terminal */
541
542#define MAXWIN 30 /**< maximum number of windows that can be created */
543typedef unsigned char uchar;
544
545extern void sig_prog_mode();
546extern void sig_shell_mode();
547extern char di_getch();
548extern int enter_option();
549
550extern WINDOW *win; /**< generic window pointer, used for various purposes */
551extern WINDOW
552 *win_win[MAXWIN]; /**< array of pointers to windows, indexed by window ID */
553extern WINDOW *
554 win_win2[MAXWIN]; /**< array of pointers to windows, indexed by window ID */
555extern WINDOW *win_box[MAXWIN]; /**< array of pointers to box windows, indexed
556 by window ID */
557
558extern int win_attr; /**< Ncurses attributes for the current window, such as
559 color pair, bold, etc. */
560extern int
561 win_attr_odd; /**< Ncurses attributes for the current window odd lines,
562 which may be different from the attributes for even lines
563 to create a striped effect in the window. */
564extern int
565 win_attr_even; /**< Ncurses attributes for the current window even lines,
566 which may be different from the attributes for odd lines
567 to create a striped effect in the window. */
568extern int win_ptr; /**< Pointer to the current window pair, box and window,
569 which can be used to keep track of the currently active
570 window and its associated box. */
571extern bool win_pair; /**< Flag to indicate whether the current window is part
572 of a window pair */
573extern int
574 mlines; /**< number of lines in the current window, which may be less than
575 the total number of lines in the terminal if the window is
576 resized or if multiple windows are being used. */
577extern int
578 mcols; /**< number of columns in the current window, which may be less than
579 the total number of columns in the terminal if the window is
580 resized or if multiple windows are being used. */
581extern int
582 mbegy; /**< beginning y coordinate of the current window, which can be used
583 to determine the position of the window on the terminal screen. */
584extern int
585 mbegx; /**< beginning x coordinate of the current window, which can be used
586 to determine the position of the window on the terminal screen. */
587extern int mg_action; /**< action in progress, which can be used to keep track
588 of the current state of the program and determine how
589 to respond to user input or other events. */
590extern int mg_col; /**< window column, which can be used to determine the
591 current column position in the window for displaying text
592 or other content. */
593extern int
594 mg_line; /**< window line, which can be used to determine the current line
595 position in the window for displaying text or other content. */
596/** to_uppercase(c) - convert a lowercase letter to uppercase */
597#define to_uppercase(c)
598 if (c >= 'a' && c <= 'z')
599 c -= ' '
600/** to_lowercase(c) - convert an uppercase letter to lowercase */
601#define to_lowercase(c)
602 if (c >= 'A' && c <= 'Z')
603 c += ' '
604extern int tty_fd; /**< the file descriptor for the terminal, for error messages
605 and other output */
606extern int
607 dbgfd; /**< the file descriptor for debug output, for debugging purposes */
608extern int src_line; /**< the line number of the source file being processed,
609 for error messages */
610extern char *src_name; /**< the name of the source file being processed, for
611 error messages */
612extern char fn[MAXLEN]; /**< function name for error messages */
613extern char em0[MAXLEN]; /**< error message string for error messages */
614extern char em1[MAXLEN]; /**< error message string for error messages */
615extern char em2[MAXLEN]; /**< error message string for error messages */
616extern char em3[MAXLEN]; /**< error message string for error messages */
617
618extern int exit_code; /**< the exit code for the program, for error messages and
619 other output */
620
621extern WINDOW *win_del();
622extern void destroy_win(WINDOW *);
623extern void destroy_box(WINDOW *);
624extern void restore_wins();
625extern void cbox(WINDOW *);
626extern void win_init_attrs();
627extern void win_Toggle_Attrs();
628extern void mvwaddstr_fill(WINDOW *, int, int, char *, int);
630extern void init_stdscr();
631extern void curskeys(WINDOW *);
632extern void mouse_getch(int *, int *, int *, int *);
633extern void w_mouse_getch(WINDOW *, int *, int *, int *, int *);
634
635/** @struct Arg
636 @brief The Arg structure represents a string argument with a pointer to the
637 string and its allocated length. */
638typedef struct {
639 char *s; /**< pointer to the string argument */
640 size_t l; /**< allocated length */
641} Arg;
642/** @struct Argv
643 @brief The Argv structure represents an argument vector, which is an array of
644 Arg structures, along with the number of allocated elements in the array. */
645typedef struct {
646 Arg **v; /**< pointer to an array of Arg pointers, representing the argument
647 vector */
648 size_t n; /**< allocated array elements */
649} Argv;
650/** @struct String
651 @brief The String structure represents a string object with a pointer to the
652 string and its allocated length. */
653typedef struct {
654 char *s; /**< pointer to the string */
655 size_t l; /**< allocated length */
656} String;
657/** @struct WCStr
658 @brief wide character string object with a pointer to the wide character
659 string and its allocated length
660 @details The WCStr structure represents a wide character string with a
661 pointer to the wide character string and its allocated length. */
662typedef struct {
663 wchar_t *s; /**< pointer to the wide character string */
664 size_t l; /**< @brief allocated length */
665} WCStr;
666/** @struct CCStr
667 @brief complex character objectl with a pointer to the complex character
668 string and its allocated length
669 @details The CCStr structure represents a complex character string, which is
670 a string that can contain both regular characters and attributes (such as
671 color, bold, etc.) in the ncurses library. This structure includes a pointer
672 to the complex character string and its allocated length, allowing for
673 dynamic handling of complex character strings in the terminal interface. */
674typedef struct {
675 cchar_t *s; /**< pointer to the complex character string */
676 size_t l; /**< allocated length */
677} CCStr;
678/** simple macro to convert a character to uppercase */
679#define to_uppercase(c)
680 if (c >= 'a' && c <= 'z')
681 c -= ' '
682/** @struct SIO
683 @brief The SIO structure encapsulates various aspects of the terminal's
684 state and configuration, including color management, file pointers, and
685 terminal device information.
686 @details The SIO structure serves as a central repository for all relevant
687 information needed to manage the terminal's appearance and behavior
688 effectively, allowing for a highly customizable and visually appealing
689 terminal experience. The SIO structure includes fields for managing colors,
690 gamma correction values, color codes for different colors, file pointers and
691 descriptors for standard input/output/error and the terminal device, as well
692 as counters and indices for color management. Additionally, it contains a
693 field for storing the name of the terminal device. This comprehensive
694 structure allows for efficient management of the terminal's state and
695 configuration in a structured way. */
696typedef struct {
697 double red_gamma; /**< red gamma correction value */
698 double green_gamma; /**< green gamma correction value */
699 double blue_gamma; /**< blue gamma correction value */
700 double gray_gamma; /**< gray gamma correction value */
701 char black[COLOR_LEN]; /**< color code for black */
702 char red[COLOR_LEN]; /**< color code for red */
703 char green[COLOR_LEN]; /**< color code for green */
704 char yellow[COLOR_LEN]; /**< color code for yellow */
705 char blue[COLOR_LEN]; /**< color code for blue */
706 char magenta[COLOR_LEN]; /**< color code for magenta */
707 char cyan[COLOR_LEN]; /**< color code for cyan */
708 char white[COLOR_LEN]; /**< color code for white */
709 char orange[COLOR_LEN]; /**< color code for orange */
710 char bblack[COLOR_LEN]; /**< color code for bold black */
711 char bred[COLOR_LEN]; /**< color code for bold red */
712 char bgreen[COLOR_LEN]; /**< color code for bold green */
713 char byellow[COLOR_LEN]; /**< color code for bold yellow */
714 char bblue[COLOR_LEN]; /**< color code for bold blue */
715 char bmagenta[COLOR_LEN]; /**< color code for bold magenta */
716 char bcyan[COLOR_LEN]; /**< color code for bold cyan */
717 char bwhite[COLOR_LEN]; /**< color code for bold white */
718 char borange[COLOR_LEN]; /**< color code for bold orange */
719 char bg[COLOR_LEN]; /**< color code for background */
720 char abg[COLOR_LEN]; /**< color code for background with alpha */
721 char fg_clr_x[COLOR_LEN]; /**< foreground color index */
722 char bg_clr_x[COLOR_LEN]; /**< background color index */
723 char bo_clr_x[COLOR_LEN]; /**< bold color index */
724 char ln_clr_x[COLOR_LEN]; /**< line number color index */
725 char ln_bg_clr_x[COLOR_LEN]; /**< line number background index */
726 char nt_fg[COLOR_LEN]; /**< color code for normal text foreground */
727 char nt_bg[COLOR_LEN]; /**< color code for normal text background */
728 char nt_rev_fg[COLOR_LEN]; /**< normal text reverse foreground */
729 char nt_rev_bg[COLOR_LEN]; /**< normal text reverse background */
730 char nt_hl_fg[COLOR_LEN]; /**< normal text highlight foreground */
731 char nt_hl_bg[COLOR_LEN]; /**< normal text highlight background */
732 char
733 nt_hl_rev_fg[COLOR_LEN]; /** normal text highlight reverse foreground */
734 char
735 nt_hl_rev_bg[COLOR_LEN]; /** normal text highlight reverse background */
736 char tty_name[MAXLEN]; /**< name of the terminal device */
737 FILE *stdin_fp; /**< stdin stream pointer */
738 FILE *stdout_fp; /**< stdout stream pointer */
739 FILE *stderr_fp; /**< stderr stream pointer */
740 FILE *tty_fp; /**< terminal device stream pointer */
741 int stdin_fd; /**< stdin file descriptor */
742 int stdout_fd; /**< stdout file descriptor */
743 int stderr_fd; /**< stderr file descriptor */
744 int tty_fd; /**< terminal device file descriptor */
745 int clr_cnt; /**< number of colors currently in use */
746 int clr_pair_cnt; /**< number of color pairs currently in use */
747 int clr_idx; /**< current color index */
748 int clr_pair_idx; /**< current color pair index */
749 int cp_default; /**< default color pair index */
750 int cp_norm; /**< normal color pair index */
751 int cp_win; /**< window color pair index */
752 int cp_nt_rev; /**< reverse color pair index */
753 int cp_nt_hl; /**< highlight color pair index */
754 int cp_nt_hl_rev; /**< reverse highlight color pair index */
755 int cp_box; /**< box color pair index */
756 int cp_bold; /**< bold color pair index */
757 int cp_title; /**< title color pair index */
758 int cp_highlight; /**< highlight color pair index */
759 int cp_ln; /**< line number color pair index */
760 int cp_ln_bg; /**< line number background pair index */
761} SIO;
762extern void destroy_curses();
763extern int a_toi(char *, bool *);
764extern bool chrep(char *, char, char);
765extern char *rep_substring(const char *, const char *, const char *);
766extern size_t strip_ansi(char *, char *);
767extern bool strip_quotes(char *);
768extern bool stripz_quotes(char *);
769extern int str_to_args(char **, char *, int);
770extern int destroy_argv(int argc, char **argv);
771extern bool str_to_bool(const char *);
772extern bool str_to_lower(char *);
773extern bool str_to_upper(char *);
774extern bool strnfill(char *, char, int);
775extern bool str_subc(char *, char *, char, char *, int);
776extern size_t strnz(char *, size_t);
777extern size_t strnlf(char *, size_t);
778extern char *strnz_dup(char *, size_t);
779extern size_t ssnprintf(char *, size_t, const char *, ...);
780extern size_t strnz__cpy(char *, const char *, size_t);
781extern size_t strnz__cat(char *, const char *, size_t);
782extern double str_to_double(char *);
783extern size_t string_cpy(String *, const String *);
784extern size_t string_cat(String *, const String *);
785extern size_t string_ncat(String *, const String *, size_t);
786extern size_t string_ncpy(String *, const String *, size_t);
787extern size_t trim(char *);
788extern size_t rtrim(char *);
789extern String to_string(const char *);
790extern String mk_string(size_t);
791extern String free_string(String);
792extern void apply_gamma(RGB *);
793extern int get_clr_pair(int, int);
794extern int clr_name_to_idx(char *);
795extern int rgb_to_xterm256_idx(RGB *);
796extern bool init_clr_palette(SIO *);
797extern bool open_curses(SIO *);
798extern int rgb_clr_to_cube(int);
799extern int rgb_to_curses_clr(RGB *);
800extern RGB xterm256_idx_to_rgb(int);
801extern int fork_exec(char **);
802extern int full_screen_fork_exec(char **);
803extern int full_screen_shell(char *);
804extern int shell(char *);
805extern char errmsg[];
806extern void get_rfc3339_s(char *, size_t);
807extern int open_log(char *);
808extern void write_log(char *);
809extern void compile_chyron(Chyron *);
810extern void display_chyron(WINDOW *, Chyron *, int, int);
811extern int get_chyron_key(Chyron *, int);
812extern bool is_set_chyron_key(Chyron *, int);
813extern void set_chyron_key(Chyron *, int, char *, int);
814extern void set_chyron_key_cp(Chyron *, int, char *, int, int);
815extern void unset_chyron_key(Chyron *, int);
816extern Chyron *new_chyron();
817extern Chyron *destroy_chyron(Chyron *chyron);
818extern void abend(int, char *);
819extern void display_argv_error_msg(char *, char **);
820extern int display_error(char *, char *, char *, char *);
821extern int answer_yn(char *, char *, char *, char *);
822extern int display_ok_message(char *);
823extern int Perror(char *);
824extern void user_end();
825extern unsigned long a_to_ul(const char *);
826extern size_t canonicalize_file_spec(char *);
827extern bool construct_file_spec(char *, char *, char *, char *, char *, int);
828extern bool file_spec_path(char *, char *);
829extern bool file_spec_name(char *, char *);
830extern bool is_directory(const char *);
831extern bool is_symlink_to_dir(const char *);
832extern bool is_valid_regex(const char *);
833extern bool dir_name(char *, char *);
834extern bool base_name(char *, char *);
835extern bool expand_tilde(char *, int);
836extern bool locate_file_in_path(char *, char *);
837extern bool normalize_file_spec(char *);
838extern bool trim_ext(char *, char *);
839extern bool trim_path(char *);
840extern bool verify_file(char *, int);
841extern bool verify_file_q(char *, int);
842extern bool verify_dir(char *, int);
843extern bool verify_dir_q(char *, int);
844extern bool verify_spec_arg(char *, char *, char *, char *, int);
845
846#endif
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
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
#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
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 init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:60
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 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