Allow clicking on branch arrows to scroll target into view (#302)

This commit is contained in:
LagoLunatic
2025-12-21 11:55:55 -05:00
committed by GitHub
parent 90c93164ab
commit 6ad60de32a
14 changed files with 232 additions and 191 deletions
+14 -2
View File
@@ -37,6 +37,8 @@ pub enum DiffText<'a> {
Argument(InstructionArgValue<'a>),
/// Branch destination
BranchDest(u64),
/// Branch source/destination arrow, scrolls to a specific row when clicked
BranchArrow(u32),
/// Symbol name
Symbol(&'a Symbol),
/// Relocation addend
@@ -185,7 +187,13 @@ pub fn display_row(
pad_to: 5,
})?;
if let Some(branch) = &ins_row.branch_from {
cb(DiffTextSegment::basic(" ~> ", DiffTextColor::Rotating(branch.branch_idx as u8)))?;
// Pick the first branch source if there are multiple.
let ins_idx = branch.ins_idx[0];
cb(DiffTextSegment {
text: DiffText::BranchArrow(ins_idx),
color: DiffTextColor::Rotating(branch.branch_idx as u8),
pad_to: 0,
})?;
} else {
cb(DiffTextSegment::spacing(4))?;
}
@@ -307,7 +315,11 @@ pub fn display_row(
cb(DiffTextSegment::basic(">", base_color))?;
}
if let Some(branch) = &ins_row.branch_to {
cb(DiffTextSegment::basic(" ~>", DiffTextColor::Rotating(branch.branch_idx as u8)))?;
cb(DiffTextSegment {
text: DiffText::BranchArrow(branch.ins_idx),
color: DiffTextColor::Rotating(branch.branch_idx as u8),
pad_to: 0,
})?;
}
cb(EOL_SEGMENT)?;
Ok(())