Some colors fixes

This commit is contained in:
xarkes 2018-02-24 08:15:49 +01:00
parent fb0d79e6ab
commit 184d2ccb5c
3 changed files with 11 additions and 22 deletions

View File

@ -95,7 +95,7 @@ struct {
{ "bblue", RColor_BBLUE, Color_BBLUE, Color_BGBLUE },
{ "gray", RColor_GRAY, Color_GRAY, Color_BGGRAY },
{ "bgray", RColor_BGRAY, Color_BGRAY, Color_BGGRAY },
{ "none", RColor_WHITE, Color_RESET, Color_RESET },
{ "none", RColor_NULL, Color_RESET, Color_RESET },
{ NULL, RColor_NULL, NULL, NULL }
};
@ -163,6 +163,7 @@ R_API void r_cons_pal_init () {
cons->cpal.gui_border = (RColor) RColor_BLACK;
cons->cpal.highlight = (RColor) RColor_BGRED;
cons->cpal.graph_box = (RColor) RColor_NULL;
cons->cpal.graph_box2 = (RColor) RColor_BLUE;
cons->cpal.graph_box3 = (RColor) RColor_MAGENTA;
cons->cpal.graph_box4 = (RColor) RColor_GRAY;
@ -176,7 +177,6 @@ R_API void r_cons_pal_init () {
cons->pal.rainbow_sz = 0;
r_cons_pal_free ();
cons->pal.reset = Color_RESET; // reset is not user accessible, const char* is ok
cons->pal.graph_box = strdup (Color_RESET); // customizable by users, going to be freed
r_cons_pal_update_event ();
}
@ -184,7 +184,7 @@ R_API void r_cons_pal_init () {
R_API void r_cons_pal_free () {
int i;
for (i = 0; keys[i].name; i++) {
char **color = COLOR_AT(i);
char **color = COLOR_AT (i);
if (color && *color) {
R_FREE (*color);
}
@ -449,7 +449,7 @@ R_API int r_cons_pal_set(const char *key, const char *val) {
RColor *rcolor;
for (i = 0; keys[i].name; i++) {
if (!strcmp (key, keys[i].name)) {
rcolor = RCOLOR_AT(i);
rcolor = RCOLOR_AT (i);
r_cons_pal_parse (val, rcolor);
return true;
}
@ -464,7 +464,7 @@ R_API RColor r_cons_pal_get (const char *key) {
RColor *rcolor;
for (i = 0; keys[i].name; i++) {
if (!strcmp (key, keys[i].name)) {
rcolor = RCOLOR_AT(i);
rcolor = RCOLOR_AT (i);
return rcolor? *rcolor: (RColor) RColor_NULL;
}
}
@ -473,7 +473,7 @@ R_API RColor r_cons_pal_get (const char *key) {
/* Get the RColor at specified index */
R_API RColor r_cons_pal_get_i (int index) {
return *(RCOLOR_AT(index));
return *(RCOLOR_AT (index));
}
/* Get color name at index */

View File

@ -101,16 +101,6 @@ static void unrgb (int color, int *r, int *g, int *b) {
*b = rgb & 0xff;
}
static inline void rgbinit (int r, int g, int b) {
#if __UNIX__ || __CYGWIN__
r_cons_printf ("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
16 + (r * 36) + (g * 6) + b,
(r ? (r * 40 + 55) : 0),
(g ? (g * 40 + 55) : 0),
(b ? (b * 40 + 55) : 0));
#endif
}
R_API void r_cons_rgb_init (void) {
RCons *cons = r_cons_singleton ();
if (cons->truecolor < 2) {
@ -119,11 +109,6 @@ R_API void r_cons_rgb_init (void) {
if (color_table[255] == 0) {
init_color_table ();
}
int r, g, b;
for (r = 0; r < 6; r++)
for (g = 0; g < 6; g++)
for (b = 0; b < 6; b++)
rgbinit (r, g, b);
}
R_API int r_cons_rgb_parse(const char *p, ut8 *r, ut8 *g, ut8 *b, ut8 *a) {
@ -192,6 +177,10 @@ R_API char *r_cons_rgb_str(char *outstr, ut8 r, ut8 g, ut8 b, ut8 a) {
return NULL;
}
*outstr = 0;
if (a == ALPHA_RESET) {
sprintf (outstr, "%s", Color_RESET);
return outstr;
}
switch (r_cons_singleton ()->truecolor) {
case 1: // 256 color palette
sprintf (outstr, "\x1b[%d;5;%dm", fgbg, rgb (r, g, b));

View File

@ -140,7 +140,7 @@ enum {
};
#endif
enum { ALPHA_NORMAL = 0x00, ALPHA_BG = 0x01, ALPHA_BOLD = 0x02 };
enum { ALPHA_RESET = 0x00, ALPHA_NORMAL = 0x01, ALPHA_BG = 0x02, ALPHA_BOLD = 0x03 };
typedef struct rcolor_t {
ut8 a;