mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Use id16 instead of id256 for color id (#14316)
This commit is contained in:
parent
5bcc45902b
commit
1bb248d761
@ -271,7 +271,7 @@ R_API void r_cons_pal_random() {
|
||||
R_API char *r_cons_pal_parse(const char *str, RColor *outcol) {
|
||||
int i;
|
||||
RColor rcolor = (RColor) RColor_BLACK;
|
||||
rcolor.id256 = -1;
|
||||
rcolor.id16 = -1;
|
||||
char *fgcolor;
|
||||
char *bgcolor;
|
||||
char *attr = NULL;
|
||||
@ -356,7 +356,7 @@ R_API char *r_cons_pal_parse(const char *str, RColor *outcol) {
|
||||
rcolor.r = colors[i].rcolor.r;
|
||||
rcolor.g = colors[i].rcolor.g;
|
||||
rcolor.b = colors[i].rcolor.b;
|
||||
rcolor.id256 = colors[i].rcolor.id256;
|
||||
rcolor.id16 = colors[i].rcolor.id16;
|
||||
if (!outcol) {
|
||||
strncat (out, colors[i].code,
|
||||
sizeof (out) - strlen (out) - 1);
|
||||
@ -367,7 +367,7 @@ R_API char *r_cons_pal_parse(const char *str, RColor *outcol) {
|
||||
rcolor.r2 = colors[i].rcolor.r; // Initial color doesn't
|
||||
rcolor.g2 = colors[i].rcolor.g; // have r2, g2, b2
|
||||
rcolor.b2 = colors[i].rcolor.b;
|
||||
rcolor.id256 = colors[i].rcolor.id256;
|
||||
rcolor.id16 = colors[i].rcolor.id16;
|
||||
if (!outcol) {
|
||||
strncat (out, colors[i].bgcode,
|
||||
sizeof (out) - strlen (out) - 1);
|
||||
|
@ -175,7 +175,7 @@ R_API int r_cons_rgb_parse(const char *p, ut8 *r, ut8 *g, ut8 *b, ut8 *a) {
|
||||
|
||||
R_API char *r_cons_rgb_str_off(char *outstr, size_t sz, ut64 off) {
|
||||
RColor rc = RColor_BLACK;
|
||||
rc.id256 = -1;
|
||||
rc.id16 = -1;
|
||||
rc.r = (off >> 2) & 0xff;
|
||||
rc.g = (off >> 6) & 0xff;
|
||||
rc.b = (off >> 12) & 0xff;
|
||||
@ -184,7 +184,7 @@ R_API char *r_cons_rgb_str_off(char *outstr, size_t sz, ut64 off) {
|
||||
|
||||
/* Compute color string depending on cons->color */
|
||||
static void r_cons_rgb_gen(RConsColorMode mode, char *outstr, size_t sz, ut8 attr, ut8 a, ut8 r, ut8 g, ut8 b,
|
||||
st16 id256) {
|
||||
st8 id16) {
|
||||
ut8 fgbg = (a == ALPHA_BG)? 48: 38; // ANSI codes for Background/Foreground
|
||||
|
||||
if (sz < 4) { // must have at least room for "<esc>[m\0"
|
||||
@ -224,9 +224,9 @@ static void r_cons_rgb_gen(RConsColorMode mode, char *outstr, size_t sz, ut8 att
|
||||
case COLOR_MODE_16: { // ansi 16 colors
|
||||
ut8 bright, c;
|
||||
fgbg -= 8;
|
||||
if (id256 != -1) {
|
||||
c = id256 % 8;
|
||||
bright = (id256 >= 8 && id256 <= 15) ? 60 : 0;
|
||||
if (id16 >= 0 && id16 <= 15) {
|
||||
c = id16 % 8;
|
||||
bright = id16 >= 8 ? 60 : 0;
|
||||
} else {
|
||||
bright = (r == 0x80 && g == 0x80 && b == 0x80) ? 53
|
||||
: (r == 0xff || g == 0xff || b == 0xff) ? 60 : 0; // eco bright-specific
|
||||
@ -270,12 +270,12 @@ R_API char *r_cons_rgb_str_mode(RConsColorMode mode, char *outstr, size_t sz, RC
|
||||
}
|
||||
// If the color handles both foreground and background, also add background
|
||||
if (rcolor->a == ALPHA_FGBG) {
|
||||
r_cons_rgb_gen (mode, outstr, sz, 0, ALPHA_BG, rcolor->r2, rcolor->g2, rcolor->b2, rcolor->id256);
|
||||
r_cons_rgb_gen (mode, outstr, sz, 0, ALPHA_BG, rcolor->r2, rcolor->g2, rcolor->b2, rcolor->id16);
|
||||
}
|
||||
// APPEND
|
||||
size_t len = strlen (outstr);
|
||||
r_cons_rgb_gen (mode, outstr + len, sz - len, rcolor->attr, rcolor->a, rcolor->r, rcolor->g, rcolor->b,
|
||||
rcolor->id256);
|
||||
rcolor->id16);
|
||||
|
||||
return outstr;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ typedef struct rcolor_t {
|
||||
ut8 r2; // Background color
|
||||
ut8 g2; // Only used when a &= ALPHA_FGBG
|
||||
ut8 b2;
|
||||
st16 id256;
|
||||
st8 id16; // Mapping to 16-color table
|
||||
} RColor;
|
||||
|
||||
typedef struct r_cons_palette_t {
|
||||
@ -585,9 +585,9 @@ typedef struct r_cons_t {
|
||||
#define Color_BBGBLUE "\x1b[104m"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define RCOLOR(a, r, g, b, bgr, bgg, bgb, id256) {0, a, r, g, b, bgr, bgg, bgb, id256}
|
||||
#define RCOLOR(a, r, g, b, bgr, bgg, bgb, id16) {0, a, r, g, b, bgr, bgg, bgb, id16}
|
||||
#else
|
||||
#define RCOLOR(a, r, g, b, bgr, bgg, bgb, id256) (RColor) {0, a, r, g, b, bgr, bgg, bgb, id256}
|
||||
#define RCOLOR(a, r, g, b, bgr, bgg, bgb, id16) (RColor) {0, a, r, g, b, bgr, bgg, bgb, id16}
|
||||
#endif
|
||||
#define RColor_NULL RCOLOR(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1)
|
||||
#if __WINDOWS__
|
||||
|
Loading…
Reference in New Issue
Block a user