|
C-Menu 0.2.9
A User Interface Toolkit
|
Window support for C-Menu - EXPERIMENTAL. More...
#include "cm.h"#include "ui_backend.h"#include <errno.h>#include <fcntl.h>#include <iso646.h>#include <math.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 <unistd.h>#include <wchar.h>Go to the source code of this file.
Typedefs | |
| typedef enum Cells | cells_t |
Enumerations | |
| enum | Cells { _DEFAULT , _FILL_CHAR , _BRKTL , _BRKTR , _NT , _NT_REV , _NT_HL , _NT_HL_REV , _BOX , _IND , _CMDLN , _TITLE , _LN , _RAN , _CHK , _LS , _RS , _TS , _BS , _TL , _TR , _HO , _VE , _BL , _BR , _LT , _RT , _TT , _BT , _CR , _SP , _DEFAULT , _FILL_CHAR , _BRKTL , _BRKTR , _NT , _NT_REV , _NT_HL , _NT_HL_REV , _BOX , _IND , _CMDLN , _TITLE , _LN , _RAN , _CHK , _LS , _RS , _TS , _BS , _TL , _TR , _HO , _VE , _BL , _BR , _LT , _RT , _TT , _BT , _CR , _SP } |
| enum | Cells { _DEFAULT , _FILL_CHAR , _BRKTL , _BRKTR , _NT , _NT_REV , _NT_HL , _NT_HL_REV , _BOX , _IND , _CMDLN , _TITLE , _LN , _RAN , _CHK , _LS , _RS , _TS , _BS , _TL , _TR , _HO , _VE , _BL , _BR , _LT , _RT , _TT , _BT , _CR , _SP , _DEFAULT , _FILL_CHAR , _BRKTL , _BRKTR , _NT , _NT_REV , _NT_HL , _NT_HL_REV , _BOX , _IND , _CMDLN , _TITLE , _LN , _RAN , _CHK , _LS , _RS , _TS , _BS , _TL , _TR , _HO , _VE , _BL , _BR , _LT , _RT , _TT , _BT , _CR , _SP } |
Functions | |
| void | abend (int ec, char *s) |
| Abnormal program termination. | |
| bool | action_disposition (char *title, char *action_str) |
| Display a simple action disposition message window or print to stderr. | |
| void | activate_all_chyron_keys (Chyron *chyron) |
| Deactivate chyron key. | |
| void | activate_chyron_key (Chyron *chyron, uint k) |
| Activate chyron key. | |
| int | answer_yn (char *msg0, char *msg1, char *msg2, char *msg3) |
| Accept a single letter answer. | |
| void | apply_gamma (RGB *rgb) |
| Apply gamma correction to RGB color. | |
| int | assign_chyron_win (Chyron *chyron, UiSurface *sfc, uint win, char *y) |
| int | border_draw (UiSurface *sfc) |
| int | border_title (UiSurface *sfc, char *title) |
| Draw a box with a title around the specified window. | |
| int | border_ysplit (UiSurface *sfc, uint y) |
| Draw a box with a separator line around the specified window. | |
| int | border_ysplit_text (UiSurface *sfc, char *text, uint separator_line) |
| Draw a box with a separator line and text around the specified window. | |
| int | cm_surface_destroy (UiSurface *sfc) |
| Destroy the most recently created surface. | |
| void | compile_chyron (Chyron *chyron) |
| construct the chyron string from the chyron structure | |
| void | deactivate_all_chyron_keys (Chyron *chyron) |
| Deactivate all chyron keys. | |
| void | deactivate_chyron_key (Chyron *chyron, uint k) |
| Deactivate chyron key. | |
| Chyron * | destroy_chyron (Chyron *chyron) |
| Destroy Chyron structure. | |
| void | destroy_curses () |
| Gracefully shut down NCurses and restore terminal settings. | |
| void | display_chyron (UiSurface *sfc, uint w, Chyron *chyron, uint line, uint col) |
| Display chyron on the specified line and column of the surface. | |
| int | display_error (char *msg0, char *msg1, char *msg2, char *msg3) |
| Display an error message window or print to stderr. | |
| int | get_chyron_key (Chyron *chyron, uint x) |
| Get keycode from chyron. | |
| bool | init_clr_palette (SIO *sio) |
| Initialize color palette based on SIO settings. | |
| void | initialize_cells (SIO *sio) |
| Initialize local color variables and color pairs based on SIO settings. | |
| bool | is_set_chyron_key (Chyron *chyron, uint k) |
| Check if function key label is set. | |
| void | mbc_to_wc (wchar_t wc[2], const char mbc) |
| uint | mbstr_to_cellstr (UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost) |
| Convert multibyte string to complex character array. | |
| wchar_t * | mbstr_to_wcstr (const char *mb_str) |
| Chyron * | new_chyron () |
| Create and initialize Chyron structure. | |
| int | Perror (char *emsg_str) |
| Display a simple error message window or print to stderr. | |
| uint | rgb_to_xterm256_idx (RGB *rgb) |
| Convert RGB color to XTerm 256 color index. | |
| void | set_chyron_key (Chyron *chyron, uint k, char *s, uint kc) |
| Set chyron key with default color pair (cp_nt_rev). | |
| void | set_chyron_key_cb (Chyron *chyron, uint k, char *s, uint kc, UiCell cell_base) |
| Set chyron key with color pair (cp). | |
| int | surface_box_win_new (uint wlines, uint wcols, uint wbegy, uint wbegx, char *wtitle) |
| int | surface_split_box_win_new (uint wlines, uint wcols, uint split_y, uint split_x, uint wbegy, uint wbegx, char *wtitle) |
| void | unset_chyron_key (Chyron *chyron, uint k) |
| Unset chyron key. | |
| RGB | xterm256_idx_to_rgb (uint idx) |
| Convert XTerm 256 color index to RGB. | |
Window support for C-Menu - EXPERIMENTAL.
This file contains functions for managing NCurses windows and color settings for the Chyron structure for function key labels and mouse click handling. This file is a work in progress and may be subject to change as the C-Menu project evolves. Generally, don't try to use it yet unless you want complete the half-done code modifications.
Definition in file dwin.c.
| enum Cells |
Definition at line 56 of file dwin.c.
| enum Cells |
Definition at line 56 of file dwin.c.
| void apply_gamma | ( | RGB * | rgb | ) |
Apply gamma correction to RGB color.
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 307 of file dwin.c.
References BLUE_GAMMA, GRAY_GAMMA, GREEN_GAMMA, and RED_GAMMA.
Referenced by ui_add_color_rgb(), ui_chg_color(), and ui_init_color_hex().
Definition at line 962 of file dwin.c.
References a_toi(), Chyron::sfc, ui_getmaxy(), Chyron::win, and Chyron::y.
Referenced by open_pick_win().
| int border_draw | ( | UiSurface * | sfc | ) |
Definition at line 581 of file dwin.c.
References BOX, cell_bl, cell_br, cell_ho, cell_tl, cell_tr, cell_ve, ui_getmaxx(), ui_getmaxy(), ui_mvwadd_wchnstr(), and ui_render().
Referenced by ui_box_surface_new(), and ui_box_surface_new().
| bool init_clr_palette | ( | SIO * | sio | ) |
Initialize color palette based on SIO settings.
init_clr_palette
| sio | Pointer to SIO struct with color settings |
This function initializes the xterm256 color cube and applies any color overrides specified in the SIO struct. The color strings in the SIO struct are expected to be six-digit HTML style hex color codes (e.g., "#RRGGBB"). If a color override is specified for any of the standard colors, it is applied using the ui_add_color_hex function.
Definition at line 333 of file dwin.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 initialize_cells().
| void initialize_cells | ( | SIO * | sio | ) |
Initialize local color variables and color pairs based on SIO settings.
| sio | Pointer to SIO struct with color settings |
This function initializes local color variables and color pairs based on the settings in the SIO struct. It applies gamma correction to colors and sets up cchar_t variables for use in NCurses functions. The color pair indices are stored in global variables for easy reference throughout the code when applying colors to various parts of the interface using NCurses functions that accept color pair indices.
gamma correction values
These are read from ~/.minitrc
used when initializing colors
Definition at line 177 of file dwin.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, init_clr_palette(), 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_add_pair(), and ui_cell_from_ucp().
Referenced by main(), and read_theme().
| void mbc_to_wc | ( | wchar_t | wc[2], |
| const char | mbc ) |
| wchar_t * mbstr_to_wcstr | ( | const char * | mb_str | ) |
Definition at line 404 of file dwin.c.
Referenced by border_title(), and border_ysplit_text().
| uint rgb_to_xterm256_idx | ( | RGB * | rgb | ) |
Convert RGB color to XTerm 256 color index.
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 252 of file dwin.c.
| int surface_box_win_new | ( | uint | wlines, |
| uint | wcols, | ||
| uint | wbegy, | ||
| uint | wbegx, | ||
| char * | wtitle ) |
Definition at line 521 of file dwin.c.
References BOX, Perror(), sfc_ptr, ui_box_surface_new(), ui_get_screen_size(), ui_render(), ui_surface, ui_surface_addwin(), and WIN.
Referenced by action_disposition(), answer_yn(), display_error(), display_form(), menu_engine(), Perror(), and popup_ckeys().
| int surface_split_box_win_new | ( | uint | wlines, |
| uint | wcols, | ||
| uint | split_y, | ||
| uint | split_x, | ||
| uint | wbegy, | ||
| uint | wbegx, | ||
| char * | wtitle ) |
Definition at line 539 of file dwin.c.
References border_ysplit(), BOX, Perror(), sfc_ptr, ui_box_surface_new(), ui_curs_set(), ui_get_screen_size(), ui_render(), ui_surface, ui_surface_addwin(), WIN, and WIN2.
Referenced by open_pick_win().
| RGB xterm256_idx_to_rgb | ( | uint | idx | ) |
Convert XTerm 256 color index to RGB.
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 274 of file dwin.c.
References STDRGB::b, STDRGB::g, STDRGB::r, and std_color.
Referenced by parse_ansi(), and parse_ansi_str().
| double BLUE_GAMMA = 1.2 |
Definition at line 125 of file dwin.c.
Referenced by apply_gamma(), and initialize_cells().
| UiCell cell_bl |
Definition at line 113 of file dwin.c.
Referenced by border_draw(), and initialize_cells().
| UiCell cell_box |
Definition at line 98 of file dwin.c.
Referenced by border_title(), initialize_cells(), ui_bkgd(), and ui_box_surface_new().
| UiCell cell_br |
Definition at line 114 of file dwin.c.
Referenced by border_draw(), and initialize_cells().
| UiCell cell_brktl |
Definition at line 92 of file dwin.c.
Referenced by display_form(), and initialize_cells().
| UiCell cell_brktr |
Definition at line 93 of file dwin.c.
Referenced by display_form(), and initialize_cells().
| UiCell cell_bt |
Definition at line 118 of file dwin.c.
Referenced by initialize_cells().
| UiCell cell_chk |
Definition at line 104 of file dwin.c.
Referenced by initialize_cells(), picker(), remove_right_angle(), reverse_object(), toggle_object(), and unreverse_object().
| UiCell cell_cmdln |
Definition at line 100 of file dwin.c.
Referenced by initialize_cells().
| UiCell cell_cr |
Definition at line 119 of file dwin.c.
Referenced by initialize_cells().
| UiCell cell_default |
Definition at line 90 of file dwin.c.
Referenced by initialize_cells().
| UiCell cell_fill_char |
Definition at line 91 of file dwin.c.
Referenced by form_display_fields(), and initialize_cells().
| UiCell cell_ho |
Definition at line 111 of file dwin.c.
Referenced by border_draw(), border_title(), border_ysplit(), border_ysplit_text(), and initialize_cells().
| UiCell cell_ind |
Definition at line 99 of file dwin.c.
Referenced by initialize_cells().
| UiCell cell_ln |
Definition at line 102 of file dwin.c.
Referenced by init_view_boxwin(), init_view_full_screen(), and initialize_cells().
| UiCell cell_lt |
Definition at line 115 of file dwin.c.
Referenced by border_title(), border_ysplit(), border_ysplit_text(), and initialize_cells().
| UiCell cell_nt |
Definition at line 94 of file dwin.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(), initialize_cells(), menu_cmd_processor(), menu_engine(), popup_ckeys(), reverse_object(), ui_surface_addpad(), ui_surface_addwin(), and unreverse_object().
| UiCell cell_nt_hl |
Definition at line 96 of file dwin.c.
Referenced by border_ysplit_text(), initialize_cells(), menu_cmd_processor(), and menu_engine().
| UiCell cell_nt_hl_rev |
Definition at line 97 of file dwin.c.
Referenced by field_editor(), form_engine(), initialize_cells(), menu_cmd_processor(), and picker().
| UiCell cell_nt_rev |
Definition at line 95 of file dwin.c.
Referenced by compile_chyron(), display_prompt(), field_editor(), get_cmd_arg(), initialize_cells(), menu_cmd_processor(), picker(), popup_ckeys(), reverse_object(), search(), and set_chyron_key().
| UiCell cell_ran |
Definition at line 103 of file dwin.c.
Referenced by get_cmd_arg(), get_cmd_char(), initialize_cells(), and picker().
| UiCell cell_rt |
Definition at line 116 of file dwin.c.
Referenced by border_title(), border_ysplit(), border_ysplit_text(), and initialize_cells().
| UiCell cell_sp |
Definition at line 120 of file dwin.c.
Referenced by border_title(), border_ysplit_text(), deselect_object(), get_cmd_char(), initialize_cells(), picker(), remove_right_angle(), reverse_object(), toggle_object(), unreverse_object(), and view_cmd_processor().
| UiCell cell_title |
Definition at line 101 of file dwin.c.
Referenced by border_title(), and initialize_cells().
| UiCell cell_tl |
Definition at line 109 of file dwin.c.
Referenced by border_draw(), border_title(), and initialize_cells().
| UiCell cell_tr |
Definition at line 110 of file dwin.c.
Referenced by border_draw(), and initialize_cells().
| UiCell cell_tt |
Definition at line 117 of file dwin.c.
Referenced by initialize_cells().
| UiCell cell_ve |
Definition at line 112 of file dwin.c.
Referenced by border_draw(), and initialize_cells().
| int click_x |
the x coordinate of a mouse click
Definition at line 45 of file dwin.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 44 of file dwin.c.
Referenced by cf_accept(), field_editor(), form_post(), and form_process().
| unsigned int cmd_key |
Definition at line 128 of file dwin.c.
Referenced by action_disposition(), answer_yn(), and display_error().
| char const colors_text |
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 51 of file dwin.c.
| ushort cp_blue |
blue background color pair index
Definition at line 162 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_box |
| ushort cp_brackets |
color pair index for field brackets
Definition at line 158 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_cmdln |
Definition at line 149 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_default |
| ushort cp_fill_char |
fill character color pair index
Definition at line 157 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_green |
green background color pair index
Definition at line 160 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_ind |
| ushort cp_ln |
Definition at line 155 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_nt |
normal color pair index
Definition at line 151 of file dwin.c.
Referenced by fmt_line(), initialize_cells(), and mbstr_to_cc().
| ushort cp_nt_hl |
| ushort cp_nt_hl_rev |
highlight reverse color pair index
Definition at line 154 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_nt_rev |
| ushort cp_red |
red background color pair index
Definition at line 159 of file dwin.c.
Referenced by initialize_cells().
| ushort cp_title |
| ushort cp_yellow |
yellow background color pair index
Definition at line 161 of file dwin.c.
Referenced by initialize_cells().
| char em0 |
error message string for error messages
Definition at line 142 of file dwin.c.
Referenced by action_disposition(), 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(), notcurses_input(), open_cmenu_log(), parse_menu_description(), ui_add_pair(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), and write_view_buffer().
| char em1 |
error message string for error messages
Definition at line 143 of file dwin.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(), notcurses_input(), parse_menu_description(), ui_add_pair(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), write_cmenu_log_ts(), and write_view_buffer().
| char em2 |
error message string for error messages
Definition at line 144 of file dwin.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(), notcurses_input(), parse_menu_description(), ui_add_pair(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), and write_view_buffer().
| char em3 |
error message string for error messages
Definition at line 145 of file dwin.c.
Referenced by verify_dir(), and verify_file().
| int exit_code |
| char fn |
function name for error messages
Definition at line 141 of file dwin.c.
Referenced by verify_dir(), and verify_file().
| double GRAY_GAMMA = 1.2 |
Gamma correction. Set in .minitrc
Definition at line 122 of file dwin.c.
Referenced by apply_gamma(), and initialize_cells().
| double GREEN_GAMMA = 1.2 |
Definition at line 124 of file dwin.c.
Referenced by apply_gamma(), and initialize_cells().
| double RED_GAMMA = 1.2 |
Definition at line 123 of file dwin.c.
Referenced by apply_gamma(), and initialize_cells().
| uint src_line |
the line number of the source file being processed, for error messages
Definition at line 139 of file dwin.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 140 of file dwin.c.
Referenced by verify_dir(), and verify_file().
| int stderr_fd |
| int stdin_fd |
| int stdout_fd |