Class TextEditorSession
- Namespace
- TextEdit.Core
- Assembly
- TextEdit.Core.dll
Independent mutable selection and input state for one view of a shared source document.
public sealed class TextEditorSession : IDisposable
- Inheritance
-
TextEditorSession
- Implements
- Inherited Members
Properties
Composition
Gets this view's provisional composition, or null when input is committed.
public TextComposition? Composition { get; }
Property Value
Document
Gets the shared source document.
public TextDocument Document { get; }
Property Value
InputRules
Gets synchronous rules applied to this session's native input and composition commits.
public TextInputRules InputRules { get; }
Property Value
IsReadOnly
Gets or sets whether edits originating from this view are rejected.
public bool IsReadOnly { get; set; }
Property Value
SelectionGeneration
Gets a generation that changes whenever this session's selection changes or is mapped.
public long SelectionGeneration { get; }
Property Value
Selections
Gets or sets this view's independent selection set.
public TextSelectionSet Selections { get; set; }
Property Value
Methods
ApplyInput(IEnumerable<TextReplacement>, TextSelectionSet, DocumentRevision?, long?)
Commits recorded sequential native replacements and their dependent input rules atomically.
public TextEditResult ApplyInput(IEnumerable<TextReplacement> replacements, TextSelectionSet selections, DocumentRevision? expectedRevision = null, long? expectedSelectionGeneration = null)
Parameters
replacementsIEnumerable<TextReplacement>selectionsTextSelectionSetexpectedRevisionDocumentRevision?expectedSelectionGenerationlong?
Returns
Remarks
The native adapter supplies all originating replacements and resulting selections. Rule conflicts throw before publication.
BeginComposition()
Acquires the document's composition lease while leaving committed text unchanged.
public TextComposition BeginComposition()
Returns
Dispose()
Detaches the view without clearing shared history or affecting other views.
public void Dispose()
Edit(Action<TextDocumentEdit>, TextEditOptions, DocumentRevision?, long?)
Commits a view-originating transaction, optionally checking a captured revision and selection generation.
public TextEditResult Edit(Action<TextDocumentEdit> edit, TextEditOptions options = default, DocumentRevision? expectedRevision = null, long? expectedSelectionGeneration = null)
Parameters
editAction<TextDocumentEdit>optionsTextEditOptionsexpectedRevisionDocumentRevision?expectedSelectionGenerationlong?
Returns
Redo()
Redoes one unit and restores its recorded selection in this view.
public void Redo()
ReplaceSelections(string, TextEditOptions)
Replaces every selection atomically, materializing virtual padding only for nonempty inserted text.
public TextEditResult ReplaceSelections(string text, TextEditOptions options = default)
Parameters
textstringoptionsTextEditOptions
Returns
Undo()
Undoes one unit and restores its recorded selection in this view.
public void Undo()
Events
Changed
Occurs after the document and every view's selections have been synchronized.
public event EventHandler<TextDocumentChangedEventArgs>? Changed
Event Type
CompositionChanged
Occurs when this view's provisional input starts, changes, commits, or cancels.
public event EventHandler? CompositionChanged
Event Type
SelectionChanged
Occurs when the session's selections change.
public event EventHandler? SelectionChanged