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
22#if __STDC_VERSION__ < 202311L
23#define nullptr NULL
24#endif
25
26#define DEBUG false
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 Ctrl(c) ((c) & 0x1f)
34
35/** @brief max macro evaluates two expressions, returning greatest result.
36 @details These macros use compound statements to create local scopes for the
37 temporary variables _x and _y, which store the values of x and y,
38 respectively. This ensures that if x or y have side effects (such as being
39 incremented), they will only be evaluated once when the macro is expanded.
40 @note The use of typeof allows the macro to work with any data type.
41 @note The line (void)(&_x == &_y) is a compile-time check to ensure that the
42 types of the arguments are compatible.
43 @note This implementation of the min and max macros provides a safer and
44 more robust way to determine the minimum and maximum values between two
45 expressions without risking unintended consequences from multiple
46 evaluations.
47 */
48#define max(a, b)
49 ({
50 typeof(a) _a = (a);
51 typeof(b) _b = (b);
52 _a > _b ? _a : _b;
53 })
54/** @brief min macro evaluates two expressions, returning least result */
55#define min(x, y)
56 ({
57 typeof(x) _x = (x);
58 typeof(y) _y = (y);
59 (void)(&_x == &_y);
60 _x < _y ? _x : _y;
61 })
62/** @note /usr/include/sys/param.h contains implementations of the MIN and MAX
63 macros, which are simple but can lead to issues with multiple evaluations of
64 the arguments if they have side effects.
65
66 @note Here are the macros from /usr/include/sys/param.h. You may comment out
67 the macros defined herein and use the macros in param.h if you prefer.
68
69 @code
70 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
71 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
72 @endcode
73*/
74/** @brief MIN macro for compatibility with code that uses the same name,
75 while avoiding multiple evaluations of the arguments.
76 @note The following macro provides a safer alternative to param.h
77 */
78#define MAX(a, b)
79 ({
80 typeof(a) _a = (a);
81 typeof(b) _b = (b);
82 _a > _b ? _a : _b;
83 })
84/** @brief MAX macro for compatibility with code that uses the same name,
85 while avoiding multiple evaluations of the arguments.
86 @note The following macro provides a safer alternative to param.h
87 */
88#define MIN(x, y)
89 ({
90 typeof(x) _x = (x);
91 typeof(y) _y = (y);
92 (void)(&_x == &_y);
93 _x < _y ? _x : _y;
94 })
95/** @brief ABS macro for absolute value, which evaluates the expression once and
96 returns the absolute value.
97 @note This macro uses a compound statement to create a local scope for the
98 temporary variable _a, which stores the value of x. This ensures that if x
99 has side effects (such as being incremented), it will only be evaluated once
100 when the macro is expanded. The use of typeof allows the macro to work with
101 any data type that supports comparison with zero and negation.
102 */
103#define ABS(x)
104 ({
105 __typeof__(x) _a = (x);
106 _a < 0 ? -_a : _a;
107 })
108#define S_TOLOWER(c)
109 ({
110 int __c = (c);
111 (__c >= 'A' && __c <= 'Z') ? (__c + ('a' - 'A')) : __c;
112 })
113#define S_TOUPPER(c)
114 ({
115 int __c = (c);
116 (__c >= 'a' && __c <= 'z') ? (__c - ('a' - 'A')) : __c;
117 })
118
119/** @enum colors_enum
120 @note Used for xterm256 color conversions
121 @note These colors can be overridden in ".minitrc" */
146};
147
149 LF_HIDE = 1, /**< 1 Don't list hidden files */
150 LF_ICASE = 2, /**< 2 Ignore case in search */
151 LF_EXC_REGEX = 4, /**< 4 Exclude files matching regular expression */
152 LF_REGEX = 8, /**< 8 Include files matching regular expression */
153 LF_EXEC = 16, /**< 16 Execute command each file */
154};
155
156enum FTypes {
157 FT_BLK = 1, /** b00000001 */
158 FT_CHR = 2, /** b00000010 */
159 FT_DIR = 4, /** b00000100 */
160 FT_FIFO = 8, /** b00001000 */
161 FT_LNK = 16, /** b00010000 */
162 FT_REG = 32, /** b00100000 */
163 FT_SOCK = 64, /** b01000000 */
164 FT_UNKNOWN = 128, /** b10000000 */
165};
166/**
167 Include Exclude
168 ---------- ----------
169 LF_BLK 1 0 00000001 7 11111110 block device
170 LF_CHR 2 1 00000010 6 11111101 character device
171 LF_DIR 4 2 00000100 5 11111011 directory
172 LF_FIFO 8 3 00001000 4 11110111 named pipe
173 LF_LNK 16 4 00010000 3 11101111 link
174 LF_REG 32 5 00100000 2 11011111 regular file
175 LF_SOCK 64 6 01000000 1 10111111 socket
176 LF_UNKNOWN 128 7 10000000 0 01111111 unknown
177*/
178
179#define W_BOX 0x40 /**< box window flag for win_new() */
180#define COLOR_LEN 8 /**< length of color code strings */
181#define DEFAULTSHELL "/bin/bash"
182#define S_WCOK 0x1000 /**< write or create permitted */
183#define S_QUIET 0x2000 /**< quiet mode flag for file validation */
184
185/** @brief This macro registers the end_pgm function to be called when the
186 program exits.
187 @note It checks the return value of atexit() to ensure that the
188 registration was successful, and if not, it prints an error message and
189 exits with a failure status. Programs using libcm should call __atexit in
190 their main function to ensure that the end_pgm function is registered to be
191 called on program exit. This will help ensure that the terminal is properly
192 restored to its original state, even if the program encounters an error or
193 is terminated unexpectedly. */
194#define __atexit
195 {
196 int rc;
197 rc = atexit(end_pgm);
198 if (rc != 0) {
199 fprintf(stderr, "\nCannot set exit function\n");
200 exit(EXIT_FAILURE);
201 }
202 }
203
204/** @struct Chyron
205 @note The Chyron structure represents a key binding for a command in the
206 chyron, which is a status line or message area in the terminal interface.
207 @details The ChyronKey structure includes fields for displayable text,
208 the key code, and the end position of the command text in the chyron.
209 @note This structure allows xwgetch to map mouse clicks to key codes
210 as defined by NCursesw and the C-Menu program.
211 @note The text field holds the displayable text associated with the command.
212 xwgetch() translates a mouse click on the chyron with a particular key code
213 stored in this table.
214 @note The use case is when the developer wants a dynamic chyron that can be
215 easily changed depending on the context of the program without having to
216 worry about translating mouse click positions to key codes.
217 @note While many key codes are defined by NCursesw, the developer is free to
218 define their own key codes for custom commands in the chyron. However,
219 xwgetch() will translate mouse clicks to the key codes defined in this table,
220 even if they interfere with standard NCurses key codes, Unicode code points,
221 or ASCII characters. Just use common sense.
222 @note In addition to returning the key code associated with mouse clicks on
223 the chyron, xwgetch() also returns the key codes for standard keyboard input,
224 and sets the global variables cliek_y and click_x to the coordinates of the
225 mouse click.
226 */
227#define CHYRON_KEY_MAXLEN
228 64 /**< maximum length of the command text for a key \
229 binding in the chyron */
230#define CHYRON_KEYS 20 /**< maximum number of key bindings for the chyron */
231
232typedef struct {
233 char text[CHYRON_KEY_MAXLEN]; /**< command text associated with the key code
234 */
235 int keycode; /**< key code associated with the command */
236 int end_pos; /**< end position of the command text in the chyron */
237 int cp; /**< color pair index for the command text in the chyron */
238} ChyronKey;
239
240typedef struct {
241 ChyronKey *key[CHYRON_KEYS]; /**< array of key bindings for the chyron */
242 char s[MAXLEN]; /**< the chyron string, for displaying messages in */
243 cchar_t cmplx_buf[MAXLEN]; /**< the chyron wide character string */
244 int l; /**< length of the chyron string, for display purposes */
245} Chyron;
246
247extern int xwgetch(WINDOW *, Chyron *, int);
248
249extern int click_y; /**< the y coordinate of a mouse click */
250extern int click_x; /**< the x coordinate of a mouse click */
251
252extern Chyron *wait_mk_chyron();
253extern WINDOW *wait_mk_win(Chyron *, char *);
254extern int wait_continue(WINDOW *, Chyron *, int);
255extern bool wait_destroy(Chyron *);
256extern bool waitpid_with_timeout(pid_t, int);
257extern int wait_timeout;
258extern bool action_disposition(char *title, char *action_str);
259
260extern bool f_debug; /**< a flag to indicate whether debug
261 output should be printed, for debugging purposes */
262extern unsigned int cmd_key; /**< the command key for the current command, for
263 error messages and other output */
264/** @struct RGB */
265typedef struct {
266 int r; /**< red component (0-255) */
267 int g; /**< green component (0-255) */
268 int b; /**< blue component (0-255) */
269} RGB;
270
271#define FG_COLOR 2 /**< default foreground color */
272#define BG_COLOR 0 /**< default background color */
273#define BO_COLOR 1 /**< default bold foreground color */
274#define LN_COLOR 4 /**< default line number color */
275#define LN_BG_COLOR 7 /**< default line number background */
276
277extern int cp_default; /**< default color pair index */
278extern int cp_norm; /**< normal color pair index */
279extern int cp_win; /**< window color pair index */
280extern int cp_box; /**< box color pair index */
281extern int cp_bold; /**< bold color pair index */
282extern int cp_title; /**< title color pair index */
283extern int cp_highlight; /**< highlight color pair index */
284extern int cp_reverse; /**< reverse color pair index */
285extern int cp_reverse_highlight; /**< reverse highlight color pair index */
286extern int cp_ln; /**< line number color pair index */
287extern int cp_ln_bg; /** line number background color pair index */
288extern int clr_idx; /**< current color index */
289extern int clr_cnt; /**< number of colors used */
290extern int clr_pair_idx; /**< current color pair index */
291extern int clr_pair_cnt; /**< number of color pairs supported by the terminal */
292extern char const colors_text[][10]; /**< color codes for the 16 basic colors */
293
294/** @struct ColorPair
295 @note The ColorPair structure is a simple structure that holds information
296 about a color pair, including the foreground color index, background color
297 index, and the color pair index. This structure can be used to manage and
298 apply color pairs in the ncurses library, allowing for easy customization of
299 the terminal's appearance. By using this structure, you can easily keep track
300 of the different color pairs you have defined and apply them to various
301 elements in your terminal interface. */
302typedef struct {
303 int fg; /**< foreground color index */
304 int bg; /**< background color index */
305 int pair_id; /**< color pair index */
306} ColorPair;
307
308/**< see termios.h */
309extern struct termios shell_tioctl, curses_tioctl;
310extern struct termios shell_in_tioctl, curses_in_tioctl;
311extern struct termios shell_out_tioctl, curses_out_tioctl;
312extern struct termios shell_err_tioctl, curses_err_tioctl;
313
314extern bool f_have_shell_tioctl; /**< shell tioctl captured */
315extern bool f_have_curses_tioctl; /**< curses tioctl captured */
316extern bool f_curses_open; /**< curses mode is active */
317extern bool f_restore_screen; /**< whether to restore the screen */
318
319extern void dump_opts(); /**< dump options to stdout */
320
321extern void dump_opts_by_use(char *, char *); /**< dump options to stdout */
322extern bool capture_shell_tioctl();
323extern bool restore_shell_tioctl();
324extern bool capture_curses_tioctl();
325extern bool restore_curses_tioctl();
326extern bool mk_raw_tioctl(struct termios *);
327extern bool set_sane_tioctl(struct termios *);
328extern int win_new(int, int, int, int, char *, int);
329extern void win_redraw(WINDOW *);
330extern void win_resize(int, int, char *);
331extern void signal_handler(int);
332extern bool handle_signal(sig_atomic_t);
333extern volatile sig_atomic_t sig_received;
334extern void sig_prog_mode();
335extern void sig_dfl_mode();
336extern bool mk_dir(char *dir);
337extern int segmentation_fault();
338
339extern cchar_t CCC_NORM; /**< normal color pair complex character */
340extern cchar_t CCC_WIN; /**< window color pair complex character */
341extern cchar_t CCC_BOX; /**< box color pair complex character */
342extern cchar_t CCC_REVERSE; /**< reverse color pair complex character */
343extern cchar_t CCC_LN; /* line number color pair complex character */
344
345#define KEY_ALTF0 0x138
346#define KEY_ALTF(n) (KEY_ALTF0 + (n)) /**< define alt function keys */
347#define XTERM_256COLOR /**< use xterm-256color terminfo for altkey bindings */
348/**
349 EXTENDED NCURSES KEYS
350
351 Key code bindings are customarily defined in terminfo.
352 xterm-256color tends to be the most complete, and indeed, it seems to
353 work with Ghostty, Kitty, and Alacritty. If you want to use the
354 altkey bindings, you may need to set your terminal's TERM environment
355 variable to xterm-256color. Here's why:
356
357 Ghostty, Kitty, and Alacritty all come with their own terminfo files:
358
359 Ghostty with xterm-ghostty,
360 Kitty with xterm-kitty, and
361 Alacritty with alacritty
362
363 None of the three produced the correct extended altkey bindings when
364 paired with the terminfo provided in their distribution, yet all
365 three worked with xterm-256color.
366
367 The extended altkeys were not defined in any of the terminfo files, not
368 even xterm-256color. Yet, xterm-256color produced consistent keycode
369 bindings with all three emulators. The standard key bindings, ins, delete,
370 up, down arrows, etc., were the same for all three terminfos, and all
371 three emulators produced the correct key bindings for those keys.
372
373 The fact that xterm-256color produced consistent keycode bindings for the
374 altkeys, while the other three terminfos did not, is likely due to the fact
375 that xterm-256color is more widely used and has better support for extended
376 key bindings, even if they are not explicitly defined in the terminfo file.
377 It's possible that xterm-256color has some default behavior or fallback
378 mechanism that allows it to recognize and produce key codes for the altkeys,
379 while the other terminfos do not have such a mechanism in place. This could
380 explain why xterm-256color produced consistent keycode bindings for the
381 altkeys across all three emulators, while the other terminfos did not.
382 @code
383 mapped altkey ncurses
384 2nd fld - 1 name binding keycode
385 ------------- --------- -------- -------
386 kIC=\E[2;2~, key_ins \E[2;3~, 223
387 kHOM=\E[1;2H, key_home \E[1;3H, 21e
388 kPRV=\E[5;2~, key_pgup \E[5;3~, 232
389 kDC=\E[3;2~, key_del \E[3;3~, 20e
390 kEND=\E[1;2F, key_end \E[1;3F, 219
391 kNXT=\E[6;2~, key_pgdn \E[6;3~, 22d
392 kri=\E[1;2A, key_up \E[1;3A, 23d
393 kind=\E[1;2B, key_down \E[1;3B, 214
394 kRIT=\E[1;2C, key_right \E[1;3C, 237
395 kLFT=\E[1;2D, key_left \E[1;3D, 228
396 @endcode
397 */
398#if defined(XTERM_256COLOR)
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
420#endif
421
422/** UNICODE BOX DRAWING SYMBOLS */
423#define BW_HO L'\x2500' /**< horizontal line */
424#define BW_VE L'\x2502' /**< vertical line */
425#define BW_TL L'\x250C' /**< top left */
426#define BW_TR L'\x2510' /**< top right */
427#define BW_BL L'\x2514' /**< bottom left */
428#define BW_BR L'\x2518' /**< bottom right */
429#define BW_RTL L'\x256d' /**< rounded left tee */
430#define BW_RTR L'\x256e' /**< rounded right tee */
431#define BW_RBL L'\x2570' /**< rounded bottom left */
432#define BW_RBR L'\x256f' /**< rounded bottom right */
433#define BW_LT L'\x251C' /**< left tee */
434#define BW_TT L'\x252C' /**< top tee */
435#define BW_RT L'\x2524' /**< right tee */
436#define BW_CR L'\x253C' /**< cross */
437#define BW_BT L'\x2534' /**< bottom tee */
438#define BW_SP L'\x20' /**< space */
439
440/** The following are the actual wchar_t variables that will hold the box
441 drawing characters. These correspond to the above Unicode code points. By
442 defining them as wchar_t, we can use them in the ncurses library to draw
443 boxes and lines in the terminal. The variables are named with a "bw_" prefix
444 to indicate that they are box (wide) drawing characters, and they will be
445 initialized with the corresponding Unicode characters defined above. */
446
447extern const wchar_t bw_ho; /**< horizontal line */
448extern const wchar_t bw_ve; /**< vertical line */
449extern const wchar_t bw_tl; /**< top left corner */
450extern const wchar_t bw_tr; /**< top right corner */
451extern const wchar_t bw_bl; /**< bottom left corner */
452extern const wchar_t bw_br; /**< bottom right corner */
453extern const wchar_t bw_lt; /**< left tee */
454extern const wchar_t bw_tt; /**< top tee */
455extern const wchar_t bw_rt; /**< right tee */
456extern const wchar_t bw_cr; /**< cross */
457extern const wchar_t bw_bt; /**< bottom tee */
458
459extern int n_lines; /**< number of lines in the terminal */
460extern int n_cols; /**< number of columns in the terminal */
461extern int lines; /**< current number of lines (may be less than n_lines if the
462 terminal is resized) */
463extern int cols; /**< current number of columns (may be less than n_cols if the
464 terminal is resized) */
465extern int begx; /**< beginning x coordinate of the terminal */
466extern int begy; /**< beginning y coordinate of the terminal */
467
468#define MAXWIN 30 /**< maximum number of windows that can be created */
469typedef unsigned char uchar;
470
471extern void sig_prog_mode();
472extern void sig_shell_mode();
473extern char di_getch();
474extern int enter_option();
475
476extern WINDOW *win; /**< generic window pointer, used for various purposes */
477extern WINDOW
478 *win_win[MAXWIN]; /**< array of pointers to windows, indexed by window ID */
479extern WINDOW *win_box[MAXWIN]; /**< array of pointers to box windows, indexed
480 by window ID */
481
482extern int win_attr; /**< Ncurses attributes for the current window, such as
483 color pair, bold, etc. */
484extern int
485 win_attr_odd; /**< Ncurses attributes for the current window odd lines,
486 which may be different from the attributes for even lines
487 to create a striped effect in the window. */
488extern int
489 win_attr_even; /**< Ncurses attributes for the current window even lines,
490 which may be different from the attributes for odd lines
491 to create a striped effect in the window. */
492extern int win_ptr; /**< Pointer to the current window pair, box and window,
493 which can be used to keep track of the currently active
494 window and its associated box. */
495extern int
496 mlines; /**< number of lines in the current window, which may be less than
497 the total number of lines in the terminal if the window is
498 resized or if multiple windows are being used. */
499extern int
500 mcols; /**< number of columns in the current window, which may be less than
501 the total number of columns in the terminal if the window is
502 resized or if multiple windows are being used. */
503extern int
504 mbegy; /**< beginning y coordinate of the current window, which can be used
505 to determine the position of the window on the terminal screen. */
506extern int
507 mbegx; /**< beginning x coordinate of the current window, which can be used
508 to determine the position of the window on the terminal screen. */
509extern int mg_action; /**< action in progress, which can be used to keep track
510 of the current state of the program and determine how
511 to respond to user input or other events. */
512extern int mg_col; /**< window column, which can be used to determine the
513 current column position in the window for displaying text
514 or other content. */
515extern int
516 mg_line; /**< window line, which can be used to determine the current line
517 position in the window for displaying text or other content. */
518/** to_uppercase(c) - convert a lowercase letter to uppercase */
519#define to_uppercase(c)
520 if (c >= 'a' && c <= 'z')
521 c -= ' '
522/** to_lowercase(c) - convert an uppercase letter to lowercase */
523#define to_lowercase(c)
524 if (c >= 'A' && c <= 'Z')
525 c += ' '
526extern int eargc; /**< general use argument count, for external commands or
527 error messages */
528/** earg - general use argument string */
529extern char earg_str[MAXLEN]; /**< general use argument string, for external
530 commands or error messages */
531/** eargv - argument vector for external commands, or error messages */
532extern char *eargv[MAXARGS];
533/** tty_fd - the file descriptor for the terminal, for error messages and other
534 */
535extern int tty_fd; /**< the file descriptor for the terminal, for error messages
536 and other output */
537extern int
538 dbgfd; /**< the file descriptor for debug output, for debugging purposes */
539extern int src_line; /**< the line number of the source file being processed,
540 for error messages */
541extern char *src_name; /**< the name of the source file being processed, for
542 error messages */
543extern char fn[MAXLEN]; /**< function name for error messages */
544extern char em0[MAXLEN]; /**< error message string for error messages */
545extern char em1[MAXLEN]; /**< error message string for error messages */
546extern char em2[MAXLEN]; /**< error message string for error messages */
547extern char em3[MAXLEN]; /**< error message string for error messages */
548
549extern int exit_code; /**< the exit code for the program, for error messages and
550 other output */
551
552extern WINDOW *win_del();
553extern void destroy_win(WINDOW *);
554extern void destroy_box(WINDOW *);
555extern void restore_wins();
556extern void cbox(WINDOW *);
557extern void win_init_attrs();
558extern void win_Toggle_Attrs();
559extern void mvwaddstr_fill(WINDOW *, int, int, char *, int);
561extern void init_stdscr();
562extern void curskeys(WINDOW *);
563extern void mouse_getch(int *, int *, int *, int *);
564extern void w_mouse_getch(WINDOW *, int *, int *, int *, int *);
565
566/** @struct Arg
567 @brief The Arg structure represents a string argument with a pointer to the
568 string and its allocated length. */
569typedef struct {
570 char *s; /**< pointer to the string argument */
571 size_t l; /**< allocated length */
572} Arg;
573/** @struct Argv
574 @brief The Argv structure represents an argument vector, which is an array of
575 Arg structures, along with the number of allocated elements in the array. */
576typedef struct {
577 Arg **v; /**< pointer to an array of Arg pointers, representing the argument
578 vector */
579 size_t n; /**< allocated array elements */
580} Argv;
581/** @struct String
582 @brief The String structure represents a string object with a pointer to the
583 string and its allocated length. */
584typedef struct {
585 char *s; /**< pointer to the string */
586 size_t l; /**< allocated length */
587} String;
588/** @struct WCStr
589 @brief wide character string object with a pointer to the wide character
590 string and its allocated length
591 @note The WCStr structure represents a wide character string with a pointer
592 to the wide character string and its allocated length. */
593typedef struct {
594 wchar_t *s; /**< pointer to the wide character string */
595 size_t l; /**< @brief allocated length */
596} WCStr;
597/** @struct CCStr
598 @brief complex character objectl with a pointer to the complex character
599 string and its allocated length
600 @note The CCStr structure represents a complex character string, which is a
601 string that can contain both regular characters and attributes (such as
602 color, bold, etc.) in the ncurses library. This structure includes a pointer
603 to the complex character string and its allocated length, allowing for
604 dynamic handling of complex character strings in the terminal interface. */
605typedef struct {
606 cchar_t *s; /**< pointer to the complex character string */
607 size_t l; /**< allocated length */
608} CCStr;
609/** simple macro to convert a character to uppercase */
610#define to_uppercase(c)
611 if (c >= 'a' && c <= 'z')
612 c -= ' '
613/** @struct SIO
614 @brief The SIO structure encapsulates various aspects of the terminal's
615 state and configuration, including color management, file pointers, and
616 terminal device information. @note The SIO structure serves as a central
617 repository for all relevant information needed to manage the terminal's
618 appearance and behavior effectively, allowing for a highly customizable and
619 visually appealing terminal experience. @note The SIO structure includes
620 fields for managing colors, gamma correction values, color codes for
621 different colors, file pointers and descriptors for standard
622 input/output/error and the terminal device, as well as counters and indices
623 for color management. Additionally, it contains a field for storing the name
624 of the terminal device. This comprehensive structure allows for efficient
625 management of the terminal's state and configuration in a structured way. */
626typedef struct {
627 double red_gamma; /**< red gamma correction value */
628 double green_gamma; /**< green gamma correction value */
629 double blue_gamma; /**< blue gamma correction value */
630 double gray_gamma; /**< gray gamma correction value */
631 char black[COLOR_LEN]; /**< color code for black */
632 char red[COLOR_LEN]; /**< color code for red */
633 char green[COLOR_LEN]; /**< color code for green */
634 char yellow[COLOR_LEN]; /**< color code for yellow */
635 char blue[COLOR_LEN]; /**< color code for blue */
636 char magenta[COLOR_LEN]; /**< color code for magenta */
637 char cyan[COLOR_LEN]; /**< color code for cyan */
638 char white[COLOR_LEN]; /**< color code for white */
639 char orange[COLOR_LEN]; /**< color code for orange */
640 char bblack[COLOR_LEN]; /**< color code for bold black */
641 char bred[COLOR_LEN]; /**< color code for bold red */
642 char bgreen[COLOR_LEN]; /**< color code for bold green */
643 char byellow[COLOR_LEN]; /**< color code for bold yellow */
644 char bblue[COLOR_LEN]; /**< color code for bold blue */
645 char bmagenta[COLOR_LEN]; /**< color code for bold magenta */
646 char bcyan[COLOR_LEN]; /**< color code for bold cyan */
647 char bwhite[COLOR_LEN]; /**< color code for bold white */
648 char borange[COLOR_LEN]; /**< color code for bold orange */
649 char bg[COLOR_LEN]; /**< color code for background */
650 char abg[COLOR_LEN]; /**< color code for background with alpha */
651 char fg_clr_x[COLOR_LEN]; /**< foreground color index */
652 char bg_clr_x[COLOR_LEN]; /**< background color index */
653 char bo_clr_x[COLOR_LEN]; /**< bold color index */
654 char ln_clr_x[COLOR_LEN]; /**< line number color index */
655 char ln_bg_clr_x[COLOR_LEN]; /**< line number background index */
656 char tty_name[MAXLEN]; /**< name of the terminal device */
657 FILE *stdin_fp; /**< stdin stream pointer */
658 FILE *stdout_fp; /**< stdout stream pointer */
659 FILE *stderr_fp; /**< stderr stream pointer */
660 FILE *tty_fp; /**< terminal device stream pointer */
661 int stdin_fd; /**< stdin file descriptor */
662 int stdout_fd; /**< stdout file descriptor */
663 int stderr_fd; /**< stderr file descriptor */
664 int tty_fd; /**< terminal device file descriptor */
665 int clr_cnt; /**< number of colors currently in use */
666 int clr_pair_cnt; /**< number of color pairs currently in use */
667 int clr_idx; /**< current color index */
668 int clr_pair_idx; /**< current color pair index */
669 int cp_default; /**< default color pair index */
670 int cp_norm; /**< normal color pair index */
671 int cp_win; /**< window color pair index */
672 int cp_reverse; /**< reverse color pair index */
673 int cp_reverse_highlight; /**< reverse highlight color pair index */
674 int cp_box; /**< box color pair index */
675 int cp_bold; /**< bold color pair index */
676 int cp_title; /**< title color pair index */
677 int cp_highlight; /**< highlight color pair index */
678 int cp_ln; /**< line number color pair index */
679 int cp_ln_bg; /**< line number background pair index */
680} SIO;
681extern void destroy_curses();
682extern int a_toi(char *, bool *);
683extern bool chrep(char *, char, char);
684extern char *rep_substring(const char *, const char *, const char *);
685extern size_t strip_ansi(char *, char *);
686extern bool strip_quotes(char *);
687extern bool stripz_quotes(char *);
688extern int str_to_args(char **, char *, int);
689extern void destroy_argv(int argc, char **argv);
690extern bool str_to_bool(const char *);
691extern bool str_to_lower(char *);
692extern bool str_to_upper(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);
697extern char *strnz_dup(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);
701extern double str_to_double(char *);
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 *);
708extern String to_string(const char *);
709extern String mk_string(size_t);
710extern String free_string(String);
711extern void apply_gamma(RGB *);
712extern int get_clr_pair(int, int);
713extern int clr_name_to_idx(char *);
714extern int rgb_to_xterm256_idx(RGB *);
715extern bool init_clr_palette(SIO *);
716extern bool open_curses(SIO *);
717extern int rgb_clr_to_cube(int);
718extern int rgb_to_curses_clr(RGB *);
719extern RGB xterm256_idx_to_rgb(int);
720extern int fork_exec(char **);
721extern int full_screen_fork_exec(char **);
722extern int full_screen_shell(char *);
723extern int shell(char *);
724extern char errmsg[];
725extern void get_rfc3339_s(char *, size_t);
726extern int open_log(char *);
727extern void write_log(char *);
728extern void compile_chyron(Chyron *);
729extern void display_chyron(WINDOW *, Chyron *, int, int);
730extern int get_chyron_key(Chyron *, int);
731extern bool is_set_chyron_key(Chyron *, int);
732extern void set_chyron_key(Chyron *, int, char *, int);
733extern void set_chyron_key_cp(Chyron *, int, char *, int, int);
734extern void unset_chyron_key(Chyron *, int);
735extern Chyron *new_chyron();
736extern Chyron *destroy_chyron(Chyron *chyron);
737extern void abend(int, char *);
738extern void display_argv_error_msg(char *, char **);
739extern int display_error(char *, char *, char *, char *);
740extern int answer_yn(char *, char *, char *, char *);
741extern int display_ok_message(char *);
742extern int Perror(char *);
743extern void user_end();
744extern bool lf_find(const char *, const char *, const char *, int, int);
745extern size_t canonicalize_file_spec(char *);
746extern bool construct_file_spec(char *, char *, char *, char *, char *, int);
747extern bool file_spec_path(char *, char *);
748extern bool file_spec_name(char *, char *);
749extern bool is_directory(const char *);
750extern bool is_valid_regex(const char *);
751extern bool dir_name(char *, char *);
752extern bool base_name(char *, char *);
753extern bool expand_tilde(char *, int);
754extern bool locate_file_in_path(char *, char *);
755extern bool normalize_file_spec(char *);
756extern bool trim_ext(char *, char *);
757extern bool trim_path(char *);
758extern bool verify_file(char *, int);
759extern bool verify_file_q(char *, int);
760extern bool verify_dir(char *, int);
761extern bool verify_dir_q(char *, int);
762extern bool verify_spec_arg(char *, char *, char *, char *, int);
763
764#endif
int cmd_processor(Init *)
Init * init
Definition common.h:186
OptType
option types
Definition common.h:78
@ OT_INT
Definition common.h:80
@ OT_BOOL
Definition common.h:81
@ OT_HEX
Definition common.h:82
@ OT_STRING
Definition common.h:79
Caller
Definition common.h:75
@ FORM
Definition common.h:75
@ MENU
Definition common.h:75
@ VIEW
Definition common.h:75
@ PICK
Definition common.h:75
int popup_form(Init *, int, char **, int, int)
Definition popups.c:34
OptGroup
option groups
Definition common.h:86
@ OG_FILES
Definition common.h:87
@ OG_DIRS
Definition common.h:88
@ OG_SPECS
Definition common.h:89
@ OG_MISC
Definition common.h:90
@ OG_FLAGS
Definition common.h:92
@ OG_PARMS
Definition common.h:91
@ OG_COL
Definition common.h:93
int popup_menu(Init *, int, char **, int, int)
Definition popups.c:8
int popup_view(Init *, int, char **, int, int, int, int)
Definition popups.c:47
int parse_opt_args(Init *, int, char **)
Definition init.c:393
int popup_pick(Init *, int, char **, int, int)
Definition popups.c:21
@ IC_MENU
Definition common.h:184
@ IC_VIEW
Definition common.h:184
@ IC_FORM
Definition common.h:184
@ IC_PICK
Definition common.h:184
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:102
bool handle_signal(sig_atomic_t)
int eargc
Definition futil.c:41
void win_Toggle_Attrs()
#define MAXWIN
Definition cm.h:468
int n_cols
#define KEY_ALTEND
Definition cm.h:403
int mbegx
#define KEY_ALTLEFT
Definition cm.h:406
void curskeys(WINDOW *)
#define KEY_ALTDOWN
Definition cm.h:407
void sig_shell_mode()
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:400
int dbgfd
colors_enum
Definition cm.h:122
@ CLR_FG
Definition cm.h:140
@ CLR_RED
Definition cm.h:124
@ CLR_YELLOW
Definition cm.h:126
@ CLR_BCYAN
Definition cm.h:137
@ CLR_WHITE
Definition cm.h:130
@ CLR_MAGENTA
Definition cm.h:128
@ CLR_BLACK
Definition cm.h:123
@ CLR_BWHITE
Definition cm.h:138
@ CLR_LN_BG
Definition cm.h:144
@ CLR_BO
Definition cm.h:142
@ CLR_BBLACK
Definition cm.h:131
@ CLR_BBLUE
Definition cm.h:135
@ CLR_LN
Definition cm.h:143
@ CLR_BGREEN
Definition cm.h:133
@ CLR_BYELLOW
Definition cm.h:134
@ CLR_BMAGENTA
Definition cm.h:136
@ CLR_BORANGE
Definition cm.h:139
@ CLR_BG
Definition cm.h:141
@ CLR_BRED
Definition cm.h:132
@ CLR_NCOLORS
Definition cm.h:145
@ CLR_BLUE
Definition cm.h:127
@ CLR_GREEN
Definition cm.h:125
@ CLR_CYAN
Definition cm.h:129
void mouse_getch(int *, int *, int *, int *)
int display_ok_message(char *)
int cp_title
#define KEY_ALTF0
Definition cm.h:345
int cp_default
#define MAXARGS
Definition cm.h:30
void destroy_win(WINDOW *)
int cols
bool f_curses_open
Definition sig.c:33
int enter_option()
#define CHYRON_KEYS
Definition cm.h:230
struct termios shell_tioctl curses_tioctl
Definition scriou.c:34
void dump_opts()
FTypes
Definition cm.h:156
@ FT_UNKNOWN
Definition cm.h:164
@ FT_SOCK
Definition cm.h:163
@ FT_DIR
Definition cm.h:159
@ FT_FIFO
Definition cm.h:160
@ FT_REG
Definition cm.h:162
@ FT_CHR
Definition cm.h:158
@ FT_BLK
Definition cm.h:157
@ FT_LNK
Definition cm.h:161
int mg_line
const wchar_t bw_tt
void write_log(char *)
unsigned char uchar
Definition cm.h:469
int cp_bold
char earg_str[MAXLEN]
Definition futil.c:40
bool verify_dir_q(char *, int)
String mk_string(size_t)
Create a String struct with a dynamically allocated string.
Definition futil.c:1396
bool construct_file_spec(char *, char *, char *, char *, char *, int)
int mcols
const wchar_t bw_cr
#define KEY_ALTPGDN
Definition cm.h:404
int mg_action
#define XTERM_256COLOR
Definition cm.h:347
const wchar_t bw_bt
#define KEY_ALTRIGHT
Definition cm.h:408
#define CHYRON_KEY_MAXLEN
Definition cm.h:227
bool verify_file_q(char *, int)
bool f_debug
int lines
#define KEY_ALTDEL
Definition cm.h:402
int cp_highlight
void dump_opts_by_use(char *, char *)
int open_log(char *)
int begx
int wait_timeout
Definition futil.c:98
int win_attr_even
char errmsg[]
Definition futil.c:84
#define KEY_ALTUP
Definition cm.h:405
LFFlags
Definition cm.h:148
@ LF_EXC_REGEX
Definition cm.h:151
@ LF_HIDE
Definition cm.h:149
@ LF_ICASE
Definition cm.h:150
@ LF_EXEC
Definition cm.h:153
@ LF_REGEX
Definition cm.h:152
int mlines
#define KEY_ALTPGUP
Definition cm.h:401
void destroy_box(WINDOW *)
bool f_restore_screen
#define COLOR_LEN
Definition cm.h:180
char * eargv[MAXARGS]
Definition futil.c:42
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:346
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:649
#define __atexit
This macro registers the end_pgm function to be called when the program exits.
Definition cm.h:194
struct termios shell_out_tioctl curses_out_tioctl
Definition scriou.c:36
void user_end()
int display_curses_keys()
#define KEY_ALTINS
Definition cm.h:399
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:138
unsigned int cmd_key
Definition dwin.c:117
WINDOW * win
Definition dwin.c:113
const wchar_t bw_rt
Definition dwin.c:102
const wchar_t bw_ho
Definition dwin.c:95
cchar_t CCC_LN
Definition dwin.c:151
int cp_win
Definition dwin.c:137
int clr_pair_cnt
Definition dwin.c:144
WINDOW * win_win[MAXWIN]
Definition dwin.c:114
bool waitpid_with_timeout(pid_t pid, int timeout)
Definition dwin.c:1431
bool action_disposition(char *title, char *action_str)
Definition dwin.c:1224
const wchar_t bw_tl
Definition dwin.c:97
char em1[MAXLEN]
Definition dwin.c:133
int tty_fd
Definition dwin.c:153
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
Definition dwin.c:297
cchar_t CCC_WIN
Definition dwin.c:146
int clr_cnt
Definition dwin.c:142
const wchar_t bw_tr
Definition dwin.c:98
int clr_pair_idx
Definition dwin.c:143
int cp_ln
Definition dwin.c:141
const wchar_t bw_lt
Definition dwin.c:101
int click_x
Definition dwin.c:45
int src_line
Definition dwin.c:129
char * src_name
Definition dwin.c:130
cchar_t CCC_BOX
Definition dwin.c:148
const wchar_t bw_bl
Definition dwin.c:99
int win_ptr
Definition dwin.c:121
int exit_code
Definition dwin.c:116
int click_y
Definition dwin.c:44
char em0[MAXLEN]
Definition dwin.c:132
char em3[MAXLEN]
Definition dwin.c:135
int cp_reverse_highlight
Definition dwin.c:140
char const colors_text[][10]
Definition dwin.c:91
int rgb_clr_to_cube(int)
void set_chyron_key(Chyron *, int, char *, int)
Definition dwin.c:245
const wchar_t bw_ve
Definition dwin.c:96
cchar_t CCC_REVERSE
Definition dwin.c:149
cchar_t CCC_NORM
Definition dwin.c:145
int cp_reverse
Definition dwin.c:139
int win_attr
Definition dwin.c:119
WINDOW * win_box[MAXWIN]
Definition dwin.c:115
char fn[MAXLEN]
Definition dwin.c:131
char em2[MAXLEN]
Definition dwin.c:134
int cp_norm
Definition dwin.c:136
const wchar_t bw_br
Definition dwin.c:100
struct termios shell_tioctl
Definition scriou.c:22
bool open_curses(SIO *)
Initialize NCurses and color settings.
Definition dwin.c:423
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
Definition dwin.c:1359
void restore_wins()
Restore all windows after a screen resize.
Definition dwin.c:938
int win_new(int, int, int, int, char *, int)
Create a new window with optional box and title.
Definition dwin.c:783
void win_init_attrs()
Initialize window attributes.
Definition dwin.c:162
WINDOW * win_del()
Delete the current window and its associated box window.
Definition dwin.c:902
void mvwaddstr_fill(WINDOW *, int, int, char *, int)
For lines shorter than their display area, fill the rest with spaces.
Definition dwin.c:1262
void cbox(WINDOW *)
Draw a box around the specified window.
Definition dwin.c:960
void win_resize(int, int, char *)
Resize the current window and its box, and update the title.
Definition dwin.c:851
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
Definition dwin.c:738
void win_redraw(WINDOW *)
Redraw the specified window.
Definition dwin.c:891
bool is_set_chyron_key(Chyron *, int)
Check if function key label is set.
Definition dwin.c:217
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
Definition dwin.c:198
int get_chyron_key(Chyron *, int)
Get keycode from chyron.
Definition dwin.c:369
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key.
Definition dwin.c:237
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
Definition dwin.c:268
void unset_chyron_key(Chyron *, int)
Unset chyron key.
Definition dwin.c:258
Chyron * new_chyron()
Create and initialize Chyron structure.
Definition dwin.c:183
RGB xterm256_idx_to_rgb(int)
Convert XTerm 256 color index to RGB color.
Definition dwin.c:590
int clr_name_to_idx(char *)
Get color index from color name.
Definition dwin.c:1282
int rgb_to_curses_clr(RGB *)
Get color index for RGB color.
Definition dwin.c:541
bool init_clr_palette(SIO *)
Initialize color palette based on SIO settings.
Definition dwin.c:651
void apply_gamma(RGB *)
Apply gamma correction to RGB color.
Definition dwin.c:624
int rgb_to_xterm256_idx(RGB *)
Convert RGB color to XTerm 256 color index.
Definition dwin.c:569
int get_clr_pair(int fg, int bg)
Get color pair index for foreground and background colors.
Definition dwin.c:510
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
Definition dwin.c:1203
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
Definition dwin.c:1215
int answer_yn(char *em0, char *em1, char *em2, char *em3)
Accept a single letter answer.
Definition dwin.c:994
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
Definition dwin.c:1172
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1110
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
Definition dwin.c:1054
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:1331
Chyron * wait_mk_chyron()
Create a Chyron struct for the waiting message.
Definition dwin.c:1161
int fork_exec(char **)
Fork and exec a command.
Definition exec.c:128
int shell(char *)
Execute a shell command.
Definition exec.c:80
int full_screen_fork_exec(char **)
Execute a command in full screen mode.
Definition exec.c:44
int full_screen_shell(char *)
Execute a shell command in full screen mode.
Definition exec.c:60
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:59
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:939
void destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:221
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1216
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:269
bool trim_ext(char *, char *)
trims the file extension from "filename" and copies the result to "buf"
Definition futil.c:741
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:469
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
Definition futil.c:118
bool is_directory(const char *)
Checks if the given path is a directory.
Definition futil.c:1245
bool file_spec_path(char *, char *)
extracts the path component of a file specification
Definition futil.c:578
bool str_to_upper(char *)
Converts a string to uppercase.
Definition futil.c:247
bool dir_name(char *, char *)
Returns the directory name of a file specification.
Definition futil.c:801
double str_to_double(char *)
converts string to double
Definition futil.c:637
bool str_to_lower(char *)
Converts a string to lowercase.
Definition futil.c:233
bool lf_find(const char *, const char *, const char *, int, int)
Find files in a directory matching a regular expression.
Definition futil.c:977
bool strnfill(char *, char, int)
Fills string s with character c n.
Definition futil.c:440
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
Definition futil.c:340
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:147
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:454
bool is_valid_regex(const char *)
Checks if the given regular expression pattern is valid.
Definition futil.c:1256
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:379
size_t strip_ansi(char *, char *)
Strips ANSI SGR escape sequences (ending in 'm') from string s to d.
Definition futil.c:537
bool mk_dir(char *dir)
If directory doesn't exist, make it.
Definition futil.c:1195
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:298
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:415
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:892
char * rep_substring(const char *, const char *, const char *)
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
Definition futil.c:1292
size_t strnlf(char *, size_t)
terminates string with line feed
Definition futil.c:358
int a_toi(char *, bool *)
a safer alternative to atoi() for converting ASCII strings to integers.
Definition futil.c:505
bool file_spec_name(char *, char *)
extracts the file name component of a file specification
Definition futil.c:605
bool expand_tilde(char *, int)
Replace Leading Tilde With Home Directory.
Definition futil.c:684
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:841
bool chrep(char *, char, char)
Replaces all occurrences of old_chr in s with new_chr in place.
Definition futil.c:486
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:775
bool normalize_file_spec(char *)
replace backslashes with forward lashes
Definition futil.c:561
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
Definition futil.c:167
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:713
size_t string_cpy(String *, const String *)
Copy src String to dest String, allocating additional memory for dest String if necessary.
Definition futil.c:1430
String to_string(const char *)
String functions provide a simple string library to facilitate string manipulation in C,...
Definition futil.c:1375
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:1487
size_t string_cat(String *, const String *)
Concatenates src String to dest String, allocating additional memory for dest String if necessary.
Definition futil.c:1447
String free_string(String)
Free the dynamically allocated String.
Definition futil.c:1415
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:1466
int segmentation_fault()
Function to intentionally cause a segmentation fault for testing purposes.
Definition futil.c:1512
bool derive_file_spec(char *, char *, char *)
Derive full file specification from directory and file name.
Definition init.c:821
int write_config(Init *)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:723
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:324
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:408
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
Definition init_view.c:40
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:123
int view_init_input(View *, char *)
Initialize the input for a C-Menu View.
Definition init_view.c:223
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:346
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:253
bool init_menu_files(Init *, int, char **)
Initialize Menu file specifications.
Definition mem.c:486
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Definition mem.c:373
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:276
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:300
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:230
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:37
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:59
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()
sget single character from terminal in raw mode
Definition scriou.c:139
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:123
char mapp_data[MAXLEN]
Definition common.h:139
char minitrc[MAXLEN]
Definition common.h:164
bool f_out_spec
Definition common.h:161
char mapp_help[MAXLEN]
Definition common.h:140
int begx
Definition common.h:112
bool f_title
Definition common.h:156
char chyron_s[MAXLEN]
Definition common.h:122
SIO * sio
Definition common.h:108
int pick_cnt
Definition common.h:177
bool f_cmd_all
Definition common.h:155
Form * form
Definition common.h:174
char in_spec[MAXLEN]
Definition common.h:158
char cmd_all[MAXLEN]
Definition common.h:117
bool f_mapp_help
Definition common.h:147
bool f_mapp_msrc
Definition common.h:148
int argc
Definition common.h:124
char fill_char[2]
Definition common.h:137
bool f_cmd
Definition common.h:154
int prompt_type
Definition common.h:120
char about_fn[MAXLEN]
Definition common.h:165
char mapp_msrc[MAXLEN]
Definition common.h:141
int cols
Definition common.h:110
int menu_cnt
Definition common.h:173
int tab_stop
Definition common.h:171
bool f_mapp_home
Definition common.h:144
bool f_erase_remainder
Definition common.h:134
bool f_mapp_data
Definition common.h:145
bool f_mapp_desc
Definition common.h:151
char mapp_home[MAXLEN]
Definition common.h:138
bool f_mapp_user
Definition common.h:149
char prompt_str[MAXLEN]
Definition common.h:119
bool f_squeeze
Definition common.h:130
int begy
Definition common.h:111
char parent_cmd[MAXLEN]
Definition common.h:118
char mapp_spec[MAXLEN]
Definition common.h:166
char receiver_cmd[MAXLEN]
Definition common.h:115
bool f_multiple_cmd_args
Definition common.h:132
int select_max
Definition common.h:169
bool f_ln
Definition common.h:135
bool f_mapp_spec
Definition common.h:146
char provider_cmd[MAXLEN]
Definition common.h:114
char out_spec[MAXLEN]
Definition common.h:159
bool f_strip_ansi
Definition common.h:129
View * view
Definition common.h:178
Menu * menu
Definition common.h:172
bool f_at_end_remove
Definition common.h:128
int view_cnt
Definition common.h:179
char brackets[3]
Definition common.h:136
bool f_ignore_case
Definition common.h:127
char ** argv
Definition common.h:125
int lines
Definition common.h:109
char mapp_user[MAXLEN]
Definition common.h:142
char cmd[MAXLEN]
Definition common.h:116
int optind
Definition common.h:126
bool f_help_spec
Definition common.h:157
bool f_receiver_cmd
Definition common.h:153
bool f_provider_cmd
Definition common.h:152
int form_cnt
Definition common.h:175
char help_spec[MAXLEN]
Definition common.h:167
char editor[MAXLEN]
Definition common.h:162
Pick * pick
Definition common.h:176
bool f_in_spec
Definition common.h:160
char menuapp[MAXLEN]
Definition common.h:163
char text[CHYRON_KEY_MAXLEN]
Definition cm.h:233
int end_pos
Definition cm.h:236
int cp
Definition cm.h:237
int keycode
Definition cm.h:235
int l
Definition cm.h:244
cchar_t cmplx_buf[MAXLEN]
Definition cm.h:243
char s[MAXLEN]
Definition cm.h:242
ChyronKey * key[CHYRON_KEYS]
Definition cm.h:241
int r
Definition cm.h:266
int b
Definition cm.h:268
int g
Definition cm.h:267
int pair_id
Definition cm.h:305
int fg
Definition cm.h:303
int bg
Definition cm.h:304
char * s
Definition cm.h:570
size_t l
Definition cm.h:571
Arg ** v
Definition cm.h:577
size_t n
Definition cm.h:579
size_t l
Definition cm.h:586
char * s
Definition cm.h:585
size_t l
allocated length
Definition cm.h:595
wchar_t * s
Definition cm.h:594
size_t l
Definition cm.h:607
cchar_t * s
Definition cm.h:606
double green_gamma
Definition cm.h:628
char black[COLOR_LEN]
Definition cm.h:631
FILE * stdout_fp
Definition cm.h:658
char bg_clr_x[COLOR_LEN]
Definition cm.h:652
char fg_clr_x[COLOR_LEN]
Definition cm.h:651
int cp_reverse_highlight
Definition cm.h:673
double blue_gamma
Definition cm.h:629
int clr_idx
Definition cm.h:667
char bred[COLOR_LEN]
Definition cm.h:641
char yellow[COLOR_LEN]
Definition cm.h:634
int cp_ln_bg
Definition cm.h:679
int clr_cnt
Definition cm.h:665
int stdout_fd
Definition cm.h:662
char bo_clr_x[COLOR_LEN]
Definition cm.h:653
char abg[COLOR_LEN]
Definition cm.h:650
int stderr_fd
Definition cm.h:663
int cp_ln
Definition cm.h:678
int cp_box
Definition cm.h:674
FILE * stdin_fp
Definition cm.h:657
char bcyan[COLOR_LEN]
Definition cm.h:646
char borange[COLOR_LEN]
Definition cm.h:648
double red_gamma
Definition cm.h:627
char red[COLOR_LEN]
Definition cm.h:632
FILE * tty_fp
Definition cm.h:660
char magenta[COLOR_LEN]
Definition cm.h:636
char bgreen[COLOR_LEN]
Definition cm.h:642
int cp_bold
Definition cm.h:675
char ln_clr_x[COLOR_LEN]
Definition cm.h:654
char byellow[COLOR_LEN]
Definition cm.h:643
char bwhite[COLOR_LEN]
Definition cm.h:647
int cp_reverse
Definition cm.h:672
char ln_bg_clr_x[COLOR_LEN]
Definition cm.h:655
char cyan[COLOR_LEN]
Definition cm.h:637
int cp_default
Definition cm.h:669
FILE * stderr_fp
Definition cm.h:659
char tty_name[MAXLEN]
Definition cm.h:656
int cp_highlight
Definition cm.h:677
int cp_title
Definition cm.h:676
char orange[COLOR_LEN]
Definition cm.h:639
int clr_pair_cnt
Definition cm.h:666
char green[COLOR_LEN]
Definition cm.h:633
char white[COLOR_LEN]
Definition cm.h:638
char bg[COLOR_LEN]
Definition cm.h:649
char bblue[COLOR_LEN]
Definition cm.h:644
int tty_fd
Definition cm.h:664
int cp_norm
Definition cm.h:670
char bmagenta[COLOR_LEN]
Definition cm.h:645
char blue[COLOR_LEN]
Definition cm.h:635
int cp_win
Definition cm.h:671
int stdin_fd
Definition cm.h:661
double gray_gamma
Definition cm.h:630
char bblack[COLOR_LEN]
Definition cm.h:640
int clr_pair_idx
Definition cm.h:668