no-more-secrets-rust/src/sneakers.rs

76 lines
2.6 KiB
Rust

const head1Left: &str = "DATANET PROC RECORD: 45-3456-W-3452";
const head1Right: &str = "Transnet on/xc-3";
const head2Center: &str = "FEDERAL RESERVE TRANSFER NODE";
const head3Center: &str = "National Headquarters";
const head4Center: &str = "************ Remote Systems Network Input Station ************";
const head5Center: &str = "================================================================";
const menu1: &str = "[1] Interbank Funds Transfer (Code Prog: 485-GWU)";
const menu2: &str = "[2] International Telelink Access (Code Lim: XRP-262)";
const menu3: &str = "[3] Remote Facsimile Send/Receive (Code Tran: 2LZP-517)";
const menu4: &str = "[4] Regional Bank Interconnect (Security Code: 47-B34)";
const menu5: &str = "[5] Update System Parameters (Entry Auth. Req.)";
const menu6: &str = "[6] Remote Operator Logon/Logoff";
const foot1Center: &str = "================================================================";
const foot2Center: &str = "[ ] Select Option or ESC to Abort";
#[no_mangle]
pub extern "C" fn rust_sneakers_effect() {
use std::time::Duration;
unsafe {
crate::nmstermio_set_clearscr(1);
}
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);
crate::exec_effect(buf, false, false, true);
}