Skip to content

Commit b7b177a

Browse files
committed
Symbol diff UI improvements
1 parent 5259828 commit b7b177a

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

src/views/symbol_diff.rs

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,35 @@ fn write_text(str: &str, color: Color32, job: &mut LayoutJob) {
2727
job.append(str, 0.0, TextFormat { font_id: FONT_ID, color, ..Default::default() });
2828
}
2929

30+
fn symbol_context_menu_ui(ui: &mut Ui, symbol: &ObjSymbol) {
31+
ui.scope(|ui| {
32+
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
33+
ui.style_mut().wrap = Some(false);
34+
35+
if let Some(name) = &symbol.demangled_name {
36+
if ui.button(format!("Copy \"{}\"", name)).clicked() {
37+
ui.output().copied_text = name.clone();
38+
ui.close_menu();
39+
}
40+
}
41+
if ui.button(format!("Copy \"{}\"", symbol.name)).clicked() {
42+
ui.output().copied_text = symbol.name.clone();
43+
ui.close_menu();
44+
}
45+
});
46+
}
47+
48+
fn symbol_hover_ui(ui: &mut Ui, symbol: &ObjSymbol) {
49+
ui.scope(|ui| {
50+
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
51+
ui.style_mut().wrap = Some(false);
52+
53+
ui.colored_label(Color32::WHITE, format!("Name: {}", symbol.name));
54+
ui.colored_label(Color32::WHITE, format!("Address: {:x}", symbol.address));
55+
ui.colored_label(Color32::WHITE, format!("Size: {:x}", symbol.size));
56+
});
57+
}
58+
3059
fn symbol_ui(
3160
ui: &mut Ui,
3261
symbol: &ObjSymbol,
@@ -63,7 +92,10 @@ fn symbol_ui(
6392
write_text(") ", Color32::GRAY, &mut job);
6493
}
6594
write_text(name, Color32::WHITE, &mut job);
66-
let response = SelectableLabel::new(selected, job).ui(ui);
95+
let response = SelectableLabel::new(selected, job)
96+
.ui(ui)
97+
.context_menu(|ui| symbol_context_menu_ui(ui, symbol))
98+
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, symbol));
6799
if response.clicked() {
68100
*selected_symbol = Some(symbol.name.clone());
69101
*current_view = View::FunctionDiff;
@@ -125,10 +157,13 @@ fn symbol_list_ui(
125157
}
126158

127159
fn build_log_ui(ui: &mut Ui, status: &BuildStatus) {
128-
ui.scope(|ui| {
129-
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
130-
ui.style_mut().wrap = Some(false);
131-
ui.colored_label(Color32::from_rgb(255, 0, 0), &status.log);
160+
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
161+
ui.scope(|ui| {
162+
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
163+
ui.style_mut().wrap = Some(false);
164+
165+
ui.colored_label(Color32::from_rgb(255, 0, 0), &status.log);
166+
});
132167
});
133168
}
134169

0 commit comments

Comments
 (0)