feat(text): in-place editors for all text entities

Route every text-bearing entity to an in-place editor instead of the
command line: a plain text box for single-line text (Text, attributes,
dimension override, tolerance) and the rich MText editor for MText /
MultiLeader. A Leader resolves to the entity it annotates.

- TEXT places a plain text box at the click; double-click edits in place.
- DDEDIT and double-click on any text entity open the matching editor.
- MLEADER places the leader then opens the MText editor on its content.
- LEADER follows the classic flow: points, Enter, then a linked empty
  MText annotation opens in the editor; the leader's annotation_handle
  links the pair so they edit/erase as a unit.

Adds shared field read/write helpers and a begin_text_edit router, plus
CommitAndEditText / CommitManyAndEditText results that commit an entity
and open its editor (commit_entity now returns the new handle).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-05-31 14:44:18 +03:00
1 parent ac9022676f
commit 2627d06224
13 files changed
+551 -346

No files matched your search

+7 -31
View File
@@ -1,6 +1,3 @@
use acadrust::types::Vector3;
use acadrust::{EntityType, Text};
use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::wire_model::WireModel;
@@ -19,7 +16,6 @@ pub fn tool() -> ToolDef {
enum Step {
InsertPoint,
WaitText(Vec3),
}
pub struct TextCommand {
@@ -42,16 +38,17 @@ impl CadCommand for TextCommand {
fn prompt(&self) -> String {
match &self.step {
Step::InsertPoint => "TEXT Specify insertion point:".into(),
Step::WaitText(pos) => format!(
"TEXT Type text, press Enter [at {:.2},{:.2}]:",
pos.x, pos.z
),
}
}
fn on_point(&mut self, pt: Vec3) -> CmdResult {
self.step = Step::WaitText(pt);
CmdResult::NeedPoint
// Hand off to the in-place plain-text editor anchored at the click.
CmdResult::OpenTextEditor {
pos: pt,
handle: None,
initial: String::new(),
height: 0.25,
}
}
fn on_enter(&mut self) -> CmdResult {
@@ -61,27 +58,6 @@ impl CadCommand for TextCommand {
CmdResult::Cancel
}
fn wants_text_input(&self) -> bool {
matches!(self.step, Step::WaitText(_))
}
fn wants_text_with_spaces(&self) -> bool {
matches!(self.step, Step::WaitText(_))
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
if let Step::WaitText(pos) = &self.step {
if text.trim().is_empty() {
return Some(CmdResult::Cancel);
}
let t = Text::with_value(text, Vector3::new(pos.x as f64, pos.y as f64, pos.z as f64))
.with_height(0.25);
Some(CmdResult::CommitEntity(EntityType::Text(t)))
} else {
None
}
}
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> {
None
}