本文整理汇总了C#中ITextSnapshotLine.GetTextIncludingLineBreak方法的典型用法代码示例。如果您正苦于以下问题:C# ITextSnapshotLine.GetTextIncludingLineBreak方法的具体用法?C# ITextSnapshotLine.GetTextIncludingLineBreak怎么用?C# ITextSnapshotLine.GetTextIncludingLineBreak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextSnapshotLine
的用法示例。
在下文中一共展示了ITextSnapshotLine.GetTextIncludingLineBreak方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformMove
public int PerformMove(IWpfTextView view, ITextSnapshotLine lineToSwap, int insertPosition)
{
var insertedText = lineToSwap.GetTextIncludingLineBreak();
if(insertPosition == view.TextSnapshot.Length)
{
// We don't want ot move the line break if the insert position is the last character of the
// document but also the first character of the line (i.e. an empty line at the end of the document)
var lineUnderInsertPosition = view.TextSnapshot.GetLineFromPosition(insertPosition);
if (lineUnderInsertPosition.Length > 0)
{
// Move the line break to the start of the text to insert
insertedText = (Environment.NewLine + insertedText).Substring(0, insertedText.Length);
}
}
using (var edit = view.TextBuffer.CreateEdit())
{
edit.Delete(lineToSwap.Start, lineToSwap.LengthIncludingLineBreak);
edit.Insert(insertPosition, insertedText);
edit.Apply();
}
return -lineToSwap.LengthIncludingLineBreak;
}
示例2: PerformMove
public int PerformMove(IWpfTextView view, ITextSnapshotLine lineToSwap, int insertPosition)
{
var insertedText = lineToSwap.GetTextIncludingLineBreak();
var deleteStartPosition = lineToSwap.Start.Position;
if(lineToSwap.End == lineToSwap.EndIncludingLineBreak)
{
insertedText = insertedText + Environment.NewLine;
deleteStartPosition = deleteStartPosition - Environment.NewLine.Length;
}
using (var edit = view.TextBuffer.CreateEdit())
{
edit.Delete(deleteStartPosition, insertedText.Length);
edit.Insert(insertPosition, insertedText);
edit.Apply();
}
return insertedText.Length;
}