forked from 1b-agent/opencadstudio-upstream
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:
1 parent
71cebbb3fe
commit
1c242eb489
13 files changed
+229
-19
No files matched your search
@@ -488,6 +488,22 @@ fn font_stem(name: &str) -> String {
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// How many inked glyphs (non-blank characters, stacked parts included) an
|
||||
/// MTEXT string draws, in drawing order: the index of the first glyph of
|
||||
/// what follows `s` in a longer string.
|
||||
pub fn mtext_glyph_count(s: &str) -> usize {
|
||||
let ink = |t: &str| t.chars().filter(|c| !c.is_whitespace()).count();
|
||||
adapt_mtext_paragraphs(s, 1.0, false)
|
||||
.iter()
|
||||
.flat_map(|line| &line.runs)
|
||||
.map(|run| match &run.kind {
|
||||
MTextRunKind::Glyphs(text) => ink(text),
|
||||
MTextRunKind::Tab => 0,
|
||||
MTextRunKind::Stack { numerator, denominator, .. } => ink(numerator) + ink(denominator),
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
|
||||
/// Parse an MTEXT string into the layout's `Vec<MTextLine>`, using opencadcodec's
|
||||
/// structured `mtext_format::parse_mtext` — OCS keeps only the layout engine
|
||||
/// (`layout_mtext` and callers read `MTextLine`/`RunState`), not a second MTEXT
|
||||
|
||||
Reference in new issue
Block a user