mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 14:28:07 +00:00
Add scr.color.bytes and rename scr.colorops to scr.color.ops
This commit is contained in:
parent
0db6959c6d
commit
64d91ce2fb
@ -3809,11 +3809,12 @@ R_API void r_print_offset(RPrint *p, ut64 off, int invert, int offseg, int delta
|
||||
int sz2 = lenof (delta, 1);
|
||||
if (delta > 0 || label) {
|
||||
if (label) {
|
||||
const int label_padding = 10;
|
||||
if (delta > 0) {
|
||||
const char *pad = r_str_pad (' ', sz - sz2 + 20); //label? strlen (label):0);
|
||||
const char *pad = r_str_pad (' ', sz - sz2 + label_padding);
|
||||
r_cons_printf ("%s%s"Color_RESET"+0x%x%s", k, label, delta, pad);
|
||||
} else {
|
||||
const char *pad = r_str_pad (' ', sz + 20); //label? strlen (label):0);
|
||||
const char *pad = r_str_pad (' ', sz + label_padding);
|
||||
r_cons_printf ("%s%s"Color_RESET"%s", k, label, pad);
|
||||
}
|
||||
} else {
|
||||
|
@ -1557,7 +1557,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETPREF("asm.offset", "true", "Show offsets at disassembly");
|
||||
SETPREF("asm.spacy", "false", "Spacy disasm after calls and before flags");
|
||||
SETPREF("asm.reloff", "false", "Show relative offsets instead of absolute address in disasm");
|
||||
SETPREF("asm.reloff.flags", "true", "Show relative offsets to flags (not only functions)");
|
||||
SETPREF("asm.reloff.flags", "false", "Show relative offsets to flags (not only functions)");
|
||||
SETPREF("asm.section", "false", "Show section name before offset");
|
||||
SETI("asm.section.col", 20, "Columns width to show asm.section");
|
||||
SETPREF("asm.pseudo", "false", "Enable pseudo syntax");
|
||||
@ -1833,7 +1833,9 @@ R_API int r_core_config_init(RCore *core) {
|
||||
#endif
|
||||
r_config_desc (cfg, "scr.fgets", "Use fgets() instead of dietline for prompt input");
|
||||
SETCB("scr.echo", "false", &cb_screcho, "Show rcons output in realtime to stderr and buffer");
|
||||
SETPREF("scr.colorops", "true", "Colorize numbers and registers in opcodes");
|
||||
/* TODO: rename to asm.color.ops ? */
|
||||
SETPREF("scr.color.ops", "true", "Colorize numbers and registers in opcodes");
|
||||
SETPREF("scr.color.bytes", "true", "Colorize bytes that represent the opcodes of the instruction");
|
||||
#if __WINDOWS__ && !__CYGWIN__
|
||||
SETCB("scr.ansicon", r_str_bool (r_cons_singleton()->ansicon),
|
||||
&scr_ansicon, "Use ANSICON mode or not on Windows");
|
||||
|
@ -48,6 +48,7 @@ typedef struct r_disam_options_t {
|
||||
char str[1024], strsub[1024];
|
||||
bool use_esil;
|
||||
bool show_color;
|
||||
bool show_color_bytes;
|
||||
int colorop;
|
||||
int acase;
|
||||
bool show_flgoff;
|
||||
@ -351,7 +352,8 @@ static RDisasmState * ds_init(RCore *core) {
|
||||
ds->show_nodup = r_config_get_i (core->config, "asm.nodup");
|
||||
ds->show_spacy = r_config_get_i (core->config, "asm.spacy");
|
||||
ds->show_color = r_config_get_i (core->config, "scr.color");
|
||||
ds->colorop = r_config_get_i (core->config, "scr.colorops");
|
||||
ds->show_color_bytes = r_config_get_i (core->config, "scr.color.bytes"); // maybe rename to asm.color.bytes
|
||||
ds->colorop = r_config_get_i (core->config, "scr.color.ops"); // XXX confusing name // asm.color.inst (mnemonic + operands) ?
|
||||
ds->show_utf8 = r_config_get_i (core->config, "scr.utf8");
|
||||
ds->acase = r_config_get_i (core->config, "asm.ucase");
|
||||
ds->atabs = r_config_get_i (core->config, "asm.tabs");
|
||||
@ -1912,13 +1914,15 @@ static void ds_print_show_bytes(RDisasmState *ds) {
|
||||
RCore* core = ds->core;
|
||||
char *nstr, *str = NULL, pad[64];
|
||||
char *flagstr = NULL;
|
||||
int oldFlags = core->print->flags;
|
||||
char extra[64];
|
||||
int j,k;
|
||||
if (!ds->show_bytes) {
|
||||
int j, k;
|
||||
|
||||
if (!ds->show_bytes || ds->nb < 1) {
|
||||
return;
|
||||
}
|
||||
if (ds->nb < 1) {
|
||||
return;
|
||||
if (!ds->show_color_bytes) {
|
||||
core->print->flags &= ~R_PRINT_FLAGS_COLOR;
|
||||
}
|
||||
strcpy (extra, " ");
|
||||
if (ds->show_flag_in_bytes) {
|
||||
@ -1927,10 +1931,11 @@ static void ds_print_show_bytes(RDisasmState *ds) {
|
||||
if (flagstr) {
|
||||
str = flagstr;
|
||||
if (ds->nb > 0) {
|
||||
k = ds->nb-strlen (flagstr)-1;
|
||||
k = ds->nb-strlen (flagstr) - 1;
|
||||
if (k < 0 || k > sizeof(pad)) k = 0;
|
||||
for (j = 0; j < k; j++)
|
||||
for (j = 0; j < k; j++) {
|
||||
pad[j] = ' ';
|
||||
}
|
||||
pad[j] = '\0';
|
||||
} else {
|
||||
pad[0] = 0;
|
||||
@ -1938,9 +1943,12 @@ static void ds_print_show_bytes(RDisasmState *ds) {
|
||||
} else {
|
||||
if (ds->show_flag_in_bytes) {
|
||||
k = ds->nb - 1;
|
||||
if (k < 0 || k > sizeof(pad)) k = 0;
|
||||
for (j=0; j<k; j++)
|
||||
if (k < 0 || k > sizeof (pad)) {
|
||||
k = 0;
|
||||
}
|
||||
for (j = 0; j < k; j++) {
|
||||
pad[j] = ' ';
|
||||
}
|
||||
pad[j] = '\0';
|
||||
str = strdup ("");
|
||||
} else {
|
||||
@ -1957,7 +1965,7 @@ static void ds_print_show_bytes(RDisasmState *ds) {
|
||||
if (ds->print->bytespace) {
|
||||
k = (ds->nb + (ds->nb / 2)) - r_str_ansi_len (nstr) + 2;
|
||||
} else {
|
||||
k = ds->nb - r_str_ansi_len (nstr)+1;
|
||||
k = ds->nb - r_str_ansi_len (nstr) + 1;
|
||||
}
|
||||
if (k > 0) {
|
||||
// setting to sizeof screw up the disasm
|
||||
@ -1986,6 +1994,7 @@ static void ds_print_show_bytes(RDisasmState *ds) {
|
||||
r_cons_printf ("%s%s %s", pad, str, extra);
|
||||
}
|
||||
free (str);
|
||||
core->print->flags = oldFlags;
|
||||
}
|
||||
|
||||
static void ds_print_indent(RDisasmState *ds) {
|
||||
@ -2030,11 +2039,13 @@ static int ds_print_middle(RDisasmState *ds, int ret) {
|
||||
static bool ds_print_labels(RDisasmState *ds, RAnalFunction *f) {
|
||||
RCore *core = ds->core;
|
||||
const char *label;
|
||||
|
||||
if (!f) f = r_anal_get_fcn_in (core->anal, ds->at, 0);
|
||||
if (!f) {
|
||||
f = r_anal_get_fcn_in (core->anal, ds->at, 0);
|
||||
}
|
||||
label = r_anal_fcn_label_at (core->anal, f, ds->at);
|
||||
if (!label)
|
||||
if (!label) {
|
||||
return false;
|
||||
}
|
||||
if (ds->show_color) {
|
||||
r_cons_strcat (ds->color_label);
|
||||
r_cons_printf (" .%s:\n", label);
|
||||
|
Loading…
x
Reference in New Issue
Block a user