Skip to content

Commit

Permalink
Added 'ecc' (css output) command to cmd_eval
Browse files Browse the repository at this point in the history
- Implemented 'ecc' command in pal.c
- Fixed indentation issues and added scope
  • Loading branch information
Monokles authored and radare committed Mar 18, 2015
1 parent ddbacdb commit b9c59d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libr/cons/pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,22 @@ R_API void r_cons_pal_list (int rad) {
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:
Expand Down
2 changes: 2 additions & 0 deletions libr/core/cmd_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static int cmd_eval(void *data, const char *input) {
"ecr","","set random palette",
"ecs","","show a colorful palette",
"ecj","","show palette in JSON",
"ecc","","show palette in CSS",
"eco"," dark|white","load white color scheme template",
"ec"," prompt red","change color of prompt",
"ec"," prompt red blue","change color and background of prompt",
Expand Down Expand Up @@ -108,6 +109,7 @@ static int cmd_eval(void *data, const char *input) {
case 's': r_cons_pal_show (); break;
case '*': r_cons_pal_list (1); break;
case 'j': r_cons_pal_list ('j'); break;
case 'c': r_cons_pal_list ('c'); break;
case '\0': r_cons_pal_list (0); break;
case 'r': r_cons_pal_random (); break;
default: {
Expand Down

0 comments on commit b9c59d3

Please sign in to comment.