C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
ui_common.c File Reference
#include "cm.h"
#include "ui_backend.h"
#include <fcntl.h>
#include <iso646.h>
#include <math.h>
#include <poll.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <wchar.h>
Include dependency graph for ui_common.c:

Go to the source code of this file.

Macros

#define AS_STRING(NAME)
#define AS_STRING(NAME)

Functions

void ui_abend (int ec, char *s)
 Convert multibyte string to complex character array.
bool ui_action_disposition (char *title, char *action_str)
 Display a simple action disposition message window or print to stderr.
void ui_activate_all_chyron_keys (UiChyron *chyron)
 Deactivate chyron key.
void ui_activate_chyron_key (UiChyron *chyron, uint k)
 Activate chyron key.
int ui_answer_yn (char *msg0, char *msg1, char *msg2, char *msg3)
 Accept a single letter answer.
void ui_apply_gamma (RGB *rgb)
 Apply gamma correction to RGB color.
int ui_assign_chyron_win (UiChyron *chyron, UiSurface *sfc, ss_t w, char *y)
 Assign surface and window to chyron structure.
int ui_border_draw (UiSurface *sfc)
int ui_border_title (UiSurface *sfc, const char *title)
 Draw a box with a title around the specified window.
int ui_border_ysplit (UiSurface *sfc, uint y)
 Draw a box with a separator line around the specified window.
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.
int ui_cm_surface_destroy (UiSurface *sfc)
 Destroy the most recently created surface.
void ui_compile_chyron (UiChyron *chyron)
 construct the chyron string from the chyron structure
void ui_deactivate_all_chyron_keys (UiChyron *chyron)
 Deactivate all chyron keys.
void ui_deactivate_chyron_key (UiChyron *chyron, uint k)
 Deactivate chyron key.
UiChyron * ui_destroy_chyron (UiChyron *chyron)
 Destroy UiChyron structure.
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.
int ui_display_error (char *msg0, char *msg1, char *msg2, char *msg3)
 Display an error message window or print to stderr.
int ui_get_chyron_key (UiChyron *chyron, uint x)
 Get keycode from chyron.
bool ui_init_clr_palette (SIO *sio)
void ui_initialize_sio (SIO *sio)
bool ui_is_set_chyron_key (UiChyron *chyron, uint k)
 Check if function key label is set.
char * ui_iso8601_timestamp (char *buf, size_t n, bool local)
 Generate an ISO 8601 timestamp string.
void ui_mbc_to_wc (wchar_t wc[2], const char mbc)
 Convert a multibyte character to a wide character.
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.
FILE * ui_open_log ()
 Open the log file for writing.
void ui_parse_ansi (char *ansi_str, attr_t *attr, uint *cpx)
 Parse ANSI escape sequences for color and attributes.
int ui_perror (char *emsg_str)
 Display a simple error message window or print to stderr.
int ui_poll_reg_read_fd (int timeout_ms)
 Poll for input on registered external files.
void ui_register_read_fd (int fd, int token_id)
 Register an external file descriptor for polling.
uint ui_rgb_to_xterm256_idx (RGB *rgb)
 Convert RGB color to XTerm 256 color index.
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_set_chyron_key_cb (UiChyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
 Set chyron key with color pair (cp).
const char * ui_sub_surface_str (ss_t w)
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_tracked_sfc_box (uint wlines, uint wcols, uint wbegy, uint wbegx, const char *wtitle)
 Create a new surface with a box window.
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.
void ui_unregister_read_fd (int fd)
 Unregister an external file descriptor from polling.
void ui_unset_chyron_key (UiChyron *chyron, uint k)
 Unset chyron key.
int ui_update_timeout_prompt (UiSurface *sfc, ss_t w, uint timeout_ms)
 Update the timeout prompt with the remaining time.
RGB ui_xterm256_idx_to_rgb (uint idx)
 Convert XTerm 256 color index to RGB.

Variables

double BLUE_GAMMA = 1.2
const wchar_t * border_double = L"═║╠╣╦╩╬╔╗╚╝"
const wchar_t * border_heavy = L"━┃┣┫┳┻╋┏┓┗┛"
const wchar_t * border_none = L" "
const wchar_t * border_rounded = L"─│├┤┬┴┼╭╮╰╯"
const wchar_t * border_single = L"─│├┤┬┴┼┌┐└┘"
uint16_t box_attr
BorderWide bw
const wchar_t * bw_chk = L"\u2611"
const wchar_t * bw_da = L"\u2193"
const wchar_t * bw_h09 = L"\u23BD"
const wchar_t * bw_la = L"\u2190"
const wchar_t * bw_lan = L"\u276E"
const wchar_t * bw_ra = L"\u2192"
const wchar_t * bw_ran = L"\u276F"
const wchar_t * bw_rbl = L"\u2570"
const wchar_t * bw_rbr = L"\u256f"
const wchar_t * bw_rtl = L"\u256d"
const wchar_t * bw_rtr = L"\u256e"
const wchar_t * bw_sp = L"\x20"
const wchar_t * bw_ua = L"\u2191"
UiCell cell_bl
UiCell cell_box
UiCell cell_br
UiCell cell_brktl
UiCell cell_brktr
UiCell cell_bs
UiCell cell_bt
UiCell cell_chk
UiCell cell_cmdln
UiCell cell_cr
UiCell cell_default
UiCell cell_fill_char
UiCell cell_ho
UiCell cell_ind
UiCell cell_ln
UiCell cell_ls
UiCell cell_lt
UiCell cell_nt
UiCell cell_nt_hl
UiCell cell_nt_hl_rev
UiCell cell_nt_rev
UiCell cell_ran
UiCell cell_rs
UiCell cell_rt
UiCell cell_sp
UiCell cell_title
UiCell cell_tl
UiCell cell_tr
UiCell cell_ts
UiCell cell_tt
UiCell cell_ve
int click_x
int click_y
unsigned int cmd_key
char const colors_text [][10]
 Color names for .minitrc overrides.
ushort cp_blue
ushort cp_box
ushort cp_brackets
ushort cp_cmdln
ushort cp_default
ushort cp_fill_char
ushort cp_green
ushort cp_ind
ushort cp_ln
ushort cp_nt
ushort cp_nt_hl
ushort cp_nt_hl_rev
ushort cp_nt_rev
ushort cp_red
ushort cp_title
ushort cp_yellow
char em0 [MAXLEN]
char em1 [MAXLEN]
char em2 [MAXLEN]
char em3 [MAXLEN]
int exit_code
bool f_ncurses_open = false
bool f_notcurses_open = false
bool f_sigwench = false
char fn [MAXLEN]
double GRAY_GAMMA = 1.2
double GREEN_GAMMA = 1.2
uint m_begx = -1
uint m_begy = -1
uint m_cols
uint m_lines
uint mouse_support
int pipe_in
int pipe_out
double RED_GAMMA = 1.2
uint src_line
char * src_name
STDRGB std_color []
int stderr_fd
int stdin_fd
int stdout_fd
const char * subsfc_s []
int tty_fd
ui_context_t ui_ctx
char ui_log_file_name [MAXLEN] = "/tmp/ui.log"
FILE * ui_log_fp = NULL
const char *const ui_log_level_s []
const char *const ui_logcolor []
UiLogLevel ui_min_log_level = INFO
char ui_timestamp [32]
bool ui_timestamp_local = true
uint16_t win_attr

Macro Definition Documentation

◆ AS_STRING [1/2]

#define AS_STRING ( NAME)
Value:
#NAME,

Definition at line 1365 of file ui_common.c.

◆ AS_STRING [2/2]

#define AS_STRING ( NAME)
Value:
#NAME,

Definition at line 1365 of file ui_common.c.

Function Documentation

◆ ui_abend()

void ui_abend ( int ec,
char * s )

Convert multibyte string to complex character array.

ui_mbstr_to_cellstr

Parameters
cmplx_bufOutput buffer for complex characters
strInput multibyte string
cell_baseBase cell for attributes and color pair
pPointer to current position in the output buffer, updated as characters are added
atmostMaximum length of the output buffer
Returns
Number of bytes processed from the input string

This function converts a multibyte string to an array of complex characters (cchar_t) that can be used with NCurses functions. It handles multibyte characters and applies the attributes and color pair from the base cell to each character. The p parameter is updated to reflect the current position in the output buffer, and the function ensures that it does not exceed the maximum length specified by atmost. ui_abend

Handle abnormal termination of the program

Parameters
ecExit code to return to the operating system
sMessage describing the reason for termination

This function is called when the program encounters a critical error that requires it to terminate. It performs necessary cleanup, restores terminal settings, and outputs an error message to stderr before exiting with the specified exit code.

Definition at line 362 of file ui_common.c.

362 {
363 ui_shutdown();
365 sig_dfl_mode();
366 fprintf(stderr, _("\n\nABEND: %s (code: %d)\n"), s, ec);
367 exit(EXIT_FAILURE);
368}
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
Definition ui_ncurses.c:418
#define _(String)
Definition amort.c:23
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
Definition scriou.c:57
void sig_dfl_mode()
Set signal handlers to default behavior.
Definition sig.c:41

References restore_shell_tioctl(), sig_dfl_mode(), and ui_shutdown().

Referenced by form_parse_desc(), init_menu_files(), init_pick(), mapp_initialization(), new_form(), new_init(), new_menu(), new_pick(), new_view(), parse_menu_description(), sig_prog_mode(), signal_handler(), ui_answer_yn(), ui_display_error(), ui_new_chyron(), ui_timeout_prompt(), and view_init_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_activate_all_chyron_keys()

void ui_activate_all_chyron_keys ( UiChyron * chyron)

Deactivate chyron key.

deactivate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 750 of file ui_common.c.

750 {
751 for (int k = 0; k < CHYRON_KEYS; k++)
752 chyron->key[k]->active = true;
753}
#define CHYRON_KEYS
Definition ui_backend.h:50

◆ ui_activate_chyron_key()

void ui_activate_chyron_key ( UiChyron * chyron,
uint k )

Activate chyron key.

activate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 741 of file ui_common.c.

741 {
742 chyron->key[k]->active = true;
743}

◆ ui_apply_gamma()

void ui_apply_gamma ( RGB * rgb)

Apply gamma correction to RGB color.

ui_apply_gamma

Parameters
rgbPointer to RGB color

This function modifies the RGB color in place. It applies gamma correction to the RGB color based on the gamma values set in the SIO struct. If the color is a shade of gray, it applies the gray gamma correction. Otherwise, it applies the individual red, green, and blue gamma corrections.

Definition at line 941 of file ui_common.c.

941 {
942 if (rgb->r == rgb->g && rgb->r == rgb->b) {
943 if (GRAY_GAMMA > 0.0f && GRAY_GAMMA != 1.0f) {
944 rgb->r = (int)(pow((rgb->r / 255.0f), 1.0f / GRAY_GAMMA) * 255.0f);
945 rgb->g = rgb->r;
946 rgb->b = rgb->r;
947 }
948 return;
949 }
950 if (rgb->r != 0 && RED_GAMMA > 0.0f && RED_GAMMA != 1.0f)
951 rgb->r = (int)(pow((rgb->r / 255.0f), 1.0f / RED_GAMMA) * 255.0f);
952 if (rgb->g != 0 && GREEN_GAMMA > 0.0f && GREEN_GAMMA != 1.0f)
953 rgb->g = (int)(pow((rgb->g / 255.0f), 1.0f / GREEN_GAMMA) * 255.0f);
954 if (rgb->b != 0 && BLUE_GAMMA > 0.0f && BLUE_GAMMA != 1.0f)
955 rgb->b = (int)(pow((rgb->b / 255.0f), 1.0f / BLUE_GAMMA) * 255.0f);
956}
double BLUE_GAMMA
Definition ui_common.c:65
double GRAY_GAMMA
Definition ui_common.c:62
double RED_GAMMA
Definition ui_common.c:63
double GREEN_GAMMA
Definition ui_common.c:64
uint8_t b
Definition ui_backend.h:308
uint8_t r
Definition ui_backend.h:308
uint8_t g
Definition ui_backend.h:308

References BLUE_GAMMA, GRAY_GAMMA, GREEN_GAMMA, and RED_GAMMA.

Referenced by ui_chg_color(), ui_color_from_rgb(), and ui_init_color_hex().

Here is the caller graph for this function:

◆ ui_assign_chyron_win()

int ui_assign_chyron_win ( UiChyron * chyron,
UiSurface * sfc,
ss_t w,
char * y )

Assign surface and window to chyron structure.

assign_chyron_win

Parameters
chyronpointer to UiChyron structure
sfcpointer to UiSurface structure
winwindow index (WIN or BOX)
yline number for chyron display
Returns
0 on success, -1 on error

This function assigns the specified surface and window to the chyron structure. It also sets the line number for displaying the chyron. If the input string y is "-", it sets the line number to the last line of the surface. Otherwise, it converts the string y to an integer and sets it as the line number, ensuring it does not exceed the maximum line number of the surface.

Note
Drop-down menus from the chyron will be added in the future

Definition at line 634 of file ui_common.c.

634 {
635 bool a_toi_error = false;
636 if (!sfc)
637 return -1;
638 chyron->sfc = sfc;
639 chyron->w = w;
640 if (*y == '-')
641 chyron->y = ui_getmaxy(sfc, w) - 1;
642 else {
643 chyron->y = a_toi(y, &a_toi_error);
644 if (a_toi_error)
645 return -1;
646 chyron->y = min(chyron->y, ui_getmaxy(sfc, w) - 1);
647 }
648 return 0;
649}
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:104
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
Definition ui_ncurses.c:701
int a_toi(char *, bool *)
a safer alternative to atoi() for converting ASCII strings to integers.
Definition futil.c:784

References a_toi(), and ui_getmaxy().

Here is the call graph for this function:

◆ ui_border_draw()

int ui_border_draw ( UiSurface * sfc)

Definition at line 474 of file ui_common.c.

474 {
475 uint maxy = ui_getmaxy(sfc, BOX);
476 uint maxx = ui_getmaxx(sfc, BOX);
477 uint y = 0;
478 uint x = 0;
479 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_tl, 1);
480 for (x = 1; x < maxx - 1; x++)
481 ui_mvwadd_wchnstr(sfc, BOX, y, x, &cell_ho, 1);
482 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_tr, 1);
483 for (y = 1; y < maxy - 1; y++) {
484 ui_mvwadd_wchnstr(sfc, BOX, y, 0, &cell_ve, 1);
485 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_ve, 1);
486 }
487 ui_mvwadd_wchnstr(sfc, BOX, y, 0, &cell_bl, 1);
488 for (x = 1; x < maxx - 1; x++)
489 ui_mvwadd_wchnstr(sfc, BOX, y, x, &cell_ho, 1);
490 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_br, 1);
491 return 0;
492}
UiCell cell_ve
Definition ui_common.c:124
UiCell cell_tr
Definition ui_common.c:122
UiCell cell_br
Definition ui_common.c:126
UiCell cell_tl
Definition ui_common.c:121
UiCell cell_ho
Definition ui_common.c:123
int ui_getmaxx(UiSurface *s, ss_t w)
Get the maximum number of columns of a UiSurface.
Definition ui_ncurses.c:712
UiCell cell_bl
Definition ui_common.c:125
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.

