Skip to content

Commit

Permalink
fix cursor and selection rendering bugs on Hexstring tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
misson20000 committed Nov 30, 2024
1 parent 3e769fe commit 8f33b67
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/view/listing/token_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl TokenView {

for i in 0..token.extent.len().bytes() {
let (byte, flags) = self.data.as_ref().map(|fetcher| fetcher.byte_and_flags(i as usize)).unwrap_or_default();
let byte_extent = addr::Extent::sized(i, addr::Offset::BYTE).intersection(token.extent);
let byte_extent = addr::Extent::sized(i, addr::Offset::BYTE).offset(token.extent.begin).intersection(token.extent);
let selected = byte_extent.map_or(false, |be| selection.includes(be.begin));

let mut text_color = render.config.text_color.rgba();
Expand All @@ -204,12 +204,12 @@ impl TokenView {

for low_nybble in [false, true] {
let nybble = if low_nybble { byte & 0xf } else { byte >> 4 };
let has_cursor = hexstring_cursor.map_or(false, |hxc| sync::Arc::ptr_eq(&hxc.token.common.node, &self.token.node()) && hxc.offset.bytes() == i && hxc.low_nybble == low_nybble);
let nybble_has_cursor = has_cursor && hexstring_cursor.map_or(false, |hxc| sync::Arc::ptr_eq(&hxc.token.common.node, &self.token.node()) && hxc.offset.bytes() == i && hxc.low_nybble == low_nybble);

let digit = if pending { gsc::Entry::Space } else { gsc::Entry::Digit(nybble) };

render.gsc_mono.begin(digit, text_color, &mut pos)
.cursor(has_cursor, cursor, render.config.cursor_fg_color.rgba(), render.config.cursor_bg_color.rgba())
.cursor(nybble_has_cursor, cursor, render.config.cursor_fg_color.rgba(), render.config.cursor_bg_color.rgba())
.selected(selected, render.config.selection_color.rgba())
.placeholder(pending, render.config.placeholder_color.rgba())
.render(snapshot);
Expand Down

0 comments on commit 8f33b67

Please sign in to comment.