From cde6e64005b8cc1b426b1aea15398eb7acb11d08 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 15 Feb 2025 09:05:20 +0200 Subject: feat(vm/vmm): Improved fancy output --- vm/src/vmm/mod.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'vm/src') diff --git a/vm/src/vmm/mod.rs b/vm/src/vmm/mod.rs index 9ad250f..0bfca73 100644 --- a/vm/src/vmm/mod.rs +++ b/vm/src/vmm/mod.rs @@ -10,9 +10,16 @@ pub(crate) struct VirtualMachineMonitor { refresh_rate: u64, } -macro_rules! above { + +macro_rules! info { + () => { + print!("\x1B[90m|\x1B[0m{:^8}\x1B[90m|> \x1B[0m", "RUN") + }; + (error $str:expr) => { + info!(format!("\x1B[41m{:^8}\x1B[0m", $str)) + }; ($str:expr) => { - concat!("\x1B7\x1B[1F|", $str, "|\x1B8") + print!("\x1B7\x1B[1G\x1B[90m|\x1B[0m{:^8}\x1B[90m|> \x1B[0m\x1B8", $str) }; } @@ -32,7 +39,7 @@ impl VirtualMachineMonitor { tx.send(buffer).unwrap(); }); - print!("\n> "); + info!(); loop { match rx.try_recv() { Ok(input) => { @@ -44,16 +51,16 @@ impl VirtualMachineMonitor { println!("{}", msg); } } - print!("\n> "); + info!(); }, _ => {}, } { if vm.is_halted() { - print!(above!("HALTED!")); } } + info!(error "HALTED"); let _ = stdout().flush(); thread::sleep(time::Duration::from_millis(self.refresh_rate)); -- cgit v1.3.1-26-gb76a