From 7d38f70918661e7d716881b03ab713d21b824483 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 5 Dec 2022 09:45:38 +0100 Subject: [PATCH] =?UTF-8?q?Show=200x00-bytes=20as=20'=E2=8B=84'=20instead?= =?UTF-8?q?=20of=20'0',=20closes=20#166?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 13 +++++-------- src/lib.rs | 6 +++--- tests/integration_tests.rs | 36 ++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d8748..3e78959 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,19 +6,16 @@ - Added variable panels through the `--panels` and `--terminal-width` flags, see [#13](https://github.com/sharkdp/hexyl/issues/13) and [#164](https://github.com/sharkdp/hexyl/pull/164) (@sharifhsn) - Added new `--group-bytes`/`-g` option, see #104 and #170 (@RinHizakura) - Added new `--base B` option (where `B` can be `binary`, `octal`, `decimal` or `hexadecimal`), see #147 and #178 (@sharifhsn) - -## Bugfixes - - -## Other - -- More tests for the squeezing feature, see #177 (@mkatychev) - +- Show actual zero bytes as `⋄` in the character panel (previously: `0`), in order not to confuse them with ASCII + `0` bytes if colors are deactivated. Closes #166 (@sharkdp) ## `hexyl` as a library - Breaking change: `Printer::new` is deprecated as a part of the public API. Alternatively, you can now construct a `Printer` using the `PrinterBuilder` builder API, see [#168](https://github.com/sharkdp/hexyl/pull/168). (@sharifhsn) +## Other + +- More tests for the squeezing feature, see #177 (@mkatychev) ## Thank you diff --git a/src/lib.rs b/src/lib.rs index 42878d2..46f8503 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ impl Byte { use crate::ByteCategory::*; match self.category() { - Null => '0', + Null => '⋄', AsciiPrintable => self.0 as char, AsciiWhitespace if self.0 == 0x20 => ' ', AsciiWhitespace => '_', @@ -819,9 +819,9 @@ mod tests { let input = io::Cursor::new(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); let expected_string = "\ ┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐ -│00000000│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │00000000┊00000000│ +│00000000│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│ │* │ ┊ │ ┊ │ -│00000020│ 00 ┊ │0 ┊ │ +│00000020│ 00 ┊ │⋄ ┊ │ └────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘ " .to_owned(); diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 7a0fae1..d07831e 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -90,8 +90,8 @@ mod length { .success() .stdout( "┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\ - │00000000│ 7f 45 4c 46 02 01 01 00 ┊ 00 00 00 00 00 00 00 00 │•ELF•••0┊00000000│\n\ - │00000010│ 02 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │•0>0•000┊0•@00000│\n\ + │00000000│ 7f 45 4c 46 02 01 01 00 ┊ 00 00 00 00 00 00 00 00 │•ELF•••⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│\n\ + │00000010│ 02 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │•⋄>⋄•⋄⋄⋄┊⋄•@⋄⋄⋄⋄⋄│\n\ └────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n", ); } @@ -223,7 +223,7 @@ mod display_offset { .success() .stdout( "┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\ - │00000030│ 02 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │•0>0•000┊0•@00000│\n\ + │00000030│ 02 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │•⋄>⋄•⋄⋄⋄┊⋄•@⋄⋄⋄⋄⋄│\n\ └────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n", ); } @@ -442,11 +442,11 @@ mod group { .pretty_stdout( "\ ┌─────────────────────────┬─────────────────────────┬────────┬────────┐ -│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │00000000┊00000000│ +│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│ │* ┊ │ ┊ │ -│ ba 0e 00 00 00 b9 00 20 ┊ 40 00 bb 01 00 00 00 b8 │ו000×0 ┊@0ו000×│ -│ 04 00 00 00 cd 80 b8 01 ┊ 00 00 00 cd 80 00 00 00 │•000××ו┊000××000│ -│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │00000000┊00000000│ +│ ba 0e 00 00 00 b9 00 20 ┊ 40 00 bb 01 00 00 00 b8 │ו⋄⋄⋄×⋄ ┊@⋄ו⋄⋄⋄×│ +│ 04 00 00 00 cd 80 b8 01 ┊ 00 00 00 cd 80 00 00 00 │•⋄⋄⋄××ו┊⋄⋄⋄××⋄⋄⋄│ +│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│ │* ┊ │ ┊ │ │* ┊ │ ┊ │ └─────────────────────────┴─────────────────────────┴────────┴────────┘ @@ -467,13 +467,13 @@ mod group { .pretty_stdout( "\ ┌─────────────────────────┬────────┐ -│ 00 00 00 00 00 00 00 00 │00000000│ +│ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄│ │* │ │ -│ ba 0e 00 00 00 b9 00 20 │ו000×0 │ -│ 40 00 bb 01 00 00 00 b8 │@0ו000×│ -│ 04 00 00 00 cd 80 b8 01 │•000××ו│ -│ 00 00 00 cd 80 00 00 00 │000××000│ -│ 00 00 00 00 00 00 00 00 │00000000│ +│ ba 0e 00 00 00 b9 00 20 │ו⋄⋄⋄×⋄ │ +│ 40 00 bb 01 00 00 00 b8 │@⋄ו⋄⋄⋄×│ +│ 04 00 00 00 cd 80 b8 01 │•⋄⋄⋄××ו│ +│ 00 00 00 cd 80 00 00 00 │⋄⋄⋄××⋄⋄⋄│ +│ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄│ │* │ │ │* │ │ └─────────────────────────┴────────┘ @@ -493,13 +493,13 @@ mod group { .pretty_stdout( "\ ┌────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┬────────┬────────┬────────┐ -│00000400│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │00000000┊00000000┊00000000│ +│00000400│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│ │* │ ┊ ┊ │ ┊ ┊ │ -│00001000│ ba 0e 00 00 00 b9 00 20 ┊ 40 00 bb 01 00 00 00 b8 ┊ 04 00 00 00 cd 80 b8 01 │ו000×0 ┊@0ו000×┊•000××ו│ -│00001018│ 00 00 00 cd 80 00 00 00 ┊ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │000××000┊00000000┊00000000│ -│00001030│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │00000000┊00000000┊00000000│ +│00001000│ ba 0e 00 00 00 b9 00 20 ┊ 40 00 bb 01 00 00 00 b8 ┊ 04 00 00 00 cd 80 b8 01 │ו⋄⋄⋄×⋄ ┊@⋄ו⋄⋄⋄×┊•⋄⋄⋄××ו│ +│00001018│ 00 00 00 cd 80 00 00 00 ┊ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │⋄⋄⋄××⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│ +│00001030│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│ │* │ ┊ ┊ │ ┊ ┊ │ -│000013f0│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 ┊ │00000000┊0000 ┊ │ +│000013f0│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 ┊ │⋄⋄⋄⋄⋄⋄⋄⋄┊⋄⋄⋄⋄ ┊ │ └────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴────────┴────────┴────────┘ ", );