32 for (
i = 0;
i < 216;
i++) {
37 ((
g << 8) & 0xffff) + (
b & 0xff);
40 for (
i = 0;
i < 24;
i++) {
43 ((
r << 8) & 0xffff) + (
r & 0xff);
50 for (
i = 16;
i < 256;
i++) {
59 bool grey = (
r > 0 &&
r < 255 &&
r ==
g &&
r ==
b);
61 return 232 + (
int)((
double)
r / (255 / 24.1));
79 const int k = (256.0 / 6);
83 return 16 + (
r * 36) + (
g * 6) +
b;
87 static int rgb(
int r,
int g,
int b) {
96 if (color < 0 || color > 255) {
100 *
r = (
rgb >> 16) & 0xff;
101 *
g = (
rgb >> 8) & 0xff;
115 ut8 isbg = 0, bold = 127;
135 if (!
p[1] || !
p[2]) {
140 case '3': isbg = 0;
break;
141 case '4': isbg = 1;
break;
143 #define SETRGB(x, y, z) \
150 if (bold != 255 && strchr(
p,
';')) {
151 if (!
p[0] || !
p[1] || !
p[2]) {
156 if (!
p[3] || !
p[4]) {
164 if (!
p[3] || !
p[4]) {
178 q = strchr(q + 1,
';');
196 case '0':
SETRGB(0, 0, 0);
break;
197 case '1':
SETRGB(bold, 0, 0);
break;
198 case '2':
SETRGB(0, bold, 0);
break;
199 case '3':
SETRGB(bold, bold, 0);
break;
200 case '4':
SETRGB(0, 0, bold);
break;
201 case '5':
SETRGB(bold, 0, bold);
break;
202 case '6':
SETRGB(0, bold, bold);
break;
203 case '7':
SETRGB(bold, bold, bold);
break;
212 rc.
r = (
off >> 2) & 0xff;
213 rc.
g = (
off >> 6) & 0xff;
214 rc.
b = (
off >> 12) & 0xff;
233 for (; attr; attr &= attr - 1) {
238 switch (attr & -attr) {
255 written =
snprintf(outstr +
i, sz -
i,
"%d;2;%d;%d;%dm", fgbg,
r,
g,
b);
260 if (id16 >= 0 && id16 <= 15) {
262 bright = id16 >= 8 ? 60 : 0;
264 bright = (
r == 0x80 &&
g == 0x80 &&
b == 0x80) ? 53
265 : (
r == 0xff ||
g == 0xff ||
b == 0xff) ? 60
267 if (
r ==
g &&
g ==
b) {
268 r = (
r > 0x7f) ? 1 : 0;
269 g = (
g > 0x7f) ? 1 : 0;
270 b = (
b > 0x7f) ? 1 : 0;
273 r = (
r >=
k) ? 1 : 0;
274 g = (
g >=
k) ? 1 : 0;
275 b = (
b >=
k) ? 1 : 0;
277 c = (
r ? 1 : 0) + (
g ? (
b ? 6 : 2) : (
b ? 4 : 0));
279 written =
snprintf(outstr +
i, sz -
i,
"%dm", fgbg + bright +
c);
286 if (written < 0 || written >= sz -
i) {
310 size_t len = strlen(outstr);
324 if (
r == 0x00 &&
g ==
b &&
g == 0) {
327 if (
r == 0xff &&
g ==
b &&
g == 0xff) {
330 if (
r == 0xff &&
g ==
b &&
g == 0) {
333 if (
g == 0xff &&
r ==
b &&
r == 0) {
336 if (
b == 0xff &&
r ==
g &&
r == 0) {
339 if (
r == 0xff &&
g == 0xff &&
b == 0x00) {
342 if (
r == 0x00 &&
g == 0xff &&
b == 0xff) {
345 if (
r == 0xff &&
g == 0x00 &&
b == 0xff) {
RZ_API RzCons * rz_cons_singleton(void)
void * calloc(size_t number, size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API void rz_cons_rgb_init(void)
RZ_API char * rz_cons_rgb_str_mode(RzConsColorMode mode, char *outstr, size_t sz, const RzColor *rcolor)
RZ_API int rz_cons_rgb_parse(const char *p, ut8 *r, ut8 *g, ut8 *b, ut8 *a)
static void init_color_table(void)
RZ_API char * rz_cons_rgb_str_off(char *outstr, size_t sz, ut64 off)
RZ_API char * rz_cons_rgb_str(char *outstr, size_t sz, const RzColor *rcolor)
RZ_API char * rz_cons_rgb_tostring(ut8 r, ut8 g, ut8 b)
static int rgb(int r, int g, int b)
static void rz_cons_rgb_gen(RzConsColorMode mode, char *outstr, size_t sz, ut8 attr, ut8 a, ut8 r, ut8 g, ut8 b, st8 id16)
static ut32 __approximate_rgb(int r, int g, int b)
static int __lookup_rgb(int r, int g, int b)
static void __unrgb(int color, int *r, int *g, int *b)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
ut64(WINAPI *w32_GetEnabledXStateFeatures)()