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

Print using custom width #13

Open
ErichDonGubler opened this issue Jan 9, 2019 · 6 comments · Fixed by #164
Open

Print using custom width #13

ErichDonGubler opened this issue Jan 9, 2019 · 6 comments · Fixed by #164
Labels
enhancement New feature or request

Comments

@ErichDonGubler
Copy link
Contributor

ErichDonGubler commented Jan 9, 2019

This is excellent, and the default width of 16 is great! It'd be really nice if we could print according to custom alignments, though -- this is a fairly standard feature in most hex editors, and I can't imagine it being egregiously complex to add this.

Another couple of ideas:

  • Getting the max width based on a provided terminal width would be nice -- this would let me simply plug in a width and let hexyl calculate the space overhead of borders for me.
  • An auto-width flag (which is like the above for the current terminal width) to be used would also be handy -- it would have some overlap with the above, but there could be reasons for setting

Prototypical suggestion for options:

# Ideas for a fixed column width:
-c --columns        Sets the number of hex data columns to be displayed.
                    Cannot be used with other width-setting options.
-w --width

# Ideas for terminal auto-width:
-a --auto-width     Sets the number of hex data columns to be adjusted according
                    to the detected terminal width. Conceptually, this could be an
                    alias of `-t $terminal_width`.
                    Cannot be used with other width-setting options.

# Ideas for fixed terminal width:
-t --terminal-width Sets the number of terminal columns to be displayed.
                    Since the terminal width may not be an evenly divisible by the 
                    width per hex data column, this will use the greatest number of 
                    hex data columns that can fit in the requested width but still
                    leave some space to the right.
                    Cannot be used with other width-setting options.

I'm more than happy to push on this, if effort is a concern. :)

@sharkdp
Copy link
Owner

sharkdp commented Jan 9, 2019

Sounds good, but would probably require a small rewrite of the layout rendering "logic".

@sharkdp sharkdp added the enhancement New feature or request label Jan 9, 2019
@ErichDonGubler
Copy link
Contributor Author

Updated option proposals to actually have something. :)

@sharkdp
Copy link
Owner

sharkdp commented Jan 9, 2019

I'd go with --width N/--columns N first. Once this functionality works reliably (or errors) for all possible N, we can think of adding the auto-width feature which would simply calculate a certain N internally.

It might also be a good idea to look at hexdump and/or xxd. If possible, we should even aim for drop-in compatibility for some options (like I did for -n/--length). Not sure if that should be our prime goal, though.

@sharkdp
Copy link
Owner

sharkdp commented Jan 9, 2019

And yes, I'd be more than happy if you would work on this!

@kilobyte
Copy link

It'd probably be good to, by default for -a, observe alignment to 64 bits. Any my use of hd I recently remember that didn't work on a text file dealt with data aligned to either 32 or 64 bits. This also matches hexyl's current display.

@sharkdp
Copy link
Owner

sharkdp commented Dec 5, 2022

I think this should still be open, because --columns is not the same as --width (it's similar to --width for a limited number of widths, that are multiples of 8)

@sharkdp sharkdp reopened this Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants