Skip to content

feat: add --emphasize option for bold non-zero bytes#282

Open
leno23 wants to merge 5 commits into
sharkdp:masterfrom
leno23:feat/emphasize-non-zero-227
Open

feat: add --emphasize option for bold non-zero bytes#282
leno23 wants to merge 5 commits into
sharkdp:masterfrom
leno23:feat/emphasize-non-zero-227

Conversation

@leno23

@leno23 leno23 commented May 26, 2026

Copy link
Copy Markdown

Summary

  • Add --emphasize with nothing (default) and non-zero modes, as suggested in Bold output similar to xxd #227.
  • In non-zero mode, zero bytes are rendered with dim styling and non-zero bytes with bold styling in both the hex and character panels.

Fixes #227

Example

hexyl --emphasize=non-zero file.bin

Test plan

  • cargo fmt
  • cargo test emphasize:: (new integration tests)
  • cargo test unit tests (15 passed)
  • Manual check: \x00A with --emphasize=non-zero emits \x1b[2m for 00 and \x1b[1m for 41

Made with Cursor

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/lib.rs
Comment on lines 716 to +717
if i % 8 == 7 {
if self.show_color {
self.curr_color = None;
self.writer.write_all(COLOR_RESET.as_bytes())?;
}
self.clear_byte_style()?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

leno23 added 2 commits May 26, 2026 22:06
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.
@leno23 leno23 force-pushed the feat/emphasize-non-zero-227 branch from 8154283 to 99492c5 Compare May 26, 2026 14:14
leno23 added 2 commits May 26, 2026 22:41
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.
@leno23 leno23 force-pushed the feat/emphasize-non-zero-227 branch from d8bcb42 to 6d1d2c0 Compare May 26, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bold output similar to xxd

1 participant