public void Copy()
        {
            Init();
            lines.SetText(SimpleText);
            ClipboardExecutor.PutToClipboard("-");

            controller.PutCursor(new Pos(3, 2), false);
            controller.PutCursor(new Pos(7, 2), true);
            AssertSelection().Anchor(3, 2).Caret(7, 2);
            controller.Copy();
            Assert.AreEqual("hast", ClipboardExecutor.GetFromClipboard());

            controller.PutCursor(new Pos(0, 0), false);
            controller.PutCursor(new Pos(12, 2), true);
            controller.Copy();
            Assert.AreEqual(SimpleText, ClipboardExecutor.GetFromClipboard());

            controller.PutCursor(new Pos(0, 0), false);
            controller.PutCursor(new Pos(7, 1), true);
            controller.Copy();
            Assert.AreEqual("Du\nDu hast", ClipboardExecutor.GetFromClipboard());

            controller.PutCursor(new Pos(0, 0), false);
            controller.PutCursor(new Pos(0, 2), true);
            controller.Copy();
            Assert.AreEqual("Du\nDu hast\n", ClipboardExecutor.GetFromClipboard());
        }
        public void Past_Multiline_DifferentCount()
        {
            Init();
            lines.SetText(SimpleText);

            ClipboardExecutor.PutToClipboard("text\ntext1\nend");

            //Du
            //Du h[as]t
            //Du| hast mich
            controller.ClearMinorSelections();
            controller.PutCursor(new Pos(4, 1), false);
            controller.PutCursor(new Pos(6, 1), true);
            controller.PutNewCursor(new Pos(2, 2));
            AssertSelection().Anchor(4, 1).Caret(6, 1).Next().Both(2, 2).NoNext();

            controller.Paste();
            Assert.AreEqual("Du\n", GetLineText(0));
            Assert.AreEqual("Du htext\n", GetLineText(1));
            Assert.AreEqual("text1\n", GetLineText(2));
            Assert.AreEqual("endt\n", GetLineText(3));
            Assert.AreEqual("Dutext\n", GetLineText(4));
            Assert.AreEqual("text1\n", GetLineText(5));
            Assert.AreEqual("end hast mich", GetLineText(6));
            Assert.AreEqual(7, lines.LinesCount);
            AssertSelection().Both(3, 3).Next().Both(3, 6).NoNext();
        }
        public void Paste()
        {
            Init();

            lines.SetText("Du\nDu hast\nDu hast mich");
            // Du|\n
            // D[u ][hast\n
            // Du h]ast mich
            controller.PutCursor(new Pos(2, 0), false);
            controller.PutNewCursor(new Pos(1, 1));
            controller.PutCursor(new Pos(3, 1), true);
            controller.PutNewCursor(new Pos(4, 2));
            controller.PutCursor(new Pos(3, 1), true);
            AssertSelection().Both(2, 0).Next().Anchor(1, 1).Caret(3, 1).Next().Anchor(4, 2).Caret(3, 1).NoNext();

            ClipboardExecutor.PutToClipboard("a\ntext\nanother text");
            controller.Paste();
            // Dua|\n
            // Dtext|another text|ast mich
            Assert.AreEqual("Dua\nDtextanother textast mich", lines.GetText());
            AssertSelection().Both(3, 0).Next().Both(5, 1).Next().Both(17, 1).NoNext();

            controller.processor.Undo();
            Assert.AreEqual("Du\nDu hast\nDu hast mich", lines.GetText());
            AssertSelection().Both(2, 0).Next().Anchor(1, 1).Caret(3, 1).Next().Anchor(4, 2).Caret(3, 1).NoNext();

            controller.processor.Redo();
            Assert.AreEqual("Dua\nDtextanother textast mich", lines.GetText());
            AssertSelection().Both(3, 0).Next().Both(5, 1).Next().Both(17, 1).NoNext();
        }
