AvalonStudio.TextEditor.Document.TextDocument.Insert C# (CSharp) Method

Insert() public method

Inserts text.
Anchors positioned exactly at the insertion offset will move according to their movement type. For AnchorMovementType.Default, they will move behind the inserted text. The caret will also move behind the inserted text.
public Insert ( int offset, ITextSource text ) : void
offset int The offset at which the text is inserted.
text ITextSource The new text.
return void
		public void Insert(int offset, ITextSource text)
		{
			Replace(offset, 0, text, null);
		}

Same methods

TextDocument::Insert ( int offset, ITextSource text, AnchorMovementType defaultAnchorMovementType ) : void
TextDocument::Insert ( int offset, string text ) : void
TextDocument::Insert ( int offset, string text, AnchorMovementType defaultAnchorMovementType ) : void

Usage Example

        private void OpenBracket(TextEditor.TextEditor editor, TextDocument document, string text)
        {
            if (text[0].IsOpenBracketChar() && editor.CaretIndex <= document.TextLength && editor.CaretIndex > 0)
            {
                var nextChar = ' ';

                if (editor.CaretIndex != document.TextLength)
                {
                    document.GetCharAt(editor.CaretIndex);
                }

                if (char.IsWhiteSpace(nextChar) || nextChar.IsCloseBracketChar())
                {
                    document.Insert(editor.CaretIndex, text[0].GetCloseBracketChar().ToString());
                }
            }
        }
All Usage Examples Of AvalonStudio.TextEditor.Document.TextDocument::Insert