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

Replace() public method

Replaces text.
public Replace ( ISegment segment, ITextSource text ) : void
segment ISegment
text ITextSource
return void
		public void Replace(ISegment segment, ITextSource text)
		{
			if (segment == null)
				throw new ArgumentNullException("segment");
			Replace(segment.Offset, segment.Length, text, null);
		}

Same methods

TextDocument::Replace ( ISegment segment, string text ) : void
TextDocument::Replace ( int offset, int length, ITextSource text ) : void
TextDocument::Replace ( int offset, int length, ITextSource text, OffsetChangeMap offsetChangeMap ) : void
TextDocument::Replace ( int offset, int length, ITextSource text, OffsetChangeMappingType offsetChangeMappingType ) : void
TextDocument::Replace ( int offset, int length, string text ) : void
TextDocument::Replace ( int offset, int length, string text, OffsetChangeMap offsetChangeMap ) : void
TextDocument::Replace ( int offset, int length, string text, OffsetChangeMappingType offsetChangeMappingType ) : void

Usage Example

		/// <inheritdoc />
		public virtual int IndentLine(TextDocument document, DocumentLine line, int caretOffset)
		{
			if (document == null)
				throw new ArgumentNullException("document");
			if (line == null)
				throw new ArgumentNullException("line");

			var previousLine = line.PreviousLine;
			if (previousLine != null)
			{
				var indentationSegment = TextUtilities.GetWhitespaceAfter(document, previousLine.Offset);
				var indentation = document.GetText(indentationSegment);
				// copy indentation to line
				indentationSegment = TextUtilities.GetWhitespaceAfter(document, line.Offset);
				document.Replace(indentationSegment, indentation);
			}

			return caretOffset;
		}
All Usage Examples Of AvalonStudio.TextEditor.Document.TextDocument::Replace