Skip to content

Commit

Permalink
feat: style register print
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrcy committed Dec 1, 2024
1 parent cc4f642 commit c9b0a8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/debugger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,18 @@ impl Debugger {
}

pub fn print_registers(f: &mut impl io::Write, state: &RunState) {
writeln!(f, "┌────────────────────────────────────┐").unwrap();
writeln!(f, "│ HEX INT UINT CHAR │").unwrap();
writeln!(f, "\x1b[2m┌────────────────────────────────────┐\x1b[0m").unwrap();
writeln!(
f,
"\x1b[2m│ \x1b[3mhex int uint char\x1b[0m\x1b[2m │\x1b[0m"
)
.unwrap();
for i in 0..8 {
write!(f, " R{} ", i).unwrap();
write!(f, "\x1b[2m│\x1b[0m R{} ", i).unwrap();
print_integer(f, state.reg(i));
writeln!(f, " ").unwrap();
writeln!(f, " \x1b[2m│\x1b[0m").unwrap();
}
writeln!(f, "└────────────────────────────────────┘").unwrap();
writeln!(f, "\x1b[2m└────────────────────────────────────┘\x1b[0m").unwrap();
}

fn print_integer(f: &mut impl io::Write, value: u16) {
Expand Down
1 change: 1 addition & 0 deletions src/debugger/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::runtime::terminal_line_start;

pub struct Writer;

// TODO(feat): impl `fmt::Writer` instead
impl io::Write for Writer {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
// TODO: Make this good
Expand Down

0 comments on commit c9b0a8b

Please sign in to comment.