mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-10 22:17:51 +00:00
Start project config file support & rework UI
This commit is contained in:
56
src/views/appearance.rs
Normal file
56
src/views/appearance.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use egui::Color32;
|
||||
|
||||
use crate::app::ViewState;
|
||||
|
||||
pub const DEFAULT_COLOR_ROTATION: [Color32; 9] = [
|
||||
Color32::from_rgb(255, 0, 255),
|
||||
Color32::from_rgb(0, 255, 255),
|
||||
Color32::from_rgb(0, 128, 0),
|
||||
Color32::from_rgb(255, 0, 0),
|
||||
Color32::from_rgb(255, 255, 0),
|
||||
Color32::from_rgb(255, 192, 203),
|
||||
Color32::from_rgb(0, 0, 255),
|
||||
Color32::from_rgb(0, 255, 0),
|
||||
Color32::from_rgb(213, 138, 138),
|
||||
];
|
||||
|
||||
pub fn appearance_window(ctx: &egui::Context, view_state: &mut ViewState) {
|
||||
egui::Window::new("Appearance").open(&mut view_state.show_view_config).show(ctx, |ui| {
|
||||
egui::ComboBox::from_label("Theme")
|
||||
.selected_text(format!("{:?}", view_state.view_config.theme))
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut view_state.view_config.theme, eframe::Theme::Dark, "Dark");
|
||||
ui.selectable_value(
|
||||
&mut view_state.view_config.theme,
|
||||
eframe::Theme::Light,
|
||||
"Light",
|
||||
);
|
||||
});
|
||||
ui.label("UI font:");
|
||||
egui::introspection::font_id_ui(ui, &mut view_state.view_config.ui_font);
|
||||
ui.separator();
|
||||
ui.label("Code font:");
|
||||
egui::introspection::font_id_ui(ui, &mut view_state.view_config.code_font);
|
||||
ui.separator();
|
||||
ui.label("Diff colors:");
|
||||
if ui.button("Reset").clicked() {
|
||||
view_state.view_config.diff_colors = DEFAULT_COLOR_ROTATION.to_vec();
|
||||
}
|
||||
let mut remove_at: Option<usize> = None;
|
||||
let num_colors = view_state.view_config.diff_colors.len();
|
||||
for (idx, color) in view_state.view_config.diff_colors.iter_mut().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.color_edit_button_srgba(color);
|
||||
if num_colors > 1 && ui.small_button("-").clicked() {
|
||||
remove_at = Some(idx);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(idx) = remove_at {
|
||||
view_state.view_config.diff_colors.remove(idx);
|
||||
}
|
||||
if ui.small_button("+").clicked() {
|
||||
view_state.view_config.diff_colors.push(Color32::BLACK);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,19 +1,32 @@
|
||||
#[cfg(windows)]
|
||||
use std::string::FromUtf16Error;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
use anyhow::{Context, Result};
|
||||
use const_format::formatcp;
|
||||
use egui::output::OpenUrl;
|
||||
use egui::{
|
||||
output::OpenUrl, text::LayoutJob, CollapsingHeader, FontFamily, FontId, RichText,
|
||||
SelectableLabel, TextFormat, Widget,
|
||||
};
|
||||
use globset::Glob;
|
||||
use self_update::cargo_crate_version;
|
||||
|
||||
use crate::{
|
||||
app::{AppConfig, DiffKind, ViewState},
|
||||
app::{AppConfig, DiffKind, ViewConfig, ViewState},
|
||||
config::{ProjectUnit, ProjectUnitNode},
|
||||
jobs::{bindiff::queue_bindiff, objdiff::queue_build, update::queue_update},
|
||||
update::RELEASE_URL,
|
||||
};
|
||||
|
||||
const DEFAULT_WATCH_PATTERNS: &[&str] = &[
|
||||
"*.c", "*.cp", "*.cpp", "*.cxx", "*.h", "*.hp", "*.hpp", "*.hxx", "*.s", "*.S", "*.asm",
|
||||
"*.inc", "*.py", "*.yml", "*.txt", "*.json",
|
||||
];
|
||||
|
||||
#[cfg(windows)]
|
||||
fn process_utf16(bytes: &[u8]) -> Result<String, FromUtf16Error> {
|
||||
let u16_bytes: Vec<u16> = bytes
|
||||
@@ -50,19 +63,18 @@ fn fetch_wsl2_distros() -> Vec<String> {
|
||||
pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state: &mut ViewState) {
|
||||
let mut config_guard = config.write().unwrap();
|
||||
let AppConfig {
|
||||
custom_make,
|
||||
available_wsl_distros,
|
||||
selected_wsl_distro,
|
||||
project_dir,
|
||||
target_obj_dir,
|
||||
base_obj_dir,
|
||||
obj_path,
|
||||
build_target,
|
||||
left_obj,
|
||||
right_obj,
|
||||
project_dir_change,
|
||||
queue_update_check,
|
||||
auto_update_check,
|
||||
units,
|
||||
unit_nodes,
|
||||
..
|
||||
} = &mut *config_guard;
|
||||
|
||||
ui.heading("Updates");
|
||||
@@ -106,10 +118,9 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
}
|
||||
ui.separator();
|
||||
|
||||
ui.heading("Build config");
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
ui.heading("Build");
|
||||
if available_wsl_distros.is_none() {
|
||||
*available_wsl_distros = Some(fetch_wsl2_distros());
|
||||
}
|
||||
@@ -121,6 +132,7 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
ui.selectable_value(selected_wsl_distro, Some(distro.clone()), distro);
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
@@ -128,96 +140,58 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
let _ = selected_wsl_distro;
|
||||
}
|
||||
|
||||
ui.label("Custom make program:");
|
||||
let mut custom_make_str = custom_make.clone().unwrap_or_default();
|
||||
if ui.text_edit_singleline(&mut custom_make_str).changed() {
|
||||
if custom_make_str.is_empty() {
|
||||
*custom_make = None;
|
||||
} else {
|
||||
*custom_make = Some(custom_make_str);
|
||||
ui.horizontal(|ui| {
|
||||
ui.heading("Project");
|
||||
if ui.button(RichText::new("Settings")).clicked() {
|
||||
view_state.show_project_config = true;
|
||||
}
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.heading("Project config");
|
||||
});
|
||||
|
||||
if view_state.diff_kind == DiffKind::SplitObj {
|
||||
if ui.button("Select project dir").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new().pick_folder() {
|
||||
*project_dir = Some(path);
|
||||
*project_dir_change = true;
|
||||
*target_obj_dir = None;
|
||||
*base_obj_dir = None;
|
||||
*obj_path = None;
|
||||
}
|
||||
}
|
||||
if let Some(dir) = project_dir {
|
||||
ui.label(dir.to_string_lossy());
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
if let Some(project_dir) = project_dir {
|
||||
if ui.button("Select target build dir").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new().set_directory(&project_dir).pick_folder()
|
||||
{
|
||||
*target_obj_dir = Some(path);
|
||||
*obj_path = None;
|
||||
}
|
||||
}
|
||||
if let Some(dir) = target_obj_dir {
|
||||
ui.label(dir.to_string_lossy());
|
||||
}
|
||||
ui.checkbox(build_target, "Build target");
|
||||
|
||||
ui.separator();
|
||||
|
||||
if ui.button("Select base build dir").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new().set_directory(&project_dir).pick_folder()
|
||||
{
|
||||
*base_obj_dir = Some(path);
|
||||
*obj_path = None;
|
||||
}
|
||||
}
|
||||
if let Some(dir) = base_obj_dir {
|
||||
ui.label(dir.to_string_lossy());
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
}
|
||||
|
||||
if let (Some(base_dir), Some(target_dir)) = (base_obj_dir, target_obj_dir) {
|
||||
if ui.button("Select obj").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new()
|
||||
.set_directory(&target_dir)
|
||||
.add_filter("Object file", &["o", "elf"])
|
||||
.pick_file()
|
||||
{
|
||||
let mut new_build_obj: Option<String> = None;
|
||||
if let Ok(obj_path) = path.strip_prefix(&base_dir) {
|
||||
new_build_obj = Some(obj_path.display().to_string());
|
||||
} else if let Ok(obj_path) = path.strip_prefix(&target_dir) {
|
||||
new_build_obj = Some(obj_path.display().to_string());
|
||||
}
|
||||
if let Some(new_build_obj) = new_build_obj {
|
||||
*obj_path = Some(new_build_obj);
|
||||
view_state
|
||||
.jobs
|
||||
.push(queue_build(config.clone(), view_state.diff_config.clone()));
|
||||
let mut new_build_obj = obj_path.clone();
|
||||
if units.is_empty() {
|
||||
if ui.button("Select obj").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new()
|
||||
.set_directory(&target_dir)
|
||||
.add_filter("Object file", &["o", "elf"])
|
||||
.pick_file()
|
||||
{
|
||||
if let Ok(obj_path) = path.strip_prefix(&base_dir) {
|
||||
new_build_obj = Some(obj_path.display().to_string());
|
||||
} else if let Ok(obj_path) = path.strip_prefix(&target_dir) {
|
||||
new_build_obj = Some(obj_path.display().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(obj) = obj_path {
|
||||
ui.label(&*obj);
|
||||
if ui.button("Build").clicked() {
|
||||
view_state
|
||||
.jobs
|
||||
.push(queue_build(config.clone(), view_state.diff_config.clone()));
|
||||
if let Some(obj) = obj_path {
|
||||
ui.label(&*obj);
|
||||
}
|
||||
} else {
|
||||
CollapsingHeader::new(RichText::new("Objects").font(FontId {
|
||||
size: view_state.view_config.ui_font.size,
|
||||
family: view_state.view_config.code_font.family.clone(),
|
||||
}))
|
||||
.default_open(true)
|
||||
.show(ui, |ui| {
|
||||
for node in unit_nodes {
|
||||
display_node(ui, &mut new_build_obj, node, &view_state.view_config);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
let mut build = false;
|
||||
if new_build_obj != *obj_path {
|
||||
*obj_path = new_build_obj;
|
||||
// TODO apply reverse_fn_order
|
||||
build = true;
|
||||
}
|
||||
if obj_path.is_some() && ui.button("Build").clicked() {
|
||||
build = true;
|
||||
}
|
||||
if build {
|
||||
view_state.jobs.push(queue_build(config.clone(), view_state.diff_config.clone()));
|
||||
}
|
||||
}
|
||||
} else if view_state.diff_kind == DiffKind::WholeBinary {
|
||||
if ui.button("Select left obj").clicked() {
|
||||
@@ -249,6 +223,316 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
}
|
||||
}
|
||||
|
||||
ui.checkbox(&mut view_state.view_config.reverse_fn_order, "Reverse function order (deferred)");
|
||||
// ui.checkbox(&mut view_state.view_config.reverse_fn_order, "Reverse function order (deferred)");
|
||||
ui.separator();
|
||||
}
|
||||
|
||||
fn display_unit(
|
||||
ui: &mut egui::Ui,
|
||||
obj_path: &mut Option<String>,
|
||||
name: &str,
|
||||
unit: &ProjectUnit,
|
||||
view_config: &ViewConfig,
|
||||
) {
|
||||
let path_string = unit.path.to_string_lossy().to_string();
|
||||
let selected = matches!(obj_path, Some(path) if path == &path_string);
|
||||
if SelectableLabel::new(
|
||||
selected,
|
||||
RichText::new(name).font(FontId {
|
||||
size: view_config.ui_font.size,
|
||||
family: view_config.code_font.family.clone(),
|
||||
}),
|
||||
)
|
||||
.ui(ui)
|
||||
.clicked()
|
||||
{
|
||||
*obj_path = Some(path_string);
|
||||
}
|
||||
}
|
||||
|
||||
fn display_node(
|
||||
ui: &mut egui::Ui,
|
||||
obj_path: &mut Option<String>,
|
||||
node: &ProjectUnitNode,
|
||||
view_config: &ViewConfig,
|
||||
) {
|
||||
match node {
|
||||
ProjectUnitNode::File(name, unit) => {
|
||||
display_unit(ui, obj_path, name, unit, view_config);
|
||||
}
|
||||
ProjectUnitNode::Dir(name, children) => {
|
||||
CollapsingHeader::new(RichText::new(name).font(FontId {
|
||||
size: view_config.ui_font.size,
|
||||
family: view_config.code_font.family.clone(),
|
||||
}))
|
||||
.default_open(false)
|
||||
.show(ui, |ui| {
|
||||
for node in children {
|
||||
display_node(ui, obj_path, node, view_config);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const HELP_ICON: &str = "ℹ";
|
||||
|
||||
fn subheading(ui: &mut egui::Ui, text: &str, view_config: &ViewConfig) {
|
||||
ui.label(
|
||||
RichText::new(text).size(view_config.ui_font.size).color(view_config.emphasized_text_color),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn project_window(
|
||||
ctx: &egui::Context,
|
||||
config: &Arc<RwLock<AppConfig>>,
|
||||
view_state: &mut ViewState,
|
||||
) {
|
||||
let mut config_guard = config.write().unwrap();
|
||||
let AppConfig {
|
||||
custom_make,
|
||||
project_dir,
|
||||
target_obj_dir,
|
||||
base_obj_dir,
|
||||
obj_path,
|
||||
build_target,
|
||||
config_change,
|
||||
watcher_change,
|
||||
watcher_enabled,
|
||||
watch_patterns,
|
||||
load_error,
|
||||
..
|
||||
} = &mut *config_guard;
|
||||
|
||||
egui::Window::new("Project").open(&mut view_state.show_project_config).show(ctx, |ui| {
|
||||
let text_format = TextFormat::simple(
|
||||
view_state.view_config.ui_font.clone(),
|
||||
view_state.view_config.text_color,
|
||||
);
|
||||
let code_format = TextFormat::simple(
|
||||
FontId {
|
||||
size: view_state.view_config.ui_font.size,
|
||||
family: view_state.view_config.code_font.family.clone(),
|
||||
},
|
||||
view_state.view_config.emphasized_text_color,
|
||||
);
|
||||
|
||||
fn pick_folder_ui(
|
||||
ui: &mut egui::Ui,
|
||||
dir: &mut Option<PathBuf>,
|
||||
label: &str,
|
||||
tooltip: impl FnOnce(&mut egui::Ui),
|
||||
clicked: impl FnOnce(&mut Option<PathBuf>),
|
||||
view_config: &ViewConfig,
|
||||
) {
|
||||
ui.horizontal(|ui| {
|
||||
subheading(ui, label, view_config);
|
||||
ui.link(HELP_ICON).on_hover_ui(tooltip);
|
||||
if ui.button("Select").clicked() {
|
||||
clicked(dir);
|
||||
}
|
||||
});
|
||||
if let Some(dir) = dir {
|
||||
if let Some(home) = dirs::home_dir() {
|
||||
if let Ok(rel) = dir.strip_prefix(&home) {
|
||||
ui.label(RichText::new(format!("~/{}", rel.display())).color(view_config.replace_color).family(FontFamily::Monospace));
|
||||
return;
|
||||
}
|
||||
}
|
||||
ui.label(RichText::new(format!("{}", dir.display())).color(view_config.replace_color).family(FontFamily::Monospace));
|
||||
} else {
|
||||
ui.label(RichText::new("[none]").color(view_config.delete_color).family(FontFamily::Monospace));
|
||||
}
|
||||
}
|
||||
|
||||
if view_state.diff_kind == DiffKind::SplitObj {
|
||||
pick_folder_ui(
|
||||
ui,
|
||||
project_dir,
|
||||
"Project directory",
|
||||
|ui| {
|
||||
let mut job = LayoutJob::default();
|
||||
job.append(
|
||||
"The root project directory.\n\n",
|
||||
0.0,
|
||||
text_format.clone()
|
||||
);
|
||||
job.append(
|
||||
"If a configuration file exists, it will be loaded automatically.",
|
||||
0.0,
|
||||
text_format.clone(),
|
||||
);
|
||||
ui.label(job);
|
||||
},
|
||||
|project_dir| {
|
||||
if let Some(path) = rfd::FileDialog::new().pick_folder() {
|
||||
*project_dir = Some(path);
|
||||
*config_change = true;
|
||||
*watcher_change = true;
|
||||
*target_obj_dir = None;
|
||||
*base_obj_dir = None;
|
||||
*obj_path = None;
|
||||
}
|
||||
},
|
||||
&view_state.view_config,
|
||||
);
|
||||
ui.separator();
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
subheading(ui, "Custom make program", &view_state.view_config);
|
||||
ui.link(HELP_ICON).on_hover_ui(|ui| {
|
||||
let mut job = LayoutJob::default();
|
||||
job.append("By default, objdiff will build with ", 0.0, text_format.clone());
|
||||
job.append("make", 0.0, code_format.clone());
|
||||
job.append(
|
||||
".\nIf the project uses a different build system (e.g. ",
|
||||
0.0,
|
||||
text_format.clone(),
|
||||
);
|
||||
job.append("ninja", 0.0, code_format.clone());
|
||||
job.append(
|
||||
"), specify it here.\nThe program must be in your ",
|
||||
0.0,
|
||||
text_format.clone(),
|
||||
);
|
||||
job.append("PATH", 0.0, code_format.clone());
|
||||
job.append(".", 0.0, text_format.clone());
|
||||
ui.label(job);
|
||||
});
|
||||
});
|
||||
let mut custom_make_str = custom_make.clone().unwrap_or_default();
|
||||
if ui.text_edit_singleline(&mut custom_make_str).changed() {
|
||||
if custom_make_str.is_empty() {
|
||||
*custom_make = None;
|
||||
} else {
|
||||
*custom_make = Some(custom_make_str);
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
|
||||
if let Some(project_dir) = project_dir {
|
||||
pick_folder_ui(
|
||||
ui,
|
||||
target_obj_dir,
|
||||
"Target build directory",
|
||||
|ui| {
|
||||
let mut job = LayoutJob::default();
|
||||
job.append(
|
||||
"This contains the \"target\" or \"expected\" objects, which are the intended result of the match.\n\n",
|
||||
0.0,
|
||||
text_format.clone(),
|
||||
);
|
||||
job.append(
|
||||
"These are usually created by the project's build system or assembled.",
|
||||
0.0,
|
||||
text_format.clone(),
|
||||
);
|
||||
ui.label(job);
|
||||
},
|
||||
|target_obj_dir| {
|
||||
if let Some(path) =
|
||||
rfd::FileDialog::new().set_directory(&project_dir).pick_folder()
|
||||
{
|
||||
*target_obj_dir = Some(path);
|
||||
*obj_path = None;
|
||||
}
|
||||
},
|
||||
&view_state.view_config,
|
||||
);
|
||||
ui.checkbox(build_target, "Build target objects").on_hover_ui(|ui| {
|
||||
let mut job = LayoutJob::default();
|
||||
job.append("Tells the build system to produce the target object.\n", 0.0, text_format.clone());
|
||||
job.append("For example, this would call ", 0.0, text_format.clone());
|
||||
job.append("make path/to/target.o", 0.0, code_format.clone());
|
||||
job.append(".\n\n", 0.0, text_format.clone());
|
||||
job.append("This is useful if the target objects are not already built\n", 0.0, text_format.clone());
|
||||
job.append("or if they can change based on project configuration,\n", 0.0, text_format.clone());
|
||||
job.append("but requires that the build system is configured correctly.", 0.0, text_format.clone());
|
||||
ui.label(job);
|
||||
});
|
||||
ui.separator();
|
||||
|
||||
pick_folder_ui(
|
||||
ui,
|
||||
base_obj_dir,
|
||||
"Base build directory",
|
||||
|ui| {
|
||||
let mut job = LayoutJob::default();
|
||||
job.append(
|
||||
"This contains the objects built from your decompiled code.",
|
||||
0.0,
|
||||
text_format.clone(),
|
||||
);
|
||||
ui.label(job);
|
||||
},
|
||||
|base_obj_dir| {
|
||||
if let Some(path) =
|
||||
rfd::FileDialog::new().set_directory(&project_dir).pick_folder()
|
||||
{
|
||||
*base_obj_dir = Some(path);
|
||||
*obj_path = None;
|
||||
}
|
||||
},
|
||||
&view_state.view_config,
|
||||
);
|
||||
ui.separator();
|
||||
}
|
||||
|
||||
subheading(ui, "Watch settings", &view_state.view_config);
|
||||
let response = ui.checkbox(watcher_enabled, "Rebuild on changes").on_hover_ui(|ui| {
|
||||
let mut job = LayoutJob::default();
|
||||
job.append("Automatically re-run the build & diff when files change.", 0.0, text_format.clone());
|
||||
ui.label(job);
|
||||
});
|
||||
if response.changed() {
|
||||
*watcher_change = true;
|
||||
};
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new("File Patterns").color(view_state.view_config.text_color));
|
||||
if ui.button("Reset").clicked() {
|
||||
*watch_patterns = DEFAULT_WATCH_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect();
|
||||
*watcher_change = true;
|
||||
}
|
||||
});
|
||||
let mut remove_at: Option<usize> = None;
|
||||
for (idx, glob) in watch_patterns.iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new(format!("{}", glob))
|
||||
.color(view_state.view_config.text_color)
|
||||
.family(FontFamily::Monospace));
|
||||
if ui.small_button("-").clicked() {
|
||||
remove_at = Some(idx);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(idx) = remove_at {
|
||||
watch_patterns.remove(idx);
|
||||
*watcher_change = true;
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
egui::TextEdit::singleline(&mut view_state.watch_pattern_text)
|
||||
.desired_width(100.0)
|
||||
.show(ui);
|
||||
if ui.small_button("+").clicked() {
|
||||
if let Ok(glob) = Glob::new(&view_state.watch_pattern_text) {
|
||||
watch_patterns.push(glob);
|
||||
*watcher_change = true;
|
||||
view_state.watch_pattern_text.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(error) = &load_error {
|
||||
let mut open = true;
|
||||
egui::Window::new("Error").open(&mut open).show(ctx, |ui| {
|
||||
ui.label("Failed to load project config:");
|
||||
ui.colored_label(view_state.view_config.delete_color, error);
|
||||
});
|
||||
if !open {
|
||||
*load_error = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ pub fn data_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
|
||||
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||
ui.style_mut().wrap = Some(false);
|
||||
if view_state.jobs.iter().any(|job| job.job_type == Job::ObjDiff) {
|
||||
ui.label("Building...");
|
||||
ui.colored_label(view_state.view_config.replace_color, "Building…");
|
||||
} else {
|
||||
ui.label("Last built:");
|
||||
let format =
|
||||
|
||||
26
src/views/demangle.rs
Normal file
26
src/views/demangle.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use egui::TextStyle;
|
||||
|
||||
use crate::app::ViewState;
|
||||
|
||||
pub fn demangle_window(ctx: &egui::Context, view_state: &mut ViewState) {
|
||||
egui::Window::new("Demangle").open(&mut view_state.show_demangle).show(ctx, |ui| {
|
||||
ui.text_edit_singleline(&mut view_state.demangle_text);
|
||||
ui.add_space(10.0);
|
||||
if let Some(demangled) =
|
||||
cwdemangle::demangle(&view_state.demangle_text, &Default::default())
|
||||
{
|
||||
ui.scope(|ui| {
|
||||
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
|
||||
ui.colored_label(view_state.view_config.replace_color, &demangled);
|
||||
});
|
||||
if ui.button("Copy").clicked() {
|
||||
ui.output_mut(|output| output.copied_text = demangled);
|
||||
}
|
||||
} else {
|
||||
ui.scope(|ui| {
|
||||
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
|
||||
ui.colored_label(view_state.view_config.replace_color, "[invalid]");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -446,7 +446,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
|
||||
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||
ui.style_mut().wrap = Some(false);
|
||||
if view_state.jobs.iter().any(|job| job.job_type == Job::ObjDiff) {
|
||||
ui.label("Building...");
|
||||
ui.colored_label(view_state.view_config.replace_color, "Building…");
|
||||
} else {
|
||||
ui.label("Last built:");
|
||||
let format =
|
||||
|
||||
@@ -35,14 +35,14 @@ pub fn jobs_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
|
||||
ui.colored_label(
|
||||
view_state.view_config.delete_color,
|
||||
if err_string.len() > STATUS_LENGTH - 10 {
|
||||
format!("Error: {}...", &err_string[0..STATUS_LENGTH - 10])
|
||||
format!("Error: {}…", &err_string[0..STATUS_LENGTH - 10])
|
||||
} else {
|
||||
format!("Error: {:width$}", err_string, width = STATUS_LENGTH - 7)
|
||||
},
|
||||
);
|
||||
} else {
|
||||
ui.label(if status.status.len() > STATUS_LENGTH - 3 {
|
||||
format!("{}...", &status.status[0..STATUS_LENGTH - 3])
|
||||
format!("{}…", &status.status[0..STATUS_LENGTH - 3])
|
||||
} else {
|
||||
format!("{:width$}", &status.status, width = STATUS_LENGTH)
|
||||
});
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use egui::{text::LayoutJob, Color32, FontId, TextFormat};
|
||||
|
||||
pub(crate) mod appearance;
|
||||
pub(crate) mod config;
|
||||
pub(crate) mod data_diff;
|
||||
pub(crate) mod demangle;
|
||||
pub(crate) mod function_diff;
|
||||
pub(crate) mod jobs;
|
||||
pub(crate) mod symbol_diff;
|
||||
|
||||
Reference in New Issue
Block a user