diff --git a/src/usr/hex.rs b/src/usr/hex.rs index b7af5eca..e7964695 100644 --- a/src/usr/hex.rs +++ b/src/usr/hex.rs @@ -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); } }