feat: add --emphasize option for bold non-zero bytes#282
Conversation
Add --emphasize=nothing (default) and --emphasize=non-zero to apply dim styling to zero bytes and bold styling to non-zero bytes in the hex and character panels, similar to recent xxd output. Fixes sharkdp#227
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b898c2116
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if i % 8 == 7 { | ||
| if self.show_color { | ||
| self.curr_color = None; | ||
| self.writer.write_all(COLOR_RESET.as_bytes())?; | ||
| } | ||
| self.clear_byte_style()?; |
There was a problem hiding this comment.
Reset emphasis before writing padding cells
When --emphasize=non-zero is active, styles are applied in set_byte_style but only cleared when i % 8 == 7; for short final lines, the code switches to Squeezer::Print to emit padding before that boundary, so the active bold/dim style leaks onto placeholder spaces (and separators) that are not real bytes. This violates the option’s stated behavior (“non-zero bytes” bold, zero bytes dim) and produces misleading formatting on incomplete trailing lines.
Useful? React with 👍 / 👎.
When --emphasize is not set, do not emit COLOR_RESET between byte color changes within a panel. Fixes color integration test regressions.
Adjust the color map template spacing so colored integration test expectations match the printer output after the emphasize refactor.
8154283 to
99492c5
Compare
Restore seven dots after offset color marker and 24-space padding before the ASCII panel border so ColorMap matches expected_text.
Use 25-space padding and literal panel borders instead of default color markers on separators that hexyl does not colorize.
d8bcb42 to
6d1d2c0
Compare
Summary
--emphasizewithnothing(default) andnon-zeromodes, as suggested in Bold output similar to xxd #227.non-zeromode, zero bytes are rendered with dim styling and non-zero bytes with bold styling in both the hex and character panels.Fixes #227
Example
Test plan
cargo fmtcargo test emphasize::(new integration tests)cargo testunit tests (15 passed)\x00Awith--emphasize=non-zeroemits\x1b[2mfor00and\x1b[1mfor41Made with Cursor