|
C-Menu 0.2.9
A User Interface Toolkit
|
Conversion of Color Data Types and Management of Colors and Color Pairs. More...
Functions | |
| void | apply_gamma (RGB *rgb) |
| Apply gamma correction to RGB color. | |
| int | clr_name_to_idx (char *s) |
| Get color index from color name. | |
| void | display_cmplx_str (WINDOW *win, cchar_t *cmplx_buf, int line, int col) |
| Display a complex character string on a window. | |
| int | get_clr_pair (int fg, int bg) |
| Get color pair index for foreground and background colors. | |
| RGB | hex_clr_str_to_rgb (char *s) |
| Convert six-digit HTML style hex color code to RGB struct. | |
| bool | init_clr_palette (SIO *sio) |
| Initialize color palette based on SIO settings. | |
| void | init_hex_clr (int idx, char *s) |
| Initialize extended ncurses color from HTML style hex string. | |
| void | initialize_local_colors (SIO *sio) |
| Initialize local color variables and color pairs based on SIO settings. | |
| void | list_colors () |
| list colors to stderr | |
| size_t | mk_cmplx_str (cchar_t *cmplx_buf, char *s, attr_t attr, int cp) |
| Convert a multibyte string to an array of cchar_t complex characters. | |
| cchar_t | mkcc (int cp, attr_t attr, const char *s) |
| Create a cchar_t with the specified color pair index. | |
| int | rgb_to_curses_clr (RGB *rgb) |
| Get color index for RGB color. | |
| int | rgb_to_xterm256_idx (RGB *rgb) |
| Convert RGB color to XTerm 256 color index. | |
| size_t | str_to_cc (cchar_t *cmplx_buf, const char *s, attr_t attr, int cp, size_t maxlen) |
| Convert a multibyte string to an array of cchar_t complex characters. | |
| RGB | xterm256_idx_to_rgb (int idx) |
| Convert XTerm 256 color index to RGB. | |
Conversion of Color Data Types and Management of Colors and Color Pairs.
| 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 518 of file dwin.c.
References RGB::b, BLUE_GAMMA, RGB::g, GRAY_GAMMA, GREEN_GAMMA, RGB::r, and RED_GAMMA.
Referenced by init_hex_clr(), and rgb_to_curses_clr().
| int clr_name_to_idx | ( | char * | s | ) |
Get color index from color name.
clr_name_to_idx
| s | Color name |
Definition at line 1966 of file dwin.c.
References colors_text, and str_to_lower().
| void display_cmplx_str | ( | WINDOW * | win, |
| cchar_t * | cmplx_buf, | ||
| int | line, | ||
| int | col ) |
Display a complex character string on a window.
display_cmplx_str
| win | NCurses window to display the string on |
| cmplx_buf | Array of cchar_t complex characters to display |
| line | Line number to display the string on |
| col | Column number to start displaying the string from |
This function clears the line where the string will be displayed, then uses wadd_wchstr to add the complex character string (cmplx_buf) to the window. Finally, it moves the cursor to the specified column position.
Definition at line 857 of file dwin.c.
| int get_clr_pair | ( | int | fg, |
| int | bg ) |
Get color pair index for foreground and background colors.
get_clr_pair
| fg | Foreground color index |
| bg | Background color index |
Definition at line 401 of file dwin.c.
References clr_pair_cnt, display_error(), em0, em1, em2, and ssnprintf().
Referenced by initialize_local_colors(), parse_ansi_str(), and ui_style_to_cch().
| RGB hex_clr_str_to_rgb | ( | char * | s | ) |
Convert six-digit HTML style hex color code to RGB struct.
hex_clr_str_to_rgb
| s | six-digit HTML style hex color code |
Definition at line 656 of file dwin.c.
References RGB::b, RGB::g, and RGB::r.
Referenced by init_hex_clr().
| 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 init_hex_clr function. After processing all colors, the clr_cnt variable is set to CLR_NCOLORS to indicate that the standard colors have been initialized.
Definition at line 546 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_cnt, 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_TITLE_FG, CLR_WHITE, CLR_YELLOW, SIO::cyan, SIO::fg, SIO::fill_char_bg, SIO::fill_char_fg, SIO::green, SIO::ind_bg, SIO::ind_fg, init_hex_clr(), 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, SIO::title_fg, SIO::white, and SIO::yellow.
Referenced by initialize_local_colors().
| void init_hex_clr | ( | int | idx, |
| char * | s ) |
Initialize extended ncurses color from HTML style hex string.
init_hex_clr
| idx | Color index |
| s | Hex color string |
NCurses uses 0-1000 for RGB values, so the RGB values from the hex string are converted to this range before initializing the color. If the color index is less than 16, the RGB values are also stored in the StdColors array for reference.
Definition at line 638 of file dwin.c.
References apply_gamma(), RGB::b, RGB::g, hex_clr_str_to_rgb(), RGB::r, and StdColors.
Referenced by init_clr_palette().
| void initialize_local_colors | ( | 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 320 of file dwin.c.
References bl, BLUE_GAMMA, SIO::blue_gamma, br, bs, bw_bl, bw_br, bw_chk, bw_da, bw_ho, bw_la, bw_lt, bw_ra, bw_ran, bw_rt, bw_sp, bw_tl, bw_tr, bw_ua, bw_ve, CC_BLUE, CC_BOX, CC_BRKTL, CC_BRKTR, CC_CHK, CC_CMDLN, CC_FILL_CHAR, CC_GREEN, CC_IND, CC_LN, CC_NORM, CC_NT, CC_NT_HL, CC_NT_HL_REV, CC_NT_REV, CC_RAN, CC_RED, CC_TITLE, CC_YELLOW, chk, 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, cp_blue, cp_box, cp_brackets, cp_cmdln, cp_fill_char, cp_green, cp_ind, cp_ln, cp_norm, cp_nt, cp_nt_hl, cp_nt_hl_rev, cp_nt_rev, cp_red, cp_title, cp_yellow, da, get_clr_pair(), GRAY_GAMMA, SIO::gray_gamma, GREEN_GAMMA, SIO::green_gamma, init_clr_palette(), la, ls, lt, mkcc(), ra, ran, RED_GAMMA, SIO::red_gamma, rs, rt, sp, tl, tr, ts, and ua.
Referenced by main(), and read_theme().
| void list_colors | ( | ) |
list colors to stderr
list_colors
only lists the first 16, since that's how many we let the user redefine
Definition at line 1985 of file dwin.c.
References colors_text.
| size_t mk_cmplx_str | ( | cchar_t * | cmplx_buf, |
| char * | s, | ||
| attr_t | attr, | ||
| int | cp ) |
Convert a multibyte string to an array of cchar_t complex characters.
mk_cmplx_str
| cmplx_buf | Output buffer for complex characters |
| s | Input multibyte string |
| attr | Attributes to apply to the complex characters |
| cp | Color pair index for the complex characters |
Definition at line 828 of file dwin.c.
| cchar_t mkcc | ( | int | cp, |
| attr_t | attr, | ||
| const char * | s ) |
Create a cchar_t with the specified color pair index.
mkcc
| cp | Color pair index |
| attr | Attributes to apply to the cchar_t |
| s | Multibyte string to convert to wide character (only the first character is used) |
Definition at line 748 of file dwin.c.
Referenced by init_form(), initialize_local_colors(), and ui_style_to_cch().
| int rgb_to_curses_clr | ( | RGB * | rgb | ) |
Get color index for RGB color.
rgb_to_curses_clr
| rgb | RGB color |
Curses uses 0-1000 for RGB values. If the color does not exist, it is created along with a new color index
Definition at line 432 of file dwin.c.
References apply_gamma(), RGB::b, clr_cnt, RGB::g, and RGB::r.
Referenced by parse_ansi_str(), and ui_style_to_cch().
| int 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 461 of file dwin.c.
| size_t str_to_cc | ( | cchar_t * | cmplx_buf, |
| const char * | s, | ||
| attr_t | attr, | ||
| int | cp, | ||
| size_t | maxlen ) |
Convert a multibyte string to an array of cchar_t complex characters.
str_to_cc
| cmplx_buf | Output buffer for complex characters |
| s | Input multibyte string |
| attr | Attributes to apply to the complex characters |
| cp | Color pair index for the complex characters |
| maxlen | Maximum length of the output buffer |
This function converts a multibyte string to an array of cchar_t complex characters that can be used with NCurses functions. It handles multibyte characters and applies the specified color pair to each character. The function ensures that it does not exceed the maximum length of the output buffer.
Definition at line 786 of file dwin.c.
Referenced by form_display_field(), and form_display_fields().
| RGB xterm256_idx_to_rgb | ( | int | 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 483 of file dwin.c.
References RGB::b, RGB::g, RGB::r, and StdColors.
Referenced by parse_ansi_str().