|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
The TextPatch type and applyPatches function form the editor's canvas-to-text writeback sideband. When a tool mutates an attribute via EditorApp::applyMutation, it also produces a TextPatch that describes the corresponding byte-level splice in the source text. The main loop drains pending patches after flushFrame() and before rendering the source pane. More...
#include <cstddef>#include <cstdint>#include <span>#include <string>#include <string_view>#include <vector>Classes | |
| struct | donner::editor::TextPatch |
| A byte-level splice in the source text buffer. More... | |
| struct | donner::editor::ApplyPatchesResult |
| Result of an applyPatches call. More... | |
Namespaces | |
| namespace | donner |
| Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css. | |
Functions | |
| ApplyPatchesResult | donner::editor::applyPatches (std::string &source, std::span< const TextPatch > patches) |
| Apply a batch of TextPatch values to a source string. | |
The TextPatch type and applyPatches function form the editor's canvas-to-text writeback sideband. When a tool mutates an attribute via EditorApp::applyMutation, it also produces a TextPatch that describes the corresponding byte-level splice in the source text. The main loop drains pending patches after flushFrame() and before rendering the source pane.
See docs/design_docs/structured_text_editing.md M3 for the full design.
| ApplyPatchesResult donner::editor::applyPatches | ( | std::string & | source, |
| std::span< const TextPatch > | patches ) |
Apply a batch of TextPatch values to a source string.
Patches are sorted by descending offset before application so each splice doesn't shift the byte offsets of subsequent patches. Patches that would read past the end of the current string are rejected (counted in result.rejectedBounds). The remaining patches are applied in place.
| source | The mutable source text. Modified in place. |
| patches | The patches to apply. Order does not matter — the function sorts internally. |