1
0

Reimplement disassembly styling

This commit is contained in:
Jeff 2024-12-10 01:38:40 -05:00
parent 85a706e0fb
commit 942b494b7f

View File

@ -40,9 +40,7 @@
//! ``` //! ```
use std::{ use std::{
env::current_exe, env::current_exe,
io::{self, ErrorKind, Write}, io::{self, Write},
iter::empty,
str::Chars,
}; };
use colored::{ColoredString, Colorize}; use colored::{ColoredString, Colorize};
@ -147,6 +145,10 @@ impl<'a, W: Write> Disassembler<'a, W> {
write!(&mut self.writer, "{}", text) write!(&mut self.writer, "{}", text)
} }
fn write_colored(&mut self, text: &ColoredString) -> Result<(), io::Error> {
write!(&mut self.writer, "{}", text)
}
fn write_content( fn write_content(
&mut self, &mut self,
text: &str, text: &str,
@ -196,7 +198,13 @@ impl<'a, W: Write> Disassembler<'a, W> {
} }
} }
self.write_str(line_content)?; if style_bold {
self.write_colored(&line_content.bold())?;
} else if style_dim {
self.write_colored(&line_content.dimmed())?;
} else {
self.write_str(line_content)?;
}
if center { if center {
for _ in 0..right_pad_length { for _ in 0..right_pad_length {