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

Add file percentage in visual mode (V/Vv) #4494

Merged
merged 2 commits into from
May 17, 2024

Conversation

PeiweiHu
Copy link
Contributor

@PeiweiHu PeiweiHu commented May 16, 2024

PLEASE DON'T SQUASH

two commits are individual

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

calculation logics

For Vv, the percentage is calculated based on the lines of output in the right column:

current_line_no / total_line_num

For V, the percentage is calculated based on the percentage of the current address against the mapped section memory:

(address - section_start_addr) / section_size

This pr adds a static global variable:

static ut64 column_nlines = 0;

No worries. I will remove it with other related global variables in subsequent pr.

static int level = 0;
static st64 delta = 0;
static ut64 column_nlines = 0;
// output is used to store the result of printCmds
// and avoid duplicated analysis while j and k is pressed
static char *output = NULL;
// output_mode labels which printCmds' result is stored in output
static int output_mode = -1;
static int output_addr = -1;
static int option = 0;
static int variable_option = 0;
static int printMode = 0;
static bool selectPanel = false;

Test plan

manual test since we don't have a mechanism for testing tui

Closing issues

closes #4477

Screen.Recording.2024-05-16.at.15.43.32.mov

@wargio
Copy link
Member

wargio commented May 16, 2024

it would be nice to at least have one big struct and just one global.

@wargio
Copy link
Member

wargio commented May 16, 2024

For those like me not seeing it, percentage is on the lower corner in v mode and upper corner in V mode.

Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see where the global added. While they should be eliminated, if you really plan to remove them in bulk from vmenus.c - I suppose it's okay for now.

@XVilka
Copy link
Member

XVilka commented May 17, 2024

Please rebase to fix the red CI

@PeiweiHu
Copy link
Contributor Author

For those like me not seeing it, percentage is on the lower corner in v mode and upper corner in V mode.

Sorry, I don't get it. I think I didn't add percentage in v mode (visual panel mode). Do you mean that the positions of percentage are different in Vv and V modes?

librz/core/tui/visual.c Fixed Show fixed Hide fixed
* add new strcut RzCoreVisualView to store old global variables
* move some variables related to visual view in RzCoreVisual to RzCoreVisualView
@wargio
Copy link
Member

wargio commented May 17, 2024

For those like me not seeing it, percentage is on the lower corner in v mode and upper corner in V mode.

Sorry, I don't get it. I think I didn't add percentage in v mode (visual panel mode). Do you mean that the positions of percentage are different in Vv and V modes?

kinda. i actually never seen the perc value thus that is why i was actively searching for it :D ignore my comment :)

Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

@XVilka XVilka merged commit 7a767f2 into rizinorg:dev May 17, 2024
44 checks passed
@XVilka
Copy link
Member

XVilka commented May 20, 2024

@PeiweiHu it doesn't work in the simple visual mode. Simply do rizin /bin/ls, then V and scroll. You can try different modes with p/P and scroll - it also always stays at 0%.

@XVilka
Copy link
Member

XVilka commented May 20, 2024

@PeiweiHu it doesn't work in the simple visual mode. Simply do rizin /bin/ls, then V and scroll. You can try different modes with p/P and scroll - it also always stays at 0%.

What's interesting, that it works in the "last" of the visual modes (the "hexII" mode, the "sparse hexdump", press V then p multiple times), while doesn't in any other mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show file/address space percentage in the right screen corner in the visual mode
3 participants