Website Summary Files Commits Branches @commit @diff @stats
path: root / vm / src
diff options
context:
space:
mode:
Commitcde6e64005b8cc1b426b1aea15398eb7acb11d08 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-15 09:05:20 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-15 09:05:20 +0200
Filesf5eb0b6ca2d318f6a76ef4e5fefba2ec00bc7c84 /vm/src
tonkobali-cde6e64005b8cc1b426b1aea15398eb7acb11d08.tar
tonkobali-cde6e64005b8cc1b426b1aea15398eb7acb11d08.tar.gz
tonkobali-cde6e64005b8cc1b426b1aea15398eb7acb11d08.zip
Parent9372bbd7617de25d1729765401f4ed00c23e0a22 (diff)
feat(vm/vmm): Improved fancy output
1 files changed, 12 insertions, 5 deletions
-rw-r--r--vm/src/vmm/mod.rs17
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));