本文整理汇总了C#中ITextDocument.ReplaceText方法的典型用法代码示例。如果您正苦于以下问题:C# ITextDocument.ReplaceText方法的具体用法?C# ITextDocument.ReplaceText怎么用?C# ITextDocument.ReplaceText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextDocument
的用法示例。
在下文中一共展示了ITextDocument.ReplaceText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertVerbatimStringToNormal
static void ConvertVerbatimStringToNormal (ITextDocument textEditorData, int offset)
{
var endOffset = offset;
while (endOffset < textEditorData.Length) {
char ch = textEditorData.GetCharAt (endOffset);
if (ch == '"' && (endOffset + 1 < textEditorData.Length && textEditorData.GetCharAt (endOffset + 1) == '"')) {
endOffset += 2;
continue;
}
if (ch == '"') {
break;
}
endOffset++;
}
var plainText = TextPasteUtils.VerbatimStringStrategy.Decode (textEditorData.GetTextAt (offset, endOffset - offset));
var newText = TextPasteUtils.StringLiteralPasteStrategy.Instance.Encode (plainText);
textEditorData.ReplaceText (offset, endOffset - offset, newText);
}
示例2: ApplyChanges
static int ApplyChanges (Projection projection, ITextDocument data, List<TextChange> changes)
{
int delta = 0;
foreach (var change in changes) {
var offset = change.Span.Start;
if (projection != null) {
int originalOffset;
//If change is outside projection segments don't apply it...
if (projection.TryConvertFromProjectionToOriginal (offset, out originalOffset)) {
offset = originalOffset;
data.ReplaceText (offset, change.Span.Length, change.NewText);
delta += change.Span.Length - change.NewText.Length;
}
} else {
data.ReplaceText (offset, change.Span.Length, change.NewText);
delta += change.Span.Length - change.NewText.Length;
}
}
return delta;
}
示例3: ConvertNormalToVerbatimString
static void ConvertNormalToVerbatimString (ITextDocument textEditorData, int offset)
{
var endOffset = offset;
while (endOffset < textEditorData.Length) {
char ch = textEditorData.GetCharAt (endOffset);
if (ch == '\\') {
if (endOffset + 1 < textEditorData.Length && NewLine.IsNewLine (textEditorData.GetCharAt (endOffset + 1)))
return;
endOffset += 2;
continue;
}
if (ch == '"')
break;
if (NewLine.IsNewLine (ch))
return;
endOffset++;
}
if (offset > endOffset || endOffset == textEditorData.Length)
return;
var plainText = TextPasteUtils.StringLiteralPasteStrategy.Instance.Decode (textEditorData.GetTextAt (offset, endOffset - offset));
var newText = TextPasteUtils.VerbatimStringStrategy.Encode (plainText);
textEditorData.ReplaceText (offset, endOffset - offset, newText);
}