Skip to content

Commit 803eaaf

Browse files
committed
Hide hidden symbols by default; add "Diff Options" to menu
1 parent e1dc846 commit 803eaaf

File tree

4 files changed

+47
-9
lines changed

4 files changed

+47
-9
lines changed

src/app.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,23 @@ impl eframe::App for App {
373373
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
374374
egui::menu::bar(ui, |ui| {
375375
ui.menu_button("File", |ui| {
376+
if ui.button("Project…").clicked() {
377+
*show_project_config = !*show_project_config;
378+
ui.close_menu();
379+
}
376380
let recent_projects = if let Ok(guard) = config.read() {
377381
guard.recent_projects.clone()
378382
} else {
379383
vec![]
380384
};
381385
if recent_projects.is_empty() {
382-
ui.add_enabled(false, egui::Button::new("Recent Projects…"));
386+
ui.add_enabled(false, egui::Button::new("Recent projects…"));
383387
} else {
384388
ui.menu_button("Recent Projects…", |ui| {
389+
if ui.button("Clear").clicked() {
390+
config.write().unwrap().recent_projects.clear();
391+
};
392+
ui.separator();
385393
for path in recent_projects {
386394
if ui.button(format!("{}", path.display())).clicked() {
387395
config.write().unwrap().set_project_dir(path);
@@ -404,6 +412,29 @@ impl eframe::App for App {
404412
ui.close_menu();
405413
}
406414
});
415+
ui.menu_button("Diff Options", |ui| {
416+
let mut config = config.write().unwrap();
417+
let response = ui
418+
.checkbox(&mut config.rebuild_on_changes, "Rebuild on changes")
419+
.on_hover_text("Automatically re-run the build & diff when files change.");
420+
if response.changed() {
421+
config.watcher_change = true;
422+
};
423+
ui.add_enabled(
424+
!diff_state.symbol_state.disable_reverse_fn_order,
425+
egui::Checkbox::new(
426+
&mut diff_state.symbol_state.reverse_fn_order,
427+
"Reverse function order (-inline deferred)",
428+
),
429+
)
430+
.on_disabled_hover_text(
431+
"Option disabled because it's set by the project configuration file.",
432+
);
433+
ui.checkbox(
434+
&mut diff_state.symbol_state.show_hidden_symbols,
435+
"Show hidden symbols",
436+
);
437+
});
407438
});
408439
});
409440

src/obj/elf.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cwdemangle::demangle;
66
use flagset::Flags;
77
use object::{
88
elf, Architecture, File, Object, ObjectSection, ObjectSymbol, RelocationKind, RelocationTarget,
9-
SectionIndex, SectionKind, Symbol, SymbolKind, SymbolSection,
9+
SectionIndex, SectionKind, Symbol, SymbolKind, SymbolScope, SymbolSection,
1010
};
1111

1212
use crate::obj::{
@@ -42,6 +42,9 @@ fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> R
4242
if symbol.is_weak() {
4343
flags = ObjSymbolFlagSet(flags.0 | ObjSymbolFlags::Weak);
4444
}
45+
if symbol.scope() == SymbolScope::Linkage {
46+
flags = ObjSymbolFlagSet(flags.0 | ObjSymbolFlags::Hidden);
47+
}
4548
let section_address = if let Some(section) =
4649
symbol.section_index().and_then(|idx| obj_file.section_by_index(idx).ok())
4750
{

src/obj/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ flags! {
1818
Local,
1919
Weak,
2020
Common,
21+
Hidden,
2122
}
2223
}
2324
#[derive(Debug, Copy, Clone, Default)]

src/views/symbol_diff.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct SymbolViewState {
4747
pub selected_symbol: Option<SymbolReference>,
4848
pub reverse_fn_order: bool,
4949
pub disable_reverse_fn_order: bool,
50+
pub show_hidden_symbols: bool,
5051
}
5152

5253
impl DiffViewState {
@@ -136,6 +137,9 @@ fn symbol_ui(
136137
state: &mut SymbolViewState,
137138
appearance: &Appearance,
138139
) -> Option<View> {
140+
if symbol.flags.0.contains(ObjSymbolFlags::Hidden) && !state.show_hidden_symbols {
141+
return None;
142+
}
139143
let mut ret = None;
140144
let mut job = LayoutJob::default();
141145
let name: &str =
@@ -155,6 +159,9 @@ fn symbol_ui(
155159
if symbol.flags.0.contains(ObjSymbolFlags::Weak) {
156160
write_text("w", appearance.text_color, &mut job, appearance.code_font.clone());
157161
}
162+
if symbol.flags.0.contains(ObjSymbolFlags::Hidden) {
163+
write_text("h", appearance.deemphasized_text_color, &mut job, appearance.code_font.clone());
164+
}
158165
write_text("] ", appearance.text_color, &mut job, appearance.code_font.clone());
159166
if let Some(match_percent) = symbol.match_percent {
160167
write_text("(", appearance.text_color, &mut job, appearance.code_font.clone());
@@ -336,13 +343,9 @@ pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appea
336343
}
337344
});
338345

339-
ui.add_enabled(
340-
!symbol_state.disable_reverse_fn_order,
341-
egui::Checkbox::new(
342-
&mut symbol_state.reverse_fn_order,
343-
"Reverse function order (-inline deferred)",
344-
),
345-
);
346+
if ui.add_enabled(!state.build_running, egui::Button::new("Build")).clicked() {
347+
state.queue_build = true;
348+
}
346349
},
347350
);
348351
},

0 commit comments

Comments
 (0)