Table of Contents

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

TextComposition

Document

Gets the shared source document.

public TextDocument Document { get; }

Property Value

TextDocument

InputRules

Gets synchronous rules applied to this session's native input and composition commits.

public TextInputRules InputRules { get; }

Property Value

TextInputRules

IsReadOnly

Gets or sets whether edits originating from this view are rejected.

public bool IsReadOnly { get; set; }

Property Value

bool

SelectionGeneration

Gets a generation that changes whenever this session's selection changes or is mapped.

public long SelectionGeneration { get; }

Property Value

long

Selections

Gets or sets this view's independent selection set.

public TextSelectionSet Selections { get; set; }

Property Value

TextSelectionSet

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

replacements IEnumerable<TextReplacement>
selections TextSelectionSet
expectedRevision DocumentRevision?
expectedSelectionGeneration long?

Returns

TextEditResult

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

TextComposition

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

edit Action<TextDocumentEdit>
options TextEditOptions
expectedRevision DocumentRevision?
expectedSelectionGeneration long?

Returns

TextEditResult

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

text string
options TextEditOptions

Returns

TextEditResult

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

EventHandler<TextDocumentChangedEventArgs>

CompositionChanged

Occurs when this view's provisional input starts, changes, commits, or cancels.

public event EventHandler? CompositionChanged

Event Type

EventHandler

SelectionChanged

Occurs when the session's selections change.

public event EventHandler? SelectionChanged

Event Type

EventHandler