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

Revert to old graph edges positioning (added an option) #10430

Merged
merged 3 commits into from Jun 20, 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
2 changes: 1 addition & 1 deletion libr/cons/canvas.c
Expand Up @@ -378,7 +378,7 @@ R_API void r_cons_canvas_write(RConsCanvas *c, const char *s) {
s = s_part;
if (ch == '\n') {
c->attr = Color_RESET;
stamp_attr (c, c->y*c->w + attr_x, strlen (Color_RESET));
stamp_attr (c, c->y*c->w + attr_x, 0);
c->y++;
s++;
if (*s == '\0' || c->y >= c->h) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/cconfig.c
Expand Up @@ -2819,6 +2819,7 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("graph.extension", "gif", &cb_graphformat, "Graph extension when using 'w' format (png, jpg, pdf, ps, svg, json)");
SETPREF ("graph.refs", "false", "Graph references in callgraphs (.agc*;aggi)");
SETI ("graph.edges", 2, "0=no edges, 1=simple edges, 2=avoid collisions");
SETPREF ("graph.altedgepos", "false", "Switch to alternative (very experimental) positioning of edges");
SETI ("graph.layout", 0, "Graph layout (0=vertical, 1=horizontal)");
SETI ("graph.linemode", 1, "Graph edges (0=diagonal, 1=square)");
SETPREF ("graph.font", "Courier", "Font for dot graphs");
Expand Down
14 changes: 10 additions & 4 deletions libr/core/graph.c
Expand Up @@ -2739,15 +2739,20 @@ static void agraph_print_edges(RAGraph *g) {
a_x_inc = R_EDGES_X_INC + 2 * (out_nth + 1);
b_x_inc = R_EDGES_X_INC + 2 * (in_nth + 1);

ax = a->is_dummy ? a->x : (a->x + a->w - a_x_inc);
ay = a->y + a->h;
if (g->altedgepos) {
ax = a->is_dummy ? a->x : (a->x + a->w - a_x_inc);
bx = b->is_dummy ? b->x : (b->x + b_x_inc);
} else {
ax = a->is_dummy ? a->x : (a->x + a_x_inc);
bx = b->is_dummy ? b->x : (b->x + a_x_inc);
}

bx = b->is_dummy ? b->x : (b->x + b_x_inc);
ay = a->y + a->h;
by = b->y - 1;

if (!a->is_dummy && itn == neighbours->head && out_nth == 0 && bx > ax) {
a_x_inc += 4;
ax -= 4;
ax += g->altedgepos ? -4 : 4;
}
if (a->h < a->layer_height) {
r_cons_canvas_line (g->can, ax, ay, ax, ay + a->layer_height - a->h, &style);
Expand Down Expand Up @@ -3726,6 +3731,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
g->on_curnode_change = (RANodeCallback) seek_to_node;
g->on_curnode_change_data = core;
g->edgemode = r_config_get_i (core->config, "graph.edges");
g->altedgepos = r_config_get_i (core->config, "graph.altedgepos");
g->is_interactive = is_interactive;
bool asm_comments = r_config_get_i (core->config, "asm.comments");
r_config_set (core->config, "asm.comments",
Expand Down
1 change: 1 addition & 0 deletions libr/include/r_cons.h
Expand Up @@ -901,6 +901,7 @@ typedef struct r_ascii_graph_t {
bool is_tiny;
bool is_dis;
int edgemode;
bool altedgepos;
int mode;
bool is_callgraph;
bool is_interactive;
Expand Down