summaryrefslogtreecommitdiff
path: root/src/registers.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2023-10-15 22:00:43 +0200
committerSanto Cariotti <santo@dcariotti.me>2023-10-15 22:00:43 +0200
commitf9207a326c7f0e5861ee9489313861fdcd7bbff0 (patch)
treea647f8da6f596a608efffff8170da8d8db3a3b22 /src/registers.rs
parentd3095900b941d7b08d579f9dc5e9dac45690228b (diff)
Add lines style
Diffstat (limited to 'src/registers.rs')
-rw-r--r--src/registers.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/registers.rs b/src/registers.rs
index 80b4a9b..d73424d 100644
--- a/src/registers.rs
+++ b/src/registers.rs
@@ -1,4 +1,9 @@
use nix::libc::user_regs_struct;
+use owo_colors::OwoColorize;
+use ratatui::{
+ prelude::{Line, Span, Style},
+ style::Modifier,
+};
/// Struct used to manipulate registers data from https://docs.rs/libc/0.2.147/libc/struct.user_regs_struct.html
pub struct RegistersData {
@@ -25,7 +30,28 @@ impl RegistersData {
pub fn output(&self) -> String {
format!(
"{}({:x}, {:x}, {:x}, ...) = {:x}",
- self.orig_rax, self.rdi, self.rsi, self.rdx, self.rax
+ self.orig_rax.bold(),
+ self.rdi,
+ self.rsi,
+ self.rdx,
+ self.rax
)
}
+
+ /// Returns a good line for TUI
+ pub fn output_ui(&self) -> Line {
+ Line::from(vec![
+ Span::styled(
+ format!("{}", self.orig_rax),
+ Style::default().add_modifier(Modifier::BOLD),
+ ),
+ Span::styled(
+ format!(
+ "({:x}, {:x}, {:x}, ...) = {:x}",
+ self.rdi, self.rsi, self.rdx, self.rax
+ ),
+ Style::default(),
+ ),
+ ])
+ }
}