preview bytes under cursor when replacing
This commit is contained in:
+18
-1
@@ -78,7 +78,7 @@ mod hex {
|
|||||||
use itertools::{Itertools, repeat_n};
|
use itertools::{Itertools, repeat_n};
|
||||||
use ratatui::{style::{Color, Style, Stylize}, text::Span};
|
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 {
|
impl App {
|
||||||
pub fn render_chunks(
|
pub fn render_chunks(
|
||||||
@@ -189,6 +189,23 @@ mod hex {
|
|||||||
&self,
|
&self,
|
||||||
address: usize,
|
address: usize,
|
||||||
byte: u8
|
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> {
|
) -> Span<'static> {
|
||||||
const SPAN_FOR_BYTE: [Span; u8::CARDINALITY] = create_byte_lookup_table();
|
const SPAN_FOR_BYTE: [Span; u8::CARDINALITY] = create_byte_lookup_table();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use crate::{app::App, cursor::Cursor};
|
use crate::{app::App, cursor::Cursor};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum EditAction {
|
pub enum EditAction {
|
||||||
Delete {
|
Delete {
|
||||||
cursor: Cursor,
|
cursor: Cursor,
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ fn main() {
|
|||||||
|
|
||||||
ratatui::restore();
|
ratatui::restore();
|
||||||
|
|
||||||
|
// dbg!(app.edit_history);
|
||||||
|
|
||||||
for log in app.logs {
|
for log in app.logs {
|
||||||
println!("{log}");
|
println!("{log}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user