From cc4fad453292188fec9d59d491a9a29291dc32e5 Mon Sep 17 00:00:00 2001 From: Stanislav Pastushenko Date: Tue, 9 Dec 2025 18:31:25 +0100 Subject: [PATCH] tabs names fix --- src/ui/tabs_panel.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/ui/tabs_panel.rs b/src/ui/tabs_panel.rs index b12634e..b0187a1 100644 --- a/src/ui/tabs_panel.rs +++ b/src/ui/tabs_panel.rs @@ -29,16 +29,36 @@ pub fn render_tabs_panel( ui.horizontal(|ui| { for (idx, tab) in tabs.iter().enumerate() { let is_active = idx == *active_tab_index; - let button_text = if is_active { - egui::RichText::new(format!("📄 {}", tab.filename())).strong() + let filename = tab.filename(); + + // Truncate filename if too long (max 20 characters) + let display_name = if filename.len() > 20 { + format!("{}...", &filename[..17]) } else { - egui::RichText::new(format!("📄 {}", tab.filename())) + filename.clone() }; - if ui.selectable_label(is_active, button_text).clicked() { + let button_text = if is_active { + egui::RichText::new(format!("📄 {}", display_name)).strong() + } else { + egui::RichText::new(format!("📄 {}", display_name)) + }; + + // Fixed width for tab label (150 pixels) + let tab_response = ui.add_sized( + [150.0, ui.available_height()], + egui::SelectableLabel::new(is_active, button_text) + ); + + if tab_response.clicked() { *active_tab_index = idx; } + // Show full filename on hover + if filename.len() > 20 { + tab_response.on_hover_text(&filename); + } + if ui.small_button("✖").clicked() { *on_close_tab = Some(idx); }