feat(attribute): route ATTMAN/BATTMAN to the attribute editor (ATTEDIT)

ATTMAN and BATTMAN previously produced a command-line listing of block
attributes. Route both to the attribute editor instead: extract the bare
ATTEDIT behavior into a shared open_attedit_dialog helper (edit the
selected block, or start the block-pick command) and call it from the
ATTEDIT, ATTMAN, and BATTMAN arms.

Kept as a match arm rather than an ocad.pgp alias so it works for
existing users, whose config pgp is only seeded on first run.

Replace the listing regression tests with one asserting ATTMAN and
BATTMAN behave byte-for-byte like ATTEDIT.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-11 09:37:54 +03:00
1 parent bd6a8845b4
commit 2a72227d5d
3 files changed
+53 -135

No files matched your search

+32 -22
View File
@@ -258,28 +258,7 @@ impl OpenCADStudio {
// that block; otherwise the pick command runs and the editor opens
// once a block is chosen (see `command_driver`).
"ATTEDIT" => {
let selected_attr_insert = {
let sel = self.tabs[i].scene.selected_entities();
if sel.len() == 1 {
let (h, e) = sel[0];
match e {
acadrust::EntityType::Insert(ins) if !ins.attributes.is_empty() => {
Some(h)
}
_ => None,
}
} else {
None
}
};
if let Some(handle) = selected_attr_insert {
self.open_attribute_editor(handle);
} else {
use crate::modules::draw::modify::attedit::AtteditCommand;
let cmd_obj = AtteditCommand::new();
self.command_line.push_info(&cmd_obj.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd_obj));
}
self.open_attedit_dialog();
}
// ── REFEDIT — in-place block editing ─────────────────────────────
@@ -1250,6 +1229,37 @@ fn arith_eval(expr: &str) -> Result<f64, String> {
Ok(v)
}
impl OpenCADStudio {
/// Open the attribute editor. If a single block with attributes is already
/// selected it opens directly on that block; otherwise it starts the
/// block-pick command and opens once a block is chosen (see
/// `command_driver`). Shared by ATTEDIT and its command aliases
/// ATTMAN / BATTMAN.
pub(in crate::app) fn open_attedit_dialog(&mut self) {
let i = self.active_tab;
let selected_attr_insert = {
let sel = self.tabs[i].scene.selected_entities();
if sel.len() == 1 {
let (h, e) = sel[0];
match e {
acadrust::EntityType::Insert(ins) if !ins.attributes.is_empty() => Some(h),
_ => None,
}
} else {
None
}
};
if let Some(handle) = selected_attr_insert {
self.open_attribute_editor(handle);
} else {
use crate::modules::draw::modify::attedit::AtteditCommand;
let cmd_obj = AtteditCommand::new();
self.command_line.push_info(&cmd_obj.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd_obj));
}
}
}
struct ArithParser {
chars: Vec<char>,
pos: usize,