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


C# TextBuffer.UndoTextEditing方法代码示例

本文整理汇总了C#中TextBuffer.UndoTextEditing方法的典型用法代码示例。如果您正苦于以下问题:C# TextBuffer.UndoTextEditing方法的具体用法?C# TextBuffer.UndoTextEditing怎么用?C# TextBuffer.UndoTextEditing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextBuffer的用法示例。


在下文中一共展示了TextBuffer.UndoTextEditing方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSecondLastLineDeleteUndo

        public void TestSecondLastLineDeleteUndo()
        {
            string initialContent = "First line\nSecond line\nThird line\nFourth line";

            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Second line\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Third line\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("Fourth line", localBuffer.GetLineContent(3));

            // Replace the second last line when there's no "\n" on the fourth line.
            localBuffer.ReplaceText(2, 0, 2, 11, "Three line\n");
            Assert.AreEqual(4, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Second line\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Three line\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("Fourth line", localBuffer.GetLineContent(3));

            // Undo once should restore the original third line content.
            System.Drawing.Point cursorPosition = new Point();
            localBuffer.UndoTextEditing(ref cursorPosition);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Second line\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Third line\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("Fourth line", localBuffer.GetLineContent(3));
        }
开发者ID:samuto,项目名称:designscript,代码行数:28,代码来源:TextBufferTests.cs

示例2: TestSameLineDeleteUndo

        public void TestSameLineDeleteUndo()
        {
            string initialContent = "First line\nSecond line\nThird line\nFourth line\n";

            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(5, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Fourth line\n", localBuffer.GetLineContent(3));

            // Continuously deleting the line-break on first line.
            localBuffer.ReplaceText(0, 10, 0, 11, string.Empty);
            localBuffer.ReplaceText(0, 21, 0, 22, string.Empty);
            localBuffer.ReplaceText(0, 31, 0, 32, string.Empty);

            // Now we're left with just one line-break at the end of "Fourth line\n".
            Assert.AreEqual(2, localBuffer.GetLineCount());
            Assert.AreEqual("First lineSecond lineThird lineFourth line\n", localBuffer.GetLineContent(0));

            System.Drawing.Point dummyCursor = new Point();

            // Undo once, should break the first line up again.
            localBuffer.UndoTextEditing(ref dummyCursor);
            Assert.AreEqual(3, localBuffer.GetLineCount());
            Assert.AreEqual("First lineSecond lineThird line\n", localBuffer.GetLineContent(0));

            // Undo once more, should break the first line up again.
            localBuffer.UndoTextEditing(ref dummyCursor);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            Assert.AreEqual("First lineSecond line\n", localBuffer.GetLineContent(0));

            // Undo once more, should break the first line up again.
            localBuffer.UndoTextEditing(ref dummyCursor);
            Assert.AreEqual(5, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Second line\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Third line\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("Fourth line\n", localBuffer.GetLineContent(3));
        }
开发者ID:samuto,项目名称:designscript,代码行数:38,代码来源:TextBufferTests.cs

示例3: TestInsertTextLastLineUndo03

        public void TestInsertTextLastLineUndo03()
        {
            string initialContent = "Master Wayne";

            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(1, localBuffer.GetLineCount());
            Assert.AreEqual("Master Wayne", localBuffer.GetLineContent(0));

            localBuffer.ReplaceText(0, 0, 0, 12, "\n\nBatman\n\n");
            Assert.AreEqual(5, localBuffer.GetLineCount());
            Assert.AreEqual("\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Batman\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("\n", localBuffer.GetLineContent(3));

            System.Drawing.Point cursorPosition = new Point();
            localBuffer.UndoTextEditing(ref cursorPosition);
            Assert.AreEqual(1, localBuffer.GetLineCount());
            Assert.AreEqual("Master Wayne", localBuffer.GetLineContent(0));

            localBuffer.RedoTextEditing(ref cursorPosition);
            Assert.AreEqual("\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Batman\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("\n", localBuffer.GetLineContent(3));
        }
开发者ID:samuto,项目名称:designscript,代码行数:26,代码来源:TextBufferTests.cs

示例4: TestReplaceUndo01

        public void TestReplaceUndo01()
        {
            string initialContent = "First line\nSecond line\nThird line\nFourth line";
            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            localBuffer.FindReplace("line", "design", FindOptions.ReplaceOnce);
            List<FindPosition> findResults = new List<FindPosition>();
            localBuffer.GetSearchResults(ref findResults);

            Assert.AreEqual(4, findResults.Count);
            Assert.AreEqual("First design\n", localBuffer.GetLineContent(0));

            Point cursor = new Point(0, 0);
            localBuffer.UndoTextEditing(ref cursor);

            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
        }
开发者ID:samuto,项目名称:designscript,代码行数:17,代码来源:TextBufferTests.cs

示例5: TestInsertTextLastLineUndo01

        public void TestInsertTextLastLineUndo01()
        {
            string initialContent = "First line\nSecond line\nThird line\nFourth line\n";

            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(5, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Second line\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Third line\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("Fourth line\n", localBuffer.GetLineContent(3));

            localBuffer.InsertText(4, 0, "Fifth line\nSixth line\n");
            Assert.AreEqual(7, localBuffer.GetLineCount());
            Assert.AreEqual("Fifth line\n", localBuffer.GetLineContent(4));
            Assert.AreEqual("Sixth line\n", localBuffer.GetLineContent(5));

            System.Drawing.Point cursorPosition = new Point();
            localBuffer.UndoTextEditing(ref cursorPosition);
            Assert.AreEqual(5, localBuffer.GetLineCount());
            Assert.AreEqual("First line\n", localBuffer.GetLineContent(0));
            Assert.AreEqual("Second line\n", localBuffer.GetLineContent(1));
            Assert.AreEqual("Third line\n", localBuffer.GetLineContent(2));
            Assert.AreEqual("Fourth line\n", localBuffer.GetLineContent(3));
        }
开发者ID:samuto,项目名称:designscript,代码行数:24,代码来源:TextBufferTests.cs


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