Refactor TUI panels and fix several memleaks (#4452)
This commit is contained in:
parent
a7a29f110d
commit
3aaa1bfe4d
6 changed files with 1050 additions and 1022 deletions
|
|
@ -685,7 +685,7 @@ RZ_IPI int rz_cmd_panels(void *data, const char *input) {
|
|||
char *sp = strchr(input, ' ');
|
||||
switch (input[0]) {
|
||||
case ' ': // "v [name]"
|
||||
if (visual->panels) {
|
||||
if (visual->panels_root->active_tab) {
|
||||
rz_load_panels_layout(core, input + 1);
|
||||
}
|
||||
rz_config_set(core->config, "scr.layout", input + 1);
|
||||
|
|
|
|||
|
|
@ -1781,7 +1781,7 @@ RZ_API void rz_core_fini(RzCore *c) {
|
|||
rz_core_seek_free(c);
|
||||
RZ_FREE(c->rtr_host);
|
||||
RZ_FREE(c->curtheme);
|
||||
rz_core_visual_free(c->visual);
|
||||
RZ_FREE_CUSTOM(c->visual, rz_core_visual_free);
|
||||
}
|
||||
|
||||
RZ_API void rz_core_free(RzCore *c) {
|
||||
|
|
|
|||
|
|
@ -267,9 +267,9 @@ typedef struct rz_core_visual_tab_t {
|
|||
|
||||
typedef int (*RzPanelsMenuCallback)(void *user);
|
||||
typedef struct rz_panels_menu_item {
|
||||
int n_sub, selectedIndex;
|
||||
int selectedIndex;
|
||||
char *name;
|
||||
struct rz_panels_menu_item **sub;
|
||||
RzPVector /*<RzPanelsMenuItem *>*/ submenus;
|
||||
RzPanelsMenuCallback cb;
|
||||
RzPanel *p;
|
||||
} RzPanelsMenuItem;
|
||||
|
|
@ -295,7 +295,7 @@ typedef enum {
|
|||
PANEL_LAYOUT_DEFAULT_DYNAMIC = 1
|
||||
} RzPanelsLayout;
|
||||
|
||||
typedef struct rz_panels_t {
|
||||
typedef struct rz_panels_tab_t {
|
||||
RzConsCanvas *can;
|
||||
RzPanel **panel;
|
||||
int n_panels;
|
||||
|
|
@ -316,7 +316,7 @@ typedef struct rz_panels_t {
|
|||
RzPanelsLayout layout;
|
||||
char *name;
|
||||
bool first_run;
|
||||
} RzPanels;
|
||||
} RzPanelsTab;
|
||||
|
||||
typedef enum {
|
||||
DEFAULT,
|
||||
|
|
@ -326,12 +326,12 @@ typedef enum {
|
|||
} RzPanelsRootState;
|
||||
|
||||
typedef struct rz_panels_root_t {
|
||||
int n_panels;
|
||||
int cur_panels;
|
||||
Sdb *pdc_caches;
|
||||
Sdb *cur_pdc_cache;
|
||||
RzPanels **panels;
|
||||
int cur_tab;
|
||||
RzPVector /*<RzPanelsTab *>*/ tabs;
|
||||
RzPanelsTab *active_tab; // Seems redudant since we have cur_tab index
|
||||
RzPanelsRootState root_state;
|
||||
RzList /*<char *>*/ *theme_list; ///< List of themes
|
||||
bool from_visual;
|
||||
} RzPanelsRoot;
|
||||
|
||||
typedef struct rz_core_visual_t {
|
||||
|
|
@ -363,12 +363,13 @@ typedef struct rz_core_visual_t {
|
|||
int current5format;
|
||||
/* Panels */
|
||||
RzPanelsRoot *panels_root;
|
||||
RzPanels *panels;
|
||||
} RzCoreVisual;
|
||||
|
||||
RZ_IPI RZ_OWN RzCoreVisual *rz_core_visual_new();
|
||||
RZ_IPI void rz_core_visual_free(RZ_NULLABLE RzCoreVisual *visual);
|
||||
|
||||
RZ_IPI void rz_panels_root_free(RZ_NULLABLE RzPanelsRoot *panels_root);
|
||||
|
||||
RZ_IPI void rz_core_visual_prompt_input(RzCore *core);
|
||||
RZ_IPI void rz_core_visual_toggle_hints(RzCore *core);
|
||||
RZ_IPI void rz_core_visual_toggle_decompiler_disasm(RzCore *core, bool for_graph, bool reset);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -28,7 +28,8 @@ RZ_IPI void rz_core_visual_free(RZ_NULLABLE RzCoreVisual *visual) {
|
|||
if (!visual) {
|
||||
return;
|
||||
}
|
||||
RZ_FREE_CUSTOM(visual->tabs, rz_list_free);
|
||||
rz_panels_root_free(visual->panels_root);
|
||||
rz_list_free(visual->tabs);
|
||||
free(visual->inputing);
|
||||
free(visual);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define RZ_PANELS_H
|
||||
|
||||
#include <rz_types.h>
|
||||
#include <rz_vector.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -49,7 +50,7 @@ typedef struct rz_panel_model_t {
|
|||
char *cmdStrCache;
|
||||
char *readOnly;
|
||||
char *funcName;
|
||||
char **filter;
|
||||
RzPVector /*<char *>*/ filter;
|
||||
int n_filter;
|
||||
int rotate;
|
||||
} RzPanelModel;
|
||||
|
|
@ -71,6 +72,8 @@ typedef struct rz_panel_t {
|
|||
|
||||
typedef void (*RzPanelAlmightyCallback)(void *user, RzPanel *panel, const RzPanelLayout dir, RZ_NULLABLE const char *title);
|
||||
|
||||
RZ_IPI void rz_panel_free(RZ_NULLABLE RzPanel *panel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue