Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::editor::DocumentSyncController Class Reference

Owns source-pane debounce, parse-error markers, and XML-owned source view mirroring. More...

#include "donner/editor/DocumentSyncController.h"

Public Member Functions

 DocumentSyncController (std::string initialSource)
 Initialize source synchronization from the displayed source.
void resetForLoadedDocument (const std::string &source)
 Reset pending synchronization state after a document replacement.
void syncParseErrorMarkers (EditorApp &app, TextEditor &textEditor)
 Refresh source diagnostics and editor markers from the application parse state.
const SourceDiagnosticSnapshot & sourceDiagnostics () const
 Diagnostics normalized for the current source buffer and parse revision.
bool mirrorSourceDeltas (EditorApp &app, TextEditor &textEditor, const std::vector< xml::XMLSourceDelta > &sourceDeltas)
 Mirror XML-owned source deltas into the source pane.
std::vector< xml::XMLSourceDelta > takeSourceDeltasOrMirrorWholeSource (EditorApp &app, TextEditor &textEditor)
 Take the document's unmirrored source deltas. When too many accumulated to keep, mirror the whole source instead and return none.
void handleTextEdits (EditorApp &app, TextEditor &textEditor, float deltaSeconds)
 Observe source edits and dispatch eligible document updates through the debounce policy.
std::optional< float > nextTextSyncWakeSeconds () const
 Return the pending source-text sync wake interval, if a throttled edit is waiting.
void applyPendingWritebacks (EditorApp &app, SelectTool &selectTool, TextEditor &textEditor)
 Apply queued document-to-source changes when document access permits.
bool hasPendingWritebacks () const
 True when applyPendingWritebacks still has queued work. Writebacks accumulate while the async renderer owns the document and are drained by the first frame that finds it idle - so a frame that skips the document-sync stage while this holds would strand them until the next user input.
bool hasPendingSourceTextSync () const
 True while text typed in the source pane is held back by the typing throttle and has not been dispatched to the document yet.

Detailed Description

Owns source-pane debounce, parse-error markers, and XML-owned source view mirroring.

Constructor & Destructor Documentation

◆ DocumentSyncController()

donner::editor::DocumentSyncController::DocumentSyncController ( std::string initialSource)
explicit

Initialize source synchronization from the displayed source.

Parameters
initialSourceInitial source text owned by the controller.

Member Function Documentation

◆ applyPendingWritebacks()

void donner::editor::DocumentSyncController::applyPendingWritebacks ( EditorApp & app,
SelectTool & selectTool,
TextEditor & textEditor )

Apply queued document-to-source changes when document access permits.

Parameters
appApplication containing completed mutations.
selectToolSelection tool whose element handles may need remapping.
textEditorSource pane to synchronize.

◆ handleTextEdits()

void donner::editor::DocumentSyncController::handleTextEdits ( EditorApp & app,
TextEditor & textEditor,
float deltaSeconds )

Observe source edits and dispatch eligible document updates through the debounce policy.

Parameters
appApplication receiving source changes.
textEditorSource editor containing the current text.
deltaSecondsElapsed frame time used by pending-edit timers.

◆ mirrorSourceDeltas()

bool donner::editor::DocumentSyncController::mirrorSourceDeltas ( EditorApp & app,
TextEditor & textEditor,
const std::vector< xml::XMLSourceDelta > & sourceDeltas )

Mirror XML-owned source deltas into the source pane.

Use this when a canvas/DOM operation already mutated the XML document and returned xml::XMLSourceDelta records. The controller replays the deltas into textEditor with source-change suppression and falls back to mirroring the document source if the delta sequence cannot be applied precisely.

Parameters
appEditor app containing the source-backed document.
textEditorSource pane to update.
sourceDeltasSource deltas emitted by the XML document.
Returns
True if the source pane was updated from the deltas or fallback mirror.

◆ resetForLoadedDocument()

void donner::editor::DocumentSyncController::resetForLoadedDocument ( const std::string & source)

Reset pending synchronization state after a document replacement.

Parameters
sourceSource text of the newly loaded document.

◆ syncParseErrorMarkers()

void donner::editor::DocumentSyncController::syncParseErrorMarkers ( EditorApp & app,
TextEditor & textEditor )

Refresh source diagnostics and editor markers from the application parse state.

Parameters
appApplication containing the current document and diagnostics.
textEditorSource editor receiving diagnostic markers.

The documentation for this class was generated from the following file: