Skip to content

Commit 4fddcd4

Browse files
committed
move symbol size config to config-schema
1 parent ee02a79 commit 4fddcd4

File tree

5 files changed

+35
-33
lines changed

5 files changed

+35
-33
lines changed

objdiff-core/config-schema.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@
8282
"name": "Space between args",
8383
"description": "Adds a space between arguments in the diff output."
8484
},
85+
{
86+
"id": "showSymbolSizes",
87+
"type": "choice",
88+
"default": "off",
89+
"name": "Show symbol sizes",
90+
"description": "Shows symbol sizes in the symbol view.",
91+
"items": [
92+
{
93+
"value": "off",
94+
"name": "Off"
95+
},
96+
{
97+
"value": "hex",
98+
"name": "Hex"
99+
},
100+
{
101+
"value": "decimal",
102+
"name": "Decimal"
103+
}
104+
]
105+
},
85106
{
86107
"id": "combineDataSections",
87108
"type": "boolean",
@@ -296,6 +317,7 @@
296317
"properties": [
297318
"functionRelocDiffs",
298319
"demangler",
320+
"showSymbolSizes",
299321
"spaceBetweenArgs",
300322
"combineDataSections",
301323
"combineTextSections"

objdiff-gui/src/app_config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use objdiff_core::{
66
config::ScratchConfig,
77
diff::{
88
ArmArchVersion, ArmR9Usage, DiffObjConfig, FunctionRelocDiffs, MipsAbi, MipsInstrCategory,
9-
X86Formatter,
9+
ShowSymbolSizes, X86Formatter,
1010
},
1111
};
1212
use typed_path::{Utf8PlatformPathBuf, Utf8UnixPathBuf};
@@ -227,6 +227,7 @@ pub struct DiffObjConfigV1 {
227227
pub relax_reloc_diffs: bool,
228228
#[serde(default = "bool_true")]
229229
pub space_between_args: bool,
230+
pub show_symbol_sizes: ShowSymbolSizes,
230231
pub combine_data_sections: bool,
231232
// x86
232233
pub x86_formatter: X86Formatter,
@@ -248,6 +249,7 @@ impl Default for DiffObjConfigV1 {
248249
Self {
249250
relax_reloc_diffs: false,
250251
space_between_args: true,
252+
show_symbol_sizes: Default::default(),
251253
combine_data_sections: false,
252254
x86_formatter: Default::default(),
253255
mips_abi: Default::default(),
@@ -272,6 +274,7 @@ impl DiffObjConfigV1 {
272274
FunctionRelocDiffs::default()
273275
},
274276
space_between_args: self.space_between_args,
277+
show_symbol_sizes: self.show_symbol_sizes,
275278
combine_data_sections: self.combine_data_sections,
276279
x86_formatter: self.x86_formatter,
277280
mips_abi: self.mips_abi,

objdiff-gui/src/views/appearance.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub struct Appearance {
1313
pub diff_colors: Vec<Color32>,
1414
pub diff_bg_color: Option<Color32>,
1515
pub theme: egui::Theme,
16-
pub show_symbol_sizes: ShowSymbolSizeState,
1716

1817
// Applied by theme
1918
#[serde(skip)]
@@ -44,12 +43,6 @@ pub struct Appearance {
4443
pub next_code_font: Option<FontId>,
4544
}
4645

47-
#[derive(serde::Deserialize, serde::Serialize, PartialEq, Debug)]
48-
pub enum ShowSymbolSizeState {
49-
Off,
50-
Decimal,
51-
Hex,
52-
}
5346
pub struct FontState {
5447
definitions: egui::FontDefinitions,
5548
source: font_kit::source::SystemSource,
@@ -67,7 +60,6 @@ impl Default for Appearance {
6760
code_font: DEFAULT_CODE_FONT,
6861
diff_colors: DEFAULT_COLOR_ROTATION.to_vec(),
6962
theme: egui::Theme::Dark,
70-
show_symbol_sizes: ShowSymbolSizeState::Off,
7163
text_color: Color32::GRAY,
7264
emphasized_text_color: Color32::LIGHT_GRAY,
7365
deemphasized_text_color: Color32::DARK_GRAY,
@@ -310,26 +302,6 @@ pub fn appearance_window(ctx: &egui::Context, show: &mut bool, appearance: &mut
310302
appearance,
311303
);
312304
ui.separator();
313-
egui::ComboBox::from_label("Show symbol sizes")
314-
.selected_text(format!("{:?}", appearance.show_symbol_sizes))
315-
.show_ui(ui, |ui| {
316-
ui.selectable_value(
317-
&mut appearance.show_symbol_sizes,
318-
ShowSymbolSizeState::Off,
319-
"Off",
320-
);
321-
ui.selectable_value(
322-
&mut appearance.show_symbol_sizes,
323-
ShowSymbolSizeState::Decimal,
324-
"Decimal",
325-
);
326-
ui.selectable_value(
327-
&mut appearance.show_symbol_sizes,
328-
ShowSymbolSizeState::Hex,
329-
"Hex",
330-
);
331-
});
332-
ui.separator();
333305
ui.horizontal(|ui| {
334306
ui.label("Diff fill color:");
335307
let mut diff_bg_color =

objdiff-gui/src/views/diff.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ fn diff_col_ui(
665665
appearance,
666666
column,
667667
open_sections,
668+
diff_config,
668669
) {
669670
match (column, action) {
670671
(
@@ -703,6 +704,7 @@ fn diff_col_ui(
703704
appearance,
704705
column,
705706
open_sections,
707+
diff_config,
706708
) {
707709
ret = Some(result);
708710
}

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use egui::{
66
};
77
use objdiff_core::{
88
diff::{
9-
ObjectDiff, SymbolDiff,
9+
DiffObjConfig, ObjectDiff, ShowSymbolSizes, SymbolDiff,
1010
display::{
1111
HighlightKind, SectionDisplay, SymbolFilter, SymbolNavigationKind, display_sections,
1212
symbol_context, symbol_hover,
@@ -22,7 +22,7 @@ use crate::{
2222
hotkeys,
2323
jobs::{is_create_scratch_available, start_create_scratch},
2424
views::{
25-
appearance::{Appearance, ShowSymbolSizeState},
25+
appearance::Appearance,
2626
diff::{context_menu_items_ui, hover_items_ui},
2727
function_diff::FunctionViewState,
2828
write_text,
@@ -525,6 +525,7 @@ fn symbol_ui(
525525
state: &SymbolViewState,
526526
appearance: &Appearance,
527527
column: usize,
528+
diff_config: &DiffObjConfig,
528529
) -> Option<DiffViewAction> {
529530
let mut ret = None;
530531
let mut job = LayoutJob::default();
@@ -572,14 +573,14 @@ fn symbol_ui(
572573
write_text(") ", appearance.text_color, &mut job, appearance.code_font.clone());
573574
}
574575
write_text(name, appearance.highlight_color, &mut job, appearance.code_font.clone());
575-
if appearance.show_symbol_sizes == ShowSymbolSizeState::Decimal {
576+
if diff_config.show_symbol_sizes == ShowSymbolSizes::Decimal {
576577
write_text(
577578
&format!(" (size={})", symbol.size),
578579
appearance.deemphasized_text_color,
579580
&mut job,
580581
appearance.code_font.clone(),
581582
);
582-
} else if appearance.show_symbol_sizes == ShowSymbolSizeState::Hex {
583+
} else if diff_config.show_symbol_sizes == ShowSymbolSizes::Hex {
583584
write_text(
584585
&format!(" (size={:x})", symbol.size),
585586
appearance.deemphasized_text_color,
@@ -661,6 +662,7 @@ pub fn symbol_list_ui(
661662
appearance: &Appearance,
662663
column: usize,
663664
open_sections: Option<bool>,
665+
diff_config: &DiffObjConfig,
664666
) -> Option<DiffViewAction> {
665667
let mut ret = None;
666668
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
@@ -785,6 +787,7 @@ pub fn symbol_list_ui(
785787
state,
786788
appearance,
787789
column,
790+
diff_config,
788791
) {
789792
ret = Some(result);
790793
}

0 commit comments

Comments
 (0)