Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package hexyl for openSUSE:Factory checked in at 2022-12-13 18:56:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hexyl (Old) and /work/SRC/openSUSE:Factory/.hexyl.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hexyl" Tue Dec 13 18:56:09 2022 rev:3 rq:1042551 version:0.12.0 Changes: -------- --- /work/SRC/openSUSE:Factory/hexyl/hexyl.changes 2022-12-06 14:23:28.793680280 +0100 +++ /work/SRC/openSUSE:Factory/.hexyl.new.1835/hexyl.changes 2022-12-13 18:56:20.879485269 +0100 @@ -1,0 +2,15 @@ +Sat Dec 10 19:51:04 UTC 2022 - Martin Hauke <mar...@gmx.de> + +- Updat eto version 0.12.0 + Features + * Only show one panel by default if the terminal width is not + wide enough for two panels. + * Respect the NO_COLOR environment variable. + Bugfixes + * Do not fail with an error if --panels=auto is used and the + output is piped. + Changes + * Breaking: For xxd-compatibility reasons, --group_bytes has + been renamed to --group-size (with an --groupsize alias). + +------------------------------------------------------------------- Old: ---- hexyl-0.11.0.tar.gz New: ---- hexyl-0.12.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hexyl.spec ++++++ --- /var/tmp/diff_new_pack.fPRYEg/_old 2022-12-13 18:56:22.399493381 +0100 +++ /var/tmp/diff_new_pack.fPRYEg/_new 2022-12-13 18:56:22.399493381 +0100 @@ -18,7 +18,7 @@ Name: hexyl -Version: 0.11.0 +Version: 0.12.0 Release: 0 Summary: A command-line hex viewer License: Apache-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.fPRYEg/_old 2022-12-13 18:56:22.439493595 +0100 +++ /var/tmp/diff_new_pack.fPRYEg/_new 2022-12-13 18:56:22.443493616 +0100 @@ -1,10 +1,10 @@ <services> <service name="cargo_vendor" mode="disabled"> - <param name="srcdir">hexyl-0.11.0</param> + <param name="srcdir">hexyl-0.12.0</param> <param name="update">true</param> </service> <service name="cargo_audit" mode="disabled"> - <param name="srcdir">hexyl-0.11.0</param> + <param name="srcdir">hexyl-0.12.0</param> </service> </services> ++++++ hexyl-0.11.0.tar.gz -> hexyl-0.12.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/CHANGELOG.md new/hexyl-0.12.0/CHANGELOG.md --- old/hexyl-0.11.0/CHANGELOG.md 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/CHANGELOG.md 2022-12-07 23:48:29.000000000 +0100 @@ -1,4 +1,24 @@ -# unreleased +# v0.12.0 + +## Features + +- Only show one panel by default if the terminal width is not wide enough for two panels, see #182 (@sharkdp) +- Respect the `NO_COLOR` environment variable, see #179 (@sharifhsn) + +## Bugfixes + +- Do not fail with an error if `--panels=auto` is used and the output is piped, see #184 (@sharkdp) + +## Changes + +- Breaking: For `xxd`-compatibility reasons, `--group_bytes` has been renamed to `--group-size` (with an `--groupsize` alias), see #121 (@sharkdp) + +## `hexyl` as a library + +- Breaking: `num_group_bytes` has been renamed to `group_size`. + + +# v0.11.0 ## Features diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/Cargo.lock new/hexyl-0.12.0/Cargo.lock --- old/hexyl-0.11.0/Cargo.lock 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/Cargo.lock 2022-12-07 23:48:29.000000000 +0100 @@ -12,12 +12,6 @@ ] [[package]] -name = "anstyle" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bb0ec944fe041c41e32dcd60b49327fcb7ff761433838878cc97ddecf16db7" - -[[package]] name = "anyhow" version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -38,6 +32,17 @@ ] [[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -177,6 +182,15 @@ [[package]] name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" @@ -186,17 +200,17 @@ [[package]] name = "hexyl" -version = "0.11.0" +version = "0.12.0" dependencies = [ - "anstyle", "anyhow", "assert_cmd", "clap", "const_format", - "is-terminal", "libc", + "owo-colors", "predicates", "pretty_assertions", + "supports-color", "terminal_size", "thiserror", ] @@ -217,13 +231,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "io-lifetimes", "rustix", "windows-sys", ] [[package]] +name = "is_ci" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + +[[package]] name = "itertools" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -287,6 +307,12 @@ ] [[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] name = "predicates" version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -371,9 +397,9 @@ [[package]] name = "rustix" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" +checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" dependencies = [ "bitflags", "errno", @@ -396,6 +422,16 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] +name = "supports-color" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +dependencies = [ + "atty", + "is_ci", +] + +[[package]] name = "syn" version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/Cargo.toml new/hexyl-0.12.0/Cargo.toml --- old/hexyl-0.11.0/Cargo.toml 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/Cargo.toml 2022-12-07 23:48:29.000000000 +0100 @@ -7,15 +7,15 @@ name = "hexyl" readme = "README.md" repository = "https://github.com/sharkdp/hexyl" -version = "0.11.0" +version = "0.12.0" edition = "2021" [dependencies] -anstyle = "0.2" anyhow = "1.0" const_format = "0.2" -is-terminal = "0.4" libc = "0.2" +owo-colors = "3" +supports-color = "1" thiserror = "1.0" terminal_size = "0.2" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/README.md new/hexyl-0.12.0/README.md --- old/hexyl-0.11.0/README.md 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/README.md 2022-12-07 23:48:29.000000000 +0100 @@ -31,7 +31,7 @@ the latest `.deb` package from the release page and install it via: ``` bash -sudo dpkg -i hexyl_0.11.0_amd64.deb # adapt version number and architecture +sudo dpkg -i hexyl_0.12.0_amd64.deb # adapt version number and architecture ``` ### On Debian diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/doc/hexyl.1.md new/hexyl-0.12.0/doc/hexyl.1.md --- old/hexyl-0.11.0/doc/hexyl.1.md 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/doc/hexyl.1.md 2022-12-07 23:48:29.000000000 +0100 @@ -1,4 +1,4 @@ -% HEXYL(1) hexyl 0.11.0 | General Commands Manual +% HEXYL(1) hexyl 0.12.0 | General Commands Manual % % 2022-12-05 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/examples/simple.rs new/hexyl-0.12.0/examples/simple.rs --- old/hexyl-0.11.0/examples/simple.rs 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/examples/simple.rs 2022-12-07 23:48:29.000000000 +0100 @@ -18,7 +18,7 @@ .with_border_style(BorderStyle::Unicode) .enable_squeezing(false) .num_panels(2) - .num_group_bytes(1) + .group_size(1) .build(); printer.print_all(&input[..]).unwrap(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/src/bin/hexyl.rs new/hexyl-0.12.0/src/bin/hexyl.rs --- old/hexyl-0.11.0/src/bin/hexyl.rs 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/src/bin/hexyl.rs 2022-12-07 23:48:29.000000000 +0100 @@ -9,8 +9,6 @@ use clap::builder::ArgPredicate; use clap::{crate_name, crate_version, Arg, ArgAction, ColorChoice, Command}; -use is_terminal::IsTerminal; - use anyhow::{anyhow, Context, Result}; use const_format::formatcp; @@ -163,18 +161,21 @@ .help( "Sets the number of hex data panels to be displayed. \ `--panels=auto` will display the maximum number of hex data panels \ - based on the current terminal width", + based on the current terminal width. By default, hexyl will show \ + two panels, unless the terminal is not wide enough for that.", ), ) .arg( - Arg::new("group_bytes") + Arg::new("group_size") .short('g') - .long("group-bytes") + .long("group-size") + .alias("groupsize") .num_args(1) .value_name("N") .help( - "Sets the number of octets per group to be displayed. \ - The possible options are 1, 2, 4, 8. The default is 1", + "Number of bytes/octets that should be grouped together. \ + Possible group sizes are 1, 2, 4, 8. The default is 1. \ + '--groupsize can be used as an alias (xxd-compatibility).", ), ) .arg( @@ -293,8 +294,10 @@ let show_color = match matches.get_one::<String>("color").map(String::as_ref) { Some("never") => false, - Some("auto") => std::io::stdout().is_terminal(), - _ => true, + Some("always") => true, + _ => supports_color::on(supports_color::Stream::Stdout) + .map(|level| level.has_basic) + .unwrap_or(false), }; let border_style = match matches.get_one::<String>("border").map(String::as_ref) { @@ -322,12 +325,12 @@ .transpose()? .unwrap_or(0); - let max_panels_fn = |terminal_width: u64, base_digits: u64, group_bytes: u64| { + let max_panels_fn = |terminal_width: u64, base_digits: u64, group_size: u64| { let offset = if show_position_panel { 10 } else { 1 }; let col_width = if show_char_panel { - ((8 / group_bytes) * (base_digits * group_bytes + 1)) + 2 + 8 + ((8 / group_size) * (base_digits * group_size + 1)) + 2 + 8 } else { - ((8 / group_bytes) * (base_digits * group_bytes + 1)) + 2 + ((8 / group_size) * (base_digits * group_size + 1)) + 2 }; if (terminal_width - offset) / col_width < 1 { 1 @@ -368,33 +371,31 @@ Base::Hexadecimal => 2, }; - let group_bytes = if let Some(group_bytes) = matches - .get_one::<String>("group_bytes") + let group_size = if let Some(group_size) = matches + .get_one::<String>("group_size") .map(|s| { s.parse::<NonZeroU8>().map(u8::from).context(anyhow!( - "failed to parse `--group-bytes`/`-g` arg {:?} as unsigned nonzero integer", + "Failed to parse `--group-size`/`-g` argument {:?} as unsigned nonzero integer", s )) }) .transpose()? { - if (group_bytes <= 8) && ((group_bytes & (group_bytes - 1)) == 0) { - group_bytes + if (group_size <= 8) && ((group_size & (group_size - 1)) == 0) { + group_size } else { return Err(anyhow!( - "Possible options for the `--group-bytes`/`-g` option are 1, 2, 4 or 8. " + "Possible sizes for the `--group-size`/`-g` option are 1, 2, 4 or 8. " )); } } else { 1 }; + let terminal_width = terminal_size().map(|s| s.0 .0 as u64).unwrap_or(80); + let panels = if matches.get_one::<String>("panels").map(String::as_ref) == Some("auto") { - max_panels_fn( - terminal_size().ok_or_else(|| anyhow!("not a TTY"))?.0 .0 as u64, - base_digits, - group_bytes.into(), - ) + max_panels_fn(terminal_width, base_digits, group_size.into()) } else if let Some(panels) = matches .get_one::<String>("panels") .map(|s| { @@ -416,9 +417,12 @@ }) .transpose()? { - max_panels_fn(terminal_width, base_digits, group_bytes.into()) + max_panels_fn(terminal_width, base_digits, group_size.into()) } else { - 2 + std::cmp::min( + 2, + max_panels_fn(terminal_width, base_digits, group_size.into()), + ) }; let stdout = io::stdout(); @@ -431,7 +435,7 @@ .with_border_style(border_style) .enable_squeezing(squeeze) .num_panels(panels) - .num_group_bytes(group_bytes) + .group_size(group_size) .with_base(base) .build(); printer.display_offset(skip_offset + display_offset); @@ -449,7 +453,7 @@ std::process::exit(0); } } - eprintln!("Error: {:?}", err); + eprintln!("Error: {err:?}"); std::process::exit(1); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/src/lib.rs new/hexyl-0.12.0/src/lib.rs --- old/hexyl-0.11.0/src/lib.rs 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/src/lib.rs 2022-12-07 23:48:29.000000000 +0100 @@ -4,7 +4,7 @@ use std::io::{self, BufReader, Read, Write}; -use anstyle::{AnsiColor, Reset}; +use owo_colors::{colors, Color}; pub enum Base { Binary, @@ -13,24 +13,13 @@ Hexadecimal, } -#[derive(PartialEq, Eq)] -#[repr(usize)] -enum ByteColor { - Null = 0, - Offset = 1, - AsciiPrintable = 2, - AsciiWhitespace = 3, - AsciiOther = 4, - NonAscii = 5, - Reset = 6, -} - -const COLOR_NULL: AnsiColor = AnsiColor::BrightBlack; -const COLOR_OFFSET: AnsiColor = AnsiColor::BrightBlack; -const COLOR_ASCII_PRINTABLE: AnsiColor = AnsiColor::Cyan; -const COLOR_ASCII_WHITESPACE: AnsiColor = AnsiColor::Green; -const COLOR_ASCII_OTHER: AnsiColor = AnsiColor::Magenta; -const COLOR_NONASCII: AnsiColor = AnsiColor::Yellow; +const COLOR_NULL: &[u8] = colors::BrightBlack::ANSI_FG.as_bytes(); +const COLOR_OFFSET: &[u8] = colors::BrightBlack::ANSI_FG.as_bytes(); +const COLOR_ASCII_PRINTABLE: &[u8] = colors::Cyan::ANSI_FG.as_bytes(); +const COLOR_ASCII_WHITESPACE: &[u8] = colors::Green::ANSI_FG.as_bytes(); +const COLOR_ASCII_OTHER: &[u8] = colors::Green::ANSI_FG.as_bytes(); +const COLOR_NONASCII: &[u8] = colors::Yellow::ANSI_FG.as_bytes(); +const COLOR_RESET: &[u8] = colors::Default::ANSI_FG.as_bytes(); pub enum ByteCategory { Null, @@ -66,15 +55,15 @@ } } - fn color(self) -> ByteColor { + fn color(self) -> &'static [u8] { use crate::ByteCategory::*; match self.category() { - Null => ByteColor::Null, - AsciiPrintable => ByteColor::AsciiPrintable, - AsciiWhitespace => ByteColor::AsciiWhitespace, - AsciiOther => ByteColor::AsciiOther, - NonAscii => ByteColor::NonAscii, + Null => COLOR_NULL, + AsciiPrintable => COLOR_ASCII_PRINTABLE, + AsciiWhitespace => COLOR_ASCII_WHITESPACE, + AsciiOther => COLOR_ASCII_OTHER, + NonAscii => COLOR_NONASCII, } } @@ -168,7 +157,7 @@ border_style: BorderStyle, use_squeeze: bool, panels: u64, - group_bytes: u8, + group_size: u8, base: Base, } @@ -182,7 +171,7 @@ border_style: BorderStyle::Unicode, use_squeeze: true, panels: 2, - group_bytes: 1, + group_size: 1, base: Base::Hexadecimal, } } @@ -217,8 +206,8 @@ self } - pub fn num_group_bytes(mut self, num: u8) -> Self { - self.group_bytes = num; + pub fn group_size(mut self, num: u8) -> Self { + self.group_size = num; self } @@ -236,7 +225,7 @@ self.border_style, self.use_squeeze, self.panels, - self.group_bytes, + self.group_size, self.base, ) } @@ -250,21 +239,19 @@ show_char_panel: bool, show_position_panel: bool, show_color: bool, - colors: Vec<String>, - curr_color: Option<ByteColor>, + curr_color: Option<&'static [u8]>, border_style: BorderStyle, byte_hex_panel: Vec<String>, byte_char_panel: Vec<String>, // same as previous but in Fixed(242) gray color, for position panel byte_hex_panel_g: Vec<String>, - byte_char_panel_g: Vec<String>, squeezer: Squeezer, display_offset: u64, /// The number of panels to draw. panels: u64, squeeze_byte: usize, /// The number of octets per group. - group_bytes: u8, + group_size: u8, /// The number of digits used to write the base. base_digits: u8, } @@ -278,7 +265,7 @@ border_style: BorderStyle, use_squeeze: bool, panels: u64, - group_bytes: u8, + group_size: u8, base: Base, ) -> Printer<'a, Writer> { Printer { @@ -289,15 +276,6 @@ show_position_panel, show_color, curr_color: None, - colors: vec![ - COLOR_NULL.render_fg().to_string(), - COLOR_OFFSET.render_fg().to_string(), - COLOR_ASCII_PRINTABLE.render_fg().to_string(), - COLOR_ASCII_WHITESPACE.render_fg().to_string(), - COLOR_ASCII_OTHER.render_fg().to_string(), - COLOR_NONASCII.render_fg().to_string(), - Reset.render().to_string(), - ], border_style, byte_hex_panel: (0u8..=u8::MAX) .map(|i| match base { @@ -311,9 +289,6 @@ .map(|i| format!("{}", Byte(i).as_char())) .collect(), byte_hex_panel_g: (0u8..=u8::MAX).map(|i| format!("{i:02x}")).collect(), - byte_char_panel_g: (0u8..=u8::MAX) - .map(|i| format!("{}", Byte(i).as_char())) - .collect(), squeezer: if use_squeeze { Squeezer::Ignore } else { @@ -322,7 +297,7 @@ display_offset: 0, panels, squeeze_byte: 0x00, - group_bytes, + group_size, base_digits: match base { Base::Binary => 8, Base::Octal => 3, @@ -339,8 +314,8 @@ fn panel_sz(&self) -> usize { // add one to include the trailing space of a group - let group_sz = self.base_digits as usize * self.group_bytes as usize + 1; - let group_per_panel = 8 / self.group_bytes as usize; + let group_sz = self.base_digits as usize * self.group_size as usize + 1; + let group_per_panel = 8 / self.group_size as usize; // add one to include the leading space 1 + group_sz * group_per_panel } @@ -354,27 +329,27 @@ let h_repeat = h.to_string().repeat(self.panel_sz()); if self.show_position_panel { - write!(self.writer, "{l}{h8}{c}", l = l, c = c, h8 = h8).ok(); + write!(self.writer, "{l}{h8}{c}")?; } else { - write!(self.writer, "{}", l).ok(); + write!(self.writer, "{l}")?; } for _ in 0..self.panels - 1 { - write!(self.writer, "{h_repeat}{c}", h_repeat = h_repeat, c = c).ok(); + write!(self.writer, "{h_repeat}{c}")?; } if self.show_char_panel { - write!(self.writer, "{h_repeat}{c}", h_repeat = h_repeat, c = c).ok(); + write!(self.writer, "{h_repeat}{c}")?; } else { - write!(self.writer, "{h_repeat}", h_repeat = h_repeat).ok(); + write!(self.writer, "{h_repeat}")?; } if self.show_char_panel { for _ in 0..self.panels - 1 { - write!(self.writer, "{h8}{c}", h8 = h8, c = c).ok(); + write!(self.writer, "{h8}{c}")?; } - writeln!(self.writer, "{h8}{r}", h8 = h8, r = r).ok(); + writeln!(self.writer, "{h8}{r}")?; } else { - writeln!(self.writer, "{r}", r = r).ok(); + writeln!(self.writer, "{r}")?; } Ok(()) @@ -402,17 +377,15 @@ .as_bytes(), )?; if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Offset as usize].as_bytes())?; + self.writer.write_all(COLOR_OFFSET)?; } if self.show_position_panel { match self.squeezer { Squeezer::Print => { self.writer - .write_all(self.byte_char_panel_g[b'*' as usize].as_bytes())?; + .write_all(self.byte_char_panel[b'*' as usize].as_bytes())?; if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } self.writer.write_all(b" ")?; } @@ -427,8 +400,7 @@ .write_all(self.byte_hex_panel_g[byte as usize].as_bytes())?; } if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } } } @@ -448,8 +420,7 @@ Squeezer::Ignore | Squeezer::Disabled => { if let Some(&b) = self.line_buf.get(i as usize) { if self.show_color && self.curr_color != Some(Byte(b).color()) { - self.writer - .write_all(self.colors[Byte(b).color() as usize].as_bytes())?; + self.writer.write_all(Byte(b).color())?; self.curr_color = Some(Byte(b).color()); } self.writer @@ -461,8 +432,7 @@ } if i == 8 * self.panels - 1 { if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; self.curr_color = None; } self.writer.write_all( @@ -473,8 +443,7 @@ )?; } else if i % 8 == 7 { if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; self.curr_color = None; } self.writer.write_all( @@ -500,19 +469,15 @@ Squeezer::Print => { if !self.show_position_panel && i == 0 { if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Offset as usize].as_bytes())?; + self.writer.write_all(COLOR_OFFSET)?; } self.writer - .write_all(self.byte_char_panel_g[b'*' as usize].as_bytes())?; + .write_all(self.byte_char_panel[b'*' as usize].as_bytes())?; if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; - } - } else { - if i % (self.group_bytes as usize) == 0 { - self.writer.write_all(b" ")?; + self.writer.write_all(COLOR_RESET)?; } + } else if i % (self.group_size as usize) == 0 { + self.writer.write_all(b" ")?; } for _ in 0..self.base_digits { self.writer.write_all(b" ")?; @@ -520,12 +485,11 @@ } Squeezer::Delete => self.writer.write_all(b" ")?, Squeezer::Ignore | Squeezer::Disabled => { - if i % (self.group_bytes as usize) == 0 { + if i % (self.group_size as usize) == 0 { self.writer.write_all(b" ")?; } if self.show_color && self.curr_color != Some(Byte(b).color()) { - self.writer - .write_all(self.colors[Byte(b).color() as usize].as_bytes())?; + self.writer.write_all(Byte(b).color())?; self.curr_color = Some(Byte(b).color()); } self.writer @@ -536,8 +500,7 @@ if i % 8 == 7 { if self.show_color { self.curr_color = None; - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } self.writer.write_all(b" ")?; // byte is last in last panel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexyl-0.11.0/tests/integration_tests.rs new/hexyl-0.12.0/tests/integration_tests.rs --- old/hexyl-0.11.0/tests/integration_tests.rs 2022-12-05 09:52:27.000000000 +0100 +++ new/hexyl-0.12.0/tests/integration_tests.rs 2022-12-07 23:48:29.000000000 +0100 @@ -301,7 +301,7 @@ hexyl() .arg("ascii") .arg("--color=never") - .arg("--group-bytes=2") + .arg("--group-size=2") .assert() .success() .stdout( @@ -316,7 +316,7 @@ hexyl() .arg("ascii") .arg("--color=never") - .arg("--group-bytes=4") + .arg("--group-size=4") .assert() .success() .stdout( @@ -331,7 +331,7 @@ hexyl() .arg("ascii") .arg("--color=never") - .arg("--group-bytes=8") + .arg("--group-size=8") .assert() .success() .stdout( @@ -342,22 +342,22 @@ } #[test] - fn group_bytes_plain() { + fn group_size_plain() { hexyl() .arg("ascii") .arg("--color=never") .arg("--plain") - .arg("--group-bytes=2") + .arg("--group-size=2") .assert() .success() .stdout(" 3031 3233 3435 3637 3839 6162 6364 650a \n"); } #[test] - fn group_bytes_fill_space() { + fn group_size_fill_space() { hexyl() .arg("--color=never") - .arg("--group-bytes=2") + .arg("--group-size=2") .write_stdin("abc") .assert() .success() @@ -369,12 +369,12 @@ } #[test] - fn group_bytes_invalid() { + fn group_size_invalid() { hexyl() .arg("ascii") .arg("--color=never") .arg("--plain") - .arg("--group-bytes=3") + .arg("--group-size=3") .assert() .failure(); } @@ -565,7 +565,8 @@ .assert() .success() .pretty_stdout( - " 00110000 00110001 00110010 00110011 00110100 00110101 00110110 00110111 00111000 00111001 01100001 01100010 01100011 01100100 01100101 00001010 \n" + " 00110000 00110001 00110010 00110011 00110100 00110101 00110110 00110111 \n \ + 00111000 00111001 01100001 01100010 01100011 01100100 01100101 00001010 \n", ); } } ++++++ vendor.tar.xz ++++++ /work/SRC/openSUSE:Factory/hexyl/vendor.tar.xz /work/SRC/openSUSE:Factory/.hexyl.new.1835/vendor.tar.xz differ: char 27, line 1