mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-21 23:01:03 +00:00
Implement scr.scrollbar ##visual
This commit is contained in:
parent
6c5d98b45c
commit
a9ac72f160
@ -264,3 +264,4 @@ Any commercial use or duplication of this copylefted material without prior lice
|
|||||||
Violators will be prosecuted.
|
Violators will be prosecuted.
|
||||||
This shell has been seized by the Internet's Police.
|
This shell has been seized by the Internet's Police.
|
||||||
OpenBSD might pledge r2 but r2 unveils OpenBSD.
|
OpenBSD might pledge r2 but r2 unveils OpenBSD.
|
||||||
|
Error: There's a missing space before the opening parenthesis '('
|
||||||
|
@ -3010,6 +3010,7 @@ R_API int r_core_config_init(RCore *core) {
|
|||||||
SETDESC (n, "Select visual seek mode (affects n/N visual commands)");
|
SETDESC (n, "Select visual seek mode (affects n/N visual commands)");
|
||||||
SETOPTIONS (n, "fun", "hit", "flag", NULL);
|
SETOPTIONS (n, "fun", "hit", "flag", NULL);
|
||||||
SETCB ("scr.pager", "", &cb_pager, "System program (or '..') to use when output exceeds screen boundaries");
|
SETCB ("scr.pager", "", &cb_pager, "System program (or '..') to use when output exceeds screen boundaries");
|
||||||
|
SETPREF ("scr.scrollbar", "false", "Show scrollbar in visual mode");
|
||||||
SETPREF ("scr.randpal", "false", "Random color palete or just get the next one from 'eco'");
|
SETPREF ("scr.randpal", "false", "Random color palete or just get the next one from 'eco'");
|
||||||
SETCB ("scr.color.grep", "false", &cb_scr_color_grep, "Enable colors when using ~grep");
|
SETCB ("scr.color.grep", "false", &cb_scr_color_grep, "Enable colors when using ~grep");
|
||||||
SETPREF ("scr.pipecolor", "false", "Enable colors when using pipes");
|
SETPREF ("scr.pipecolor", "false", "Enable colors when using pipes");
|
||||||
|
@ -3093,6 +3093,54 @@ static int visual_responsive(RCore *core) {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void scrollbar(RCore *core) {
|
||||||
|
int i, h, w = r_cons_get_size (&h);
|
||||||
|
|
||||||
|
if (w < 10 || h < 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ut64 from = 0;
|
||||||
|
ut64 to = UT64_MAX;
|
||||||
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
||||||
|
from = r_num_math (core->num, "$D");
|
||||||
|
to = r_num_math (core->num, "$D+$DD");
|
||||||
|
} else if (r_config_get_i (core->config, "io.va")) {
|
||||||
|
from = r_num_math (core->num, "$S");
|
||||||
|
to = r_num_math (core->num, "$S+$SS");
|
||||||
|
} else {
|
||||||
|
to = r_num_math (core->num, "$s");
|
||||||
|
}
|
||||||
|
char *s = r_str_newf ("[0x%08"PFMT64x"]", from);
|
||||||
|
r_cons_gotoxy (w - strlen (s) + 1, 1);
|
||||||
|
r_cons_strcat (s);
|
||||||
|
free (s);
|
||||||
|
|
||||||
|
ut64 block = (to - from) / h;
|
||||||
|
bool hadMatch = false;
|
||||||
|
for (i = 0; i < h ; i++) {
|
||||||
|
// TODO: show short comment introduced by user in there
|
||||||
|
// TODO: use colors
|
||||||
|
r_cons_gotoxy (w, i + 2);
|
||||||
|
if (hadMatch) {
|
||||||
|
r_cons_printf ("|");
|
||||||
|
} else {
|
||||||
|
ut64 cur = from + (block * i);
|
||||||
|
ut64 nex = from + (block * (i + 1));
|
||||||
|
if (R_BETWEEN (cur, core->offset, nex)) {
|
||||||
|
r_cons_printf (Color_INVERT"|"Color_RESET);
|
||||||
|
hadMatch = true;
|
||||||
|
} else {
|
||||||
|
r_cons_printf ("|");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = r_str_newf ("[0x%08"PFMT64x"]", to);
|
||||||
|
r_cons_gotoxy (w - strlen (s) + 1, h + 1);
|
||||||
|
r_cons_strcat (s);
|
||||||
|
free (s);
|
||||||
|
r_cons_flush ();
|
||||||
|
}
|
||||||
|
|
||||||
static void visual_refresh(RCore *core) {
|
static void visual_refresh(RCore *core) {
|
||||||
static ut64 oseek = UT64_MAX;
|
static ut64 oseek = UT64_MAX;
|
||||||
const char *vi, *vcmd;
|
const char *vi, *vcmd;
|
||||||
@ -3199,6 +3247,7 @@ static void visual_refresh(RCore *core) {
|
|||||||
} else {
|
} else {
|
||||||
r_cons_reset ();
|
r_cons_reset ();
|
||||||
}
|
}
|
||||||
|
core->cons->blankline = false;
|
||||||
core->cons->blankline = true;
|
core->cons->blankline = true;
|
||||||
core->curtab = 0; // which command are we focusing
|
core->curtab = 0; // which command are we focusing
|
||||||
//core->seltab = 0; // user selected tab
|
//core->seltab = 0; // user selected tab
|
||||||
@ -3206,6 +3255,9 @@ static void visual_refresh(RCore *core) {
|
|||||||
if (snowMode) {
|
if (snowMode) {
|
||||||
printSnow (core);
|
printSnow (core);
|
||||||
}
|
}
|
||||||
|
if (r_config_get_i (core->config, "scr.scrollbar")) {
|
||||||
|
scrollbar (core);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void visual_refresh_oneshot(RCore *core) {
|
static void visual_refresh_oneshot(RCore *core) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user