8
9
10
11
12#define _XOPEN_SOURCE_EXTENDED 1
16#define NCURSES_WIDECHAR 1
17#include <ncursesw/ncurses.h>
18#include <ncursesw/panel.h>
22#include <notcurses/notcurses.h>
36#define SUB_SURFACE_LIST(X)
44#define AS_ENUM(NAME) NAME,
49#define CHYRON_KEY_MAXLEN 64
52#define MOUSE_ACTION(X)
58 X(UI_MOUSE_SCROLL_DOWN)
59#define AS_ENUM(NAME) NAME,
69#define LOG_LEVEL_LIST(X)
77#define AS_ENUM(NAME) NAME,
85#define FILE_TYPE_LIST(X)
93#define AS_ENUM(NAME) NAME,
147extern ui_context_t
ui_ctx;
152typedef struct UiRuntime UiRuntime;
154typedef struct UiSurface UiSurface;
155typedef struct UiSplitSurface UiSplitSurface;
156typedef union UiChannels UiChannels;
157typedef struct UiMB UiMB;
170#define BORDER_STYLE(X)
176#define AS_ENUM(NAME) NAME,
195#define ALLWINS (uint)1000
208extern bool f_curses_open;
209typedef cchar_t UiCell;
223 UiBorderStyle border_style;
229struct UiSurfaceMeta {
270 struct UiRuntime *runtime;
272 struct UiSurface *parent;
280 uint8_t b_b, b_g, b_r, b_a;
286 uint8_t f_b, f_g, f_r, f_a;
315 struct notcurses *nc;
319 UiBorderStyle border_style;
327struct UiSurfaceMeta {
332 struct nccell bkgd_cell;
343 struct ncplane *win2;
344 struct ncplane *lnno;
345 struct ncplane *cmdln;
347 struct ncplane *plane1;
348 struct ncplane *plane2;
351 struct ncplane *mplane[SUB_SFC_MAX];
354 struct UiSurfaceMeta meta[SUB_SFC_MAX];
355 struct UiRuntime *runtime;
356 struct UiSurface *parent;
365 uint8_t b_b, b_g, b_r, b_a;
371 uint8_t f_b, f_g, f_r, f_a;
387 char gcluster_backstop;
395 uint8_t b_b, b_g, b_r, b_a;
401 uint8_t f_b, f_g, f_r, f_a;
417typedef uint16_t attr_t;
418typedef nccell UiCell;
419typedef struct ncplane NcPlane;
420typedef struct notcurses NotCurses;
421typedef struct notcurses_options NotCursesOptions;
422typedef struct ncplane_options NcPlaneOptions;
423typedef struct UiPair UiPair;
424typedef struct UiColor UiColor;
425extern NcPlane *stdplane;
426extern uint LINES, COLS;
428#define CELL_CHAR_INITIALIZER(c) {
430 .gcluster_backstop = 0
,
433}
434#define CELL_INITIALIZER(c, s, chan) {
436 .gcluster_backstop = 0
,
438 .channels = (chan), \
439}
448
594extern const wchar_t *
bw_rtl;
595extern const wchar_t *
bw_rtr;
596extern const wchar_t *
bw_rbl;
597extern const wchar_t *
bw_rbr;
598extern const wchar_t *
bw_sp;
599extern const wchar_t *
bw_ra;
600extern const wchar_t *
bw_la;
601extern const wchar_t *
bw_ua;
602extern const wchar_t *
bw_da;
603extern const wchar_t *
bw_ran;
604extern const wchar_t *
bw_lan;
605extern const wchar_t *
bw_chk;
606extern const wchar_t *
bw_h09;
640#define XTERM_256COLOR 1
642#define KEY_ALTINS 0x223
643#define KEY_ALTHOME 0x21e
644#define KEY_ALTPGUP 0x232
645#define KEY_ALTDEL 0x20e
646#define KEY_ALTEND 0x219
647#define KEY_ALTPGDN 0x22d
648#define KEY_ALTUP 0x23d
649#define KEY_ALTLEFT 0x228
650#define KEY_ALTDOWN 0x214
651#define KEY_ALTRIGHT 0x237
652#elif defined(XTERM_GHOSTTY)
653#define KEY_ALTINS 0x228
654#define KEY_ALTHOME 0x223
655#define KEY_ALTPGUP 0x237
656#define KEY_ALTDEL 0x213
657#define KEY_ALTEND 0x21e
658#define KEY_ALTPGDN 0x232
659#define KEY_ALTUP 0x242
660#define KEY_ALTLEFT 0x22d
661#define KEY_ALTDOWN 0x219
662#define KEY_ALTRIGHT 0x23c
665static inline int unicode_to_utf8_gcluster(uint32_t cp, GCluster *g) {
670 }
else if (cp <= 0x7FF) {
671 g
->c[0] = (
char)(0xC0 | (cp >> 6));
672 g
->c[1] = (
char)(0x80 | (cp & 0x3F));
675 }
else if (cp <= 0xFFFF) {
676 g
->c[0] = (
char)(0xE0 | (cp >> 12));
677 g
->c[1] = (
char)(0x80 | ((cp >> 6) & 0x3F));
678 g
->c[2] = (
char)(0x80 | (cp & 0x3F));
681 }
else if (cp <= 0x10FFFF) {
682 g
->c[0] = (
char)(0xF0 | (cp >> 18));
683 g
->c[1] = (
char)(0x80 | ((cp >> 12) & 0x3F));
684 g
->c[2] = (
char)(0x80 | ((cp >> 6) & 0x3F));
685 g
->c[3] = (
char)(0x80 | (cp & 0x3F));
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
804UiRuntime *
ui_init(
const UiConfig *config, SIO *sio);
805UiSurface *
ui_surface_new(ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x);
806UiSurface *
ui_surface_box(UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x,
const char *title);
807int ui_tracked_sfc_box(uint wlines, uint wcols, uint wbegy, uint wbegx,
const char *wtitle);
808int ui_tracked_sfc_split_box(uint wlines, uint wcols, uint split_y, uint split_x, uint wbegy, uint wbegx,
const char *wtitle);
809int ui_surface_addwin(UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x);
810int ui_surface_addpad(UiSurface *s, ss_t w, uint view_win, uint lines, uint cols, uint begy, uint begx);
839int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom);
841int ui_keypad(UiSurface *s, ss_t w,
bool enable);
842int ui_idlok(UiSurface *s, ss_t w,
bool enable);
843int ui_idcok(UiSurface *s, ss_t w,
bool enable);
844int ui_bkgd(UiSurface *s, ss_t w,
const UiCell *cell);
845int ui_bkgdset(UiSurface *s, ss_t w,
const UiCell *cell);
846int ui_bkgrnd(UiSurface *s, ss_t w,
const UiCell *cell);
847int ui_bkgrndset(UiSurface *s, ss_t w,
const UiCell *cell);
857int ui_wmove(UiSurface *s, ss_t w, uint y, uint x);
858int ui_wscrl(UiSurface *s, ss_t w,
int rows);
866void ui_getyx(UiSurface *s, ss_t w, uint *lines, uint *cols);
867void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols);
874int ui_draw_ch(UiSurface *s, ss_t w,
const char c);
875int ui_draw_ch_yx(UiSurface *s, ss_t w, uint y, uint x,
const char c);
876int ui_draw_text(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
877int ui_draw_text_n(UiSurface *s, ss_t w, uint y, uint x,
const char *text,
int m);
878int ui_draw_text_fill(UiSurface *s, ss_t w, uint y, uint x,
const char *text,
int m);
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907int ui_waddch(UiSurface *s, ss_t w,
const char c);
908int ui_mvwaddch(UiSurface *s, ss_t w, uint y, uint x,
const char c);
909int ui_waddstr(UiSurface *s, ss_t w,
const char *text);
910int ui_mvaddstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
911int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
912int ui_waddnstr(UiSurface *s, ss_t w,
const char *text,
int m);
913int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
914int ui_mvwaddstr_fill(UiSurface *s, ss_t w, uint y, uint x,
const char *str,
int m);
915int ui_mvwaddnstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text,
int m);
916int ui_waddwstr(UiSurface *s, ss_t w,
const wchar_t *wstr);
917int ui_mvwaddwstr(UiSurface *s, ss_t w, uint y, uint x,
const wchar_t *wstr);
918int ui_waddnwstr(UiSurface *s, ss_t w,
const wchar_t *wstr,
int m);
919int ui_mvwaddnwstr(UiSurface *s, ss_t w, uint y, uint x,
const wchar_t *wstr,
int m);
920int ui_wadd_wch(UiSurface *s, ss_t w,
const UiCell *cell);
921int ui_mvwadd_wch(UiSurface *s, ss_t w, uint y, uint x,
const UiCell *cell);
923int ui_mvwadd_wchstr(UiSurface *s, ss_t w, uint y, uint x,
const UiCell *cell);
925int ui_mvwadd_wchnstr(UiSurface *s, ss_t w, uint y, uint x,
const UiCell *cell, uint m);
929UiCell
ui_cell_from_ucp(
const wchar_t *ucp,
const uint32_t *fg,
const uint32_t *bg);
949int ui_answer_yn(
char *msg0,
char *msg1,
char *msg2,
char *msg3);
955FileType file_type(
const char *filename);
956int utf8_decode(
const unsigned char *s, uint32_t *codepoint);
964int ui_timeout_prompt(
char *msg0,
char *msg1, uint timeout_ms, uint timeout_secs);
984extern UiCell bkgd_cell;
985extern uint LINES, COLS;
986void ui_cursor_yx(
int *y,
int *x);
987void ui_abs_yx(UiSurface *s, ss_t w,
int *y,
int *x);
988int mk_chimera(UiCell *cell,
char c);
991int ui_init_color(uint16_t color, uint8_t r, uint8_t g, uint8_t b);
992int ui_color_content(uint16_t color, uint8_t *r, uint8_t *g, uint8_t *b);
993int ui_init_pair(uint16_t pair, uint fg, uint bg);
994uint64_t ui_get_channels_from_pair(uint16_t pair);
995int ui_get_pair(uint16_t pair, uint *fg, uint *bg);
996uint ui_init_color_hex(
char *s);
997uint ui_add_pair(uint fg, uint bg);
998uint ui_color_from_rgb(RGB *rgb);
999uint ui_add_color_hex(
char *s);
1000int ui_pair_content(uint16_t pair, uint *fg, uint *bg);
1001int ui_wch_to_utf8(
const wchar_t fill_ch);
1002uint ui_get_plane_idx(UiSurface *s, NcPlane *n);
1003NcPlane *ui_ncplane_clicked(UiSurface *s, ss_t w, NcInput *ni);
1004struct ncvisual *ui_display_image(
struct notcurses *nc, UiMultiMedia *mm,
const char *image_file,
int y,
int x,
int begy,
int begx);
1005uint ui_mbstr_to_cellstr(UiSurface *sfc, ss_t w, UiCell *cmplx_buf,
const char *str,
const UiCell *cell_base, uint *pos,
const uint atmost);
1015#define ui_get_cell(sfc, w, cell, wstr, style, cp, opts)
1016 ui_get_nccell(sfc, w, cell, wstr, style, cp);
1022 const wchar_t *wstr,
1023 const UiStyle style,
1026#define ui_set_cell(sfc, w, cell, wstr, attr, cp, opts)
1027 ui_set_nccell(sfc, w, cell, wstr, attr, cp);
1033int ui_add_color(uint r, uint g, uint b);
1040int ui_getcchar(
const UiCell *cell, wchar_t *wstr, attr_t *attrs,
short *pair,
const void *opts);
1042int ui_setcchar(UiCell *cell,
const wchar_t *wstr,
const attr_t attrs,
short pair,
const void *opts);
1049uint
ui__mbstr_to_cellstr(UiCell *cmplx_buf,
const char *str,
const UiCell *cell_base, uint *pos,
const uint atmost);
1051#define ui_mbstr_to_cellstr(sfc, w, cmplx_buf, str, cell_base, pos, atmost)
1052 ui__mbstr_to_cellstr(cmplx_buf, str, cell_base, pos, atmost);
1054#define ui_get_cell(s, w, cell, wstr, attr, pair, opts)
1055 ui_getcchar(cell, wstr, attr, pair, nullptr);
1057#define ui_set_cell(s, w, cell, wstr, attrs, pair, nullptr)
1058 ui_setcchar(cell, wstr, attrs, pair, nullptr);
1062extern UiRuntime *
ui;
1082 UiCell cmplx_buf[
MAXLEN];
1084 struct UiSurface *sfc;
1098void ui_display_chyron(UiSurface *sfc, ss_t w, UiChyron *chyron, uint line, uint col);
1105int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev,
int timeout_ms);
1111#define ANSI_RESET "\033[0m"
1121static inline void ui_logrec(
const UiLogLevel level,
const char *file,
const char *func,
const int line,
const char *fmt, ...)
__attribute__((format(printf, 5, 6)));
1123static inline void ui_logrec(
const UiLogLevel level,
const char *file,
const char *func,
const int line,
const char *fmt, ...) {
1125 fprintf(
ui_log_fp,
"[%s] %s[%s]%s <%s:%s:%d> ",
1132 va_start(args, fmt);
1138#define ui_log(level, fmt, ...)
1140 if (level <= ui_min_log_level) {
1141 ui_logrec(level, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
int form_read_description(Form *)
void form_display_chyron(Form *)
int cmd_processor(Init *)
int open_pick_win(Init *)
bool view_stack_peek(const ViewStack *, View *)
int popup_form(Init *, int, char **, uint, uint)
instantiate a form popup window
bool view_stack_push(ViewStack *, View)
int popup_menu(Init *, int, char **, uint, uint)
instantiate a menu popup window
void view_stack_free(ViewStack *)
bool view_stack_pop(ViewStack *, View *)
int popup_pick(Init *, int, char **, uint, uint)
instantiate a pick popup window
bool view_stack_init(ViewStack *, size_t)
void destroy_view_win(Init *)
int popup_view(Init *, int, char **, uint, uint, uint, uint)
instantiate a view popup window
int mpick(int, char **, int, int, int, int, char *, int)
volatile sig_atomic_t sig_received
size_t rtrim(char *)
Trims trailing spaces from string s in place.
bool handle_signal(sig_atomic_t)
bool strnfill(char *, char, uint)
void get_rfc3339_s(char *, size_t)
bool waitpid_with_timeout(pid_t, uint)
struct termios shell_out_tioctl program_out_tioctl
char stdio_names_str[4096]
bool verify_dir_q(char *, uint)
void win_resize(uint, uint, char *)
bool construct_file_spec(char *, char *, char *, char *, char *, uint)
struct termios shell_tioctl program_tioctl
char * stdio_names(char *, char *)
String mk_string(size_t)
Create a String struct with a dynamically allocated string.
bool verify_file_q(char *, uint)
struct termios shell_in_tioctl program_in_tioctl
void dump_opts_by_use(char *, char *)
struct termios shell_err_tioctl program_err_tioctl
#define min(x, y)
min macro evaluates two expressions, returning least result
bool str_to_bool(const char *)
Converts String to boolean true or false.
#define __atexit
This macro registers the end_pgm function to be called when the program exits.
bool is_image_file(const char *filename)
char * fill_field(char *, char *, char, uint)
char * stdio_fdnames(char *, char *)
UiChyron * wait_mk_chyron()
int display_curses_keys()
bool f_have_program_tioctl
void display_argv_error_msg(char *, char **)
bool wait_destroy(UiChyron *)
char * rep_substring(const char *, const char *, const char *) __attribute__((nonnull(1
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
void free_menu_line(Line *)
int ui_border_draw(UiSurface *sfc)
int ui_surface_resize(UiSurface *s, ss_t w, uint lines, uint cols)
Resize a UiSurface to new dimensions.
int ui_draw_ch_yx(UiSurface *s, ss_t w, uint y, uint x, const char c)
Draw a character at a specific position in a surface window.
int ui_surface_addwin(UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
const wchar_t * border_none
#define SUB_SURFACE_LIST(X)
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
void ui_render()
Render the UI by updating panels and refreshing the display.
void ui_getyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the current cursor position within a window of a UI surface.
int ui_wresize(UiSurface *s, ss_t w, uint lines, uint cols)
int ui_draw_text_n(UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
Draw a text string at a specific position in a surface window.
int ui_draw_text_fill(UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
Draw a text string at a specific position in a surface window, filling the remaining space with space...
int ui_whide(UiSurface *s, ss_t w)
char const colors_text[][10]
Color names for .minitrc overrides.
int ui_tracked_sfc_split_box(uint wlines, uint wcols, uint split_y, uint split_x, uint wbegy, uint wbegx, const char *wtitle)
Create a new surface with a split box window.
int ui_mice_enable(int mask)
Enable or disable mouse support.
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
int ui_draw_text(UiSurface *s, ss_t w, uint y, uint x, const char *text)
on specified window, move to y, x, add string
int ui_draw_hline(UiSurface *s, ss_t w, uint y, uint x, uint len, const UiStyle *style)
int ui_wmove(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
int ui_cursor_enable_yx(UiSurface *s, ss_t w, uint y, uint x, bool visible)
Enable or disable the cursor at a specific position within a UiSurface.
int ui_wscrl(UiSurface *s, ss_t w, int rows)
Scroll the contents of a UiSurface by a specified number of lines.
int ui_idcok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
int ui_surface_addpad(UiSurface *s, ss_t w, uint view_win, uint lines, uint cols, uint begy, uint begx)
Add a new pad to the specified UiSurface.
const char * ui_sub_surface_str(ss_t w)
int ui_cursor_move(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
int ui_cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
int ui_suspend()
Suspend the UI, saving the current program state and ending the window session.
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
int ui_wshow(UiSurface *s, ss_t w)
int ui_border_title(UiSurface *sfc, const char *title)
Draw a box with a title around the specified window.
void ui_update_panels()
Update the panels in the UI.
int ui_bkgd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
void ui_restore_wins()
Restore the state of all windows in the UI. This function refreshes the standard screen and all surfa...
int ui_idlok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
const wchar_t * border_double
int ui_surface_move(UiSurface *s, ss_t w, uint y, uint x)
Move a UiSurface to a new position on the screen.
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
int ui_draw_ch(UiSurface *s, ss_t w, const char c)
Draw a character in a surface window.
UiSurface * ui_surface_box(UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
#define CHYRON_KEY_MAXLEN
int ui_get_event_no_mouse(UiSurface *surface, ss_t w, UiEvent *ev)
Wait for an input event on target (or stdscr if NULL) without mouse support.
int ui_border_ysplit_text(UiSurface *sfc, char *text, uint separator_line)
Draw a box with a separator line and text around the specified window.
const wchar_t * border_single
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
int ui_surface_show(UiSurface *s, ss_t w)
Show a UiSurface, making it visible on the screen.
int ui_getch()
Wait for a single input character from the NotCurses context.
int ui_erase()
Erase the entire screen.
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
int ui_border_ysplit(UiSurface *sfc, uint y)
Draw a box with a separator line around the specified window.
int ui_mousemask(int mask)
Enable or disable mouse support.
#define LOG_LEVEL_LIST(X)
void ui_initialize_sio(SIO *sio)
int ui_wclrtobot(UiSurface *s, ss_t w)
Set the style of a surface window.
int ui_curs_set(int visibility)
Set the visibility of the cursor.
int ui_resume()
Resume the UI, restoring the previous program state and updating the display.
int ui_bkgrndset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_top_surface(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
int ui_wclear(UiSurface *s, ss_t w)
Clear the contents of a UiSurface or all surfaces.
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
int ui_tracked_sfc_box(uint wlines, uint wcols, uint wbegy, uint wbegx, const char *wtitle)
Create a new surface with a box window.
int ui_cursor_enable(UiSurface *s, ss_t w, bool visible)
Enable or disable the cursor for a UiSurface.
int ui_clear()
Clear the entire screen.
int ui_getmaxx(UiSurface *s, ss_t w)
Get the maximum number of columns of a UiSurface.
const wchar_t * border_heavy
int ui_surface_hide(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
const wchar_t * border_rounded
int ui_bkgrnd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
int ui_wclrtoeol(UiSurface *s, ss_t w)
Clear to the end of the line in a surface window.
int ui_wnoutrefresh(UiSurface *s, ss_t w)
Refresh a specific window within a UiSurface.
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
int ui_bkgdset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_doupdate()
Refresh the display by updating the screen.
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
#define FILE_TYPE_LIST(X)
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
int get_cmd_spec(View *, char *)
int view_accept_cmd(View *)
void go_to_position(View *, long)
int ui_get_pair(uint16_t pair, uint *fg, uint *bg)
Get the foreground and background color indices for a given color pair index.
void ui_flush_input()
Flush any pending input events from the NotCurses context. This function discards any input events th...
int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev, int timeout_ms)
Read input events.
void ui_unset_chyron_key(UiChyron *chyron, uint k)
Unset chyron key.
void ui_set_chyron_key(UiChyron *chyron, uint k, char *s, uint kc)
Set chyron key with default color pair (cp_nt_rev).
void ui_deactivate_all_chyron_keys(UiChyron *chyron)
Deactivate all chyron keys.
FILE * ui_open_log()
Open the log file for writing.
wchar_t * ui_mbstr_to_wcstr(const char *mb_str)
Convert a multibyte string to a wide character string.
UiChyron * ui_new_chyron(UiSurface *sfc, ss_t w)
Create new chyron structure.
char * ui_iso8601_timestamp(char *buf, size_t n, bool local)
Generate an ISO 8601 timestamp string.
const char *const ui_log_level_s[]
RGB ui_xterm256_idx_to_rgb(uint idx)
Convert XTerm 256 color index to RGB.
void ui_activate_chyron_key(UiChyron *chyron, uint k)
Activate chyron key.
void ui_display_chyron(UiSurface *sfc, ss_t w, UiChyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
void ui_set_chyron_key_cb(UiChyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
Set chyron key with color pair (cp).
int ui_assign_chyron_win(UiChyron *chyron, UiSurface *sfc, ss_t w, char *y)
Assign surface and window to chyron structure.
bool ui_init_clr_palette(SIO *sio)
bool ui_is_set_chyron_key(UiChyron *chyron, uint k)
Check if function key label is set.
UiLogLevel ui_min_log_level
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
void ui_parse_ansi(char *ansi_str, attr_t *attr, uint *cpx)
Parse ANSI escape sequences for color and attributes.
UiChyron * ui_destroy_chyron(UiChyron *chyron)
Destroy UiChyron structure.
int ui_get_chyron_key(UiChyron *chyron, uint x)
Get keycode from chyron.
void ui_mbc_to_wc(wchar_t wc[2], const char mbc)
Convert a multibyte character to a wide character.
void ui_deactivate_chyron_key(UiChyron *chyron, uint k)
Deactivate chyron key.
const char *const ui_logcolor[]
void ui_apply_gamma(RGB *rgb)
Apply gamma correction to RGB color.
void ui_activate_all_chyron_keys(UiChyron *chyron)
Deactivate chyron key.
uint ui_rgb_to_xterm256_idx(RGB *rgb)
Convert RGB color to XTerm 256 color index.
void ui_compile_chyron(UiChyron *chyron)
construct the chyron string from the chyron structure
int ui_setcchar(UiCell *cell, const wchar_t *wstr, const attr_t attrs, short pair, const void *opts)
Set the character and attributes of a UiCell.
uint ui__mbstr_to_cellstr(UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost)
int ui_chg_pair(uint pair, uint fg, uint bg)
Change the foreground and background colors of an existing color pair.
int ui_pair_content(uint pair, uint *fg, uint *bg)
Get the foreground and background colors of a specified color pair.
SCREEN * ui_ncurses_get_screen()
Get the current SCREEN pointer used by the UI.
int ui_getcchar(const UiCell *cell, wchar_t *wstr, attr_t *attrs, short *pair, const void *opts)
Get the character and attributes from a UiCell.
int ui_init_color(uint color, uint r, uint g, uint b)
Initialize a color in the curses color table with specified RGB values.
int ui_init_pair(uint pair, uint fg, uint bg)
Initialize a color pair in the curses color table with specified foreground and background colors.
uint ui_add_pair(uint fg, uint bg)
Add a new color pair to the UI, or retrieve the index of an existing pair.
UiSurface * ui_surface[UI_SFC_MAX]
uint32_t ui_get_color(uint16_t color_idx)
Get the RGB color value for a given color index.
int ui_color_content(uint color, uint *r, uint *g, uint *b)
void fast_exit(UiSurface *s)
Exit the UI application quickly, cleaning up resources.
RGB ui_hex_to_rgb(char *s)
Convert a hexadecimal color string to an RGB structure.
int ui_pair_from_hex(const char *fg, const char *bg)
Convert hex color strings to a curses color pair index.
UiCell ui_cell_from_ucp(const wchar_t *ucp, const uint32_t *fg, const uint32_t *bg)
Convert a Unicode code point to a curses UiCell with specified foreground and background colors.
int ui_color_from_rgb(RGB *rgb)
Convert RGB to curses color index, adding new color if necessary.
int ui_chg_color(uint16_t color_idx, uint32_t *color)
Change the RGB color value for a given color index.
int ui_mvwadd_wchnstr(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cmplx_buf, uint n)
Draw a complex character string at a specific position in a surface window, with a maximum length.
int ui_waddstr(UiSurface *s, ss_t w, const char *text)
Draw a text string in a surface window.
int ui_mvwaddnwstr(UiSurface *s, ss_t w, uint y, uint x, const wchar_t *wstr, int m)
Draw a wide-character string at a specific position in a surface window, with a maximum length.
int ui_waddwstr(UiSurface *s, ss_t w, const wchar_t *wstr)
Draw a wide-character string in a surface window.
int ui_mvwaddch(UiSurface *s, ss_t w, uint y, uint x, const char c)
Draw a character in a surface window.
int ui_waddnstr(UiSurface *s, ss_t w, const char *text, int m)
Draw a text string in a surface window, with a maximum length.
int ui_mvwaddnstr(UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
Draw a text string at a specific position in a surface window, with a maximum length.
int ui_mvwadd_wchstr(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cmplx_buf)
Draw a complex character string at a specific position in a surface window.
int ui_mvwaddwstr(UiSurface *s, ss_t w, uint y, uint x, const wchar_t *wstr)
Draw a wide-character string at a specific position in a surface window.
int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x, const char *text)
Draw a text string at a specific position in a surface window.
int ui_mvwadd_wch(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cell)
Draw a complex character at a specific position in a surface window.
int ui_mvwaddstr_fill(UiSurface *s, ss_t w, uint y, uint x, const char *str, int m)
Draw a text string at a specific position in a surface window, filling the remaining space with space...
int ui_wadd_wch(UiSurface *s, ss_t w, const UiCell *cell)
Draw a complex character in a surface window.
int ui_waddnwstr(UiSurface *s, ss_t w, const wchar_t *wstr, int m)
Draw a wide-character string in a surface window, with a maximum length.
int ui_wadd_wchstr(UiSurface *s, ss_t w, const UiCell *cmplx_buf)
Draw a complex character string in a surface window.
int ui_wadd_wchnstr(UiSurface *s, ss_t w, const UiCell *cmplx_buf, uint n)
Draw a complex character string in a surface window, with a maximum length.
int ui_waddch(UiSurface *s, ss_t w, const char c)
on specified window, at current location, add character
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
void view_boxwin_resize(Init *)
Resize the current window and its box.
void cmenu_shutdown(Init *init)
void cmenu_abend(Init *init, int ec, char *s)
uint form_yx_to_fidx(Form *, uint, uint)
int cf_accept(UiSurface *sfc, ss_t w, char *accept_s, uint flin, uint fcol, uint flen)
Accepts input for a field in a C-Menu window.
bool f_erase_remainder
Structure to hold field information for C-Menu.
int process_config_file(char *, Init *)
void display_field(UiCell *cmplx_buf, uint y, uint x)
struct termios shell_tioctl
int fork_exec(char **)
Fork and exec a command.
int shell(char *)
Execute a shell command.
int full_screen_fork_exec(char **)
Execute a command in full screen mode.
int full_screen_shell(char *)
Execute a shell command in full screen mode.
int fork_detach_execvp(char **eargv)
Fork, set new session ID, close files, and execute detached command.
int form_fmt_field(Form *form, char *s)
Format field according to its format type.
bool is_valid_date(uint yyyy, uint mm, uint dd)
Check if a given date is valid, including leap years.
int field_editor(Form *)
Accept input for a field.
void numeric(char *d, char *s)
Extract numeric characters from source string to destination string.
bool is_valid_time(uint hh, uint mm, uint ss)
Check if a given time is valid.
void right_justify(char *, uint)
Right justify string by removing trailing spaces and adding leadingspaces.
void left_justify(char *s)
Left justify string by removing leading spaces.
int form_display_field_n(Form *, uint)
Display field n.
int form_display_field(Form *)
Display current field.
int form_desc_error(Form *form, int, char *, char *)
Handle errors encountered while parsing the form description file, providing detailed error messages ...
int init_form(Init *, int, char **, uint, uint)
Initialize form data structure and parse description file.
int field_navigator(Form *)
Handle user input for field entry, allowing navigation between fields and looping until an exit actio...
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
bool parse_local_timestamp(const char *, time_t *)
Parses an ISO 8601 timestamp string in local time and converts it to time_t.
bool trim_ext(char *, char *)
trims the file extension from "filename" and copies the result to "buf"
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
char * get_local_timestamp()
Returns the current local time as an ISO 8601 formatted string.
bool is_directory(const char *)
Checks if the given path is a directory.
bool file_spec_path(char *, char *)
extracts the path component of a file specification
bool str_to_upper(char *)
Converts a string to uppercase.
bool dir_name(char *, char *)
Returns the directory name of a file specification.
bool is_hex_str(char *, uint)
Validates that a string consists of exactly len hexadecimal digits.
double str_to_double(char *)
converts string to double
bool str_to_lower(char *)
Converts a string to lowercase.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
bool strip_quotes(char *)
removes leading and trailing double quotes if present
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
bool is_valid_regex(const char *)
Checks if the given regular expression pattern is valid.
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
char * strnz_dup(char *, size_t)
Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
bool file_spec_name(char *, char *)
extracts the file name component of a file specification
char size_t strip_ansi(char *, char *)
Strips ANSI SGR escape sequences (ending in 'm') from string s to d.
bool mk_dir(char *dir)
If directory doesn't exist, make it.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
bool get_argp_doc_by_name(char *comment, const struct argp_option *, const char *)
Retrieves the documentation string for a given key name from an argp options array.
char * get_ip_addresses(char *, uint)
Retrieves the IP addresses of the local machine and formats them into a string.
bool is_symlink_to_dir(const char *)
Checks if the given path is a symbolic link to a directory.
bool verify_file(char *, uint)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
size_t strnlf(char *, size_t)
terminates string with line feed
int a_toi(char *, bool *)
a safer alternative to atoi() for converting ASCII strings to integers.
bool str_subc(char *, char *, char, char *, uint)
Replaces "ReplaceChr" in "s" with "Withstr" in "d" won't copy more than "l" bytes to "d" Replaces all...
char * strerror__r(int errnum, char *buf, size_t buflen)
A thread-safe alternative to strerror() that writes the error message corresponding to errnum into th...
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
bool chrep(char *, char, char)
Replaces all occurrences of old_chr in s with new_chr in place.
bool base_name(char *, char *)
Returns the base name of a file specification.
bool normalize_file_spec(char *)
replace backslashes with forward lashes
char * format_local_timestamp(time_t, char *, size_t)
Formats a time_t as an ISO 8601 string in local time.
bool is_newer(char *, char *)
Checks if the file specified by "fut" is newer than the file specified by "control".
char * fdname(int, char *)
Retrieves the file path associated with a given file descriptor.
bool verify_dir(char *, uint)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
char * get_user_str(char *, size_t)
Retrieves the current user's name and UID, and formats it into a string.
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
unsigned long a_to_ul(const char *)
Converts a string to an unsigned long long integer, with support for suffixes K, M,...
bool unstr_hex_clr(char *, char *)
Validates that a string is a hex color code in the format "#RRGGBB".
size_t string_cpy(String *, const String *)
Copy src String to dest String, allocating additional memory for dest String if necessary.
String to_string(const char *)
String functions provide a simple string library to facilitate string manipulation in C,...
size_t string_ncpy(String *, const String *, size_t)
copies up to n characters from src String to dest String, allocating additional memory for dest Strin...
size_t string_cat(String *, const String *)
Concatenates src String to dest String, allocating additional memory for dest String if necessary.
String free_string(String)
Free the dynamically allocated String.
size_t string_ncat(String *, const String *, size_t)
Concatenates up to n characters from src String to dest String, allocating additional memory for dest...
int segmentation_fault()
Function to intentionally cause a segmentation fault for testing purposes.
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
bool derive_file_spec(char *, char *, char *)
Derive full file specification from directory and file name.
int write_config(Init *init)
Write the current configuration to a file specified in init->minitrc.
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
void view_calc_boxwin_dimensions(Init *)
Calculate the dimensions and position of the box window for C-Menu View.
int init_view_full_screen(Init *init)
Initialize C-Menu View in full screen mode.
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
int view_init_input(Init *init, char *file_name)
Initialize the input for the C-Menu View.
bool verify_spec_arg(char *, char *, char *, char *, uint)
Verify file specification argument.
Pick * new_pick(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Pick structure.
View * destroy_view(Init *init)
Destroy View structure.
Menu * new_menu(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Menu structure.
Init * new_init(int argc, char **argv)
Create and initialize Init structure.
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Form * destroy_form(Init *init)
Destroy Form structure.
View * new_view(Init *init)
Create and initialize View structure.
Init * destroy_init(Init *init)
Destroy Init structure.
Form * new_form(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Form structure.
Pick * destroy_pick(Init *init)
Destroy Pick structure.
unsigned int menu_engine(Init *)
The main loop of the menu system.
unsigned int get_command_type(char *)
Get command type from command string.
unsigned int parse_menu_description(Init *)
Parse menu description file and create Menu.
void save_object(Pick *, char *)
Saves a string as an object in the pick structure.
void toggle_object(Pick *)
Toggles the selection state of the currently selected object in pick window.
int output_objects(Pick *)
Outputs selected objects to specified output file.
int init_pick(Init *, int, char **, uint, uint)
Initializes pick structure and opens pick input file or pipe.
void reverse_object(Pick *)
Reverses the display of the currently selected object in pick window.
void display_pick_page(Pick *)
Displays current page of objects in pick window.
bool restore_program_tioctl()
restore_program_tioctl() - restore program terminal settings
bool capture_shell_tioctl()
capture_shell_tioctl() - capture shell terminal settings
char di_getch()
get single character from terminal in raw mode
bool mk_raw_tioctl(struct termios *)
mk_raw_tioctl() - set terminal to raw mode
bool set_sane_tioctl(struct termios *)
set_sane_tioctl() - set terminal to sane settings for C-MENU
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
bool capture_program_tioctl()
capture_program_tioctl() - capture program terminal settings
void sig_dfl_mode()
Set signal handlers to default behavior.
void signal_handler(int)
Signal handler for interrupt signals.
void sig_prog_mode()
Set up signal handlers for interrupt signals.
int view_file(Init *)
Start view.
void cat_file(View *)
Concatenate File to Standard Output.
int view_cmd_processor(Init *)
Main Command Processing Loop for View.
void build_prompt(View *)
Build Prompt String.
void initialize_line_table(View *)
Initialize Line Table.
void destroy_line_table(View *)
Destroy Line Table.
void page_next(View *)
Advance to Next Page.
int pad_refresh(View *)
Refresh Pad and Line Number Window.
int display_prompt(View *, char *)
Display Command Line Prompt.
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
void ui_unregister_read_fd(int fd)
Unregister an external file descriptor from polling.
void ui_register_read_fd(int fd, int token_id)
Register an external file descriptor for polling.
int ui_timeout_prompt(char *msg0, char *msg1, uint timeout_ms, uint timeout_secs)
Display a timeout prompt window or print to stderr.
int ui_update_timeout_prompt(UiSurface *sfc, ss_t w, uint timeout_ms)
Update the timeout prompt with the remaining time.
int ui_poll_reg_read_fd(int timeout_ms)
Poll for input on registered external files.
bool ui_action_disposition(char *title, char *action_str)
Display a simple action disposition message window or print to stderr.
int ui_answer_yn(char *msg0, char *msg1, char *msg2, char *msg3)
Accept a single letter answer.
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
UiBackend ui_get_backend()
Get the UI backend type.
UiMouseAction mouse_action
ext_fd_reg_t ext_fds[MAX_EXT_FDS]
UiBorderStyle border_style
char log_file_spec[MAXLEN]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
UiCell accept_cc[FIELD_MAXLEN]
char display_s[FIELD_MAXLEN]
UiCell display_cc[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
char input_s[FIELD_MAXLEN]
UiCell filler_cc[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Text * text[FIELD_MAXCNT]
Field * field[FIELD_MAXCNT]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char mapp_spec[FIELD_MAXLEN]
char provider_cmd[MAXLEN]
Line * line[MAX_MENU_LINES]
char receiver_cmd[MAXLEN]
bool f_selected[OBJ_MAXCNT]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char ln_bg_clr_x[COLOR_LEN]
char * next_file_spec_ptr
char receiver_cmd[MAXLEN]
UiCell cmplx_buf[PAD_COLS]
char stripped_line_out[PAD_COLS]
char tmp_prompt_str[MAXLEN]
char cur_file_str[MAXLEN]
char line_out_s[PAD_COLS]