Display non printable ascii chars with a dark dot (#580)

* Display non printable ascii chars with a dark dot

* Revert into_iter
This commit is contained in:
Vincent Ollivier 2024-02-21 08:49:44 +01:00 committed by GitHub
parent 699ddf0ad8
commit e06d068f9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -33,7 +33,9 @@ pub fn print_hex(buf: &[u8]) {
}
pub fn print_hex_at(buf: &[u8], offset: usize) {
let null = 0 as char;
let cyan = Style::color("LightCyan");
let gray = Style::color("DarkGray");
let pink = Style::color("Pink");
let reset = Style::reset();
@ -50,11 +52,13 @@ pub fn print_hex_at(buf: &[u8], offset: usize) {
if *byte >= 32 && *byte <= 126 {
*byte as char
} else {
'.'
null
}
).collect();
println!("{}{:08X}: {}{:40}{}{}", cyan, addr, pink, hex, reset, ascii);
let text = ascii.replace(null, &format!("{}.{}", gray, reset));
println!("{}{:08X}: {}{:40}{}{}", cyan, addr, pink, hex, reset, text);
}
}