Allow asm.highlight color change thru ec line_highlight (#10051)

This commit is contained in:
Khairul Azhar Kasmiran 2018-05-09 15:31:33 +08:00 committed by radare
parent 004031aaeb
commit ce3ddd5f6c
3 changed files with 12 additions and 2 deletions

View File

@ -70,6 +70,7 @@ static struct {
{ "gui.alt_background", r_offsetof (RConsPrintablePalette, gui_alt_background), r_offsetof (RConsPalette, gui_alt_background) },
{ "gui.border", r_offsetof (RConsPrintablePalette, gui_border), r_offsetof (RConsPalette, gui_border) },
{ "highlight", r_offsetof (RConsPrintablePalette, highlight), r_offsetof (RConsPalette, highlight) },
{ "line_highlight", r_offsetof (RConsPrintablePalette, line_highlight), r_offsetof (RConsPalette, line_highlight) },
{ NULL, 0, 0 }
};
@ -159,6 +160,7 @@ R_API void r_cons_pal_init() {
cons->cpal.gui_alt_background = (RColor) RColor_WHITE;
cons->cpal.gui_border = (RColor) RColor_BLACK;
cons->cpal.highlight = (RColor) RColor_BGRED;
cons->cpal.line_highlight = (RColor) RCOLOR (ALPHA_BG, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00);
cons->cpal.graph_box = (RColor) RColor_NULL;
cons->cpal.graph_box2 = (RColor) RColor_BLUE;
@ -328,6 +330,9 @@ R_API char *r_cons_pal_parse(const char *str, RColor *outcol) {
}
}
if (outcol) {
if (outcol->a == ALPHA_BG && !bgcolor) {
rcolor.a = ALPHA_BG;
}
*outcol = rcolor;
}
free (fgcolor);

View File

@ -208,6 +208,7 @@ typedef struct {
const char *color_gui_background;
const char *color_gui_alt_background;
const char *color_gui_border;
const char *color_line_highlight;
RFlagItem *lastflag;
RAnalHint *hint;
@ -556,6 +557,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->color_gui_background = P(gui_background): Color_BLACK;
ds->color_gui_alt_background = P(gui_alt_background): Color_GRAY;
ds->color_gui_border = P(gui_border): Color_BGGRAY;
ds->color_line_highlight = P(line_highlight): Color_BGBLUE;
ds->immstr = r_config_get_i (core->config, "asm.immstr");
ds->immtrim = r_config_get_i (core->config, "asm.immtrim");
@ -887,7 +889,7 @@ static bool ds_must_strip(RDisasmState *ds) {
static void ds_highlight_word(RDisasmState * ds, char *word, char *color) {
char *source = ds->opstr? ds->opstr: ds->asmop.buf_asm;
const char *color_reset = ds->vat == ds->core->prompt_offset ? Color_BGBLUE : Color_RESET_BG;
const char *color_reset = ds->vat == ds->core->prompt_offset ? ds->color_line_highlight : Color_RESET_BG;
char *asm_str = r_str_highlight (source, word, color, color_reset);
ds->opstr = asm_str? asm_str:source;
}
@ -4369,7 +4371,7 @@ static bool line_highlighted(RDisasmState *ds) {
static void ds_start_line_highlight(RDisasmState *ds) {
if (ds->show_color && line_highlighted (ds)) {
r_cons_strcat (Color_BGBLUE);
r_cons_strcat (ds->color_line_highlight);
}
}

View File

@ -127,6 +127,7 @@ enum {
R_CONS_PAL_GUI_BACKGROUND,
R_CONS_PAL_GUI_ALT_BACKGROUND,
R_CONS_PAL_GUI_BORDER,
R_CONS_PAL_LINE_HIGHLIGHT,
R_CONS_PAL_GRAPH_BOX,
R_CONS_PAL_GRAPH_BOX2,
R_CONS_PAL_GRAPH_BOX3,
@ -207,6 +208,7 @@ typedef struct r_cons_palette_t {
RColor gui_alt_background;
RColor gui_border;
RColor highlight;
RColor line_highlight;
/* Graph colors */
RColor graph_box;
@ -271,6 +273,7 @@ typedef struct r_cons_printable_palette_t {
char *gui_alt_background;
char *gui_border;
char *highlight;
char *line_highlight;
/* graph colors */
char *graph_box;