From a42e68fcd6fb0147b373a7913e299faab69d5a9d Mon Sep 17 00:00:00 2001 From: Rowrow620 Date: Thu, 30 Jul 2026 02:13:43 -0700 Subject: [PATCH] feat: add copy code button to python solution inspector --- src/app.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/app.rs b/src/app.rs index 2d537f0..b8e98fc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2293,18 +2293,27 @@ impl eframe::App for VisualizerApp { render_complexity_card(ui, app_meta, &p); } - ui.add_space(10.0); - ui.label( - RichText::new("Python Implementation") - .strong() - .color(p.text_muted), - ); - ui.add_space(6.0); - let code_lines = approach_code_lines( self.current_problem, self.selected_approach_id, ); + + ui.add_space(10.0); + ui.horizontal(|ui| { + ui.label( + RichText::new("Python Implementation") + .strong() + .color(p.text_muted), + ); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if ui.button(RichText::new("Copy Code").size(11.0)).on_hover_text("Copy full Python solution to clipboard").clicked() { + let full_code = code_lines.iter().map(|(_, text)| *text).collect::>().join("\n"); + ui.output_mut(|o| o.copied_text = full_code); + } + }); + }); + ui.add_space(6.0); + let should_auto_focus = self.last_focused_step_idx != Some(self.current_step_idx);