Fields: stored values on redraw, evaluation events, per-field shading

MTEXT draws its stored text instead of re-evaluating fields on every
redraw. Fields update on their evaluation events as the reference does:
open (1), save (2, not autosave), plot (4) and REGEN/REGENALL (16), each
masked with the drawing's FIELDEVAL (variable dictionary, 0-31, with the
reference's prompt and message), and the new UPDATEFIELD command
(selection, attributes of selected block references, "N field(s)
found." / "N field(s) updated."). A Date field (on demand only) keeps
its value until UPDATEFIELD. The FIELDDISPLAY gray box now covers each
field's own glyphs, one box per line it spans, instead of the whole
text. Codec moved to the update_fields / field_spans revision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-06 11:38:01 +03:00
1 parent 71cebbb3fe
commit 1c242eb489
13 files changed
+229 -19

No files matched your search

+9 -1
View File
@@ -2144,6 +2144,14 @@ impl OpenCADStudio {
#[cfg(not(target_arch = "wasm32"))]
pub(in crate::app) fn prepare_native_save(&mut self, i: usize) {
// A save is a field evaluation event (FIELDEVAL bit 2).
self.tabs[i].scene.update_fields(2, None);
self.prepare_snapshot_save(i);
}
/// Bring the drawing state the file stores up to date, without the save
/// event an autosave does not raise.
pub(in crate::app) fn prepare_snapshot_save(&mut self, i: usize) {
self.sync_view_state_for_save(i);
sync_annotation_scale_header(&mut self.tabs[i].scene);
self.stamp_header_sysvars(i);
@@ -3275,7 +3283,7 @@ impl OpenCADStudio {
if !self.tabs[i].dirty || self.active_save_jobs.contains_key(&self.tabs[i].id) {
continue;
}
self.prepare_native_save(i);
self.prepare_snapshot_save(i);
let version = self.tabs[i].scene.document.version;
let target = self.autosave_target(i);
tasks.push(self.queue_native_save(