Add region lookup and structural edits, and reject regions Build can't write

Instrument.Source returns the flattened region and header behind a typed
region. AddRegion, RemoveRegion and MoveRegion edit the document and read
the instrument again, restoring the document if a region would read
differently. NewRegion returns a region with the format's defaults, and
Build refuses a region that can't be read back as it is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 01:19:40 +00:00
co-authored by Claude Sonnet 5.5
parent 535856ba77
commit 49fd867283
8 changed files with 571 additions and 5 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ import (
// Regions that the typed model has no region for are counted in Skipped, and
// the opcodes and headers it doesn't read in Unread.
func (f *Flat) Instrument() *Instrument {
inst := &Instrument{Unread: map[string]int{}, Skipped: map[string]int{}}
inst := &Instrument{Unread: map[string]int{}, Skipped: map[string]int{}, doc: f.doc}
for h, n := range f.Headers {
inst.Unread["<"+h+">"] += n
}