preview bytes under cursor when replacing

This commit is contained in:
alice pellerin
2026-03-18 15:39:37 -05:00
parent ba3d80f111
commit 725e6784ab
3 changed files with 21 additions and 1 deletions
+18 -1
View File
@@ -78,7 +78,7 @@ mod hex {
use itertools::{Itertools, repeat_n};
use ratatui::{style::{Color, Style, Stylize}, text::Span};
use crate::{BYTES_PER_CHUNK, BYTES_PER_LINE, CHUNKS_PER_LINE, app::{App, Mode}, cardinality::HasCardinality, cursor::InCursor, custom_greys::CustomGreys, empty_span::empty_span};
use crate::{BYTES_PER_CHUNK, BYTES_PER_LINE, CHUNKS_PER_LINE, app::{App, Mode, PartialAction}, cardinality::HasCardinality, cursor::InCursor, custom_greys::CustomGreys, empty_span::empty_span};
impl App {
pub fn render_chunks(
@@ -189,6 +189,23 @@ mod hex {
&self,
address: usize,
byte: u8
) -> Span<'static> {
if self.partial_action == Some(PartialAction::Replace) &&
self.cursor.contains(address).is_some()
{
let replaced_byte = self.partial_replace.unwrap_or(0) << 4;
self.render_byte_without_replace_preview(address, replaced_byte)
.fg(Color::Black)
} else {
self.render_byte_without_replace_preview(address, byte)
}
}
fn render_byte_without_replace_preview(
&self,
address: usize,
byte: u8
) -> Span<'static> {
const SPAN_FOR_BYTE: [Span; u8::CARDINALITY] = create_byte_lookup_table();