1 /** \file color.h
2 * \brief Header: color setup
3 *
4 * PLEASE FORGOT ABOUT tty/color.h!
5 * Use skin engine for getting needed color pairs.
6 *
7 * edit/syntax.c may use this file directly, I'm agree. :)
8 *
9 */
10
11 #ifndef MC__COLOR_H
12 #define MC__COLOR_H
13
14 #include "lib/global.h" // glib.h
15
16 #ifdef HAVE_SLANG
17 #include "color-slang.h"
18 #else
19 #include "tty-ncurses.h"
20 #endif
21
22 /*** typedefs(not structures) and defined constants **********************************************/
23
24 typedef struct
25 {
26 char *fg;
27 char *bg;
28 char *attrs;
29 size_t pair_index;
30 } tty_color_pair_t;
31
32 /*
33 * Color values below this number refer directly to the ncurses/slang color pair id.
34 *
35 * Color values beginning with this number represent a role, for which the ncurses/slang color pair
36 * id is looked up runtime from tty_color_role_to_pair which is initialized when loading the skin.
37 *
38 * This way the numbers representing skinnable colors remain the same across skin changes.
39 *
40 * (Note: Another approach could be to allocate a new ncurses/slang color pair id for every role,
41 * even if they use the same colors in the skin. The problem with this is that for 8-color terminal
42 * descriptors (like TERM=linux and TERM=xterm) ncurses only allows 64 color pairs, so we can't
43 * afford to allocate new ids for duplicates.)
44 *
45 * In src/editor/editdraw.c these values are shifted by 16 bits to the left and stored in an int.
46 * Keep this number safely below 65536 to avoid overflow.
47 */
48 #define TTY_COLOR_MAP_OFFSET 4096
49
50 /*** enums ***************************************************************************************/
51
52 /*** structures declarations (and typedefs of structures)*****************************************/
53
54 /*** global variables defined in .c file *********************************************************/
55
56 extern int *tty_color_role_to_pair;
57
58 /*** declarations of public functions ************************************************************/
59
60 void tty_init_colors (gboolean disable, gboolean force, int color_map_size);
61 void tty_colors_done (void);
62
63 gboolean tty_use_colors (void);
64 int tty_try_alloc_color_pair (const tty_color_pair_t *color, gboolean is_temp);
65
66 void tty_color_free_temp (void);
67 void tty_color_free_all (void);
68
69 void tty_setcolor (int color);
70 void tty_set_normal_attrs (void);
71
72 extern gboolean tty_use_256colors (GError **error);
73 extern gboolean tty_use_truecolors (GError **error);
74
75 /*** inline functions ****************************************************************************/
76
77 #endif