core/graph: split Node_print in two sub functions, based on small_nodes

This commit is contained in:
Riccardo Schirone 2015-05-30 12:37:42 +02:00 committed by pancake
parent 9ec497ccd8
commit 212dbc1024

View File

@ -77,32 +77,32 @@ static int ostack_pop() {
return ostack.size > 0 ? ostack.nodes[--ostack.size] : 0;
}
static void Node_print(RConsCanvas *can, Node *n, int cur) {
static void small_Node_print(RConsCanvas *can, Node *n, int cur) {
char title[128];
if (!G (n->x + 2, n->y - 1))
return;
if (cur) {
W("[_@@_]");
(void)G (-can->sx, -can->sy + 2);
snprintf (title, sizeof (title) - 1,
"0x%08"PFMT64x":", n->addr);
W (title);
(void)G (-can->sx, -can->sy + 3);
W (n->text);
} else {
W("[____]");
}
return;
}
static void normal_Node_print(RConsCanvas *can, Node *n, int cur) {
char title[128];
char *text;
int delta_x = 0;
int delta_y = 0;
int x, y;
if (!can)
return;
if (small_nodes) {
if (!G (n->x + 2, n->y - 1))
return;
if (cur) {
W("[_@@_]");
(void)G (-can->sx, -can->sy + 2);
snprintf (title, sizeof (title) - 1,
"0x%08"PFMT64x":", n->addr);
W (title);
(void)G (-can->sx, -can->sy + 3);
W (n->text);
} else {
W("[____]");
}
return;
}
n->w = r_str_bounds (n->text, &n->h);
n->w += BORDER_WIDTH;
n->h += BORDER_HEIGHT;
@ -127,24 +127,24 @@ static void Node_print(RConsCanvas *can, Node *n, int cur) {
if (cur) {
//F (n->x,n->y, n->w, n->h, '.');
snprintf (title, sizeof (title)-1,
"-[ 0x%08"PFMT64x" ]-", n->addr);
"-[ 0x%08"PFMT64x" ]-", n->addr);
} else {
snprintf (title, sizeof (title)-1,
" 0x%08"PFMT64x" ", n->addr);
" 0x%08"PFMT64x" ", n->addr);
}
if (G (n->x + 1, n->y + 1))
W (title); // delta_x
(void)G (n->x + 2 + delta_x, n->y + 2);
if (G(n->x + 1, n->y + 1))
W(title); // delta_x
(void)G(n->x + 2 + delta_x, n->y + 2);
// TODO: temporary crop depending on out of screen offsets
{
char *text = r_str_crop (n->text, delta_x, delta_y, n->w, n->h);
if (text) {
W (text);
free (text);
} else {
W (n->text);
}
text = r_str_crop (n->text, delta_x, delta_y, n->w, n->h);
if (text) {
W (text);
free (text);
} else {
W (n->text);
}
if (G (n->x + 1, n->y + 1))
W (title);
// TODO: check if node is traced or not and hsow proper color
@ -156,6 +156,16 @@ static void Node_print(RConsCanvas *can, Node *n, int cur) {
}
}
static void Node_print(RConsCanvas *can, Node *n, int cur) {
if (!can)
return;
if (small_nodes)
small_Node_print(can, n, cur);
else
normal_Node_print(can, n, cur);
}
static void Edge_print(RConsCanvas *can, Node *a, Node *b, int nth) {
int x, y, x2, y2;
int xinc = 3+((nth+1)*2);