示例#1
0
R_API void r_cons_pal_list (int rad) {
	RConsPalette *pal = &(r_cons_singleton ()->pal);
	ut8 *p = (ut8*)pal;
	ut8 r, g, b;
	char **color, rgbstr[32];
	const char *hasnext;
	int i;
	if (rad=='j')
		r_cons_printf ("{");
	for (i=0; keys[i].name; i++) {
		color = (char**)(p + keys[i].off);
		switch (rad) {
		case 'j':
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			hasnext = (keys[i+1].name)?",":"";
			r_cons_printf ("\"%s\":[%d,%d,%d]%s",
				keys[i].name, r, g, b, hasnext);
			break;
		case 'c': {
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			hasnext = (keys[i+1].name) ? "\n" : "";
			//Need to replace the '.' char because this is not valid CSS
			char *name = strdup(keys[i].name);
			int j, len = strlen(name);
			for(j=0; j < len; j++) {
				if(name[j] == '.')
					name[j] = '_';
			}
			r_cons_printf (".%s { color: rgb(%d, %d, %d); }%s",
				name, r, g, b, hasnext);
			free(name);
			}
			break;
		case '*':
		case 'r':
		case 1:
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			rgbstr[0] = 0;
			r_cons_rgb_str (rgbstr, r, g, b, 0);
			r >>= 4;
			g >>= 4;
			b >>= 4;
			r_cons_printf ("ec %s rgb:%x%x%x\n",
				keys[i].name, r&0xf, g&0xf, b&0xf);
			break;
		default:
			r_cons_printf (" %s##"Color_RESET"  %s\n", *color, keys[i].name);
		}
	}
	if (rad=='j')
		r_cons_printf ("}\n");
}
示例#2
0
文件: grep.c 项目: tutamuniz/radare2
static const char *gethtmlrgb(const char *str) {
	static char buf[32];
	ut8 r, g, b;
	r = g = b = 0;
	r_cons_rgb_parse (str, &r, &g, &b, 0);
	sprintf (buf, "#%02x%02x%02x", r, g, b);
	return buf;
}
示例#3
0
文件: pal.c 项目: commiebstrd/radare2
R_API void r_cons_pal_list (int rad) {
	RConsPalette *pal = &(r_cons_singleton ()->pal);
	ut8 *p = (ut8*)pal;
	ut8 r, g, b;
	char **color, rgbstr[32];
	const char *hasnext;
	int i;
	if (rad=='j')
		r_cons_printf ("{");
	for (i=0; keys[i].name; i++) {
		color = (char**)(p + keys[i].off);
		switch (rad) {
		case 'j':
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			hasnext = (keys[i+1].name)?",":"";
			r_cons_printf ("\"%s\":[%d,%d,%d]%s",
				keys[i].name, r, g, b, hasnext);
			break;
		case '*':
		case 'r':
		case 1:
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			rgbstr[0] = 0;
			r_cons_rgb_str (rgbstr, r, g, b, 0);
			// r >>= 4;
			// g >>= 4;
			// b >>= 4;
			r_cons_printf ("ec %s rgb:%02x%02x%02x\n",
				keys[i].name, r, g, b);
			break;
		default:
			r_cons_printf (" %s##"Color_RESET"  %s\n", *color, keys[i].name);
		}
	}
	if (rad=='j')
		r_cons_printf ("}\n");
}
示例#4
0
文件: pal.c 项目: l3acon/radare2
R_API void r_cons_pal_list (int rad) {
	RConsPalette *pal = &(r_cons_singleton ()->pal);
	ut8 *p = (ut8*)pal;
	ut8 r, g, b;
	char **color, rgbstr[32];;
	int i;
	for (i=0; keys[i].name; i++) {
		color = (char**)(p + keys[i].off);
		if (rad) {
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			rgbstr[0] = 0;
			r_cons_rgb_str (rgbstr, r, g, b, 0);
			r >>= 4;
			g >>= 4;
			b >>= 4;
			r_cons_printf ("ec %s rgb:%x%x%x\n",
				keys[i].name, r, g, b);
		} else
		r_cons_printf (" %s##"Color_RESET"  %s\n", *color, keys[i].name);
	}
示例#5
0
文件: pal.c 项目: AmesianX/radare2
R_API void r_cons_pal_list (int rad, const char *arg) {
	RConsPalette *pal = & (r_cons_singleton ()->pal);
	ut8 r, g, b, *p = (ut8*)pal;
	char *name, **color, rgbstr[32];
	const char *hasnext;
	int i;
	if (rad == 'j') r_cons_print ("{");
	for (i = 0; keys[i].name; i++) {
		color = (char**) (p + keys[i].off);
		switch (rad) {
		case 'j':
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			hasnext = (keys[i + 1].name) ? "," : "";
			r_cons_printf ("\"%s\":[%d,%d,%d]%s",
				keys[i].name, r, g, b, hasnext);
			break;
		case 'c': {
			const char *prefix = r_str_chop_ro (arg);
			if (!prefix) {
				prefix = "";
			}
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			hasnext = (keys[i + 1].name) ? "\n" : "";
			//Need to replace the '.' char because this is not
			//valid CSS
			char *name = strdup (keys[i].name);
			int j, len = strlen (name);
			for (j = 0; j < len; j++) {
				if (name[j] == '.') {
					name[j] = '_';
				}
			}
			r_cons_printf (".%s%s { color: rgb(%d, %d, %d); }%s",
				prefix, name, r, g, b, hasnext);
			free (name);
			}
			break;
		case 'h':
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			rgbstr[0] = 0;
			name = strdup (keys[i].name);
			r_str_replace_char (name, '.', '_');
			r_cons_printf (".%s { color:#%02x%02x%02x }\n",
				name, r, g, b);
			free (name);
			break;
		case '*':
		case 'r':
		case 1:
			r = g = b = 0;
			r_cons_rgb_parse (*color, &r, &g, &b, NULL);
			rgbstr[0] = 0;
			r_cons_rgb_str (rgbstr, r, g, b, 0);
			r_cons_printf ("ec %s rgb:%02x%02x%02x\n",
				keys[i].name, r, g, b);
			break;
		default:
			r_cons_printf (" %s##"Color_RESET"  %s\n", *color,
				keys[i].name);
		}
	}
	if (rad == 'j') r_cons_print ("}\n");
}