mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-13 07:57:35 +00:00
the integration between panel and graph has got heaps better now. and a bit of refactoring included too. (#10353)
This commit is contained in:
parent
7c5745b092
commit
5e4a719dff
@ -2482,7 +2482,7 @@ static ut64 rebase(RAGraph *g, int v) {
|
||||
return g->x < 0? -g->x + v: v;
|
||||
}
|
||||
|
||||
static void agraph_set_layout(RAGraph *g, bool is_interactive) {
|
||||
static void agraph_set_layout(RAGraph *g) {
|
||||
RListIter *it;
|
||||
RGraphNode *n;
|
||||
RANode *a;
|
||||
@ -2978,7 +2978,7 @@ static void agraph_toggle_tiny (RAGraph *g) {
|
||||
g->is_tiny = !g->is_tiny;
|
||||
g->need_update_dim = 1;
|
||||
agraph_refresh (r_cons_singleton ()->event_data);
|
||||
agraph_set_layout ((RAGraph *) g, r_cons_singleton ()->is_interactive);
|
||||
agraph_set_layout ((RAGraph *) g);
|
||||
//remove_dummy_nodes (g);
|
||||
}
|
||||
|
||||
@ -2989,7 +2989,7 @@ static void agraph_toggle_mini(RAGraph *g) {
|
||||
}
|
||||
g->need_update_dim = 1;
|
||||
agraph_refresh (r_cons_singleton ()->event_data);
|
||||
agraph_set_layout ((RAGraph *) g, r_cons_singleton ()->is_interactive);
|
||||
agraph_set_layout ((RAGraph *) g);
|
||||
//remove_dummy_nodes (g);
|
||||
}
|
||||
|
||||
@ -3057,7 +3057,7 @@ static int check_changes(RAGraph *g, int is_interactive,
|
||||
update_node_dimension (g->graph, is_mini (g), g->zoom, g->edgemode, g->is_callgraph, g->layout);
|
||||
}
|
||||
if (g->need_set_layout || g->need_reload_nodes || !is_interactive) {
|
||||
agraph_set_layout (g, is_interactive);
|
||||
agraph_set_layout (g);
|
||||
}
|
||||
if (core) {
|
||||
ut64 off = r_core_anal_get_bbaddr (core, core->offset);
|
||||
@ -3110,7 +3110,7 @@ static int agraph_print(RAGraph *g, int is_interactive, RCore *core, RAnalFuncti
|
||||
}
|
||||
|
||||
h = is_interactive? h: g->h + 1;
|
||||
w = is_interactive? w: g->w;
|
||||
w = is_interactive? w: g->w + 2;
|
||||
r_cons_canvas_resize (g->can, w, h);
|
||||
// r_cons_canvas_clear (g->can);
|
||||
if (!is_interactive) {
|
||||
@ -3762,8 +3762,6 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
invscroll = r_config_get_i (core->config, "graph.invscroll");
|
||||
ret = agraph_refresh (grd);
|
||||
|
||||
r_core_panels_graph (core, can);
|
||||
|
||||
if (!ret) {
|
||||
is_error = true;
|
||||
break;
|
||||
|
@ -28,12 +28,14 @@
|
||||
#define PANEL_TITLE_IMPORTS "Imports"
|
||||
#define PANEL_TITLE_CLIPBOARD "Clipboard"
|
||||
#define PANEL_TITLE_FCNINFO "FcnInfo"
|
||||
#define PANEL_TITLE_GRAPH "Graph"
|
||||
|
||||
#define PANEL_CMD_SYMBOLS "isq"
|
||||
#define PANEL_CMD_STACK "px 256@r:SP"
|
||||
#define PANEL_CMD_REGISTERS "dr="
|
||||
#define PANEL_CMD_REGISTERREFS "drr"
|
||||
#define PANEL_CMD_DISASSEMBLY "pd $r"
|
||||
#define PANEL_CMD_GRAPH "agf"
|
||||
|
||||
static const int layoutMaxCount = 2;
|
||||
|
||||
@ -129,6 +131,7 @@ static void panelSingleStepIn(RCore *core);
|
||||
static void panelSingleStepOver(RCore *core);
|
||||
static void setRefreshAll(RPanels *panels);
|
||||
static void setCursor(RCore *core, bool cur);
|
||||
static void replaceCmd(RPanels* panels, char *title, char *cmd);
|
||||
static void zoom(RPanels *panels);
|
||||
|
||||
static void panelPrint(RCore *core, RConsCanvas *can, RPanel *panel, int color) {
|
||||
@ -320,25 +323,6 @@ R_API void r_core_panels_layout_refresh(RCore *core) {
|
||||
r_core_panels_refresh (core);
|
||||
}
|
||||
|
||||
R_API void r_core_panels_graph(RCore *core, RConsCanvas *can) {
|
||||
if (!core->panels || !core->panels->isGraphInPanels) {
|
||||
return;
|
||||
}
|
||||
core->panels->can = can;
|
||||
int origx = can->sx, origy = can->sy;
|
||||
r_core_panels_refresh_except_mainpanel (core->panels);
|
||||
r_core_panels_layout_refresh (core);
|
||||
can->sx = origx;
|
||||
can->sy = origy;
|
||||
}
|
||||
|
||||
R_API void r_core_panels_refresh_except_mainpanel(RPanels *panels) {
|
||||
int i;
|
||||
for (i = 0; i < panels->n_panels; i++) {
|
||||
panels->panel[i].refresh = i == 1 ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
static void setCursor(RCore *core, bool cur) {
|
||||
core->print->cur_enabled = cur;
|
||||
if (cur) {
|
||||
@ -544,6 +528,14 @@ static void delCurPanel(RPanels *panels) {
|
||||
}
|
||||
}
|
||||
|
||||
static void replaceCmd(RPanels* panels, char *title, char *cmd) {
|
||||
free (panels->panel[panels->curnode].title);
|
||||
free (panels->panel[panels->curnode].cmd);
|
||||
panels->panel[panels->curnode].title = strdup (title);
|
||||
panels->panel[panels->curnode].cmd = r_str_newf (cmd);
|
||||
setRefreshAll (panels);
|
||||
}
|
||||
|
||||
static void zoom(RPanels *panels) {
|
||||
if (panels->n_panels > 2) {
|
||||
if (panels->curnode < 2) {
|
||||
@ -816,7 +808,6 @@ static bool init (RCore *core, RPanels *panels, int w, int h) {
|
||||
panels->menu_y = 0;
|
||||
panels->callgraph = 0;
|
||||
panels->isResizing = false;
|
||||
panels->isGraphInPanels = false;
|
||||
panels->can = r_cons_canvas_new (w, h);
|
||||
r_cons_canvas_fill (panels->can, 0, 0, w, h, ' ');
|
||||
if (!panels->can) {
|
||||
@ -1089,7 +1080,7 @@ R_API int r_core_visual_panels(RCore *core, RPanels *panels) {
|
||||
}
|
||||
|
||||
r_cons_switchbuf (false);
|
||||
panels->originCursor = core->print->cur;
|
||||
int originCursor = core->print->cur;
|
||||
core->print->cur = 0;
|
||||
core->print->cur_enabled = false;
|
||||
core->print->col = 0;
|
||||
@ -1247,7 +1238,7 @@ repeat:
|
||||
case 'A':
|
||||
r_core_visual_asm (core, core->offset);
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
r_core_visual_define (core, "");
|
||||
break;
|
||||
case 'j':
|
||||
@ -1312,13 +1303,6 @@ repeat:
|
||||
}
|
||||
panels->menu_y = 1;
|
||||
break;
|
||||
case 'G':
|
||||
if (checkFunc (core)) {
|
||||
panels->isGraphInPanels = true;
|
||||
r_core_visual_graph (core, NULL, NULL, true);
|
||||
panels->can = can;
|
||||
}
|
||||
break;
|
||||
case 'H':
|
||||
r_cons_switchbuf (false);
|
||||
panels->columnWidth += 4;
|
||||
@ -1332,6 +1316,16 @@ repeat:
|
||||
panels->columnWidth = 0;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if (checkFunc (core)) {
|
||||
replaceCmd (panels, PANEL_TITLE_DISASSEMBLY, PANEL_CMD_DISASSEMBLY);
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (checkFunc (core)) {
|
||||
replaceCmd (panels, PANEL_TITLE_GRAPH, PANEL_CMD_GRAPH);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
handleLeftKey (core);
|
||||
break;
|
||||
@ -1466,7 +1460,7 @@ repeat:
|
||||
}
|
||||
goto repeat;
|
||||
exit:
|
||||
core->print->cur = panels->originCursor;
|
||||
core->print->cur = originCursor;
|
||||
core->print->cur_enabled = false;
|
||||
core->print->col = 0;
|
||||
|
||||
|
@ -950,9 +950,7 @@ typedef struct r_panels_t {
|
||||
int menu_y;
|
||||
int callgraph;
|
||||
int curnode;
|
||||
int originCursor;
|
||||
bool isResizing;
|
||||
bool isGraphInPanels;
|
||||
} RPanels;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -296,8 +296,6 @@ R_API void r_core_panels_check_stackbase(RCore *core);
|
||||
R_API void r_core_panels_free(RPanels *panels);
|
||||
R_API void r_core_panels_layout(RPanels *panels);
|
||||
R_API void r_core_panels_layout_refresh(RCore *core);
|
||||
R_API void r_core_panels_refresh_except_mainpanel(RPanels *panels);
|
||||
R_API void r_core_panels_graph(RCore *core, RConsCanvas *can);
|
||||
R_API void r_core_visual_browse(RCore *core);
|
||||
R_API int r_core_visual_cmd(RCore *core, const char *arg);
|
||||
R_API void r_core_visual_seek_animation (RCore *core, ut64 addr);
|
||||
|
Loading…
Reference in New Issue
Block a user