|
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 | 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 | mkccc (int cp, attr_t attr, 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. | |
| RGB | xterm256_idx_to_rgb (int idx) |
| Convert XTerm 256 color index to RGB color. | |
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 401 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 1536 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.
| 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 284 of file dwin.c.
References clr_pair_cnt, display_error(), em0, em1, em2, and ssnprintf().
Referenced by open_curses(), and parse_ansi_str().
| 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 526 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 429 of file dwin.c.
References SIO::bblack, SIO::bblue, SIO::bcyan, SIO::bg_clr_x, SIO::bgreen, SIO::black, SIO::blue, SIO::bmagenta, SIO::bo_clr_x, SIO::borange, SIO::bred, SIO::bwhite, SIO::byellow, CLR_BBLACK, CLR_BBLUE, CLR_BCYAN, CLR_BG, CLR_BGREEN, CLR_BLACK, CLR_BLUE, CLR_BMAGENTA, CLR_BO, CLR_BORANGE, CLR_BRED, CLR_BWHITE, CLR_BYELLOW, clr_cnt, CLR_CYAN, CLR_FG, CLR_GREEN, CLR_LN, CLR_LN_BG, 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_WHITE, CLR_YELLOW, SIO::cyan, SIO::fg_clr_x, SIO::green, init_hex_clr(), SIO::ln_bg_clr_x, SIO::ln_clr_x, 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::white, and SIO::yellow.
Referenced by open_curses().
| 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 508 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 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 1555 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 (allocated within the function) |
| s | Input multibyte string |
| attr | Attributes to apply to the complex characters |
| cp | Color pair index for the complex characters |
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 specified color pair to each character.
Definition at line 648 of file dwin.c.
| cchar_t mkccc | ( | int | cp, |
| attr_t | attr, | ||
| char * | s ) |
Create a cchar_t with the specified color pair index.
mkccc
| 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 625 of file dwin.c.
Referenced by open_curses().
| 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 315 of file dwin.c.
References apply_gamma(), RGB::b, clr_cnt, RGB::g, and RGB::r.
Referenced by parse_ansi_str().
| 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 344 of file dwin.c.
| RGB xterm256_idx_to_rgb | ( | int | idx | ) |
Convert XTerm 256 color index to RGB color.
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 366 of file dwin.c.
References RGB::b, RGB::g, RGB::r, and StdColors.
Referenced by parse_ansi_str().