mirror of
https://github.com/linux-msm/sk8brd.git
synced 2026-02-25 13:13:15 -08:00
main: Stop the write(ln)!(stdout()..) craziness
stop the crossterm docs propaganda and flush stdout where ncessary Signed-off-by: Konrad Dybcio <konradybcio@kernel.org>
This commit is contained in:
committed by
Konrad Dybcio
parent
3e6ce0127e
commit
883752dfe7
@@ -111,7 +111,7 @@ pub async fn send_image(write_sink: &mut Arc<Mutex<impl Write>>, buf: &[u8]) ->
|
||||
|
||||
if percent_done != last_percent_done {
|
||||
let s = format!(" Sending image: {}%\r", percent_done);
|
||||
write!(stdout(), "{}", s.green()).unwrap();
|
||||
print!("{}", s.green());
|
||||
stdout().flush()?;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,9 @@ pub async fn send_image(write_sink: &mut Arc<Mutex<impl Write>>, buf: &[u8]) ->
|
||||
last_percent_done = percent_done;
|
||||
|
||||
if bytes_sent == buf.len() {
|
||||
write!(stdout(), "\r{}\r", " ".repeat(80))?;
|
||||
write!(stdout(), "{}\r\n", String::from("Image sent!").green())?;
|
||||
print!("\r{}\r", " ".repeat(80));
|
||||
print!("{}\r\n", String::from("Image sent!").green());
|
||||
stdout().flush()?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +155,7 @@ pub fn print_string_msg(buf: &[u8]) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeln!(stdout(), "{}\r", String::from_utf8_lossy(buf)).unwrap();
|
||||
println!("{}\r", String::from_utf8_lossy(buf));
|
||||
stdout().flush().unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ async fn handle_keypress(
|
||||
macro_rules! todo {
|
||||
($s: expr) => {{
|
||||
let val = format!($s);
|
||||
writeln!(stdout(), "{val}\r").unwrap();
|
||||
println!("{val}\r");
|
||||
stdout().flush()?;
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user