From cd3ea4d1a63026813980fcbe0ddbe26c4bb91566 Mon Sep 17 00:00:00 2001 From: alice pellerin Date: Sat, 25 Apr 2026 17:50:22 -0500 Subject: [PATCH] add binary to inspector for single bytes --- src/buffer/actions.rs | 11 +++++++++++ src/buffer/widget/hex.rs | 1 + src/main.rs | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/buffer/actions.rs b/src/buffer/actions.rs index 6462d0a..cba6404 100644 --- a/src/buffer/actions.rs +++ b/src/buffer/actions.rs @@ -378,6 +378,7 @@ impl Buffer { if next_cursor_index == self.cursors.len() { swap(&mut self.primary_cursor, &mut self.cursors[0]); + // TODO: is a full sort necessary ? self.cursors.sort_by_key(|cursor| cursor.head); } else { swap(&mut self.primary_cursor, &mut self.cursors[next_cursor_index]); @@ -704,6 +705,15 @@ fn inspect(selection: &[u8]) -> Vec> { let int = nat.and_then(|nat| nat_to_int_if_different(nat, selection.len())); + let binary = nat + .filter(|_| selection.len() == 1) + .map(|nat| { + let lower_bits = nat & 0b1111; + let upper_bits = nat >> 4; + + format!("{upper_bits:04b}_{lower_bits:04b}").into() + }); + let utf8 = str::from_utf8(selection).ok() .filter(|_| selection.len() != 1) .map(|utf8| utf8.trim_suffix('\0')) @@ -801,6 +811,7 @@ fn inspect(selection: &[u8]) -> Vec> { int.map(|int| format!("{int}").into()) .into_iter() .chain(nat.map(|nat| format!("{nat}").into())) + .chain(binary) .chain(utf8) .chain(fixedpoint2012_signed) .chain(fixedpoint2012) diff --git a/src/buffer/widget/hex.rs b/src/buffer/widget/hex.rs index 3591547..5e561cc 100644 --- a/src/buffer/widget/hex.rs +++ b/src/buffer/widget/hex.rs @@ -105,6 +105,7 @@ impl Buffer { address: usize, byte: u8 ) -> Span<'static> { + // TODO: checking this with lots of selections is slow if self.partial_action == Some(PartialAction::Replace) && iter::once(&self.primary_cursor) .chain(&self.cursors) diff --git a/src/main.rs b/src/main.rs index 139246e..379e699 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,12 @@ const BYTES_OF_PADDING: usize = LINES_OF_PADDING * BYTES_PER_LINE; // - update showcase // - fix scroll clamping // - inspector translations for varint +// - t in select mode doesnt work right +// - repeat in select mode doesnt work right +// - gg/G in select mode +// - gl/gj in select mode +// - scrolling in select mode +// - +/- to edit selected bytes by amount // - search // - ascii and bytes (`/` and `A-/`?) // - diffing