Skip to content

Commit

Permalink
Added color palette support to visual types menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanpencil authored and XVilka committed Jul 23, 2018
1 parent 22d369c commit 515950c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions libr/core/vmenus.c
Expand Up @@ -481,6 +481,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
const char *pre = " ";
RCoreVisualTypes *vt = (RCoreVisualTypes*)p;
bool use_color = vt->core->print->flags & R_PRINT_FLAGS_COLOR;
char *color_sel = vt->core->cons->pal.prompt;
if (vt->optword) {
if (!strcmp (vt->type, "struct")) {
char *s = r_str_newf ("struct.%s.", vt->optword);
Expand All @@ -494,7 +495,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">";
}
if (use_color && *pre=='>')
r_cons_printf (Color_YELLOW" %s %s %s\n"
r_cons_printf ("%s %s %s %s\n", color_sel,
Color_RESET, pre, k+strlen (s), v);
else
r_cons_printf (" %s %s %s\n",
Expand All @@ -515,7 +516,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">";
}
if (use_color && *pre=='>') {
r_cons_printf (Color_YELLOW" %s %s %s\n"
r_cons_printf ("%s %s %s %s\n", color_sel,
Color_RESET, pre, k, v);
} else {
r_cons_printf (" %s %s %s\n",
Expand All @@ -537,8 +538,8 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">";
}
if (use_color && *pre=='>') {
r_cons_printf (Color_YELLOW" %s pf %3s %s\n"
Color_RESET,pre, fmt, k);
r_cons_printf ("%s %s pf %3s %s\n"Color_RESET,
color_sel, pre, fmt, k);
} else {
r_cons_printf (" %s pf %3s %s\n",
pre, fmt, k);
Expand All @@ -553,7 +554,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">";
}
if (use_color && *pre == '>') {
r_cons_printf (Color_YELLOW" %s %s\n"Color_RESET,
r_cons_printf ("%s %s %s\n"Color_RESET, color_sel,
(vt->t_idx == vt->t_ctr)?
">":" ", k);
} else {
Expand Down Expand Up @@ -597,14 +598,17 @@ R_API int r_core_visual_types(RCore *core) {
for (;;) {
r_cons_clear00 ();
for (i = 0; opts[i]; i++) {
const char *fmt = use_color
? (h_opt == i)
? Color_BGREEN"[%s] "Color_RESET
: Color_GREEN" %s "Color_RESET
: (h_opt == i)
? "[%s] "
: " %s ";
r_cons_printf (fmt, opts[i]);
if (use_color) {
if (h_opt == i) {
r_cons_printf ("%s[%s]%s ", core->cons->pal.call,
opts[i], Color_RESET);
} else {
r_cons_printf ("%s%s%s ", core->cons->pal.other,
opts[i], Color_RESET);
}
} else {
r_cons_printf (h_opt == i ? "[%s] " : " %s ", opts[i]);
}
}
r_cons_newline ();
if (optword) {
Expand Down

0 comments on commit 515950c

Please sign in to comment.