A dockable 'Sam' tool view runs the plan9 sam command language against the
active document, or project-wide via X/Y. Each Run is one undo step.
Engine (src/sam/, pure, 27 unit tests, no Kate dep):
- SamEngine::run(program,text,dotStart,dotEnd) -> edits (original-offset,
non-overlapping, sorted), dot, output, applied text. Addresses computed
against the original snapshot per sam semantics.
- Recursive-descent parser + evaluator mirroring plan9port src/cmd/sam
(cmd.c table, address.c lineaddr/charaddr, xec.c s_cmd/looper).
- Language: #n n 0 $ . ' /re/ ?re? and compound + - , ; ; commands
a c i d, s (sN, g, &, \1..\9), p =, m t, k, loops x y g v (nestable),
{ } groups, shell < > | ! via sh -c.
- peelFileLoop(): recognises a leading X/Y file loop (sam allows one per
command) for the Kate layer to drive.
Kate layer:
- SamPanel (src/plugin/sampanel): program editor + Run + output log.
- OllieView creates the tool view (MainWindow::createToolView) and owns
runSamProgram/applySamToDocument/runSamFileLoop. Single-doc edits apply
inside one Document::EditingTransaction (atomic undo). X/Y enumerates the
project index (ProjectIndexer::cachedFiles), opens each matching file, and
applies the inner program; undo is per-file (no global multi-file undo).
Regexes use QRegularExpression (PCRE), not plan9 regexp(7); documented. Out of
scope: b B n D menu, e r w f file I/O, "re" file-addressing, sam u (Kate undo).
17/17 ctest green.