mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-02 19:55:14 +00:00
Support square pixels, cursor and scroll in prc, available in VPP, add hex.pcols
This commit is contained in:
parent
42e27a4aac
commit
a504ece143
@ -1186,7 +1186,10 @@ static int cb_cmddepth(void *user, void *data) {
|
||||
|
||||
static int cb_hexcols(void *user, void *data) {
|
||||
RCore *core = (RCore *)user;
|
||||
int c = R_MIN (128, R_MAX (((RConfigNode*)data)->i_value, 0));
|
||||
int c = R_MIN (1024, R_MAX (((RConfigNode*)data)->i_value, 0));
|
||||
if (c < 0) {
|
||||
c = 0;
|
||||
}
|
||||
core->print->cols = c & ~1;
|
||||
core->dbg->regcols = c/4;
|
||||
return true;
|
||||
@ -2259,6 +2262,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETCB ("hex.compact", "false", &cb_hexcompact, "Show smallest 16 byte col hexdump (60 columns)");
|
||||
SETI ("hex.flagsz", 0, "If non zero, overrides the flag size in pxa");
|
||||
SETICB ("hex.cols", 16, &cb_hexcols, "Number of columns in hexdump");
|
||||
SETI ("hex.pcols", 40, "Number of pixel columns for prc");
|
||||
SETI ("hex.depth", 5, "Maximal level of recurrence while telescoping memory");
|
||||
SETPREF ("hex.onechar", "false", "Number of columns in hexdump");
|
||||
SETICB ("hex.stride", 0, &cb_hexstride, "Line stride in hexdump (default is 0)");
|
||||
|
@ -32,11 +32,14 @@ static ut32 colormap[256] = {
|
||||
|
||||
// colordump
|
||||
static void cmd_prc (RCore *core, int len) {
|
||||
bool square = true; //false;
|
||||
int i, j;
|
||||
int cols = core->print->cols * 3.5;
|
||||
int cols = r_config_get_i (core->config, "hex.pcols") + core->print->cols; // * 3.5;
|
||||
bool show_cursor = core->print->cur_enabled;
|
||||
if (cols < 1) {
|
||||
cols = 1;
|
||||
}
|
||||
cols /= 2;
|
||||
for (i = 0; i < len; i += cols) {
|
||||
r_print_addr (core->print, core->offset + i);
|
||||
for (j = i; j < i + cols; j ++) {
|
||||
@ -44,7 +47,17 @@ static void cmd_prc (RCore *core, int len) {
|
||||
if (j < len) {
|
||||
char *str = r_str_newf ("rgb:fff rgb:%06x", colormap[*p]);
|
||||
char *color = r_cons_pal_parse (str);
|
||||
r_cons_printf ("%s ", color);
|
||||
char ch = ' ';
|
||||
if (show_cursor) {
|
||||
if (core->print->cur == j) {
|
||||
ch = '_';
|
||||
}
|
||||
}
|
||||
if (square) {
|
||||
r_cons_printf ("%s%c%c", color, ch, ch);
|
||||
} else {
|
||||
r_cons_printf ("%s%c", color, ch);
|
||||
}
|
||||
free (str);
|
||||
} else {
|
||||
break;
|
||||
@ -1431,7 +1444,7 @@ static int cmd_print_pxA(RCore *core, int len, const char *data) {
|
||||
}
|
||||
if (show_offset) {
|
||||
char offstr[128];
|
||||
snprintf (offstr, sizeof(offstr),
|
||||
snprintf (offstr, sizeof (offstr),
|
||||
"0x%08"PFMT64x " ", core->offset);
|
||||
if (strlen (offstr) > 12) {
|
||||
cols -= ((strlen (offstr) - 12) * 2);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <r_core.h>
|
||||
|
||||
#define NPF 8
|
||||
#define NPF 9
|
||||
static int obs = 0;
|
||||
static int blocksize = 0;
|
||||
static int autoblocksize = 1;
|
||||
@ -13,13 +13,13 @@ static void visual_refresh(RCore *core);
|
||||
static const char *printfmtSingle[] = {
|
||||
"xc", "pd $r",
|
||||
"pxw 64@r:SP;dr=;pd $r",
|
||||
"pxw", "pxx", "pxA", "pss", "pxa"
|
||||
"pxw", "pxx", "pxA", "pss", "prc", "pxa"
|
||||
};
|
||||
|
||||
static const char *printfmtColumns[] = {
|
||||
"pCx", "pCd $r-1",
|
||||
"pCD",
|
||||
"pCw", "pCc", "pCA", "pss", "pCa"
|
||||
"pCw", "pCc", "pCA", "pss", "prc", "pCa"
|
||||
};
|
||||
|
||||
static const char **printfmt = printfmtSingle;
|
||||
@ -1154,6 +1154,13 @@ static void cursor_nextrow(RCore *core, bool use_ocur) {
|
||||
RAsmOp op;
|
||||
|
||||
cursor_ocur (core, use_ocur);
|
||||
if (PIDX == 7 || !strcmp ("prc", r_config_get (core->config, "cmd.visual"))) {
|
||||
//int cols = r_config_get_i (core->config, "hex.cols") * 3.5;
|
||||
int cols = r_config_get_i (core->config, "hex.cols") + r_config_get_i (core->config, "hex.pcols");
|
||||
cols /= 2;
|
||||
p->cur += cols > 0? cols: 3;
|
||||
return;
|
||||
}
|
||||
if (PIDX == 2 && core->seltab == 1) {
|
||||
const int cols = core->dbg->regcols;
|
||||
p->cur += cols > 0? cols: 3;
|
||||
@ -1203,6 +1210,12 @@ static void cursor_prevrow(RCore *core, bool use_ocur) {
|
||||
ut32 roff, prev_roff;
|
||||
int row;
|
||||
|
||||
if (PIDX == 7 || !strcmp ("prc", r_config_get (core->config, "cmd.visual"))) {
|
||||
int cols = r_config_get_i (core->config, "hex.cols") + r_config_get_i (core->config, "hex.pcols");
|
||||
cols /= 2;
|
||||
p->cur -= cols > 0? cols: 3;
|
||||
return;
|
||||
}
|
||||
if (PIDX == 2 && core->seltab == 1) {
|
||||
const int cols = core->dbg->regcols;
|
||||
p->cur -= cols > 0? cols: 4;
|
||||
@ -2051,7 +2064,8 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
|
||||
if (cmtcol > 2) {
|
||||
r_config_set_i (core->config, "asm.cmtcol", cmtcol - 2);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
{
|
||||
int scrcols = r_config_get_i (core->config, "hex.cols");
|
||||
if (scrcols > 2) {
|
||||
r_config_set_i (core->config, "hex.cols", scrcols - 2);
|
||||
@ -2062,7 +2076,8 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
|
||||
if (core->print->cur_enabled) {
|
||||
int cmtcol = r_config_get_i (core->config, "asm.cmtcol");
|
||||
r_config_set_i (core->config, "asm.cmtcol", cmtcol + 2);
|
||||
} else {
|
||||
}
|
||||
{
|
||||
int scrcols = r_config_get_i (core->config, "hex.cols");
|
||||
r_config_set_i (core->config, "hex.cols", scrcols + 2);
|
||||
}
|
||||
@ -2432,9 +2447,12 @@ R_API void r_core_visual_title(RCore *core, int color) {
|
||||
int pc, hexcols = r_config_get_i (core->config, "hex.cols");
|
||||
if (autoblocksize) {
|
||||
switch (core->printidx) {
|
||||
case 7: // prc
|
||||
r_core_block_size (core, core->cons->rows * hexcols * 3.5);
|
||||
break;
|
||||
case 0: // x"
|
||||
case 6: // pxa
|
||||
r_core_block_size (core, core->cons->rows * hexcols);
|
||||
case 8: // pxa
|
||||
r_core_block_size (core, core->cons->rows * hexcols * 3.5);
|
||||
break;
|
||||
case 3: // XXX pw
|
||||
r_core_block_size (core, core->cons->rows * hexcols);
|
||||
|
Loading…
x
Reference in New Issue
Block a user