References cell_bl, cell_br, cell_ho, cell_tl, cell_tr, cell_ve, ui_getmaxx(), ui_getmaxy(), and ui_mvwadd_wchnstr().

Referenced by ui_surface_box(), and ui_surface_box().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_border_title()

int ui_border_title ( UiSurface * sfc,
const char * title )

Draw a box with a title around the specified window.

border_title

Parameters
boxPointer to the window to draw the box around
titleTitle text to display at the top of the box

This function draws a box around the specified window, similar to border_draw(), but it also includes a title at the top of the box. The title is displayed in the center of the top edge of the box, and the horizontal line is drawn on either side of the title. Use this function when you want to visually label a window with a title.

Definition at line 563 of file ui_common.c.

563 {
564 if (!title || !*title)
565 return 0;
566 uint y = 0;
567 uint x = 0;
568 uint l;
569 uint maxx = ui_getmaxx(sfc, BOX);
570 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_tl, 1);
571 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_rt, 1);
572 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_sp, 1);
573 wchar_t *title_wc;
574 title_wc = ui_mbstr_to_wcstr(title);
575 l = wcswidth(title_wc, wcslen(title_wc));
576 l = min(l, maxx - 7);
577 ui_bkgdset(sfc, BOX, &cell_title);
578 ui_mvwaddnwstr(sfc, BOX, y, x, title_wc, l);
579 ui_bkgdset(sfc, BOX, &cell_box);
580 x += l;
581 free(title_wc);
582 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_sp, 1);
583 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_lt, 1);
584 while (x < maxx - 1) {
585 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_ho, 1);
586 }
587 return 0;
588}
UiCell cell_sp
Definition ui_common.c:132
UiCell cell_lt
Definition ui_common.c:127
UiCell cell_title
Definition ui_common.c:113
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.
Definition ui_ncurses.c:941
UiCell cell_box
Definition ui_common.c:110
UiCell cell_rt
Definition ui_common.c:128
wchar_t * ui_mbstr_to_wcstr(const char *mb_str)
Convert a multibyte string to a wide character string.
Definition ui_common.c:322
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.

References cell_box, cell_ho, cell_lt, cell_rt, cell_sp, cell_title, cell_tl, ui_bkgdset(), ui_getmaxx(), ui_mbstr_to_wcstr(), ui_mvwadd_wchnstr(), and ui_mvwaddnwstr().

Referenced by new_view_file(), ui_surface_box(), ui_surface_box(), view_boxwin_resize(), and view_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_border_ysplit()

int ui_border_ysplit ( UiSurface * sfc,
uint y )

Draw a box with a separator line around the specified window.

ui_border-ysplit

Parameters
boxPointer to the window to draw the box around
yLine number where the separator line should be drawn

This function draws a box around the specified window, similar to border_draw(), but it also includes a horizontal separator line that divides the box into two sections. The separator line is drawn at a fixed position (line 00, page 00) and extends across the width of the box. Use this function when you want to visually separate two sections within a window, such as for a header and content area.

Definition at line 504 of file ui_common.c.

504 {
505 uint maxx = ui_getmaxx(sfc, BOX);
506 ui_mvwadd_wchnstr(sfc, BOX, y, 0, &cell_lt, 1);
507 for (uint x = 1; x < maxx - 1; x++)
508 ui_mvwadd_wchnstr(sfc, BOX, y, x, &cell_ho, 1);
509 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_rt, 1);
510 return 0;
511}

References cell_ho, cell_lt, cell_rt, ui_getmaxx(), and ui_mvwadd_wchnstr().

Referenced by ui_tracked_sfc_split_box().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_border_ysplit_text()

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.

ui_border_ysplit_text

Parameters
boxPointer to the window to draw the box around
textText to display in the middle of the separator line
separator_lineLine number where the separator line should be drawn

This function draws a box around the specified window, similar to border_draw(), but it also includes a horizontal separator line that divides the box into two sections. The separator line is drawn at the specified line number and extends across the width of the box, with the provided text displayed in the middle of the line. Use this function when you want to visually separate two sections within a window and label the separator with descriptive text.

Definition at line 524 of file ui_common.c.

524 {
525 char text[MAXLEN];
526 uint maxx = ui_getmaxx(sfc, BOX);
527 uint l;
528 uint y = separator_line;
529 uint x = 0;
530 // Draw the horizontal line with text in the middle, so we start by drawing
531 // the left edge, then the text, then the right edge, and finally fill in the
532 // horizontal line on either side of the text.
533 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_lt, 1);
534 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_ho, 1);
535 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_rt, 1);
536 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_sp, 1);
537 strnz__cpy(text, text_in, maxx - 7);
538 wchar_t *text_wc;
539 text_wc = ui_mbstr_to_wcstr(text);
540 l = wcswidth(text_wc, wcslen(text_wc));
541 ui_bkgdset(sfc, BOX, &cell_nt_hl);
542 ui_mvwaddnwstr(sfc, BOX, y, x, text_wc, l);
543 x += l;
544 l = min(l, maxx - 7);
545 free(text_wc);
546 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_sp, 1);
547 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_lt, 1);
548 while (x < maxx - 1)
549 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_ho, 1);
550 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_rt, 1);
551 return 0;
552}
UiCell cell_nt_hl
Definition ui_common.c:108
#define MAXLEN
Definition curskeys.c:15
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition whence.c:291

