mirror of https://github.com/vinc/moros.git
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:
parent
699ddf0ad8
commit
e06d068f9f
|
@ -33,7 +33,9 @@ pub fn print_hex(buf: &[u8]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_hex_at(buf: &[u8], offset: usize) {
|
pub fn print_hex_at(buf: &[u8], offset: usize) {
|
||||||
|
let null = 0 as char;
|
||||||
let cyan = Style::color("LightCyan");
|
let cyan = Style::color("LightCyan");
|
||||||
|
let gray = Style::color("DarkGray");
|
||||||
let pink = Style::color("Pink");
|
let pink = Style::color("Pink");
|
||||||
let reset = Style::reset();
|
let reset = Style::reset();
|
||||||
|
|
||||||
|
@ -50,11 +52,13 @@ pub fn print_hex_at(buf: &[u8], offset: usize) {
|
||||||
if *byte >= 32 && *byte <= 126 {
|
if *byte >= 32 && *byte <= 126 {
|
||||||
*byte as char
|
*byte as char
|
||||||
} else {
|
} else {
|
||||||
'.'
|
null
|
||||||
}
|
}
|
||||||
).collect();
|
).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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue