mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-01 18:25:32 -06:00
INSERT: ATTDIA defaults to 0, the command line, as in AutoCAD
AutoCAD's published system variable reference gives ATTDIA an initial value of 0: a typed INSERT asks for attribute values at the command line, which also keeps scripts and agents typing through the command line as before. ATTDIA 1 still opens the Edit Attributes dialog. The dialog tests set ATTDIA 1 themselves; a new check shows the default opens no dialog. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0332836238
commit
d3ec8efe19
@@ -131,7 +131,7 @@ pub struct Settings {
|
||||
/// default value. A user setting, as in AutoCAD (not saved in the drawing).
|
||||
pub attreq: bool,
|
||||
/// ATTDIA: INSERT typed or from a menu asks for attribute values in the Edit Attributes
|
||||
/// dialog (on by default, as in AutoCAD); off asks at the command line.
|
||||
/// dialog; off (the default, as in AutoCAD) asks at the command line.
|
||||
pub attdia: bool,
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ impl Default for Settings {
|
||||
polardist: 0.0,
|
||||
auditctl: false,
|
||||
attreq: true,
|
||||
attdia: true,
|
||||
attdia: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ const LINEWEIGHTS: [i64; 24] = [0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53,
|
||||
type Toggle = (&'static str, fn(&Settings) -> bool, fn(&mut Settings, bool));
|
||||
const SETTINGS: &[Toggle] = &[
|
||||
// ATTDIA 1: INSERT typed or from a menu asks for attribute values in the Edit Attributes
|
||||
// dialog; 0: at the command line. ATTREQ 0: INSERT gives every attribute its default.
|
||||
// dialog; 0 (the default): at the command line. ATTREQ 0: INSERT gives every attribute its default.
|
||||
("ATTDIA", |s| s.attdia, |s, v| s.attdia = v),
|
||||
("ATTREQ", |s| s.attreq, |s, v| s.attreq = v),
|
||||
("AUDITCTL", |s| s.auditctl, |s, v| s.auditctl = v),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! INSERT and the attribute modes (gap F17): Verify attributes are asked twice, Preset ones take
|
||||
//! their default without asking, ATTREQ 0 gives every attribute its default, and ATTDIA 1 asks
|
||||
//! for the values all at once in the Edit Attributes dialog (`Session::attribute_entry`), typed
|
||||
//! answers still working. The JSON form never asks. ATTREQ and ATTDIA are user settings, as in
|
||||
//! their default without asking, ATTREQ 0 gives every attribute its default, ATTDIA 0 (the
|
||||
//! default) asks at the command line and ATTDIA 1 asks for the values all at once in the Edit
|
||||
//! Attributes dialog (`Session::attribute_entry`), typed answers still working. The JSON form never asks. ATTREQ and ATTDIA are user settings, as in
|
||||
//! AutoCAD (DWG keeps them in its header only before R2000).
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -36,7 +36,7 @@ fn def(tag: &str, prompt: &str, default: &str, y: f64, constant: bool, modes: At
|
||||
}
|
||||
|
||||
/// Block T with the definitions A (Verify), B (Preset), C (plain) and D (constant); ATTREQ and
|
||||
/// ATTDIA as given (their defaults, 1, otherwise).
|
||||
/// ATTDIA as given (their defaults, ATTREQ 1 and ATTDIA 0, otherwise).
|
||||
fn session(attreq: Option<bool>, attdia: Option<bool>) -> Session {
|
||||
let mut d = cadcraft_engine::doc::Drawing::new_imperial();
|
||||
let mut b = Block::new("T");
|
||||
@@ -87,7 +87,10 @@ fn pairs(v: &[(&str, &str)]) -> Vec<(String, String)> {
|
||||
|
||||
#[test]
|
||||
fn typed_insert_asks_verify_twice_and_skips_preset_and_constant() {
|
||||
let mut s = session(None, Some(false));
|
||||
// AutoCAD's default, ATTDIA 0, with no value in the drawing: the command line asks.
|
||||
let mut s = session(None, None);
|
||||
assert_eq!(s.execute("getvar", &json!({ "name": "ATTDIA" })).unwrap()["value"], 0);
|
||||
assert_eq!(s.execute("getvar", &json!({ "name": "ATTREQ" })).unwrap()["value"], 1);
|
||||
insert_up_to_the_attributes(&mut s);
|
||||
assert!(s.attribute_entry().is_none(), "ATTDIA 0: no dialog");
|
||||
assert_eq!(s.prompt_text(), "INSERT First <1>:", "A first");
|
||||
@@ -128,10 +131,9 @@ fn attreq_0_gives_every_attribute_its_default() {
|
||||
|
||||
#[test]
|
||||
fn attdia_1_asks_for_every_value_at_once_and_typed_answers_still_work() {
|
||||
// AutoCAD's default, ATTDIA 1, with no value in the drawing.
|
||||
let mut s = session(None, None);
|
||||
s.execute("setvar", &json!({ "name": "ATTDIA", "value": 1 })).unwrap();
|
||||
assert_eq!(s.execute("getvar", &json!({ "name": "ATTDIA" })).unwrap()["value"], 1);
|
||||
assert_eq!(s.execute("getvar", &json!({ "name": "ATTREQ" })).unwrap()["value"], 1);
|
||||
s.start("insert").unwrap();
|
||||
s.cmdline("T").unwrap();
|
||||
assert!(s.attribute_entry().is_none(), "not before the attribute prompts");
|
||||
@@ -183,7 +185,7 @@ fn json_insert_never_asks_whatever_attreq_and_attdia_say() {
|
||||
|
||||
#[test]
|
||||
fn hostile_values_never_panic() {
|
||||
let mut s = session(None, None);
|
||||
let mut s = session(None, Some(true));
|
||||
insert_up_to_the_attributes(&mut s);
|
||||
let e = s.attribute_entry().expect("asks");
|
||||
// Too few answers take the defaults, too many are ignored.
|
||||
|
||||
@@ -13,9 +13,11 @@ use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::{Queryable, by};
|
||||
use serde_json::json;
|
||||
|
||||
/// Block T with the definitions A ("Room", default "101") and B ("Floor", default "1").
|
||||
/// Block T with the definitions A ("Room", default "101") and B ("Floor", default "1"), and
|
||||
/// ATTDIA 1 (the default is 0, the command line).
|
||||
fn app() -> CadApp {
|
||||
let mut app = CadApp::new(Session::new(), Services::default());
|
||||
app.run("setvar", json!({ "name": "ATTDIA", "value": 1 })).unwrap();
|
||||
let a = app.run("attdef", json!({ "tag": "A", "prompt": "Room", "default": "101", "at": [0, 2] })).unwrap();
|
||||
let b = app.run("attdef", json!({ "tag": "B", "prompt": "Floor", "default": "1", "at": [0, 4] })).unwrap();
|
||||
app.run("block", json!({ "name": "T", "base": [0, 0], "handles": [a["handle"], b["handle"]], "keep": "delete" })).unwrap();
|
||||
@@ -118,7 +120,16 @@ fn cancel_inserts_nothing() {
|
||||
#[test]
|
||||
fn no_dialog_with_attdia_0_or_from_json() {
|
||||
let mut a = app();
|
||||
a.session.settings.attdia = false;
|
||||
a.run("setvar", json!({ "name": "ATTDIA", "value": 0 })).unwrap();
|
||||
insert(&mut a);
|
||||
let h = harness(a);
|
||||
assert!(h.query_by_label("Edit Attributes").is_none());
|
||||
assert!(h.state().session.prompt_text().contains("Room"), "asked at the command line");
|
||||
|
||||
// ATTDIA's default, 0, asks at the command line too.
|
||||
let mut a = app();
|
||||
a.session.settings = Default::default();
|
||||
assert!(!a.session.settings.attdia);
|
||||
insert(&mut a);
|
||||
let h = harness(a);
|
||||
assert!(h.query_by_label("Edit Attributes").is_none());
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ Detail: [localization-parity.md](localization-parity.md).
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-27 | minor | INSERT asks a Verify attribute's value twice and gives a Preset one its default without asking; ATTREQ 0 gives every attribute its default; ATTDIA 1 (the default) asks for the values in the Edit Attributes dialog when INSERT is typed or picked, typed answers still working; both are user settings (SETVAR), not saved in the drawing, as DWG from R2000 has no place for them: F17 narrowed |
|
||||
| 2026-10-27 | minor | INSERT asks a Verify attribute's value twice and gives a Preset one its default without asking; ATTREQ 0 gives every attribute its default; ATTDIA 1 asks for the values in the Edit Attributes dialog when INSERT is typed or picked, typed answers still working, and 0 (the default) at the command line; both are user settings (SETVAR), not saved in the drawing, as DWG from R2000 has no place for them: F17 narrowed |
|
||||
| 2026-10-25 | minor | Named Viewports (View ▸ Viewports ▸ Named Viewports..., `vports.named`) lists the saved viewport configurations with a preview and the current one's name, and restores or deletes one; in a layout Restore places it as MVIEW Restore does: U11 narrowed. F15 and U11 no longer list MVIEW Restore (#633), and F21 no longer says PURGE skips multiline styles |
|
||||
| 2026-10-25 | minor | DIMTFILL limits: with DIMTFILL 1 (the drawing's background color) the written `*D` block and EXPLODE keep no background mask (a WIPEOUT over the text box would), and a true-color DIMTFILLCLR is written to DXF as the nearest ACI: F7 updated |
|
||||
| 2026-10-24 | minor | COMPAREEXPORT (typed, or Export on the comparison bar) opens the comparison as a new untitled drawing, `compare_<this> vs <other>.dwg`: this drawing's objects in one group and the other drawing's differing objects in a second group, in the comparison colors (green, red, gray for objects in both), block contents and style colors included: F22 narrowed |
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ down-arrow options menu (DYNPROMPT), and DYNDIM.
|
||||
| Clickable keywords in the prompt | yes | yes (`cmdline.rs:253-267`) |
|
||||
| UNDO with Mark, Back, BEgin, End, Auto, Control | yes | count only, whole-document snapshots capped at 2,000 (`lib.rs:477`, `edit.rs:56`) |
|
||||
| SETVAR for every system variable | ~1,000 sysvars | about 60 session/header variables by name (`sysvars.rs`) |
|
||||
| Attribute values when inserting (ATTREQ, ATTDIA, Verify, Preset) | prompts or the Edit Attributes dialog | both: ATTDIA 1 opens Edit Attributes (OK, Enter, Cancel; typed answers still work), ATTDIA 0 asks at the command line, Verify attributes asked twice there, Preset ones and ATTREQ 0 take their defaults (`attentry.rs`); no Previous/Next pages (one scrolling list) |
|
||||
| Attribute values when inserting (ATTREQ, ATTDIA, Verify, Preset) | prompts or the Edit Attributes dialog | both: ATTDIA 1 opens Edit Attributes (OK, Enter, Cancel; typed answers still work), ATTDIA 0 (the default) asks at the command line, Verify attributes asked twice there, Preset ones and ATTREQ 0 take their defaults (`attentry.rs`); no Previous/Next pages (one scrolling list) |
|
||||
| Scripts (SCRIPT, `.scr`) | yes | script text via CLI/MCP/control; no `.scr` file command |
|
||||
| Floating/docked command window, transparency, lines of history | yes | floating overlay, history lines setting |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user