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>
39#if defined(__has_c_attribute
)
40#if __has_c_attribute
(gnu::format)
41#define ATTR_FORMAT(archetype, fmt_idx, first_arg) [[gnu::format(archetype, fmt_idx, first_arg)]]
46#if defined(__GNUC__) || defined(__clang__)
47#define ATTR_FORMAT(archetype, fmt_idx, first_arg) __attribute__((format(archetype, fmt_idx, first_arg)))
49#define ATTR_FORMAT(archetype, fmt_idx, first_arg)
63#define ALLWINS (uint)1000
74#define SUB_SURFACE_LIST(X)
83#define AS_ENUM(NAME) NAME,
88#define AS_STRINGS(NAME) #NAME,
89static const char *ss_n[] = {
91#define CHYRON_KEY_MAXLEN 64
94#define MOUSE_ACTION(X)
100 X(UI_MOUSE_SCROLL_DOWN)
101#define AS_ENUM(NAME) NAME,
111#define FILE_TYPE_LIST(X)
119#define AS_ENUM(NAME) NAME,
173extern ui_context_t
ui_ctx;
178typedef struct UiRuntime UiRuntime;
180typedef struct UiSurface UiSurface;
181typedef struct UiSplitSurface UiSplitSurface;
182typedef union UiChannels UiChannels;
183typedef struct UiMB UiMB;
197#define BORDER_STYLE(X)
203#define AS_ENUM(NAME) NAME,
218#define ANSI_RESET "\033[0m"
219#define MAX_LOG_SIZE (10
* 1024
* 1024
)
220#define MAX_LOG_REC_LEN 4096
221#define LOG_LEVEL_LIST(X)
229#define AS_ENUM(NAME) NAME,
249extern bool f_curses_open;
250typedef cchar_t UiCell;
264 UiBorderStyle border_style;
270struct UiSurfaceMeta {
311 struct UiRuntime *runtime;
313 struct UiSurface *parent;
321 uint8_t b_b, b_g, b_r, b_a;
327 uint8_t f_b, f_g, f_r, f_a;
356 struct notcurses *nc;
360 UiBorderStyle border_style;
368struct UiSurfaceMeta {
373 struct nccell bkgd_cell;
384 struct ncplane *win2;
385 struct ncplane *lnno;
386 struct ncplane *cmdln;
388 struct ncplane *viewport;
389 struct ncplane *plane2;
392 struct ncplane *mplane[SUB_SFC_MAX];
395 struct UiSurfaceMeta meta[SUB_SFC_MAX];
396 struct UiRuntime *runtime;
397 struct UiSurface *parent;
406 uint8_t b_b, b_g, b_r, b_a;
412 uint8_t f_b, f_g, f_r, f_a;
428 char gcluster_backstop;
436 uint8_t b_b, b_g, b_r, b_a;
442 uint8_t f_b, f_g, f_r, f_a;
458typedef uint16_t attr_t;
459typedef nccell UiCell;
460typedef struct ncplane NcPlane;
461typedef struct notcurses NotCurses;
462typedef struct notcurses_options NotCursesOptions;
463typedef struct ncplane_options NcPlaneOptions;
464typedef struct UiPair UiPair;
465typedef struct UiColor UiColor;
466extern NcPlane *stdplane;
467extern uint LINES, COLS;
469#define CELL_CHAR_INITIALIZER(c) {
471 .gcluster_backstop = 0
,
474}
475#define CELL_INITIALIZER(c, s, chan) {
477 .gcluster_backstop = 0
,
479 .channels = (chan), \
480}
489
640extern const wchar_t *
bw_rtl;
641extern const wchar_t *
bw_rtr;
642extern const wchar_t *
bw_rbl;
643extern const wchar_t *
bw_rbr;
644extern const wchar_t *
bw_sp;
645extern const wchar_t *
bw_ra;
646extern const wchar_t *
bw_la;
647extern const wchar_t *
bw_ua;
648extern const wchar_t *
bw_da;
649extern const wchar_t *
bw_ran;
650extern const wchar_t *
bw_lan;
651extern const wchar_t *
bw_chk;
652extern const wchar_t *
bw_h09;
694#define XTERM_256COLOR 1
696#define KEY_ALTINS 0x223
697#define KEY_ALTHOME 0x21e
698#define KEY_ALTPGUP 0x232
699#define KEY_ALTDEL 0x20e
700#define KEY_ALTEND 0x219
701#define KEY_ALTPGDN 0x22d
702#define KEY_ALTUP 0x23d
703#define KEY_ALTLEFT 0x228
704#define KEY_ALTDOWN 0x214
705#define KEY_ALTRIGHT 0x237
706#elif defined(XTERM_GHOSTTY)
707#define KEY_ALTINS 0x228
708#define KEY_ALTHOME 0x223
709#define KEY_ALTPGUP 0x237
710#define KEY_ALTDEL 0x213
711#define KEY_ALTEND 0x21e
712#define KEY_ALTPGDN 0x232
713#define KEY_ALTUP 0x242
714#define KEY_ALTLEFT 0x22d
715#define KEY_ALTDOWN 0x219
716#define KEY_ALTRIGHT 0x23c
719static inline int unicode_to_utf8_gcluster(uint32_t cp, GCluster *g) {
724 }
else if (cp <= 0x7FF) {
725 g
->c[0] = (
char)(0xC0 | (cp >> 6));
726 g
->c[1] = (
char)(0x80 | (cp & 0x3F));
729 }
else if (cp <= 0xFFFF) {
730 g
->c[0] = (
char)(0xE0 | (cp >> 12));
731 g
->c[1] = (
char)(0x80 | ((cp >> 6) & 0x3F));
732 g
->c[2] = (
char)(0x80 | (cp & 0x3F));
735 }
else if (cp <= 0x10FFFF) {
736 g
->c[0] = (
char)(0xF0 | (cp >> 18));
737 g
->c[1] = (
char)(0x80 | ((cp >> 12) & 0x3F));
738 g
->c[2] = (
char)(0x80 | ((cp >> 6) & 0x3F));
739 g
->c[3] = (
char)(0x80 | (cp & 0x3F));
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
858UiRuntime *
ui_init(
const UiConfig *config, SIO *sio);
859UiSurface *
ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x);
860UiSurface *
ui_surface_box(UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x,
const char *title);
861int ui_tracked_sfc_box(uint wlines, uint wcols, uint wbegy, uint wbegx,
const char *wtitle);
862int ui_tracked_sfc_split_box(uint wlines, uint wcols, uint split_y, uint split_x, uint wbegy, uint wbegx,
const char *wtitle);
863int ui_surface_addwin(UiSurface *s, ss_t w, ss_t p, uint lines, uint cols, uint y, uint x);
864int ui_surface_addpad(UiSurface *s, ss_t w, ss_t view_win, uint lines, uint cols, uint y, uint x,
bool hidden);
893int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom);
895int ui_keypad(UiSurface *s, ss_t w,
bool enable);
896int ui_idlok(UiSurface *s, ss_t w,
bool enable);
897int ui_idcok(UiSurface *s, ss_t w,
bool enable);
898int ui_bkgd(UiSurface *s, ss_t w,
const UiCell *cell);
899int ui_bkgdset(UiSurface *s, ss_t w,
const UiCell *cell);
900int ui_bkgrnd(UiSurface *s, ss_t w,
const UiCell *cell);
901int ui_bkgrndset(UiSurface *s, ss_t w,
const UiCell *cell);
911int ui_wmove(UiSurface *s, ss_t w, uint y, uint x);
912int ui_wscrl(UiSurface *s, ss_t w,
int rows);
916int ui_immedok(UiSurface *s, ss_t w,
bool enable);
917int ui_prefresh(UiSurface *s, ss_t w,
int pminrow,
int pmincol,
int sminrow,
int smincol,
int smaxrow,
int smaxcol);
923void ui_getyx(UiSurface *s, ss_t w, uint *lines, uint *cols);
924void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols);
931int ui_draw_ch(UiSurface *s, ss_t w,
const char c);
932int ui_draw_ch_yx(UiSurface *s, ss_t w, uint y, uint x,
const char c);
933int ui_draw_text(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
934int ui_draw_text_n(UiSurface *s, ss_t w, uint y, uint x,
const char *text,
int m);
935int ui_draw_text_fill(UiSurface *s, ss_t w, uint y, uint x,
const char *text,
int m);
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964int ui_waddch(UiSurface *s, ss_t w,
const char c);
965int ui_mvwaddch(UiSurface *s, ss_t w, uint y, uint x,
const char c);
966int ui_waddstr(UiSurface *s, ss_t w,
const char *text);
967int ui_mvaddstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
968int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
969int ui_waddnstr(UiSurface *s, ss_t w,
const char *text,
int m);
970int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text);
971int ui_mvwaddstr_fill(UiSurface *s, ss_t w, uint y, uint x,
const char *str,
int m);
972int ui_mvwaddnstr(UiSurface *s, ss_t w, uint y, uint x,
const char *text,
int m);
973int ui_waddwstr(UiSurface *s, ss_t w,
const wchar_t *wstr);
974int ui_mvwaddwstr(UiSurface *s, ss_t w, uint y, uint x,
const wchar_t *wstr);
975int ui_waddnwstr(UiSurface *s, ss_t w,
const wchar_t *wstr,
int m);
976int ui_mvwaddnwstr(UiSurface *s, ss_t w, uint y, uint x,
const wchar_t *wstr,
int m);
977int ui_wadd_wch(UiSurface *s, ss_t w,
const UiCell *cell);
978int ui_mvwadd_wch(UiSurface *s, ss_t w, uint y, uint x,
const UiCell *cell);
980int ui_mvwadd_wchstr(UiSurface *s, ss_t w, uint y, uint x,
const UiCell *cell);
982int ui_mvwadd_wchnstr(UiSurface *s, ss_t w, uint y, uint x,
const UiCell *cell, uint m);
986UiCell
ui_cell_from_ucp(
const wchar_t *ucp,
const uint32_t *fg,
const uint32_t *bg);
1006int ui_answer_yn(
char *msg0,
char *msg1,
char *msg2,
char *msg3);
1012FileType file_type(
const char *filename);
1013int utf8_decode(
const unsigned char *s, uint32_t *codepoint);
1021int ui_timeout_prompt(
char *msg0,
char *msg1, uint timeout_ms, uint timeout_secs);
1041extern UiCell bkgd_cell;
1042extern uint LINES, COLS;
1043void ui_cursor_yx(
int *y,
int *x);
1044void ui_abs_yx(UiSurface *s, ss_t w,
int *y,
int *x);
1045int mk_chimera(UiCell *cell,
char c);
1048int ui_init_color(uint16_t color, uint8_t r, uint8_t g, uint8_t b);
1049int ui_color_content(uint16_t color, uint8_t *r, uint8_t *g, uint8_t *b);
1050int ui_init_pair(uint16_t pair, uint fg, uint bg);
1051uint64_t ui_get_channels_from_pair(uint16_t pair);
1052int ui_get_pair(uint16_t pair, uint *fg, uint *bg);
1053uint ui_init_color_hex(
char *s);
1054uint ui_add_pair(uint fg, uint bg);
1055uint ui_color_from_rgb(RGB *rgb);
1056uint ui_add_color_hex(
char *s);
1057int ui_pair_content(uint16_t pair, uint *fg, uint *bg);
1058int ui_wch_to_utf8(
const wchar_t fill_ch);
1059uint ui_get_plane_idx(UiSurface *s, NcPlane *n);
1060NcPlane *ui_ncplane_clicked(UiSurface *s, ss_t w, NcInput *ni);
1061struct ncvisual *ui_display_image(
struct notcurses *nc, UiMultiMedia *mm,
const char *image_file,
int y,
int x,
int begy,
int begx);
1062uint ui_mbstr_to_cellstr(UiSurface *sfc, ss_t w, UiCell *cmplx_buf,
const char *str,
const UiCell *cell_base, uint *pos,
const uint atmost);
1072#define ui_get_cell(sfc, w, cell, wstr, style, cp, opts)
1073 ui_get_nccell(sfc, w, cell, wstr, style, cp);
1079 const wchar_t *wstr,
1080 const UiStyle style,
1083#define ui_set_cell(sfc, w, cell, wstr, attr, cp, opts)
1084 ui_set_nccell(sfc, w, cell, wstr, attr, cp);
1090int ui_add_color(uint r, uint g, uint b);
1097int ui_getcchar(
const UiCell *cell, wchar_t *wstr, attr_t *attrs,
short *pair,
const void *opts);
1099int ui_setcchar(UiCell *cell,
const wchar_t *wstr,
const attr_t attrs,
short pair,
const void *opts);
1106uint
ui__mbstr_to_cellstr(UiCell *cmplx_buf,
const char *str,
const UiCell *cell_base, uint *pos,
const uint atmost);
1108#define ui_mbstr_to_cellstr(sfc, w, cmplx_buf, str, cell_base, pos, atmost)
1109 ui__mbstr_to_cellstr(cmplx_buf, str, cell_base, pos, atmost);
1111#define ui_get_cell(s, w, cell, wstr, attr, pair, opts)
1112 ui_getcchar(cell, wstr, attr, pair, nullptr);
1114#define ui_set_cell(s, w, cell, wstr, attrs, pair, nullptr)
1115 ui_setcchar(cell, wstr, attrs, pair, nullptr);
1119extern UiRuntime *
ui;
1139 UiCell cmplx_buf[
MAXLEN];
1141 struct UiSurface *sfc;
1156void ui_display_chyron(UiSurface *sfc, ss_t w, UiChyron *chyron, uint line, uint col);
1162int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev,
int timeout_ms);
1171void ui_log_write(
const UiLogLevel level,
const char *file,
const char *func,
const int line,
const char *fmt, ...);
1172#define ui_log(level, fmt, ...)
1174 if (level <= ui_log_ctx.min_level) {
1175 ui_log_write(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
bool str_to_bool(const char *)
Converts String to boolean true or false.
bool is_image_file(const char *filename)
char * fill_field(char *, char *, char, uint)
char * stdio_fdnames(char *, char *)
size_t strnz__pcat(char *d, size_t pos, const char *s, size_t max_len)
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 *)
UiSurface * ui_surface_box(UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
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.
#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)
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
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)
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_plane_cpy(NcPlane *dst, NcPlane *src, int dst_y, int dst_x, int src_y, int src_x, int ylen, int xlen)
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_immedok(UiSurface *s, ss_t w, bool enable)
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_surface_addwin(UiSurface *s, ss_t w, ss_t p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
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_surface_addpad(UiSurface *s, ss_t w, ss_t view_win, uint lines, uint cols, uint y, uint x, bool hidden)
Add a new pad to the specified UiSurface.
int ui_wshow(UiSurface *s, ss_t w)
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.
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_prefresh(UiSurface *s, ss_t w, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
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.
#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.
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.
int ui_mousemask(int mask)
Enable or disable mouse support.
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_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.
int ui_surface_hide(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
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.
const wchar_t * border_none
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).
int ui_border_draw(UiSurface *sfc, ss_t w)
void ui_deactivate_all_chyron_keys(UiChyron *chyron)
Deactivate all chyron keys.
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.
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.
const char * ui_sub_surface_str(ss_t w)
char * ui_iso8601_timestamp(char *buf, size_t n, bool local)
Generate an ISO 8601 timestamp string.
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.
int ui_cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
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.
const wchar_t * border_double
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.
int ui_border_ysplit_text(UiSurface *sfc, char *text_in, uint separator_line)
Draw a box with a separator line and text around the specified window.
const wchar_t * border_single
void ui_parse_ansi(char *ansi_str, attr_t *attrs, uint *cpx)
Parse ANSI escape sequences for color and attributes.
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
void ui_initialize_sio(SIO *sio)
int ui_border_title(UiSurface *sfc, ss_t w, const char *title)
Draw a box with a title around the specified window.
int ui_border_ysplit(UiSurface *sfc, ss_t w, uint y)
Draw a box with a separator line around the specified window.
int ui_tracked_sfc_box(uint wlines, uint wcols, uint wbegy, uint wbegx, const char *wtitle)
Create a new surface with a box window.
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 wchar_t * border_heavy
const wchar_t * border_rounded
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_open_log()
Open the log file for writing.
void ui_log_write(const UiLogLevel level, const char *file, const char *func, const int line, const char *fmt,...)
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.
#define ATTR_FORMAT(archetype, fmt_idx, first_arg)
#define LOG_LEVEL_LIST(X)
#define __atexit
This macro registers the end_pgm function to be called when the program exits.
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 *)
Check if a 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 *,...)
Custom safe string formatting utility (Variadic version).
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 *)
Check if a given path is a regular file.
bool expand_tilde(char *, uint)
Expand a tilde (~) in a file path to 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 *)
Check if a given path is a symbolic link that points 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.
size_t vssnprintf(char *buf, size_t buf_size, const char *format, va_list args)
Custom safe string formatting utility (va_list version).
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 *)
Convert a string to an unsigned long with optional size suffixes.
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.
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]
char provider_cmd[MAXLEN]
char stripped_line_out[PAD_COLS+1]
char ln_bg_clr_x[COLOR_LEN]
char line_in_s[PAD_COLS+1]
char * next_file_spec_ptr
char line_out_s[PAD_COLS+1]
char receiver_cmd[MAXLEN]
UiCell cmplx_buf[PAD_COLS+1]
char tmp_prompt_str[MAXLEN]
char cur_file_str[MAXLEN]
bool f_selected[OBJ_MAXCNT]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
UiMouseAction mouse_action
ext_fd_reg_t ext_fds[MAX_EXT_FDS]
char * color[LOG_LEVEL_COUNT]
char * level[LOG_LEVEL_COUNT]
UiBorderStyle border_style