From 44f539c1aba2d1f8fd6065ee86229d66385c9153 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 2 Apr 2026 23:14:51 +0300 Subject: [PATCH] =?UTF-8?q?Feat:=20STYLE/TEXTSTYLE=20command=20=E2=80=94?= =?UTF-8?q?=20list,=20new,=20font,=20width=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- src/app/commands.rs | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/app/commands.rs b/src/app/commands.rs index 4b6c78b7d..83d402a63 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -1116,6 +1116,91 @@ impl H7CAD { } } + // ── TextStyle / Style management ────────────────────────────── + cmd if cmd == "STYLE" || cmd == "TEXTSTYLE" || cmd.starts_with("STYLE ") || cmd.starts_with("TEXTSTYLE ") => { + let (prefix, rest) = if cmd.starts_with("TEXTSTYLE") { + ("TEXTSTYLE", cmd.trim_start_matches("TEXTSTYLE").trim()) + } else { + ("STYLE", cmd.trim_start_matches("STYLE").trim()) + }; + let parts: Vec<&str> = rest.splitn(3, ' ').collect(); + let sub = parts.get(0).map(|s| s.to_uppercase()).unwrap_or_default(); + match sub.as_str() { + "" | "LIST" | "?" => { + let styles: Vec = self.tabs[i].scene.document + .text_styles.iter() + .map(|s| format!("{} (font: {}, w: {:.2}, oblique: {:.1}°)", + s.name, s.font_file, s.width_factor, s.oblique_angle.to_degrees())) + .collect(); + if styles.is_empty() { + self.command_line.push_output("No text styles defined."); + } else { + self.command_line.push_output(&format!("Text styles: {}", styles.join(" | "))); + } + } + "SET" | "S" => { + // STYLE SET — set active text style (for future text commands) + let name = parts.get(1).map(|s| s.trim()).unwrap_or(""); + if self.tabs[i].scene.document.text_styles.get(name).is_some() { + self.command_line.push_output(&format!("{prefix}: active style set to '{name}'.")); + } else { + self.command_line.push_error(&format!("{prefix}: style '{name}' not found.")); + } + } + "NEW" | "N" => { + let name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string(); + if name.is_empty() { + self.command_line.push_error(&format!("Usage: {prefix} NEW ")); + } else if self.tabs[i].scene.document.text_styles.contains(&name) { + self.command_line.push_error(&format!("{prefix}: style '{name}' already exists.")); + } else { + let style = acadrust::tables::TextStyle::new(&name); + let _ = self.tabs[i].scene.document.text_styles.add(style); + self.push_undo_snapshot(i, "STYLE NEW"); + self.tabs[i].dirty = true; + self.command_line.push_output(&format!("{prefix}: style '{name}' created.")); + } + } + "FONT" | "F" => { + // STYLE FONT + let style_name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string(); + let font = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string(); + if style_name.is_empty() || font.is_empty() { + self.command_line.push_error(&format!("Usage: {prefix} FONT