From 16907845f15dc9e72169ba64b83ba0fdcaf1ace4 Mon Sep 17 00:00:00 2001 From: Federico Guerinoni Date: Sun, 3 Mar 2024 19:32:20 +0100 Subject: [PATCH] UI: Accept breakpoint with `0x360` or just `360` --- extra/pre-commit | 2 +- ui/src/cpu_handler.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/extra/pre-commit b/extra/pre-commit index 174526af..215be30b 100755 --- a/extra/pre-commit +++ b/extra/pre-commit @@ -2,7 +2,7 @@ set -e -which just > /dev/null || cargo install just +which just 2>&1 > /dev/null || cargo install just just check-fmt just lint diff --git a/ui/src/cpu_handler.rs b/ui/src/cpu_handler.rs index 5a12c123..1dc0fb6f 100644 --- a/ui/src/cpu_handler.rs +++ b/ui/src/cpu_handler.rs @@ -126,10 +126,22 @@ impl UiTool for CpuHandler { ui.text_edit_singleline(&mut self.b_address); if ui.button("Add").clicked() { + if self.b_address.is_empty() { + return; + } + + let a = if self.b_address.starts_with("0x") { + self.b_address[2..].to_string() + } else { + self.b_address.clone() + }; + self.breakpoints .lock() .unwrap() - .insert(u32::from_str_radix(&self.b_address, 16).unwrap()); + .insert(u32::from_str_radix(&a, 16).unwrap()); + + self.b_address.clear(); } });