Fix overflow when printing without char panel

This commit is contained in:
Sharif Haason authored and David Peter committed 2022-11-13 22:15:41 +01:00
1 parent 73bfc68cd0
commit d98c6edb55
1 file changed
+19 -27
+19 -27
View File
@@ -248,20 +248,16 @@ impl<'a, Writer: Write> Printer<'a, Writer> {
} }
}) })
.collect(), .collect(),
byte_char_panel: show_char_panel byte_char_panel: (0u8..=u8::MAX)
.then(|| { .map(|i| {
(0u8..=u8::MAX) let byte_char = format!("{}", Byte(i).as_char());
.map(|i| { if show_color {
let byte_char = format!("{}", Byte(i).as_char()); Byte(i).color().paint(byte_char).to_string()
if show_color { } else {
Byte(i).color().paint(byte_char).to_string() byte_char
} else { }
byte_char
}
})
.collect()
}) })
.unwrap_or_default(), .collect(),
byte_hex_panel_g: (0u8..=u8::MAX) byte_hex_panel_g: (0u8..=u8::MAX)
.map(|i| { .map(|i| {
let byte_hex = format!("{:02x}", i); let byte_hex = format!("{:02x}", i);
@@ -273,21 +269,17 @@ impl<'a, Writer: Write> Printer<'a, Writer> {
} }
}) })
.collect(), .collect(),
byte_char_panel_g: show_char_panel byte_char_panel_g: (0u8..=u8::MAX)
.then(|| { .map(|i| {
(0u8..=u8::MAX) let byte_char = format!("{}", Byte(i).as_char());
.map(|i| { let style = COLOR_OFFSET.normal();
let byte_char = format!("{}", Byte(i).as_char()); if show_color {
let style = COLOR_OFFSET.normal(); style.paint(byte_char).to_string()
if show_color { } else {
style.paint(byte_char).to_string() byte_char
} else { }
byte_char
}
})
.collect()
}) })
.unwrap_or_default(), .collect(),
squeezer: Squeezer::new(use_squeeze, 8 * panels as u64), squeezer: Squeezer::new(use_squeeze, 8 * panels as u64),
display_offset: 0, display_offset: 0,
panels, panels,