|
C-Menu 0.2.9
A User Interface Toolkit
|
#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>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 |
| #define AS_STRING | ( | NAME | ) |
Definition at line 1365 of file ui_common.c.
| #define AS_STRING | ( | NAME | ) |
Definition at line 1365 of file ui_common.c.
| void ui_abend | ( | int | ec, |
| char * | s ) |
Convert multibyte string to complex character array.
ui_mbstr_to_cellstr
| cmplx_buf | Output buffer for complex characters |
| str | Input multibyte string |
| cell_base | Base cell for attributes and color pair |
| p | Pointer to current position in the output buffer, updated as characters are added |
| atmost | Maximum length of the output buffer |
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
| ec | Exit code to return to the operating system |
| s | Message 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.
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().
| void ui_activate_all_chyron_keys | ( | UiChyron * | chyron | ) |
Deactivate chyron key.
deactivate_chyron_key
| chyron | structure |
| k | chyron_key index |
Definition at line 750 of file ui_common.c.
| void ui_activate_chyron_key | ( | UiChyron * | chyron, |
| uint | k ) |
Activate chyron key.
activate_chyron_key
| chyron | structure |
| k | chyron_key index |
Definition at line 741 of file ui_common.c.
| void ui_apply_gamma | ( | RGB * | rgb | ) |
Apply gamma correction to RGB color.
ui_apply_gamma
| rgb | Pointer 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.
References BLUE_GAMMA, GRAY_GAMMA, GREEN_GAMMA, and RED_GAMMA.
Referenced by ui_chg_color(), ui_color_from_rgb(), and ui_init_color_hex().
Assign surface and window to chyron structure.
assign_chyron_win
| chyron | pointer to UiChyron structure |
| sfc | pointer to UiSurface structure |
| win | window index (WIN or BOX) |
| y | line number for chyron display |
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.
Definition at line 634 of file ui_common.c.
References a_toi(), and ui_getmaxy().
| int ui_border_draw | ( | UiSurface * | sfc | ) |
Definition at line 474 of file ui_common.c.
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().
| int ui_border_title | ( | UiSurface * | sfc, |
| const char * | title ) |
Draw a box with a title around the specified window.
border_title
| box | Pointer to the window to draw the box around |
| title | Title 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.
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().
| int ui_border_ysplit | ( | UiSurface * | sfc, |
| uint | y ) |
Draw a box with a separator line around the specified window.
ui_border-ysplit
| box | Pointer to the window to draw the box around |
| y | Line 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.
References cell_ho, cell_lt, cell_rt, ui_getmaxx(), and ui_mvwadd_wchnstr().
Referenced by ui_tracked_sfc_split_box().
| 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
| box | Pointer to the window to draw the box around |
| text | Text to display in the middle of the separator line |
| separator_line | Line 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.
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().
| int ui_cm_surface_destroy | ( | UiSurface * | sfc | ) |
Destroy the most recently created surface.
ui_cm_destroy_surface
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.
Definition at line 466 of file ui_common.c.
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().
| void ui_compile_chyron | ( | UiChyron * | chyron | ) |
construct the chyron string from the chyron structure
compile_chyron
| 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.
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().
| void ui_deactivate_all_chyron_keys | ( | UiChyron * | chyron | ) |
Deactivate all chyron keys.
deactivate_all_chyron_keys
| chyron | structure |
Definition at line 768 of file ui_common.c.
| void ui_deactivate_chyron_key | ( | UiChyron * | chyron, |
| uint | k ) |
Deactivate chyron key.
deactivate_chyron_key
| chyron | structure |
| k | chyron_key index |
Definition at line 760 of file ui_common.c.
| UiChyron * ui_destroy_chyron | ( | UiChyron * | chyron | ) |
Destroy UiChyron structure.
destroy_chyron
| chyron | pointer to UiChyron structure |
Definition at line 656 of file ui_common.c.
Referenced by init_form(), pick_engine(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), and ui_timeout_prompt().
Display chyron on the specified line and column of the surface.
display_chyron
| sfc | Pointer to the UiSurface structure |
| w | Window index (WIN or BOX) |
| chyron | Pointer to the UiChyron structure |
| line | Line number where the chyron should be displayed |
| col | Column 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.
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().
| int ui_get_chyron_key | ( | UiChyron * | chyron, |
| uint | x ) |
Get keycode from chyron.
get_chyron_key
| chyron | structure |
| x | Mouse X position |
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.
Referenced by field_editor(), form_post(), form_process(), picker(), and ui_get_event().
| bool ui_init_clr_palette | ( | SIO * | sio | ) |
Definition at line 247 of file ui_common.c.
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().
| 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.
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().
| bool ui_is_set_chyron_key | ( | UiChyron * | chyron, |
| uint | k ) |
Check if function key label is set.
is_set_chyron_key
| chyron | structure |
| k | Function key index (0-19) |
Definition at line 677 of file ui_common.c.
Referenced by form_post(), and form_process().
| char * ui_iso8601_timestamp | ( | char * | buf, |
| size_t | n, | ||
| bool | local ) |
Generate an ISO 8601 timestamp string.
ui_iso8601_timestamp
| buf | Buffer to store the timestamp string |
| n | Size of the buffer |
| local | If true, use local time; if false, use UTC |
Definition at line 1353 of file ui_common.c.
| void ui_mbc_to_wc | ( | wchar_t | wc[2], |
| const char | mbc ) |
Convert a multibyte character to a wide character.
mbc_to_wc
| wc | Output array for wide characters (size 2) |
| mbc | Input 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.
| wchar_t * ui_mbstr_to_wcstr | ( | const char * | mb_str | ) |
Convert a multibyte string to a wide character string.
ui_mbstr_to_wcstr
| mb_str | Input multibyte string |
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.
Referenced by ui_border_title(), and ui_border_ysplit_text().
Create new chyron structure.
new_chyron
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.
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().
| FILE * ui_open_log | ( | ) |
Open the log file for writing.
ui_open_log
Definition at line 1397 of file ui_common.c.
References em0, em1, em2, em3, ssnprintf(), strnz__cpy(), ui_log_file_name, and ui_log_fp.
Referenced by mapp_initialization().
| void ui_parse_ansi | ( | char * | ansi_str, |
| attr_t * | attr, | ||
| uint * | cpx ) |
Parse ANSI escape sequences for color and attributes.
parse_ansi
| ansi_str | ANSI escape sequence string |
| attr | Pointer to attribute variable to be updated |
| cpx | Pointer 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.
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().
| uint ui_rgb_to_xterm256_idx | ( | RGB * | rgb | ) |
Convert RGB color to XTerm 256 color index.
ui_rgb_to_xterm256_idx
| rgb | RGB color |
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.
| 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
| chyron | structure |
| k | chyron key index (0-19) |
| s | chyron key label |
| kc | chyron 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.
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().
| 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
| chyron | structure |
| k | chyron key index (0-19) |
| s | chyron key label |
| kc | chyron key code |
| cell_base | color 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.
References ssnprintf().
Referenced by field_editor(), form_engine(), and picker().
| const char * ui_sub_surface_str | ( | ss_t | w | ) |
| 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
| wlines | Number of lines for the window |
| wcols | Number of columns for the window |
| wbegy | Starting Y position for the window |
| wbegx | Starting X position for the window |
| wtitle | Title for the window |
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.
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().
| 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
| wlines | Number of lines for the main window |
| wcols | Number of columns for the main window |
| split_y | Y position for the split line |
| split_x | X position for the split line (not implemented yet) |
| wbegy | Starting Y position for the window |
| wbegx | Starting X position for the window |
| wtitle | Title for the window |
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.
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().
| void ui_unset_chyron_key | ( | UiChyron * | chyron, |
| uint | k ) |
Unset chyron key.
unset_chyron_key
| chyron | structure |
| k | chyron_key index |
Definition at line 732 of file ui_common.c.
| RGB ui_xterm256_idx_to_rgb | ( | uint | idx | ) |
Convert XTerm 256 color index to RGB.
ui_xterm256_idx_to_rgb
| idx | XTerm 256 color index |
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
| idx | - XTerm 256 color index |
Definition at line 908 of file ui_common.c.
References std_color.
Referenced by parse_ansi_str(), and ui_parse_ansi().
| double BLUE_GAMMA = 1.2 |
Definition at line 65 of file ui_common.c.
Referenced by ui_apply_gamma(), and ui_initialize_sio().
| const wchar_t* border_double = L"═║╠╣╦╩╬╔╗╚╝" |
Definition at line 69 of file ui_common.c.
| const wchar_t* border_heavy = L"━┃┣┫┳┻╋┏┓┗┛" |
Definition at line 71 of file ui_common.c.
| const wchar_t* border_none = L" " |
Definition at line 72 of file ui_common.c.
| const wchar_t* border_rounded = L"─│├┤┬┴┼╭╮╰╯" |
Definition at line 70 of file ui_common.c.
| const wchar_t* border_single = L"─│├┤┬┴┼┌┐└┘" |
BOX WIDE UNICODE CODEPOINTS
Definition at line 68 of file ui_common.c.
| uint16_t box_attr |
Definition at line 35 of file ui_common.c.
| BorderWide bw |
Definition at line 27 of file ui_common.c.
| const wchar_t* bw_chk = L"\u2611" |
| const wchar_t* bw_da = L"\u2193" |
large down arrow
Definition at line 83 of file ui_common.c.
| const wchar_t* bw_h09 = L"\u23BD" |
horizontal line 9
Definition at line 87 of file ui_common.c.
| const wchar_t* bw_la = L"\u2190" |
large left arrow
Definition at line 81 of file ui_common.c.
| const wchar_t* bw_lan = L"\u276E" |
left_angle
Definition at line 85 of file ui_common.c.
| const wchar_t* bw_ra = L"\u2192" |
large right arrow
Definition at line 80 of file ui_common.c.
| const wchar_t* bw_ran = L"\u276F" |
| const wchar_t* bw_rbl = L"\u2570" |
rounded bottom left
Definition at line 77 of file ui_common.c.
| const wchar_t* bw_rbr = L"\u256f" |
rounded bottom right
Definition at line 78 of file ui_common.c.
| const wchar_t* bw_rtl = L"\u256d" |
MISCELANEOUS UNICODE CODEPOINTS rounded top left
Definition at line 75 of file ui_common.c.
| const wchar_t* bw_rtr = L"\u256e" |
rounded top right
Definition at line 76 of file ui_common.c.
| const wchar_t* bw_sp = L"\x20" |
| const wchar_t* bw_ua = L"\u2191" |
large up arrow
Definition at line 82 of file ui_common.c.
| UiCell cell_bl |
Definition at line 125 of file ui_common.c.
Referenced by ui_border_draw(), and ui_initialize_sio().
| UiCell cell_box |
Definition at line 110 of file ui_common.c.
Referenced by ui_border_title(), ui_initialize_sio(), and ui_surface_box().
| UiCell cell_br |
Definition at line 126 of file ui_common.c.
Referenced by ui_border_draw(), and ui_initialize_sio().
| UiCell cell_brktl |
Definition at line 104 of file ui_common.c.
Referenced by display_form(), and ui_initialize_sio().
| UiCell cell_brktr |
Definition at line 105 of file ui_common.c.
Referenced by display_form(), and ui_initialize_sio().
| UiCell cell_bs |
Definition at line 120 of file ui_common.c.
| UiCell cell_bt |
Definition at line 130 of file ui_common.c.
Referenced by ui_initialize_sio().
| UiCell cell_chk |
Definition at line 116 of file ui_common.c.
Referenced by picker(), remove_right_angle(), reverse_object(), toggle_object(), ui_initialize_sio(), and unreverse_object().
| UiCell cell_cmdln |
Definition at line 112 of file ui_common.c.
Referenced by ui_initialize_sio().
| UiCell cell_cr |
Definition at line 131 of file ui_common.c.
Referenced by ui_initialize_sio().
| UiCell cell_default |
Definition at line 102 of file ui_common.c.
Referenced by ui_initialize_sio().
| UiCell cell_fill_char |
Definition at line 103 of file ui_common.c.
Referenced by form_display_fields(), and ui_initialize_sio().
| UiCell cell_ho |
Definition at line 123 of file ui_common.c.
Referenced by ui_border_draw(), ui_border_title(), ui_border_ysplit(), ui_border_ysplit_text(), and ui_initialize_sio().
| UiCell cell_ind |
Definition at line 111 of file ui_common.c.
Referenced by ui_initialize_sio().
| 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().
| UiCell cell_ls |
Definition at line 117 of file ui_common.c.
| UiCell cell_lt |
Definition at line 127 of file ui_common.c.
Referenced by ui_border_title(), ui_border_ysplit(), ui_border_ysplit_text(), and ui_initialize_sio().
| UiCell cell_nt |
Definition at line 106 of file ui_common.c.
Referenced by display_pick_page(), display_prompt(), form_display_accept_field(), form_display_field(), form_display_fields(), get_cmd_arg(), init_view_boxwin(), init_view_full_screen(), menu_cmd_processor(), menu_engine(), popup_ckeys(), reverse_object(), ui_initialize_sio(), ui_surface_addpad(), ui_surface_addwin(), and unreverse_object().
| UiCell cell_nt_hl |
Definition at line 108 of file ui_common.c.
Referenced by menu_cmd_processor(), menu_engine(), ui_border_ysplit_text(), and ui_initialize_sio().
| 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().
| UiCell cell_nt_rev |
Definition at line 107 of file ui_common.c.
Referenced by display_prompt(), field_editor(), get_cmd_arg(), menu_cmd_processor(), picker(), popup_ckeys(), reverse_object(), ui_compile_chyron(), ui_initialize_sio(), and ui_set_chyron_key().
| 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().
| UiCell cell_rs |
Definition at line 118 of file ui_common.c.
| UiCell cell_rt |
Definition at line 128 of file ui_common.c.
Referenced by ui_border_title(), ui_border_ysplit(), ui_border_ysplit_text(), and ui_initialize_sio().
| UiCell cell_sp |
Definition at line 132 of file ui_common.c.
Referenced by deselect_object(), get_cmd_char(), picker(), remove_right_angle(), reverse_object(), toggle_object(), ui_border_title(), ui_border_ysplit_text(), ui_initialize_sio(), unreverse_object(), and view_cmd_processor().
| UiCell cell_title |
Definition at line 113 of file ui_common.c.
Referenced by ui_border_title(), and ui_initialize_sio().
| UiCell cell_tl |
Definition at line 121 of file ui_common.c.
Referenced by ui_border_draw(), ui_border_title(), and ui_initialize_sio().
| UiCell cell_tr |
Definition at line 122 of file ui_common.c.
Referenced by ui_border_draw(), and ui_initialize_sio().
| UiCell cell_ts |
Definition at line 119 of file ui_common.c.
| UiCell cell_tt |
Definition at line 129 of file ui_common.c.
Referenced by ui_initialize_sio().
| UiCell cell_ve |
Definition at line 124 of file ui_common.c.
Referenced by ui_border_draw(), and ui_initialize_sio().
| 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().
| 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().
| unsigned int cmd_key |
Definition at line 32 of file ui_common.c.
Referenced by ui_action_disposition(), ui_answer_yn(), ui_display_error(), and ui_timeout_prompt().
| char const colors_text[][10] |
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.
| ushort cp_blue |
blue background - for testing
Definition at line 153 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_box |
| ushort cp_brackets |
field enclosure brackets
Definition at line 149 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_cmdln |
| ushort cp_default |
| ushort cp_fill_char |
field fill characters
Definition at line 148 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_green |
green background - for testing
Definition at line 151 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_ind |
| ushort cp_ln |
| ushort cp_nt |
normal text
Definition at line 142 of file ui_common.c.
Referenced by fmt_line(), and ui_initialize_sio().
| ushort cp_nt_hl |
normal text highlight
Definition at line 144 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_nt_hl_rev |
normal text highlight reverse
Definition at line 145 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_nt_rev |
normal text reverse
Definition at line 143 of file ui_common.c.
Referenced by search(), and ui_initialize_sio().
| ushort cp_red |
red background - for testing
Definition at line 150 of file ui_common.c.
Referenced by ui_initialize_sio().
| ushort cp_title |
| ushort cp_yellow |
yellow background - for testing
Definition at line 152 of file ui_common.c.
Referenced by ui_initialize_sio().
| char em0[MAXLEN] |
error message string for error messages
Definition at line 46 of file ui_common.c.
Referenced by enter_file_spec(), form_desc_error(), form_parse_desc(), form_process(), form_read_data(), form_write(), handle_signal(), init_view_full_screen(), mk_dir(), new_init(), new_pick(), new_view(), pad_refresh(), parse_menu_description(), ui_action_disposition(), ui_add_pair(), ui_color_from_rgb(), ui_get_event(), ui_open_log(), ui_surface_box(), ui_surface_new(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), write_config(), and write_view_buffer().
| char em1[MAXLEN] |
error message string for error messages
Definition at line 47 of file ui_common.c.
Referenced by enter_file_spec(), form_desc_error(), form_parse_desc(), form_process(), form_read_data(), form_write(), handle_signal(), mk_dir(), new_init(), new_pick(), new_view(), parse_menu_description(), ui_add_pair(), ui_color_from_rgb(), ui_get_event(), ui_open_log(), ui_surface_box(), ui_surface_new(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), and write_view_buffer().
| char em2[MAXLEN] |
error message string for error messages
Definition at line 48 of file ui_common.c.
Referenced by enter_file_spec(), form_desc_error(), form_parse_desc(), form_process(), form_read_data(), form_write(), handle_signal(), mk_dir(), new_init(), new_view(), parse_menu_description(), ui_add_pair(), ui_get_event(), ui_open_log(), ui_surface_box(), ui_surface_new(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), and write_view_buffer().
| 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().
| int exit_code |
the exit code for the program, for error messages and other output
Definition at line 31 of file ui_common.c.
| bool f_ncurses_open = false |
Definition at line 50 of file ui_common.c.
Referenced by handle_signal(), ui_action_disposition(), ui_answer_yn(), ui_destroy_curses(), ui_display_error(), ui_init(), ui_perror(), ui_shutdown(), ui_timeout_prompt(), and ui_update_timeout_prompt().
| bool f_notcurses_open = false |
Definition at line 51 of file ui_common.c.
Referenced by handle_signal(), ui_action_disposition(), ui_answer_yn(), ui_destroy_curses(), ui_display_error(), ui_init(), ui_perror(), ui_shutdown(), ui_surface_addpad(), ui_surface_addwin(), ui_surface_new(), ui_timeout_prompt(), and ui_update_timeout_prompt().
| bool f_sigwench = false |
Definition at line 33 of file ui_common.c.
| char fn[MAXLEN] |
function name for error messages
Definition at line 45 of file ui_common.c.
Referenced by verify_dir(), and verify_file().
| 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().
| double GREEN_GAMMA = 1.2 |
Definition at line 64 of file ui_common.c.
Referenced by ui_apply_gamma(), and ui_initialize_sio().
| uint m_begx = -1 |
Definition at line 39 of file ui_common.c.
| uint m_begy = -1 |
Definition at line 38 of file ui_common.c.
| uint m_cols |
Definition at line 37 of file ui_common.c.
| uint m_lines |
Definition at line 36 of file ui_common.c.
| uint mouse_support |
Definition at line 40 of file ui_common.c.
| int pipe_in |
Definition at line 61 of file ui_common.c.
| int pipe_out |
Definition at line 61 of file ui_common.c.
| double RED_GAMMA = 1.2 |
Definition at line 63 of file ui_common.c.
Referenced by ui_apply_gamma(), and ui_initialize_sio().
| 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().
| 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().
| STDRGB std_color |
Definition at line 159 of file ui_common.c.
Referenced by ui_chg_color(), ui_color_from_rgb(), ui_init_color_hex(), and ui_xterm256_idx_to_rgb().
| int stderr_fd |
the file descriptor for the terminal, for error messages and other output
Definition at line 61 of file ui_common.c.
| int stdin_fd |
the file descriptor for the terminal, for error messages
Definition at line 41 of file ui_common.c.
| int stdout_fd |
the file descriptor for the terminal, for error messages
Definition at line 42 of file ui_common.c.
| const char * subsfc_s |
Definition at line 1366 of file ui_common.c.
Referenced by ui_sub_surface_str().
| int tty_fd |
Definition at line 61 of file ui_common.c.
| ui_context_t ui_ctx |
Definition at line 59 of file ui_common.c.
Referenced by ui_get_event(), ui_poll_reg_read_fd(), ui_register_read_fd(), and ui_unregister_read_fd().
| char ui_log_file_name = "/tmp/ui.log" |
Definition at line 1388 of file ui_common.c.
Referenced by ui_open_log().
| FILE * ui_log_fp = NULL |
Definition at line 1387 of file ui_common.c.
Referenced by mapp_initialization(), and ui_open_log().
| const char *const ui_log_level_s |
| const char *const ui_logcolor |
Definition at line 1377 of file ui_common.c.
| UiLogLevel ui_min_log_level = INFO |
Definition at line 1390 of file ui_common.c.
Referenced by mapp_initialization(), ui_init(), and ui_init().
| char ui_timestamp |
Definition at line 1392 of file ui_common.c.
| bool ui_timestamp_local = true |
Definition at line 1391 of file ui_common.c.
| 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.