feat: implement TEXTEDIT command and TEXTEDITMODE system variable

- Adds TEXTEDIT command to seamlessly edit annotation objects in-place.
- Matches industry-standard CAD tools' prompt behavior and "Current settings" banner logic.
- Implements the TEXTEDITMODE system variable (0/1) for Multiple vs Single editing modes.
- Enhances command lifecycle with CmdResult::SuspendForTextEdit and post_editor_closed hooks, allowing commands to cleanly pause and resume after external UI editors close.
This commit is contained in:
Karim Jerbi 2026-06-18 14:55:08 +01:00
commit 9a258f29ce
9 changed files with 351 additions and 6 deletions

View file

@ -1429,6 +1429,22 @@ impl OpenCADStudio {
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
}
"TEXTEDIT" | "TEDIT" => {
use crate::modules::annotate::textedit::TexteditCommand;
let mode_str = if self.texteditmode { "Single" } else { "Multiple" };
self.command_line.push_output(&format!("Current settings: Edit mode = {}", mode_str));
let new_cmd = TexteditCommand::new(self.texteditmode);
self.command_line.push_info(&new_cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
}
"TEXTEDITMODE" => {
use crate::modules::annotate::textedit::TexteditmodeCommand;
let cmd = TexteditmodeCommand::new(self.texteditmode);
self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
"DIMALIGNED" | "DAL" => {
use crate::modules::annotate::aligned_dim::AlignedDimensionCommand;
let cmd = AlignedDimensionCommand::new();
@ -4907,6 +4923,21 @@ impl OpenCADStudio {
);
}
}
cmd if cmd.starts_with("TEXTEDITMODE ") => {
let val_str = cmd.trim_start_matches("TEXTEDITMODE").trim().to_lowercase();
if val_str.is_empty() {
let v = if self.texteditmode { 1 } else { 0 };
self.command_line.push_output(&format!("TEXTEDITMODE = {v}"));
} else if val_str == "0" || val_str == "m" || val_str == "multiple" {
self.texteditmode = false;
self.command_line.push_output("TEXTEDITMODE set to 0");
} else if val_str == "1" || val_str == "s" || val_str == "single" {
self.texteditmode = true;
self.command_line.push_output("TEXTEDITMODE set to 1");
} else {
self.command_line.push_error("Requires 0 OR 1 OR MULTIPLE OR SINGLE");
}
}
cmd if cmd == "PDSIZE" || cmd.starts_with("PDSIZE ") => {
let val_str = cmd.trim_start_matches("PDSIZE").trim();
if val_str.is_empty() {