Exemplo n.º 4
0
 public void Clipboard(char register)
 {
     ClipboardExecutor.PutToRegister(register, "AAAA");
     Assert.AreEqual("AAAA", ClipboardExecutor.GetFromRegister(null, register));
     Assert.AreEqual("AAAA", ClipboardExecutor.GetFromClipboard());
     ClipboardExecutor.PutToClipboard("BBBB");
     Assert.AreEqual("BBBB", ClipboardExecutor.GetFromRegister(null, register));
     Assert.AreEqual("BBBB", ClipboardExecutor.GetFromClipboard());
 }
        public void ClipboardPutToGetFrom()
        {
            ClipboardExecutor.PutToClipboard("Test");
            Assert.AreEqual("Test", ClipboardExecutor.GetFromClipboard());

            ClipboardExecutor.PutToClipboard("??????? ?????");
            Assert.AreEqual("??????? ?????", ClipboardExecutor.GetFromClipboard());

            ClipboardExecutor.PutToClipboard("Multiline\ntext");
            Assert.AreEqual("Multiline\ntext", ClipboardExecutor.GetFromClipboard());
        }
        public void Copy_LastLine()
        {
            Init();
            lines.lineBreak = "\r";
            lines.SetText("abcd\n  EFGHI\r\n1234");
            ClipboardExecutor.PutToClipboard("-");

            controller.PutCursor(new Place(1, 2), false);
            AssertSelection().Both(1, 2).NoNext();
            controller.Copy();
            Assert.AreEqual("1234\r", ClipboardExecutor.GetFromClipboard());
            AssertSelection().Both(1, 2).NoNext();
        }
        public void Copy_WordWrap()
        {
            Init();
            lines.SetText("abcd\n  word1 word2 word3\r\n1234");
            lines.wordWrap = true;
            lines.wwValidator.Validate(10);
            Assert.AreEqual(5, lines.wwSizeY);
            ClipboardExecutor.PutToClipboard("-");

            controller.PutCursor(new Place(4, 1), false);
            AssertSelection().Both(4, 1).NoNext();
            controller.Copy();
            Assert.AreEqual("  word1 word2 word3\r\n", ClipboardExecutor.GetFromClipboard());
            AssertSelection().Both(4, 1).NoNext();
        }
        public void Paste()
        {
            Init();
            lines.SetText(SimpleText);

            ClipboardExecutor.PutToClipboard("!");
            AssertSelection().Both(0, 0);
            controller.Paste();
            Assert.AreEqual("!Du\n", GetLineText(0));
            AssertSelection().Both(1, 0);

            ClipboardExecutor.PutToClipboard("text");
            controller.PutCursor(new Pos(3, 1), false);
            AssertSelection().Both(3, 1);
            controller.Paste();
            Assert.AreEqual("Du texthast\n", GetLineText(1));
            AssertSelection().Both(7, 1);
        }
        public void CopyPaste_RN1()
        {
            Init();
            lines.SetText("Du\r\nDu hast\nDu hast\rDu hast mich");
            //D|u
            //Du| hast
            //Du |hast
            //Du h|ast mich
            controller.PutCursor(new Pos(1, 0), false);
            controller.PutNewCursor(new Pos(2, 1));
            controller.PutNewCursor(new Pos(3, 2));
            controller.PutNewCursor(new Pos(4, 3));
            AssertSelection().Both(1, 0).Next().Both(2, 1).Next().Both(3, 2).Next().Both(4, 3).NoNext();

            ClipboardExecutor.PutToClipboard("text0\r\ntext1\ntext2\rtext3");

            controller.Paste();
            Assert.AreEqual("Dtext0u\r\nDutext1 hast\nDu text2hast\rDu htext3ast mich", lines.GetText());
        }
        public void Paste_SelectionMastBeMergedBefore()
        {
            Init();
            //                  |  |
            lines.SetText("12345678901234567890123");
            controller.PutCursor(new Pos(2, 0), false);
            controller.PutNewCursor(new Pos(5, 0));
            AssertSelection().Both(2, 0).Next().Both(5, 0).NoNext();
            controller.MoveRight(true);
            controller.MoveRight(true);
            controller.MoveRight(true);
            controller.MoveRight(true);
            controller.MoveRight(true);
            AssertSelection().Anchor(2, 0).Caret(7, 0).Next().Anchor(5, 0).Caret(10, 0).NoNext();
            ClipboardExecutor.PutToClipboard("text");

            controller.Paste();
            Assert.AreEqual("12text1234567890123", lines.GetText());
            AssertSelection().Both(6, 0).NoNext();
        }
        public void Paste_Multiline()
        {
            Init();
            lines.SetText(SimpleText);

            AssertSize().XY(12, 3);

            ClipboardExecutor.PutToClipboard("line0\nline00\nline000");
            controller.PutCursor(new Pos(3, 1), false);
            AssertSelection().Both(3, 1);
            controller.Paste();

            /*
             * Du
             * Du line0
             * line00
             * line000hast
             * Du hast mich
             */
            AssertSelection().Both(7, 3);
            Assert.AreEqual("Du\n", GetLineText(0));
            Assert.AreEqual("Du line0\n", GetLineText(1));
            Assert.AreEqual("line00\n", GetLineText(2));
            Assert.AreEqual("line000hast\n", GetLineText(3));
            Assert.AreEqual("Du hast mich", GetLineText(4));

            AssertSize().XY(12, 5);

            ClipboardExecutor.PutToClipboard("text\n");
            controller.PutCursor(new Pos(0, 1), false);
            AssertSelection().Both(0, 1);
            controller.Paste();
            Assert.AreEqual("Du\n", GetLineText(0));
            Assert.AreEqual("text\n", GetLineText(1));
            Assert.AreEqual("Du line0\n", GetLineText(2));
            Assert.AreEqual("line00\n", GetLineText(3));
        }
        public void Cut()
        {
            Init();
            lines.lineBreak = "\n";
            lines.SetText("abcd\n  EFGHI\r\n1234");
            ClipboardExecutor.PutToClipboard("-");

            controller.PutCursor(new Place(1, 0), false);
            controller.PutNewCursor(new Place(3, 0));
            controller.PutNewCursor(new Place(2, 1));
            AssertSelection().Both(1, 0).Next().Both(3, 0).Next().Both(2, 1).NoNext();
            controller.Cut();
            Assert.AreEqual("abcd\n  EFGHI\r\n", ClipboardExecutor.GetFromClipboard());
            AssertText("1234");
            AssertSelection().Both(0, 0).NoNext();

            controller.processor.Undo();
            AssertText("abcd\n  EFGHI\r\n1234");
            AssertSelection().Both(1, 0).Next().Both(3, 0).Next().Both(2, 1).NoNext();

            controller.processor.Redo();
            AssertText("1234");
            AssertSelection().Both(0, 0).NoNext();
        }