Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6220 garbage print when clicking on graph #10118

Merged
merged 1 commit into from May 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 23 additions & 12 deletions libr/core/graph.c
Expand Up @@ -171,6 +171,18 @@ static void rotateAsmemu(RCore *core) {
}
}

static void showcursor(RCore *core, int x) {
if (!x) {
int wheel = r_config_get_i (core->config, "scr.wheel");
if (wheel) {
r_cons_enable_mouse (true);
}
} else {
r_cons_enable_mouse (false);
}
r_cons_show_cursor (x);
}

static char *get_title(ut64 addr) {
return r_str_newf ("0x%"PFMT64x, addr);
}
Expand Down Expand Up @@ -3726,11 +3738,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
is_error = true;
break;
}
r_cons_show_cursor (false);
wheel = r_config_get_i (core->config, "scr.wheel");
if (wheel) {
r_cons_enable_mouse (true);
}
showcursor (core, false);

// r_core_graph_inputhandle()
okey = r_cons_readchar ();
Expand Down Expand Up @@ -3772,13 +3780,15 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
break;
case '|':
{ // TODO: edit
showcursor (core, true);
const char *buf = NULL;
const char *cmd = r_config_get (core->config, "cmd.gprompt");
r_line_set_prompt ("cmd.gprompt> ");
core->cons->line->contents = strdup (cmd);
buf = r_line_readline ();
core->cons->line->contents = NULL;
r_config_set (core->config, "cmd.gprompt", buf);
showcursor (core, false);
}
break;
case '=':
Expand Down Expand Up @@ -3953,7 +3963,9 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
goto_asmqjmps (g, core);
break;
case 'o':
showcursor (core, true);
visual_offset (g, core);
showcursor (core, false);
break;
case 'O':
if (!fcn) {
Expand Down Expand Up @@ -4022,12 +4034,14 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
break;
case ';':
if (fcn) {
showcursor (core, true);
char buf[256];
r_line_set_prompt ("[comment]> ");
if (r_cons_fgets (buf, sizeof (buf) - 1, 0, NULL) > 0) {
r_core_cmdf (core, "\"CC %s\"", buf);
}
g->need_reload_nodes = true;
showcursor (core, false);
}
break;
case 'C':
Expand Down Expand Up @@ -4059,17 +4073,12 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
break;
case 'd':
{
int wheel = r_config_get_i (core->config, "scr.wheel");
if (wheel) {
r_cons_enable_mouse (false);
}
showcursor (core, true);
// WTF?
r_config_set_i (core->config, "scr.interactive", true);
r_core_visual_define (core, "");
get_bbupdate (g, core, fcn);
if (wheel) {
r_cons_enable_mouse (true);
}
showcursor (core, false);
}
break;
case 'D':
Expand Down Expand Up @@ -4185,9 +4194,11 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
}
break;
case '/':
showcursor (core, true);
r_config_set_i (core->config, "scr.interactive", true);
r_core_cmd0 (core, "?i highlight;e scr.highlight=`?y`");
r_config_set_i (core->config, "scr.interactive", false);
showcursor (core, false);
break;
case ':':
r_core_visual_prompt_input (core);
Expand Down
23 changes: 10 additions & 13 deletions libr/core/visual.c
Expand Up @@ -175,7 +175,7 @@ static void visual_repeat(RCore *core) {
static void showcursor(RCore *core, int x) {
if (core && core->vmode) {
r_cons_show_cursor (x);
if (x) {
if (!x) {
// TODO: cache this
int wheel = r_config_get_i (core->config, "scr.wheel");
if (wheel) {
Expand Down Expand Up @@ -1824,6 +1824,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
break;
case '=':
{ // TODO: edit
showcursor (core, true);
const char *buf = NULL;
#define I core->cons
const char *cmd = r_config_get (core->config, "cmd.vprompt");
Expand All @@ -1833,10 +1834,12 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
// if (r_cons_fgets (buf, sizeof (buf)-4, 0, NULL) <0) buf[0]='\0';
I->line->contents = NULL;
(void)r_config_set (core->config, "cmd.vprompt", buf);
showcursor (core, false);
}
break;
case '|':
{ // TODO: edit
showcursor (core, true);
const char *buf = NULL;
#define I core->cons
const char *cmd = r_config_get (core->config, "cmd.cprompt");
Expand All @@ -1853,19 +1856,17 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
R_FREE (I->line->contents);
(void)r_config_set (core->config, "cmd.cprompt", buf? buf: "");
}
showcursor (core, false);
}
break;
case '!':
r_core_visual_panels (core, NULL);
break;
case 'o':
{
r_cons_enable_mouse (false);
showcursor (core, true);
visual_offset (core);
int wheel = r_config_get_i (core->config, "scr.wheel");
if (wheel) {
r_cons_enable_mouse (true);
}
showcursor (core, false);
}
break;
case 'A':
Expand Down Expand Up @@ -1911,14 +1912,9 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
if (r_config_get_i (core->config, "asm.esil")) {
r_core_visual_esil (core);
} else {
int wheel = r_config_get_i (core->config, "scr.wheel");
if (wheel) {
r_cons_enable_mouse (false);
}
showcursor (core, true);
r_core_visual_define (core, arg + 1);
if (wheel) {
r_cons_enable_mouse (true);
}
showcursor (core, false);
}
break;
case 'D':
Expand Down Expand Up @@ -2556,6 +2552,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
r_core_visual_hudstuff (core);
break;
case ';':
r_cons_enable_mouse (false);
r_cons_gotoxy (0, 0);
r_cons_printf ("Enter a comment: ('-' to remove, '!' to use $EDITOR)\n");
showcursor (core, true);
Expand Down