当前位置: 首页>>代码示例>>C#>>正文


C# ITextSnapshotLine.GetTextIncludingLineBreak方法代码示例

本文整理汇总了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;
        }
开发者ID:aenmeyk,项目名称:MoveLine,代码行数:25,代码来源:LineMoverUp.cs

示例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;
        }
开发者ID:aenmeyk,项目名称:MoveLine,代码行数:20,代码来源:LineMoverDown.cs


注:本文中的ITextSnapshotLine.GetTextIncludingLineBreak方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。