本文整理汇总了C#中ITextDocument.InsertText方法的典型用法代码示例。如果您正苦于以下问题:C# ITextDocument.InsertText方法的具体用法?C# ITextDocument.InsertText怎么用?C# ITextDocument.InsertText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextDocument
的用法示例。
在下文中一共展示了ITextDocument.InsertText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertNewLine
public void InsertNewLine (ITextDocument editor, NewLineInsertion insertion, ref int offset)
{
string str = null;
switch (insertion) {
case NewLineInsertion.Eol:
str = editor.GetEolMarker ();
break;
case NewLineInsertion.BlankLine:
str = editor.GetEolMarker () + editor.GetEolMarker ();
break;
default:
return;
}
editor.InsertText (offset, str);
offset += str.Length;
}
示例2: IndentCode
static void IndentCode (ITextDocument data, string lineIndent)
{
for (int i = 1; i < data.LineCount; i++) {
var line = data.GetLine (i + 1);
if (line.Length > 0)
data.InsertText (line.Offset, lineIndent);
}
}
示例3: Insert
public int Insert (ITextDocument editor, string text)
{
int offset = editor.LocationToOffset (Location);
using (var undo = editor.OpenUndoGroup ()) {
// TODO: Run formatter !!!
// text = editor.FormatString (Location, text);
var line = editor.GetLineByOffset (offset);
int insertionOffset = line.Offset + Location.Column - 1;
offset = insertionOffset;
InsertNewLine (editor, LineBefore, ref offset);
int result = offset - insertionOffset;
editor.InsertText (offset, text);
offset += text.Length;
InsertNewLine (editor, LineAfter, ref offset);
return result;
}
}