(
ui: &mut egui::Ui,
segment: DiffTextSegment,
appearance: &Appearance,
ins_view_state: &FunctionViewState,
column: usize,
space_width: f32,
response_cb: impl Fn(Response)
| 139 | |
| 140 | #[must_use] |
| 141 | fn diff_text_ui( |
| 142 | ui: &mut egui::Ui, |
| 143 | segment: DiffTextSegment, |
| 144 | appearance: &Appearance, |
| 145 | ins_view_state: &FunctionViewState, |
| 146 | column: usize, |
| 147 | space_width: f32, |
| 148 | response_cb: impl Fn(Response) -> Response, |
| 149 | ) -> Option<DiffViewAction> { |
| 150 | let highlight_kind = HighlightKind::from(&segment.text); |
| 151 | let mut branch_to_ins_idx = None; |
| 152 | let label_text = match segment.text { |
| 153 | DiffText::Basic(text) => text.to_string(), |
| 154 | DiffText::Line(num) => format!("{num} "), |
| 155 | DiffText::Address(addr) => format!("{addr:x}:"), |
| 156 | DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "), |
| 157 | DiffText::Argument(arg) => match arg { |
| 158 | InstructionArgValue::Signed(v) => format!("{:#x}", ReallySigned(v)), |
| 159 | InstructionArgValue::Unsigned(v) => format!("{v:#x}"), |
| 160 | InstructionArgValue::Opaque(v) => v.into_owned(), |
| 161 | }, |
| 162 | DiffText::BranchDest(addr) => format!("{addr:x}"), |
| 163 | DiffText::BranchArrow(ins_idx) => { |
| 164 | branch_to_ins_idx = Some(ins_idx); |
| 165 | " ~> ".to_string() |
| 166 | } |
| 167 | DiffText::Symbol(sym) => sym.demangled_name.as_ref().unwrap_or(&sym.name).clone(), |
| 168 | DiffText::Addend(addend) => match addend.cmp(&0i64) { |
| 169 | Ordering::Greater => format!("+{addend:#x}"), |
| 170 | Ordering::Less => format!("-{:#x}", -addend), |
| 171 | _ => String::new(), |
| 172 | }, |
| 173 | DiffText::Spacing(n) => { |
| 174 | ui.add_space(n as f32 * space_width); |
| 175 | return None; |
| 176 | } |
| 177 | DiffText::Eol => "\n".to_string(), |
| 178 | }; |
| 179 | |
| 180 | let len = label_text.len(); |
| 181 | let highlight = highlight_kind != HighlightKind::None |
| 182 | && *ins_view_state.highlight(column) == highlight_kind; |
| 183 | let color = match segment.color { |
| 184 | DiffTextColor::Normal => appearance.text_color, |
| 185 | DiffTextColor::Dim => appearance.deemphasized_text_color, |
| 186 | DiffTextColor::Bright => appearance.emphasized_text_color, |
| 187 | DiffTextColor::DataFlow => appearance.dataflow_color, |
| 188 | DiffTextColor::Replace => appearance.replace_color, |
| 189 | DiffTextColor::Delete => appearance.delete_color, |
| 190 | DiffTextColor::Insert => appearance.insert_color, |
| 191 | DiffTextColor::Rotating(i) => { |
| 192 | appearance.diff_colors[i as usize % appearance.diff_colors.len()] |
| 193 | } |
| 194 | }; |
| 195 | let mut response = Label::new(LayoutJob::single_section( |
| 196 | label_text, |
| 197 | appearance.code_text_format(color, highlight), |
| 198 | )) |
no test coverage detected