print all strings

This commit is contained in:
Greg Shuflin 2023-11-15 18:34:17 -08:00
parent e159df38cc
commit 66429e6714
1 changed files with 43 additions and 1 deletions

View File

@ -20,8 +20,50 @@ pub extern "C" fn rust_sneakers_effect() {
println!("Rust sneakers effect");
use std::time::Duration;
let (term_width, _term_height) = crossterm::terminal::size().expect("Error reading terminal size");
let term_width = term_width as usize;
let mut buf = String::new();
buf.push_str(head1Left);
let spaces = term_width - head1Left.len() - head1Right.len();
buf.push_str(&" ".repeat(spaces));
buf.push_str(head1Right);
buf.push('\n');
for text in [head2Center, head3Center].iter(){
let spaces = ((term_width - text.len()) / 2);
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push_str("\n\n");
};
for text in [head4Center, head5Center].iter(){
let spaces = ((term_width - text.len()) / 2);
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push('\n');
};
buf.push('\n');
for text in [menu1, menu2, menu3, menu4, menu5, menu6].iter() {
let spaces = ((term_width - head5Center.len()) / 2) + 3;
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push('\n');
}
for text in [foot1Center, foot2Center].iter() {
let spaces = ((term_width - text.len()) / 2);
buf.push('\n');
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push('\n');
};
println!("{}", buf);
let dur = Duration::from_millis(2000);
std::thread::sleep(dur);
let mut buf = String::new();
}