Added color palette support to visual types menu

This commit is contained in:
cyanpencil 2018-07-22 23:25:25 +02:00 committed by Anton Kochkov
parent 22d369cf2b
commit 515950c559

View File

@ -481,6 +481,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
const char *pre = " "; const char *pre = " ";
RCoreVisualTypes *vt = (RCoreVisualTypes*)p; RCoreVisualTypes *vt = (RCoreVisualTypes*)p;
bool use_color = vt->core->print->flags & R_PRINT_FLAGS_COLOR; bool use_color = vt->core->print->flags & R_PRINT_FLAGS_COLOR;
char *color_sel = vt->core->cons->pal.prompt;
if (vt->optword) { if (vt->optword) {
if (!strcmp (vt->type, "struct")) { if (!strcmp (vt->type, "struct")) {
char *s = r_str_newf ("struct.%s.", vt->optword); char *s = r_str_newf ("struct.%s.", vt->optword);
@ -494,7 +495,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">"; pre = ">";
} }
if (use_color && *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); Color_RESET, pre, k+strlen (s), v);
else else
r_cons_printf (" %s %s %s\n", r_cons_printf (" %s %s %s\n",
@ -515,7 +516,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">"; pre = ">";
} }
if (use_color && *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); Color_RESET, pre, k, v);
} else { } else {
r_cons_printf (" %s %s %s\n", r_cons_printf (" %s %s %s\n",
@ -537,8 +538,8 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">"; pre = ">";
} }
if (use_color && *pre=='>') { if (use_color && *pre=='>') {
r_cons_printf (Color_YELLOW" %s pf %3s %s\n" r_cons_printf ("%s %s pf %3s %s\n"Color_RESET,
Color_RESET,pre, fmt, k); color_sel, pre, fmt, k);
} else { } else {
r_cons_printf (" %s pf %3s %s\n", r_cons_printf (" %s pf %3s %s\n",
pre, fmt, k); pre, fmt, k);
@ -553,7 +554,7 @@ static int sdbforcb (void *p, const char *k, const char *v) {
pre = ">"; pre = ">";
} }
if (use_color && *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)? (vt->t_idx == vt->t_ctr)?
">":" ", k); ">":" ", k);
} else { } else {
@ -597,14 +598,17 @@ R_API int r_core_visual_types(RCore *core) {
for (;;) { for (;;) {
r_cons_clear00 (); r_cons_clear00 ();
for (i = 0; opts[i]; i++) { for (i = 0; opts[i]; i++) {
const char *fmt = use_color if (use_color) {
? (h_opt == i) if (h_opt == i) {
? Color_BGREEN"[%s] "Color_RESET r_cons_printf ("%s[%s]%s ", core->cons->pal.call,
: Color_GREEN" %s "Color_RESET opts[i], Color_RESET);
: (h_opt == i) } else {
? "[%s] " r_cons_printf ("%s%s%s ", core->cons->pal.other,
: " %s "; opts[i], Color_RESET);
r_cons_printf (fmt, opts[i]); }
} else {
r_cons_printf (h_opt == i ? "[%s] " : " %s ", opts[i]);
}
} }
r_cons_newline (); r_cons_newline ();
if (optword) { if (optword) {