References cell_ho, cell_lt, cell_nt_hl, cell_rt, cell_sp, strnz__cpy(), ui_bkgdset(), ui_getmaxx(), ui_mbstr_to_wcstr(), ui_mvwadd_wchnstr(), and ui_mvwaddnwstr().

Referenced by picker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_cm_surface_destroy()

int ui_cm_surface_destroy ( UiSurface * sfc)

Destroy the most recently created surface.

ui_cm_destroy_surface

Returns
0 on success, -1 if no surfaces exist

This function destroys the most recently created surface and decrements the surface pointer. It should be called when a surface is no longer needed to free up resources. If there are no surfaces to destroy, it returns -1.

Note
The difference between this function and ui_surface_destroy() is that this function destroys the surface pointed to by the surface pointer (sfc_ptr) and decrements the surface pointer after destroying the surface.

Definition at line 466 of file ui_common.c.

466 {
468 sfc_ptr--;
469 return 0;
470}
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
Definition ui_ncurses.c:468
int sfc_ptr
Definition ui_ncurses.c:42

References sfc_ptr, and ui_surface_destroy().

Referenced by init_form(), init_pick(), menu_engine(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_compile_chyron()

void ui_compile_chyron ( UiChyron * chyron)

construct the chyron string from the chyron structure

compile_chyron

Parameters
chyron

The chyron string is constructed by concatenating the labels of the set keys, separated by _(" | "). The end_pos values for each key are set to determine the zones for mouse clicks. When a mouse click occurs, the get_chyron_key function uses the end_pos values to determine which key was clicked based on the X position of the click.

Definition at line 782 of file ui_common.c.

782 {
783 uint end_pos = 0;
784 uint k = 0;
785 uint pos = 0;
786 UiCell cell_base = cell_nt_rev;
787 UiCell *cx;
788 char tmp_str[MAXLEN];
789 while (k < CHYRON_KEYS) {
790 if (chyron->key[k]->text[0] == '\0' || !chyron->key[k]->active) {
791 k++;
792 continue;
793 }
794 cell_base = chyron->key[k]->cell_base;
795 if (end_pos == 0) {
796 cx = chyron->cmplx_buf;
797 ui_mbstr_to_cellstr(chyron->sfc, chyron->w,
798 cx,
799 " ",
800 &cell_base,
801 &pos,
802 MAXLEN - 1);
803 } else {
804 ui_mbstr_to_cellstr(chyron->sfc, chyron->w,
805 chyron->cmplx_buf,
806 "|",
807 &cell_base,
808 &pos,
809 MAXLEN - 1);
810 }
811 cx = chyron->cmplx_buf;
812 ui_mbstr_to_cellstr(chyron->sfc, chyron->w, cx, chyron->key[k]->text, &cell_base, &pos, MAXLEN - 1);
813 end_pos = pos;
814 chyron->l = end_pos;
815 chyron->key[k]->end_pos = end_pos;
816 ssnprintf(tmp_str, MAXLEN - 1, _("k=%d, text=%s, end_pos=%d"), k,
817 chyron->key[k]->text, chyron->key[k]->end_pos);
818 k++;
819 }
820 ui_mbstr_to_cellstr(chyron->sfc, chyron->w, chyron->cmplx_buf, " ", &cell_base, &pos, MAXLEN - 1);
821 chyron->l = end_pos;
822}
UiCell cell_nt_rev
Definition ui_common.c:107
uint ui_mbstr_to_cellstr(UiSurface *sfc, ss_t w, UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost)
Convert multibyte string to complex character array (Notcurses version).
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:390

References cell_nt_rev, and ssnprintf().

Referenced by field_editor(), form_engine(), form_post(), form_process(), open_pick_win(), picker(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_deactivate_all_chyron_keys()

void ui_deactivate_all_chyron_keys ( UiChyron * chyron)

Deactivate all chyron keys.

deactivate_all_chyron_keys

Parameters
chyronstructure

Definition at line 768 of file ui_common.c.

768 {
769 for (int k = 0; k < CHYRON_KEYS; k++)
770 chyron->key[k]->active = false;
771}

◆ ui_deactivate_chyron_key()

void ui_deactivate_chyron_key ( UiChyron * chyron,
uint k )

Deactivate chyron key.

deactivate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 760 of file ui_common.c.

760 {
761 chyron->key[k]->active = false;
762}

◆ ui_destroy_chyron()

UiChyron * ui_destroy_chyron ( UiChyron * chyron)

Destroy UiChyron structure.

destroy_chyron

Parameters
chyronpointer to UiChyron structure
Returns
nullptr

Definition at line 656 of file ui_common.c.

656 {
657 uint i;
658
659 if (!chyron)
660 return nullptr;
661 for (i = 0; i < CHYRON_KEYS; i++) {
662 if (chyron->key[i]) {
663 free(chyron->key[i]);
664 chyron->key[i] = nullptr;
665 }
666 }
667 free(chyron);
668 chyron = nullptr;
669 return chyron;
670}

Referenced by init_form(), pick_engine(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the caller graph for this function:

◆ ui_display_chyron()

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.

display_chyron

Parameters
sfcPointer to the UiSurface structure
wWindow index (WIN or BOX)
chyronPointer to the UiChyron structure
lineLine number where the chyron should be displayed
colColumn number where the chyron should start

This function displays the compiled chyron string on the specified line and column of the given surface. It first moves the cursor to the specified position, clears to the end of the line, and then writes the chyron string. Finally, it moves the cursor back to the specified column for user input.

Definition at line 837 of file ui_common.c.

837 {
838 chyron->y = line;
839 ui_wmove(sfc, w, line, 0);
840 ui_wclrtoeol(sfc, w);
841 ui_wmove(sfc, w, line, 0);
842 ui_mvwadd_wchstr(sfc, w, line, 0, chyron->cmplx_buf);
843 ui_wmove(sfc, w, line, col);
844 return;
845}
int ui_wmove(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
Definition ui_ncurses.c:653
int ui_wclrtoeol(UiSurface *s, ss_t w)
Clear to the end of the line in a surface window.
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.

References ui_mvwadd_wchstr(), ui_wclrtoeol(), and ui_wmove().

Referenced by field_editor(), form_engine(), form_post(), form_process(), picker(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_get_chyron_key()

int ui_get_chyron_key ( UiChyron * chyron,
uint x )

Get keycode from chyron.

get_chyron_key

Parameters
chyronstructure
xMouse X position
Returns
Keycode

This function uses the end_pos values set in compile_chyron to determine which key was clicked. The chyron functions provide xwgetch() with a mechanism to translate mouse click positions into key codes based on the labels set in the chyron structure. When a mouse click occurs, xwgetch() can call get_chyron_key() with the X position of the click to determine which function key was clicked, allowing for dynamic and customizable function key behavior in the chyron area of the interface.

Definition at line 861 of file ui_common.c.

861 {
862 uint i = 0;
863 uint k = -1;
864 while (i < CHYRON_KEYS - 1) {
865 if (chyron->key[i]->text[0] != '\0' && chyron->key[i]->active)
866 if (chyron->key[i]->end_pos >= x) {
867 k = i;
868 break;
869 }
870 i++;
871 }
872 return chyron->key[k]->keycode;
873}

Referenced by field_editor(), form_post(), form_process(), picker(), and ui_get_event().

Here is the caller graph for this function:

◆ ui_init_clr_palette()

bool ui_init_clr_palette ( SIO * sio)

Definition at line 247 of file ui_common.c.

247 {
249 ui_chg_color(CLR_RED, &sio->red);
252 ui_chg_color(CLR_BLUE, &sio->blue);
254 ui_chg_color(CLR_CYAN, &sio->cyan);
257 ui_chg_color(CLR_BRED, &sio->bred);
265 ui_chg_color(CLR_FG, &sio->fg);
266 ui_chg_color(CLR_BG, &sio->bg);
287 return true;
288}
@ CLR_FILL_CHAR_BG
Definition ui_backend.h:532
@ CLR_BOX_BG
Definition ui_backend.h:526
@ CLR_FILL_CHAR_FG
Definition ui_backend.h:531
@ CLR_FG
Definition ui_backend.h:523
@ CLR_RED
Definition ui_backend.h:507
@ CLR_NT_FG
Definition ui_backend.h:537
@ CLR_BRACKETS_FG
Definition ui_backend.h:529
@ CLR_YELLOW
Definition ui_backend.h:509
@ CLR_IND_FG
Definition ui_backend.h:527
@ CLR_BCYAN
Definition ui_backend.h:520
@ CLR_WHITE
Definition ui_backend.h:513
@ CLR_MAGENTA
Definition ui_backend.h:511
@ CLR_BRACKETS_BG
Definition ui_backend.h:530
@ CLR_NT_REV_BG
Definition ui_backend.h:540
@ CLR_BLACK
Definition ui_backend.h:506
@ CLR_BWHITE
Definition ui_backend.h:521
@ CLR_LN_BG
Definition ui_backend.h:534
@ CLR_NT_HL_REV_BG
Definition ui_backend.h:544
@ CLR_BBLACK
Definition ui_backend.h:514
@ CLR_LN_FG
Definition ui_backend.h:533
@ CLR_NT_HL_FG
Definition ui_backend.h:541
@ CLR_BBLUE
Definition ui_backend.h:518
@ CLR_BGREEN
Definition ui_backend.h:516
@ CLR_BYELLOW
Definition ui_backend.h:517
@ CLR_BMAGENTA
Definition ui_backend.h:519
@ CLR_BORANGE
Definition ui_backend.h:522
@ CLR_NT_HL_BG
Definition ui_backend.h:542
@ CLR_NT_HL_REV_FG
Definition ui_backend.h:543
@ CLR_BG
Definition ui_backend.h:524
@ CLR_BOX_FG
Definition ui_backend.h:525
@ CLR_NT_BG
Definition ui_backend.h:538
@ CLR_TITLE_BG
Definition ui_backend.h:546
@ CLR_BRED
Definition ui_backend.h:515
@ CLR_NCOLORS
Definition ui_backend.h:547
@ CLR_BLUE
Definition ui_backend.h:510
@ CLR_IND_BG
Definition ui_backend.h:528
@ CLR_GREEN
Definition ui_backend.h:508
@ CLR_NT_REV_FG
Definition ui_backend.h:539
@ CLR_CYAN
Definition ui_backend.h:512
uint ui_color_cnt
Definition ui_ncurses.c:43
int ui_chg_color(uint16_t color_idx, uint32_t *color)
Change the RGB color value for a given color index.
uint32_t ln_bg
Definition ui_backend.h:726
uint32_t magenta
Definition ui_backend.h:701
uint32_t nt_hl_rev_fg
Definition ui_backend.h:735
uint32_t bgreen
Definition ui_backend.h:707
uint32_t green
Definition ui_backend.h:698
uint32_t nt_fg
Definition ui_backend.h:729
uint32_t yellow
Definition ui_backend.h:699
uint32_t fill_char_fg
Definition ui_backend.h:723
uint32_t box_fg
Definition ui_backend.h:717
uint32_t ln_fg
Definition ui_backend.h:725
uint32_t ind_bg
Definition ui_backend.h:720
uint32_t bmagenta
Definition ui_backend.h:710
uint32_t ind_fg
Definition ui_backend.h:719
uint32_t byellow
Definition ui_backend.h:708
uint32_t bblue
Definition ui_backend.h:709
uint32_t borange
Definition ui_backend.h:713
uint32_t title_bg
Definition ui_backend.h:738
uint32_t fg
Definition ui_backend.h:715
uint32_t cyan
Definition ui_backend.h:702
uint32_t bblack
Definition ui_backend.h:705
uint32_t red
Definition ui_backend.h:697
uint32_t nt_hl_rev_bg
Definition ui_backend.h:736
uint32_t bred
Definition ui_backend.h:706
uint32_t fill_char_bg
Definition ui_backend.h:724
uint32_t black
Definition ui_backend.h:696
uint32_t nt_rev_bg
Definition ui_backend.h:732
uint32_t brackets_bg
Definition ui_backend.h:722
uint32_t bcyan
Definition ui_backend.h:711
uint32_t nt_bg
Definition ui_backend.h:730
uint32_t blue
Definition ui_backend.h:700
uint32_t brackets_fg
Definition ui_backend.h:721
uint32_t white
Definition ui_backend.h:703
uint32_t box_bg
Definition ui_backend.h:718
uint32_t nt_hl_fg
Definition ui_backend.h:733
uint32_t bwhite
Definition ui_backend.h:712
uint32_t nt_rev_fg
Definition ui_backend.h:731
uint32_t nt_hl_bg
Definition ui_backend.h:734
uint32_t bg
Definition ui_backend.h:716

References SIO::bblack, SIO::bblue, SIO::bcyan, SIO::bg, SIO::bgreen, SIO::black, SIO::blue, SIO::bmagenta, SIO::borange, SIO::box_bg, SIO::box_fg, SIO::brackets_bg, SIO::brackets_fg, SIO::bred, SIO::bwhite, SIO::byellow, CLR_BBLACK, CLR_BBLUE, CLR_BCYAN, CLR_BG, CLR_BGREEN, CLR_BLACK, CLR_BLUE, CLR_BMAGENTA, CLR_BORANGE, CLR_BOX_BG, CLR_BOX_FG, CLR_BRACKETS_BG, CLR_BRACKETS_FG, CLR_BRED, CLR_BWHITE, CLR_BYELLOW, CLR_CYAN, CLR_FG, CLR_FILL_CHAR_BG, CLR_FILL_CHAR_FG, CLR_GREEN, CLR_IND_BG, CLR_IND_FG, CLR_LN_BG, CLR_LN_FG, CLR_MAGENTA, CLR_NCOLORS, CLR_NT_BG, CLR_NT_FG, CLR_NT_HL_BG, CLR_NT_HL_FG, CLR_NT_HL_REV_BG, CLR_NT_HL_REV_FG, CLR_NT_REV_BG, CLR_NT_REV_FG, CLR_RED, CLR_TITLE_BG, CLR_WHITE, CLR_YELLOW, SIO::cyan, SIO::fg, SIO::fill_char_bg, SIO::fill_char_fg, SIO::green, SIO::ind_bg, SIO::ind_fg, SIO::ln_bg, SIO::ln_fg, SIO::magenta, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, SIO::red, SIO::title_bg, ui_chg_color(), ui_color_cnt, SIO::white, and SIO::yellow.

Referenced by ui_initialize_sio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_initialize_sio()

void ui_initialize_sio ( SIO * sio)

gamma correction values

These are read from ~/.minitrc

used when initializing colors

Definition at line 182 of file ui_common.c.

182 {
186 ui->sio = sio;
187 RED_GAMMA = sio->red_gamma;
189 BLUE_GAMMA = sio->blue_gamma;
190 GRAY_GAMMA = sio->gray_gamma;
192 //
193 // Initialize Standardized color pairs
194 //
211 //
212 // Initialize Standardized UiCells
213 //
216 mbstate_t mbstate;
217 memset(&mbstate, 0, sizeof(mbstate));
218 wchar_t brktl = sio->brackets[0];
219 cell_brktl = ui_cell_from_ucp(&brktl, &sio->brackets_fg, &sio->brackets_bg);
220 wchar_t brktr = sio->brackets[1];
221 cell_brktr = ui_cell_from_ucp(&brktr, &sio->brackets_fg, &sio->brackets_bg);
222 cell_nt = ui_cell_from_ucp(bw_sp, &sio->nt_fg, &sio->nt_bg);
229 cell_ln = ui_cell_from_ucp(bw_sp, &sio->ln_fg, &sio->ln_bg);
233 cell_tl = ui_cell_from_ucp(&bw_tl, &sio->box_fg, &sio->box_bg);
234 cell_tr = ui_cell_from_ucp(&bw_tr, &sio->box_fg, &sio->box_bg);
235 cell_bl = ui_cell_from_ucp(&bw_bl, &sio->box_fg, &sio->box_bg);
236 cell_br = ui_cell_from_ucp(&bw_br, &sio->box_fg, &sio->box_bg);
237 cell_ho = ui_cell_from_ucp(&bw_ho, &sio->box_fg, &sio->box_bg);
238 cell_ve = ui_cell_from_ucp(&bw_ve, &sio->box_fg, &sio->box_bg);
239 cell_lt = ui_cell_from_ucp(&bw_lt, &sio->box_fg, &sio->box_bg);
240 cell_rt = ui_cell_from_ucp(&bw_rt, &sio->box_fg, &sio->box_bg);
241 cell_tt = ui_cell_from_ucp(&bw_tt, &sio->box_fg, &sio->box_bg);
242 cell_bt = ui_cell_from_ucp(&bw_bt, &sio->box_fg, &sio->box_bg);
243 cell_cr = ui_cell_from_ucp(&bw_cr, &sio->box_fg, &sio->box_bg);
244 cell_sp = ui_cell_from_ucp(bw_sp, &sio->box_fg, &sio->box_bg);
245}
#define bw_ho
Definition ui_backend.h:581
const wchar_t * bw_sp
Definition ui_common.c:79
ushort cp_nt
Definition ui_common.c:142
UiCell cell_nt
Definition ui_common.c:106
const wchar_t * bw_ran
Definition ui_common.c:84
UiCell cell_nt_hl_rev
Definition ui_common.c:109
UiCell cell_bt
Definition ui_common.c:130
ushort cp_green
Definition ui_common.c:151
ushort cp_red
Definition ui_common.c:150
ushort cp_box
Definition ui_common.c:138
ushort cp_blue
Definition ui_common.c:153
UiCell cell_ln
Definition ui_common.c:114
#define bw_tr
Definition ui_backend.h:589
const wchar_t * bw_chk
Definition ui_common.c:86
ushort cp_nt_hl
Definition ui_common.c:144
#define bw_lt
Definition ui_backend.h:583
ushort cp_fill_char
Definition ui_common.c:148
UiCell cell_tt
Definition ui_common.c:129
ushort cp_brackets
Definition ui_common.c:149
#define bw_br
Definition ui_backend.h:591
ushort cp_yellow
Definition ui_common.c:152
#define bw_bl
Definition ui_backend.h:590
UiCell cell_default
Definition ui_common.c:102
ushort cp_nt_hl_rev
Definition ui_common.c:145
ushort cp_default
Definition ui_common.c:147
ushort cp_nt_rev
Definition ui_common.c:143
ushort cp_title
Definition ui_common.c:141
@ CLR_CMDLN_BG
Definition ui_backend.h:536
@ CLR_TITLE_FG
Definition ui_backend.h:545
@ CLR_CMDLN_FG
Definition ui_backend.h:535
UiCell cell_brktl
Definition ui_common.c:104
#define bw_tt
Definition ui_backend.h:585
UiCell cell_cr
Definition ui_common.c:131
#define bw_cr
Definition ui_backend.h:587
UiCell cell_ind
Definition ui_common.c:111
UiCell cell_ran
Definition ui_common.c:115
#define bw_bt
Definition ui_backend.h:586
#define bw_ve
Definition ui_backend.h:582
UiCell cell_cmdln
Definition ui_common.c:112
#define bw_rt
Definition ui_backend.h:584
UiCell cell_brktr
Definition ui_common.c:105
ushort cp_ind
Definition ui_common.c:139
UiCell cell_fill_char
Definition ui_common.c:103
UiCell cell_chk
Definition ui_common.c:116
#define bw_tl
Definition ui_backend.h:588
ushort cp_cmdln
Definition ui_common.c:140
bool ui_init_clr_palette(SIO *sio)
Definition ui_common.c:247
ushort cp_ln
Definition ui_common.c:146
uint ui_add_pair(uint fg, uint bg)
Add a new color pair to the UI, or retrieve the index of an existing pair.
UiRuntime * ui
Definition ui_ncurses.c:39
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.
Definition ui_ncurses.c:101
uint32_t ran_bg
Definition ui_backend.h:740
double green_gamma
Definition ui_backend.h:693
double blue_gamma
Definition ui_backend.h:694
char brackets[3]
Definition ui_backend.h:753
uint32_t cmdln_bg
Definition ui_backend.h:728
uint32_t cmdln_fg
Definition ui_backend.h:727
uint32_t ran_fg
Definition ui_backend.h:739
double red_gamma
Definition ui_backend.h:692
uint32_t title_fg
Definition ui_backend.h:737
double gray_gamma
Definition ui_backend.h:695

References BLUE_GAMMA, SIO::blue_gamma, SIO::box_bg, SIO::box_fg, SIO::brackets, SIO::brackets_bg, SIO::brackets_fg, bw_chk, bw_ran, bw_sp, cell_bl, cell_box, cell_br, cell_brktl, cell_brktr, cell_bt, cell_chk, cell_cmdln, cell_cr, cell_default, cell_fill_char, cell_ho, cell_ind, cell_ln, cell_lt, cell_nt, cell_nt_hl, cell_nt_hl_rev, cell_nt_rev, cell_ran, cell_rt, cell_sp, cell_title, cell_tl, cell_tr, cell_tt, cell_ve, CLR_BG, CLR_BLUE, CLR_BOX_BG, CLR_BOX_FG, CLR_BRACKETS_BG, CLR_BRACKETS_FG, CLR_CMDLN_BG, CLR_CMDLN_FG, CLR_FG, CLR_FILL_CHAR_BG, CLR_FILL_CHAR_FG, CLR_GREEN, CLR_IND_BG, CLR_IND_FG, CLR_LN_BG, CLR_LN_FG, CLR_NT_BG, CLR_NT_FG, CLR_NT_HL_BG, CLR_NT_HL_FG, CLR_NT_HL_REV_BG, CLR_NT_HL_REV_FG, CLR_NT_REV_BG, CLR_NT_REV_FG, CLR_RED, CLR_TITLE_BG, CLR_TITLE_FG, CLR_YELLOW, SIO::cmdln_bg, SIO::cmdln_fg, cp_blue, cp_box, cp_brackets, cp_cmdln, cp_default, cp_fill_char, cp_green, cp_ind, cp_ln, cp_nt, cp_nt_hl, cp_nt_hl_rev, cp_nt_rev, cp_red, cp_title, cp_yellow, SIO::fill_char_bg, SIO::fill_char_fg, GRAY_GAMMA, SIO::gray_gamma, GREEN_GAMMA, SIO::green_gamma, SIO::ind_bg, SIO::ind_fg, SIO::ln_bg, SIO::ln_fg, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, SIO::ran_bg, SIO::ran_fg, RED_GAMMA, SIO::red_gamma, SIO::title_bg, SIO::title_fg, ui, ui_add_pair(), ui_cell_from_ucp(), and ui_init_clr_palette().

Referenced by read_theme(), ui_init(), and ui_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_is_set_chyron_key()

bool ui_is_set_chyron_key ( UiChyron * chyron,
uint k )

Check if function key label is set.

is_set_chyron_key

Parameters
chyronstructure
kFunction key index (0-19)
Returns
true if set, false if not set

Definition at line 677 of file ui_common.c.

677 {
678 if (chyron->key[k]->text[0] != '\0')
679 return true;
680 else
681 return false;
682}

Referenced by form_post(), and form_process().

Here is the caller graph for this function:

◆ ui_iso8601_timestamp()

char * ui_iso8601_timestamp ( char * buf,
size_t n,
bool local )

Generate an ISO 8601 timestamp string.

ui_iso8601_timestamp

Parameters
bufBuffer to store the timestamp string
nSize of the buffer
localIf true, use local time; if false, use UTC
Returns
Pointer to the buffer containing the timestamp string

Definition at line 1353 of file ui_common.c.

1353 {
1354 if (buf == NULL)
1355 return NULL;
1356 time_t t = time(NULL);
1357 struct tm *tp = local ? localtime(&t) : gmtime(&t);
1358 if (local) {
1359 strftime(buf, n, _("%Y-%m-%dT%H:%M:%S%z"), tp);
1360 } else {
1361 strftime(buf, n, _("%Y-%m-%dT%H:%M:%SZ"), tp);
1362 }
1363 return buf;
1364}

◆ ui_mbc_to_wc()

void ui_mbc_to_wc ( wchar_t wc[2],
const char mbc )

Convert a multibyte character to a wide character.

mbc_to_wc

Parameters
wcOutput array for wide characters (size 2)
mbcInput multibyte character

This function converts a single multibyte character to a wide character. It uses the mbrtowc function to perform the conversion and handles any errors by setting the output to a question mark ('?') if the conversion fails. The output array is null-terminated.

Definition at line 302 of file ui_common.c.

302 {
303 wc[0] = wc[1] = L'\0';
304 mbstate_t state = {};
305 size_t len = mbrtowc(wc, &mbc, MB_CUR_MAX, &state);
306 if (len <= 0) {
307 wc[0] = L'?';
308 wc[1] = L'\0';
309 len = 1;
310 }
311}

◆ ui_mbstr_to_wcstr()

wchar_t * ui_mbstr_to_wcstr ( const char * mb_str)

Convert a multibyte string to a wide character string.

ui_mbstr_to_wcstr

Parameters
mb_strInput multibyte string
Returns
Pointer to newly allocated wide character string, or nullptr on error

This function converts a null-terminated multibyte string to a wide character string. It first calculates the required length for the wide character string, allocates memory for it, and then performs the conversion. The caller is responsible for freeing the allocated memory. If the conversion fails, it returns nullptr.

Definition at line 322 of file ui_common.c.

322 {
323 const char *src_ptr = mb_str;
324 mbstate_t state = {};
325 size_t wc_count = mbsrtowcs(NULL, &src_ptr, 0, &state);
326 if (wc_count == (size_t)-1)
327 return nullptr;
328 src_ptr = mb_str;
329 wmemset((wchar_t *)&state, 0, sizeof(state) / sizeof(wchar_t));
330 wchar_t *wc_str = malloc((wc_count + 1) * sizeof(wchar_t));
331 if (!wc_str)
332 return nullptr;
333 mbsrtowcs(wc_str, &src_ptr, wc_count + 1, &state);
334 return wc_str;
335}

Referenced by ui_border_title(), and ui_border_ysplit_text().

Here is the caller graph for this function:

◆ ui_new_chyron()

UiChyron * ui_new_chyron ( UiSurface * sfc,
ss_t w )

Create new chyron structure.

new_chyron

Returns
pointer to new chyron structure

This function allocates memory for a new chyron structure and its associated keys. It initializes the structure to zero and returns a pointer to the newly created chyron. If memory allocation fails, it calls ui_abend() to terminate the program with an error message.

Definition at line 601 of file ui_common.c.

601 {
602 UiChyron *chyron = (UiChyron *)calloc(1, sizeof(UiChyron));
603 if (!chyron) {
604 ui_abend(-1, _("calloc chyron failed"));
605 return nullptr;
606 }
607 chyron->sfc = sfc;
608 chyron->w = w;
609 for (int i = 0; i < CHYRON_KEYS; i++) {
610 chyron->key[i] = (UiChyronKey *)calloc(1, sizeof(UiChyronKey));
611 if (!chyron->key[i]) {
612 ui_abend(-1, _("calloc chyron->key[i] failed"));
613 return nullptr;
614 }
615 }
616 return chyron;
617}
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:362

References ui_abend().

Referenced by form_engine(), open_pick_win(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_open_log()

FILE * ui_open_log ( )

Open the log file for writing.

ui_open_log

Returns
FILE pointer to the opened log file

Definition at line 1397 of file ui_common.c.

1397 {
1398 if (!ui_log_fp) {
1399 if (strlen(ui_log_file_name) == 0)
1400 strnz__cpy(ui_log_file_name, "/tmp/ui_default.log", MAXLEN - 1);
1401 ui_log_fp = fopen(ui_log_file_name, "w");
1402 if (!ui_log_fp) {
1403 ssnprintf(em0, MAXLEN - 1, _("Failed to open log file: %s"), ui_log_file_name);
1404 ssnprintf(em1, MAXLEN - 1, _("Error: %s"), strerror(errno));
1405 ssnprintf(em2, MAXLEN - 1, "%s: line: %d", __FILE__, __LINE__ - 4);
1406 ssnprintf(em3, MAXLEN - 1, _("remedy: delete %s and try again"), ui_log_file_name);
1407 fprintf(stderr, "%s\n%s\n%s\n%s\n", em0, em1, em2, em3);
1408 exit(EXIT_FAILURE);
1409 }
1410 setvbuf(ui_log_fp, NULL, _IOLBF, BUFSIZ);
1411 }
1412 char ttyname[MAXLEN];
1413 char cmenu_user[MAXLEN];
1414 char *p = getenv(_("USER"));
1415 strnz__cpy(cmenu_user, p, MAXLEN - 1);
1416 if (ttyname_r(STDERR_FILENO, ttyname, sizeof(ttyname)) == 0)
1417 strnz__cpy(em0, ttyname, MAXLEN - 1);
1418 ssnprintf(em0, MAXLEN - 1, _("Ui_Log started by user '%s' on terminal '%s'"), cmenu_user, ttyname);
1419 ui_log(INFO, "%s:", em0);
1420 return ui_log_fp;
1421}
char em1[MAXLEN]
Definition ui_common.c:47
char em2[MAXLEN]
Definition ui_common.c:48
char em3[MAXLEN]
Definition ui_common.c:49
char em0[MAXLEN]
Definition ui_common.c:46
#define BUFSIZ
Definition view.h:38
char ui_log_file_name[MAXLEN]
Definition ui_common.c:1388
FILE * ui_log_fp
Definition ui_common.c:1387

References em0, em1, em2, em3, ssnprintf(), strnz__cpy(), ui_log_file_name, and ui_log_fp.

Referenced by mapp_initialization().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_parse_ansi()

void ui_parse_ansi ( char * ansi_str,
attr_t * attr,
uint * cpx )

Parse ANSI escape sequences for color and attributes.

parse_ansi

Parameters
ansi_strANSI escape sequence string
attrPointer to attribute variable to be updated
cpxPointer to color pair index to be updated

This function parses an ANSI escape sequence string (e.g., _("\033[31;1m")) and updates the provided attribute and color pair index accordingly. It handles standard colors, extended colors, and text attributes like bold, underline, etc.

Definition at line 1435 of file ui_common.c.

1435 {
1436 char *tok;
1437 char t0, t1;
1438 char tstr[3];
1439 uint len, x_idx;
1440 uint fg, bg;
1441 uint _fg_clr, _bg_clr;
1442 uint fg_clr, bg_clr;
1443 char *ansi_p = ansi_str + 2;
1444 ui_pair_content(*cpx, &_fg_clr, &_bg_clr);
1445 fg = fg_clr = (uint)_fg_clr;
1446 bg = bg_clr = (uint)_bg_clr;
1447 RGB rgb;
1448 tok = strtok((char *)ansi_p, ";m");
1449 bool a_toi_error = false;
1450 while (1) {
1451 if (tok == nullptr || *tok == '\0')
1452 break;
1453 len = strlen(tok);
1454 if (len == 2) {
1455 t0 = tok[0];
1456 t1 = tok[1];
1457 if (t0 == '3' || t0 == '4') {
1458 if (t1 == '8') {
1459 tok = strtok(nullptr, ";m");
1460 if (tok != nullptr) {
1461 if (*tok == '5') {
1462 tok = strtok(nullptr, ";m");
1463 if (tok != nullptr) {
1464 x_idx = a_toi(tok, &a_toi_error);
1465 rgb = ui_xterm256_idx_to_rgb(x_idx);
1466 }
1467 } else if (*tok == '2') {
1468 tok = strtok(nullptr, ";m");
1469 rgb.r = a_toi(tok, &a_toi_error);
1470 tok = strtok(nullptr, ";m");
1471 rgb.g = a_toi(tok, &a_toi_error);
1472 tok = strtok(nullptr, ";m");
1473 rgb.b = a_toi(tok, &a_toi_error);
1474 }
1475 }
1476 if (t0 == '3')
1477 fg_clr = ui_color_from_rgb(&rgb);
1478 else if (t0 == '4')
1479 bg_clr = ui_color_from_rgb(&rgb);
1480 } else if (t1 == '9') {
1481 if (t0 == '3')
1482 fg_clr = CLR_NT_FG;
1483 else if (t0 == '4')
1484 bg_clr = CLR_NT_BG;
1485 } else if (t1 >= '0' && t1 <= '7') {
1486 if (t0 == '3') {
1487 tstr[0] = t1;
1488 tstr[1] = '\0';
1489 x_idx = a_toi(tstr, &a_toi_error);
1490 rgb = ui_xterm256_idx_to_rgb(x_idx);
1491 fg_clr = ui_color_from_rgb(&rgb);
1492 } else if (t0 == '4') {
1493 tstr[0] = t1;
1494 tstr[1] = '\0';
1495 x_idx = a_toi(tstr, &a_toi_error);
1496 rgb = ui_xterm256_idx_to_rgb(x_idx);
1497 bg_clr = ui_color_from_rgb(&rgb);
1498 }
1499 }
1500 } else if (t0 == '0') {
1501 *tok = t1;
1502 len = 1;
1503 }
1504 }
1505 if (len == 1) {
1506 if (*tok == '0') {
1507 *attr = WA_NORMAL;
1508 fg_clr = CLR_NT_FG;
1509 bg_clr = CLR_NT_BG;
1510 } else {
1511 switch (a_toi(tok, &a_toi_error)) {
1512 case 1:
1513 *attr |= WA_BOLD;
1514 break;
1515 case 2:
1516 *attr |= WA_DIM;
1517 break;
1518 case 3:
1519 *attr |= WA_ITALIC;
1520 break;
1521 case 4:
1522 *attr |= WA_UNDERLINE;
1523 break;
1524 case 5:
1525 *attr |= WA_BLINK;
1526 break;
1527 case 7:
1528 *attr |= WA_REVERSE;
1529 break;
1530 case 8:
1531 *attr |= WA_INVIS;
1532 break;
1533 default:
1534 break;
1535 }
1536 }
1537 } else if (len == 0) {
1538 *attr = WA_NORMAL;
1539 fg_clr = CLR_NT_FG;
1540 bg_clr = CLR_NT_BG;
1541 }
1542 tok = strtok(nullptr, ";m");
1543 }
1544 if (!a_toi_error && (fg_clr != fg || bg_clr != bg))
1545 *cpx = ui_add_pair(fg_clr, bg_clr);
1546 return;
1547}
#define WA_NORMAL
#define WA_BLINK
#define WA_ITALIC
#define WA_DIM
#define WA_INVIS
#define WA_BOLD
#define WA_REVERSE
#define WA_UNDERLINE
RGB ui_xterm256_idx_to_rgb(uint idx)
Convert XTerm 256 color index to RGB.
Definition ui_common.c:908
int ui_pair_content(uint pair, uint *fg, uint *bg)
Get the foreground and background colors of a specified color pair.
int ui_color_from_rgb(RGB *rgb)
Convert RGB to curses color index, adding new color if necessary.

References a_toi(), CLR_NT_BG, CLR_NT_FG, ui_add_pair(), ui_color_from_rgb(), ui_pair_content(), and ui_xterm256_idx_to_rgb().

Here is the call graph for this function:

◆ ui_rgb_to_xterm256_idx()

uint ui_rgb_to_xterm256_idx ( RGB * rgb)

Convert RGB color to XTerm 256 color index.

ui_rgb_to_xterm256_idx

Parameters
rgbRGB color
Returns
XTerm 256 color index

This function converts an RGB color to the nearest XTerm 256 color index. It first checks if the color is a shade of gray, and if so, it uses the gray ramp. Otherwise, it calculates the nearest color in the 6x6x6 color cube.

Definition at line 886 of file ui_common.c.

886 {
887 if (rgb->r == rgb->g && rgb->g == rgb->b) {
888 if (rgb->r < 8)
889 return 16;
890 if (rgb->r > 248)
891 return 231;
892 return ((rgb->r - 8) / 10) + 231;
893 } else {
894 uint r_index = (rgb->r < 45) ? 0 : (rgb->r - 60) / 40 + 1;
895 uint g_index = (rgb->g < 45) ? 0 : (rgb->g - 60) / 40 + 1;
896 uint b_index = (rgb->b < 45) ? 0 : (rgb->b - 60) / 40 + 1;
897 return 16 + (36 * r_index) + (6 * g_index) + b_index;
898 }
899}

◆ ui_set_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).

set_chyron_key

Parameters
chyronstructure
kchyron key index (0-19)
schyron key label
kcchyron key code

This function sets the label and keycode for a function key in the chyron structure. It uses the default color pair cp_nt_rev for the key label. If the input string s is not empty, it copies the string into the chyron key's text field. If the input string is empty, it sets the first character of the text field to '\0' to indicate that the key is not set. The keycode is stored in the chyron key's keycode field, and the color pair index is set to cp_nt_rev.

Definition at line 717 of file ui_common.c.

717 {
718 if (*s != '\0')
719 ssnprintf(chyron->key[k]->text, CHYRON_KEY_MAXLEN - 1, "%s", s);
720 else
721 chyron->key[k]->text[0] = '\0';
722 chyron->key[k]->keycode = kc;
723 chyron->key[k]->active = true;
724 chyron->key[k]->cell_base = cell_nt_rev;
725}
#define CHYRON_KEY_MAXLEN
Definition ui_backend.h:49

References cell_nt_rev, and ssnprintf().

Referenced by form_engine(), open_pick_win(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_set_chyron_key_cb()

void ui_set_chyron_key_cb ( UiChyron * chyron,
uint k,
char * s,
uint kc,
UiCell cell_base )

Set chyron key with color pair (cp).

set_chyron_key

Parameters
chyronstructure
kchyron key index (0-19)
schyron key label
kcchyron key code
cell_basecolor pair for chyron key label

This function is like set_chyron_key, except it includes a color pair numbers

Definition at line 693 of file ui_common.c.

693 {
694 if (*s != '\0')
695 ssnprintf(chyron->key[k]->text, CHYRON_KEY_MAXLEN - 1, "%s", s);
696 else
697 chyron->key[k]->text[0] = '\0';
698 chyron->key[k]->keycode = kc;
699 chyron->key[k]->active = true;
700 chyron->key[k]->cell_base = cell_base;
701}

References ssnprintf().

Referenced by field_editor(), form_engine(), and picker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_sub_surface_str()

const char * ui_sub_surface_str ( ss_t w)

Definition at line 1368 of file ui_common.c.

1368 {
1369 if (w < BOX || w >= SUB_SFC_MAX)
1370 return _("unknown");
1371 return subsfc_s[w];
1372}
@ SUB_SFC_MAX
Definition ui_backend.h:47
const char * subsfc_s[]
Definition ui_common.c:1366

References SUB_SFC_MAX, and subsfc_s.

◆ ui_tracked_sfc_box()

int ui_tracked_sfc_box ( uint wlines,
uint wcols,
uint wbegy,
uint wbegx,
const char * wtitle )

Create a new surface with a box window.

ui_tracked_sfc_box_com

Parameters
wlinesNumber of lines for the window
wcolsNumber of columns for the window
wbegyStarting Y position for the window
wbegxStarting X position for the window
wtitleTitle for the window
Returns
0 on success, -1 on error

This function creates a new surface and adds a box window to it. It checks if the maximum number of surfaces has been exceeded and adjusts the window size based on the screen size. The new surface is stored in the global ui_surface array, and the surface pointer (sfc_ptr) is incremented. The window is then rendered on the screen.

Definition at line 387 of file ui_common.c.

387 {
388 if (sfc_ptr >= SFC_MAX) {
389 ui_log(ERROR, _("Maximum number of surfaces (%d) exceeded"), SFC_MAX);
390 exit(EXIT_FAILURE);
391 }
392 uint maxy, maxx;
393 ui_get_screen_size(&maxy, &maxx);
394 wlines = min(wlines, maxy);
395 wcols = min(wcols, maxx);
396 sfc_ptr++;
397 // -------------------> UI_win_box <-------------------
398 ui_surface[sfc_ptr] = ui_surface_box(nullptr, 0, wlines + 2, wcols + 2, wbegy, wbegx, wtitle);
400 ui_surface_addwin(sfc, WIN, BOX, wlines, wcols, 1, 1);
401 ui_render();
402 return 0;
403}
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.
Definition ui_ncurses.c:395
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:884
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.
Definition ui_ncurses.c:288
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
Definition ui_ncurses.c:722
#define SFC_MAX
Definition ui_backend.h:197
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:40

References sfc_ptr, ui_get_screen_size(), ui_render(), ui_surface, ui_surface_addwin(), and ui_surface_box().

Referenced by display_form(), main(), menu_engine(), popup_ckeys(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_tracked_sfc_split_box()

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.

surface_split_box_win_new

Parameters
wlinesNumber of lines for the main window
wcolsNumber of columns for the main window
split_yY position for the split line
split_xX position for the split line (not implemented yet)
wbegyStarting Y position for the window
wbegxStarting X position for the window
wtitleTitle for the window
Returns
0 on success, -1 on error

This function creates a new surface and adds a split box window to it. It checks if the maximum number of surfaces has been exceeded and adjusts the window size based on the screen size. The new surface is stored in the global ui_surface array, and the surface pointer (sfc_ptr) is incremented. The main window and the split window are then rendered on the screen, with a separator line drawn at the specified Y position.

Definition at line 425 of file ui_common.c.

425 {
426 if (sfc_ptr >= SFC_MAX) {
427 ui_log(ERROR, _("Maximum number of surfaces (%d) exceeded"), SFC_MAX);
428 exit(EXIT_FAILURE);
429 }
430 if (wlines == 0 || wcols == 0) {
431 ui_log(ERROR, _("Invalid window size: lines=%d, cols=%d"), wlines, wcols);
432 return -1;
433 }
434 uint maxy, maxx;
435 ui_get_screen_size(&maxy, &maxx);
436 if (wbegy > maxy || wbegx > maxx) {
437 ui_log(ERROR, _("Invalid window position: wbegy=%d, wbegx=%d, wlines=%d, wcols=%d"), wbegy, wbegx, wlines, wcols);
438 return -1;
439 }
440 wlines = min(wlines, maxy);
441 wcols = min(wcols, maxx);
442 split_x = min(split_x, maxx); // not implemented yet
443 uint split_wlines = min(wlines + split_y + 1, maxy);
444 wcols = min(wcols, maxx);
445 sfc_ptr++;
446 // -------------------> surface_new <-------------------
447 ui_surface[sfc_ptr] = ui_surface_box(nullptr, 0, split_wlines + 2, wcols + 2, wbegy, wbegx, wtitle);
449
450 ui_surface_addwin(sfc, WIN, BOX, wlines, wcols, 1, 1);
451 ui_border_ysplit(sfc, wlines + 1);
452 ui_surface_addwin(sfc, WIN2, BOX, 2, wcols, wlines + 2, 1);
453 ui_curs_set(0);
454 return 0;
455}
int ui_curs_set(int visibility)
Set the visibility of the cursor.
Definition ui_ncurses.c:840
int ui_border_ysplit(UiSurface *sfc, uint y)
Draw a box with a separator line around the specified window.
Definition ui_common.c:504

References sfc_ptr, ui_border_ysplit(), ui_curs_set(), ui_get_screen_size(), ui_surface, ui_surface_addwin(), and ui_surface_box().

Referenced by open_pick_win().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_unset_chyron_key()

void ui_unset_chyron_key ( UiChyron * chyron,
uint k )

Unset chyron key.

unset_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 732 of file ui_common.c.

732 {
733 chyron->key[k]->text[0] = '\0';
734}

◆ ui_xterm256_idx_to_rgb()

RGB ui_xterm256_idx_to_rgb ( uint idx)

Convert XTerm 256 color index to RGB.

ui_xterm256_idx_to_rgb

Parameters
idxXTerm 256 color index
Returns
RGB color

This function converts an XTerm 256 color index to an RGB color. It first checks if the index is in the standard 16 colors, then checks if it's in the 6x6x6 color cube, and finally checks if it's in the gray ramp.

Convert XTerm 256 color index to RGB

Parameters
idx- XTerm 256 color index
Returns
RGB struct

Definition at line 908 of file ui_common.c.

908 {
912 RGB rgb;
913 if (idx > 255)
914 idx = 255;
915 rgb.r = rgb.g = rgb.b = 0;
916 if (idx < 16) {
917 rgb.r = std_color[idx].r;
918 rgb.g = std_color[idx].g;
919 rgb.b = std_color[idx].b;
920 } else if (idx >= 16 && idx <= 231) {
921 idx -= 16;
922 rgb.r = (idx / 36) % 6 * 51;
923 rgb.g = (idx / 6) % 6 * 51;
924 rgb.b = (idx % 6) * 51;
925 } else if (idx >= 232 && idx <= 255) {
926 uint gray = (idx - 232) * 11;
927 rgb.r = rgb.g = rgb.b = gray;
928 }
929 return rgb;
930}
STDRGB std_color[]
Definition ui_common.c:159

References std_color.

Referenced by parse_ansi_str(), and ui_parse_ansi().

Here is the caller graph for this function:

Variable Documentation

◆ BLUE_GAMMA

double BLUE_GAMMA = 1.2

Definition at line 65 of file ui_common.c.

Referenced by ui_apply_gamma(), and ui_initialize_sio().

◆ border_double

const wchar_t* border_double = L"═║╠╣╦╩╬╔╗╚╝"

Definition at line 69 of file ui_common.c.

Referenced by ui_init(), and ui_init().

◆ border_heavy

const wchar_t* border_heavy = L"━┃┣┫┳┻╋┏┓┗┛"

Definition at line 71 of file ui_common.c.

Referenced by ui_init(), and ui_init().

◆ border_none

const wchar_t* border_none = L" "

Definition at line 72 of file ui_common.c.

Referenced by ui_init(), and ui_init().

◆ border_rounded

const wchar_t* border_rounded = L"─│├┤┬┴┼╭╮╰╯"

Definition at line 70 of file ui_common.c.

Referenced by ui_init(), and ui_init().

◆ border_single

const wchar_t* border_single = L"─│├┤┬┴┼┌┐└┘"

BOX WIDE UNICODE CODEPOINTS

Definition at line 68 of file ui_common.c.

Referenced by ui_init(), and ui_init().

◆ box_attr

uint16_t box_attr

Definition at line 35 of file ui_common.c.

◆ bw

Definition at line 27 of file ui_common.c.

Referenced by ui_init(), and ui_init().

◆ bw_chk

const wchar_t* bw_chk = L"\u2611"

left_angle

Definition at line 86 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ bw_da

const wchar_t* bw_da = L"\u2193"

large down arrow

Definition at line 83 of file ui_common.c.

◆ bw_h09

const wchar_t* bw_h09 = L"\u23BD"

horizontal line 9

Definition at line 87 of file ui_common.c.

◆ bw_la

const wchar_t* bw_la = L"\u2190"

large left arrow

Definition at line 81 of file ui_common.c.

◆ bw_lan

const wchar_t* bw_lan = L"\u276E"

left_angle

Definition at line 85 of file ui_common.c.

◆ bw_ra

const wchar_t* bw_ra = L"\u2192"

large right arrow

Definition at line 80 of file ui_common.c.

◆ bw_ran

const wchar_t* bw_ran = L"\u276F"

right_angle

Definition at line 84 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ bw_rbl

const wchar_t* bw_rbl = L"\u2570"

rounded bottom left

Definition at line 77 of file ui_common.c.

◆ bw_rbr

const wchar_t* bw_rbr = L"\u256f"

rounded bottom right

Definition at line 78 of file ui_common.c.

◆ bw_rtl

const wchar_t* bw_rtl = L"\u256d"

MISCELANEOUS UNICODE CODEPOINTS rounded top left

Definition at line 75 of file ui_common.c.

◆ bw_rtr

const wchar_t* bw_rtr = L"\u256e"

rounded top right

Definition at line 76 of file ui_common.c.

◆ bw_sp

const wchar_t* bw_sp = L"\x20"

space

Definition at line 79 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ bw_ua

const wchar_t* bw_ua = L"\u2191"

large up arrow

Definition at line 82 of file ui_common.c.

◆ cell_bl

UiCell cell_bl

Definition at line 125 of file ui_common.c.

Referenced by ui_border_draw(), and ui_initialize_sio().

◆ cell_box

UiCell cell_box

Definition at line 110 of file ui_common.c.

Referenced by ui_border_title(), ui_initialize_sio(), and ui_surface_box().

◆ cell_br

UiCell cell_br

Definition at line 126 of file ui_common.c.

Referenced by ui_border_draw(), and ui_initialize_sio().

◆ cell_brktl

UiCell cell_brktl

Definition at line 104 of file ui_common.c.

Referenced by display_form(), and ui_initialize_sio().

◆ cell_brktr

UiCell cell_brktr

Definition at line 105 of file ui_common.c.

Referenced by display_form(), and ui_initialize_sio().

◆ cell_bs

UiCell cell_bs

Definition at line 120 of file ui_common.c.

◆ cell_bt

UiCell cell_bt

Definition at line 130 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cell_chk

◆ cell_cmdln

UiCell cell_cmdln

Definition at line 112 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cell_cr

UiCell cell_cr

Definition at line 131 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cell_default

UiCell cell_default

Definition at line 102 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cell_fill_char

UiCell cell_fill_char

Definition at line 103 of file ui_common.c.

Referenced by form_display_fields(), and ui_initialize_sio().

◆ cell_ho

◆ cell_ind

UiCell cell_ind

Definition at line 111 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cell_ln

UiCell cell_ln

Definition at line 114 of file ui_common.c.

Referenced by init_view_boxwin(), init_view_full_screen(), and ui_initialize_sio().

◆ cell_ls

UiCell cell_ls

Definition at line 117 of file ui_common.c.

◆ cell_lt

UiCell cell_lt

◆ cell_nt

◆ cell_nt_hl

UiCell cell_nt_hl

◆ cell_nt_hl_rev

UiCell cell_nt_hl_rev

Definition at line 109 of file ui_common.c.

Referenced by field_editor(), form_engine(), menu_cmd_processor(), picker(), and ui_initialize_sio().

◆ cell_nt_rev

◆ cell_ran

UiCell cell_ran

Definition at line 115 of file ui_common.c.

Referenced by get_cmd_arg(), get_cmd_char(), picker(), and ui_initialize_sio().

◆ cell_rs

UiCell cell_rs

Definition at line 118 of file ui_common.c.

◆ cell_rt

UiCell cell_rt

◆ cell_sp

◆ cell_title

UiCell cell_title

Definition at line 113 of file ui_common.c.

Referenced by ui_border_title(), and ui_initialize_sio().

◆ cell_tl

UiCell cell_tl

Definition at line 121 of file ui_common.c.

Referenced by ui_border_draw(), ui_border_title(), and ui_initialize_sio().

◆ cell_tr

UiCell cell_tr

Definition at line 122 of file ui_common.c.

Referenced by ui_border_draw(), and ui_initialize_sio().

◆ cell_ts

UiCell cell_ts

Definition at line 119 of file ui_common.c.

◆ cell_tt

UiCell cell_tt

Definition at line 129 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cell_ve

UiCell cell_ve

Definition at line 124 of file ui_common.c.

Referenced by ui_border_draw(), and ui_initialize_sio().

◆ click_x

int click_x

the x coordinate of a mouse click

Definition at line 30 of file ui_common.c.

Referenced by cf_accept(), field_editor(), form_post(), and form_process().

◆ click_y

int click_y

the y coordinate of a mouse click

Definition at line 29 of file ui_common.c.

Referenced by cf_accept(), field_editor(), form_post(), and form_process().

◆ cmd_key

unsigned int cmd_key

◆ colors_text

char const colors_text[][10]
Initial value:
= {
_("black"), _("red"), _("green"), _("yellow"), _("blue"), _("magenta"), _("cyan"),
_("white"), _("orange"), _("bg"), _("abg"), _("bblack"), _("bred"), _("bgreen"),
_("byellow"), _("bblue"), _("bcyan"), _("bmagenta"), _("bwhite"), _("borange"), ""}

Color names for .minitrc overrides.

colors_text

These names are used in .minitrc to specify color overrides The order of these names corresponds to the ColorsEnum values

Definition at line 93 of file ui_common.c.

93 {
94 _("black"), _("red"), _("green"), _("yellow"), _("blue"), _("magenta"), _("cyan"),
95 _("white"), _("orange"), _("bg"), _("abg"), _("bblack"), _("bred"), _("bgreen"),
96 _("byellow"), _("bblue"), _("bcyan"), _("bmagenta"), _("bwhite"), _("borange"), ""};

◆ cp_blue

ushort cp_blue

blue background - for testing

Definition at line 153 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_box

ushort cp_box

border

Definition at line 138 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_brackets

ushort cp_brackets

field enclosure brackets

Definition at line 149 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_cmdln

ushort cp_cmdln

command line

Definition at line 140 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_default

ushort cp_default

default color pair

Definition at line 147 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_fill_char

ushort cp_fill_char

field fill characters

Definition at line 148 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_green

ushort cp_green

green background - for testing

Definition at line 151 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_ind

ushort cp_ind

indicator character

Definition at line 139 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_ln

ushort cp_ln

line numbers

Definition at line 146 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_nt

ushort cp_nt

normal text

Definition at line 142 of file ui_common.c.

Referenced by fmt_line(), and ui_initialize_sio().

◆ cp_nt_hl

ushort cp_nt_hl

normal text highlight

Definition at line 144 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_nt_hl_rev

ushort cp_nt_hl_rev

normal text highlight reverse

Definition at line 145 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_nt_rev

ushort cp_nt_rev

normal text reverse

Definition at line 143 of file ui_common.c.

Referenced by search(), and ui_initialize_sio().

◆ cp_red

ushort cp_red

red background - for testing

Definition at line 150 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_title

ushort cp_title

border title

Definition at line 141 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ cp_yellow

ushort cp_yellow

yellow background - for testing

Definition at line 152 of file ui_common.c.

Referenced by ui_initialize_sio().

◆ em0

◆ em1

◆ em2

◆ em3

char em3[MAXLEN]

error message string for error messages

Definition at line 49 of file ui_common.c.

Referenced by ui_open_log(), ui_timeout_prompt(), ui_update_timeout_prompt(), verify_dir(), and verify_file().

◆ exit_code

int exit_code

the exit code for the program, for error messages and other output

Definition at line 31 of file ui_common.c.

◆ f_ncurses_open

◆ f_notcurses_open

◆ f_sigwench

bool f_sigwench = false

Definition at line 33 of file ui_common.c.

◆ fn

char fn[MAXLEN]

function name for error messages

Definition at line 45 of file ui_common.c.

Referenced by verify_dir(), and verify_file().

◆ GRAY_GAMMA

double GRAY_GAMMA = 1.2

Gamma correction. Set in .minitrc

Definition at line 62 of file ui_common.c.

Referenced by ui_apply_gamma(), and ui_initialize_sio().

◆ GREEN_GAMMA

double GREEN_GAMMA = 1.2

Definition at line 64 of file ui_common.c.

Referenced by ui_apply_gamma(), and ui_initialize_sio().

◆ m_begx

uint m_begx = -1

Definition at line 39 of file ui_common.c.

◆ m_begy

uint m_begy = -1

Definition at line 38 of file ui_common.c.

◆ m_cols

uint m_cols

Definition at line 37 of file ui_common.c.

◆ m_lines

uint m_lines

Definition at line 36 of file ui_common.c.

◆ mouse_support

uint mouse_support

Definition at line 40 of file ui_common.c.

◆ pipe_in

int pipe_in

Definition at line 61 of file ui_common.c.

◆ pipe_out

int pipe_out

Definition at line 61 of file ui_common.c.

◆ RED_GAMMA

double RED_GAMMA = 1.2

Definition at line 63 of file ui_common.c.

Referenced by ui_apply_gamma(), and ui_initialize_sio().

◆ src_line

uint src_line

the line number of the source file being processed, for error messages

Definition at line 43 of file ui_common.c.

Referenced by verify_dir(), and verify_file().

◆ src_name

char* src_name

the name of the source file being processed, for error messages

Definition at line 44 of file ui_common.c.

Referenced by verify_dir(), and verify_file().

◆ std_color

STDRGB std_color
Initial value:
= {
{0, 0, 0},
{128, 0, 0},
{0, 128, 0},
{128, 128, 0},
{0, 0, 128},
{128, 0, 128},
{0, 128, 128},
{192, 192, 192},
{128, 128, 128},
{255, 0, 0},
{0, 255, 0},
{255, 255, 0},
{0, 0, 255},
{255, 0, 255},
{0, 255, 255},
{255, 255, 255}}

Definition at line 159 of file ui_common.c.

159 {
160 {0, 0, 0},
161 {128, 0, 0},
162 {0, 128, 0},
163 {128, 128, 0},
164 {0, 0, 128},
165 {128, 0, 128},
166 {0, 128, 128},
167 {192, 192, 192},
168 {128, 128, 128},
169 {255, 0, 0},
170 {0, 255, 0},
171 {255, 255, 0},
172 {0, 0, 255},
173 {255, 0, 255},
174 {0, 255, 255},
175 {255, 255, 255}};

Referenced by ui_chg_color(), ui_color_from_rgb(), ui_init_color_hex(), and ui_xterm256_idx_to_rgb().

◆ stderr_fd

int stderr_fd

the file descriptor for the terminal, for error messages and other output

Definition at line 61 of file ui_common.c.

◆ stdin_fd

int stdin_fd

the file descriptor for the terminal, for error messages

Definition at line 41 of file ui_common.c.

◆ stdout_fd

int stdout_fd

the file descriptor for the terminal, for error messages

Definition at line 42 of file ui_common.c.

◆ subsfc_s

const char * subsfc_s
Initial value:
= {
#define SUB_SURFACE_LIST(X)
Definition ui_backend.h:36
#define AS_STRING(NAME)
Definition ui_common.c:1365

Definition at line 1366 of file ui_common.c.

1366 {

Referenced by ui_sub_surface_str().

◆ tty_fd

int tty_fd

Definition at line 61 of file ui_common.c.

◆ ui_ctx

◆ ui_log_file_name

char ui_log_file_name = "/tmp/ui.log"

Definition at line 1388 of file ui_common.c.

Referenced by ui_open_log().

◆ ui_log_fp

FILE * ui_log_fp = NULL

Definition at line 1387 of file ui_common.c.

Referenced by mapp_initialization(), and ui_open_log().

◆ ui_log_level_s

const char *const ui_log_level_s
Initial value:
= {
#define LOG_LEVEL_LIST(X)
Definition ui_backend.h:69

Definition at line 1374 of file ui_common.c.

1374 {

Referenced by write_config().

◆ ui_logcolor

const char *const ui_logcolor
Initial value:
= {
[FATAL] = "\033[1;31m",
[ERROR] = "\033[0;31m",
[WARN] = "\033[0;33m",
[INFO] = "\033[0;32m",
[VERBOSE] = "\033[0;36m",
[DEBUG] = "\033[0;34m",
[SILENT] = _("SILENT"),
}

Definition at line 1377 of file ui_common.c.

1377 {
1378 [FATAL] = "\033[1;31m", // Bold Red
1379 [ERROR] = "\033[0;31m", // Regular Red
1380 [WARN] = "\033[0;33m", // Yellow
1381 [INFO] = "\033[0;32m", // Green
1382 [VERBOSE] = "\033[0;36m", // Cyan
1383 [DEBUG] = "\033[0;34m", // Blue
1384 [SILENT] = _("SILENT"),
1385};

◆ ui_min_log_level

UiLogLevel ui_min_log_level = INFO

Definition at line 1390 of file ui_common.c.

Referenced by mapp_initialization(), ui_init(), and ui_init().

◆ ui_timestamp

char ui_timestamp

Definition at line 1392 of file ui_common.c.

◆ ui_timestamp_local

bool ui_timestamp_local = true

Definition at line 1391 of file ui_common.c.

◆ win_attr

uint16_t win_attr

Ncurses attributes for the current window, such as color pair, bold, etc.

Definition at line 34 of file ui_common.c.