Mono.TextEditor.TextEditorData.Replace C# (CSharp) Method

Replace() public method

public Replace ( int offset, int count, string value ) : int
offset int
count int
value string
return int
		public int Replace (int offset, int count, string value)
		{
			string formattedString = FormatString (offset, value);
			document.Replace (offset, count, formattedString);
			return formattedString.Length;
		}
			

Usage Example

Example #1
1
		public override void CorrectIndenting (PolicyContainer policyParent, IEnumerable<string> mimeTypeChain, 
			TextEditorData data, int line)
		{
			DocumentLine lineSegment = data.Document.GetLine (line);
			if (lineSegment == null)
				return;

			try {
				var policy = policyParent.Get<CSharpFormattingPolicy> (mimeTypeChain);
				var tracker = new CSharpIndentEngine (data.Document, data.CreateNRefactoryTextEditorOptions (),  policy.CreateOptions ());

				tracker.Update (lineSegment.Offset);
				for (int i = lineSegment.Offset; i < lineSegment.Offset + lineSegment.Length; i++) {
					tracker.Push (data.Document.GetCharAt (i));
				}

				string curIndent = lineSegment.GetIndentation (data.Document);

				int nlwsp = curIndent.Length;
				if (!tracker.LineBeganInsideMultiLineComment || (nlwsp < lineSegment.LengthIncludingDelimiter && data.Document.GetCharAt (lineSegment.Offset + nlwsp) == '*')) {
					// Possibly replace the indent
					string newIndent = tracker.ThisLineIndent;
					if (newIndent != curIndent) 
						data.Replace (lineSegment.Offset, nlwsp, newIndent);
				}
			} catch (Exception e) {
				LoggingService.LogError ("Error while indenting", e);
			}
		}
All Usage Examples Of Mono.TextEditor.TextEditorData::Replace