use eframe::egui;
use crate::config::ProcessTarget;
pub fn process_targets_with_remove(
ui: &mut egui::Ui,
targets: &[ProcessTarget],
remove_label: &str,
name_match_label: &str,
) -> Option<usize> {
let mut remove_idx = None;
for (idx, target) in targets.iter().enumerate() {
let display_name = if let Some(pid) = target.pid {
format!("{} (PID {})", target.process_name, pid)
} else if target.manual {
format!("{} ({})", target.process_name, name_match_label)
} else {
target.display_name.clone()
};
ui.horizontal(|ui| {
ui.label(format!("- {}", display_name));
if ui.small_button(remove_label).clicked() {
remove_idx = Some(idx);
}
});
}
remove_idx
}