Skip to content

Commit

Permalink
Remove global variables in visual view mode
Browse files Browse the repository at this point in the history
* add new strcut RzCoreVisualView to store old global variables
* move some variables related to visual view in RzCoreVisual to RzCoreVisualView
  • Loading branch information
PeiweiHu authored and XVilka committed May 17, 2024
1 parent 48c2c5f commit 7a767f2
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 129 deletions.
24 changes: 21 additions & 3 deletions librz/core/core_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,28 @@ typedef struct rz_panels_root_t {
bool from_visual;
} RzPanelsRoot;

typedef struct rz_core_visual_t {
RzList /*<RzCoreVisualTab *>*/ *tabs;
int tab;
typedef struct rz_core_visual_view_t {
int level;
st64 delta;
ut64 column_nlines;
// output is used to store the result of printCmds
// and avoid duplicated analysis while j and k is pressed
char *output;
// output_mode labels which printCmds' result is stored in output
int output_mode;
int output_addr;
int option;
int variable_option;
int printMode;
bool selectPanel;
bool hide_legend;
bool is_inputing; // whether the user is inputing
char *inputing; // for filter on the go in Vv mode
} RzCoreVisualView;

typedef struct rz_core_visual_t {
RzList /*<RzCoreVisualTab *>*/ *tabs;
int tab;
RzCoreVisualMode printidx;
/* TODO: Reorganize */
int obs;
Expand All @@ -365,6 +381,8 @@ typedef struct rz_core_visual_t {
RzPanelsRoot *panels_root;
/* file percentage */
float percentage;
/* visual view */
RzCoreVisualView *view;
} RzCoreVisual;

RZ_IPI RZ_OWN RzCoreVisual *rz_core_visual_new();
Expand Down
9 changes: 8 additions & 1 deletion librz/core/tui/visual.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ RZ_IPI RZ_OWN RzCoreVisual *rz_core_visual_new() {
visual->debug = 1;
visual->splitPtr = UT64_MAX;
visual->insertNibble = -1;
// init visual view (Vv) mode
visual->view = RZ_NEW0(RzCoreVisualView);
visual->view->output = NULL;
visual->view->output_mode = -1;
visual->view->output_addr = -1;
visual->view->selectPanel = false;
return visual;
}

Expand All @@ -30,7 +36,8 @@ RZ_IPI void rz_core_visual_free(RZ_NULLABLE RzCoreVisual *visual) {
}
rz_panels_root_free(visual->panels_root);
rz_list_free(visual->tabs);
free(visual->inputing);
free(visual->view->inputing);
free(visual->view);
free(visual);
}

Expand Down
Loading

0 comments on commit 7a767f2

Please sign in to comment.