pub fn printable(text: &str) -> Cow<'_, str>Expand description
One line written for a terminal, as the terminal would leave it on screen: what a carriage return wrote over is gone, colour and cursor sequences are taken out, a tab becomes spaces up to the next stop of eight and no other control character is left.
Programs print for a terminal: a progress line redraws itself after \r, a build tool colours
its words with escape sequences. A cell cannot hold a control character, so text from another
program goes through this before it is drawn. Text with nothing to change is borrowed.
use qframe::text::printable;
assert_eq!(printable("10%\r50%\r100%"), "100%");
assert_eq!(printable("sent 2kB\r\r"), "sent 2kB");
assert_eq!(printable("\u{1b}[1;32mok\u{1b}[0m done"), "ok done");
assert_eq!(printable("a\tb"), "a b");