예제 #1
0
        public void TestBackspaceDeleteCase1()
        {
            var data = Create(@"1234567890$");

            DeleteActions.Delete(data);
            Check(data, @"1234567890$");
        }
예제 #2
0
        public void TestDelete()
        {
            var data = Create(@"1234$567890");

            DeleteActions.Delete(data);
            Check(data, @"1234$67890");
        }
예제 #3
0
        public void TestBackspaceUTF32()
        {
            var data = Create(@"12🚀$34");

            DeleteActions.Backspace(data);
            Check(data, @"12$34");
        }
예제 #4
0
        public void TestDeleteUTF32()
        {
            var data = Create(@"12$🚀34");

            DeleteActions.Delete(data);
            Check(data, @"12$34");
        }
예제 #5
0
        static void RemoveCharBeforCaret(TextEditorData data)
        {
            if (((ISourceEditorOptions)data.Options).AutoInsertMatchingBracket)
            {
                if (data.Caret.Offset > 0)
                {
                    char ch  = data.Document.GetCharAt(data.Caret.Offset - 1);
                    int  idx = open.IndexOf(ch);

                    if (idx >= 0)
                    {
                        int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset);
                        if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset))
                        {
                            bool updateToEnd = data.Document.OffsetToLineNumber(nextCharOffset) != data.Caret.Line;
                            data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1);
                            if (updateToEnd)
                            {
                                data.Document.CommitLineToEndUpdate(data.Caret.Line);
                            }
                        }
                    }
                }
            }
            DeleteActions.Backspace(data);
        }
예제 #6
0
        static void RemoveCharBeforCaret(TextEditorData data)
        {
            if (!data.IsSomethingSelected && MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket)
            {
                if (data.Caret.Offset > 0)
                {
                    var line  = data.GetLine(data.Caret.Line);
                    var stack = line.StartSpan.Clone();
                    if (stack.Any(s => s.Color == "string.other"))
                    {
                        DeleteActions.Backspace(data);
                        return;
                    }
                    stack = line.StartSpan.Clone();
                    if (stack.Any(s => s.Color == "string.other"))
                    {
                        DeleteActions.Backspace(data);
                        return;
                    }

                    char ch  = data.Document.GetCharAt(data.Caret.Offset - 1);
                    int  idx = open.IndexOf(ch);

                    if (idx >= 0)
                    {
                        int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset);
                        if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset))
                        {
                            data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1);
                        }
                    }
                }
            }
            DeleteActions.Backspace(data);
        }
예제 #7
0
        public void TestBackspace()
        {
            var data = Create(@"1234$567890");

            DeleteActions.Backspace(data);
            Check(data, @"123$567890");
        }
예제 #8
0
        static async void RemoveCharBeforCaret(TextEditorData data)
        {
            if (!data.IsSomethingSelected && MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket)
            {
                if (data.Caret.Offset > 0)
                {
                    char ch = data.Document.GetCharAt(data.Caret.Offset - 1);
                    DeleteActions.Backspace(data);
                    if (data.Caret.Offset > 0)
                    {
                        var stack = await data.Document.SyntaxMode.GetScopeStackAsync(data.Caret.Offset - 1, CancellationToken.None);

                        if (stack.Any(s => s.Contains("string") || s.Contains("comment")))
                        {
                            return;
                        }
                    }

                    int idx = open.IndexOf(ch);
                    if (idx >= 0)
                    {
                        int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset);
                        if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset))
                        {
                            data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1);
                        }
                    }
                    return;
                }
            }
            DeleteActions.Backspace(data);
        }
예제 #9
0
        /// <summary>
        /// Pastes the selection after the caret,
        /// or replacing an existing selection.
        /// </summary>
        private void PasteAfter(bool linemode)
        {
            TextEditorData data = Data;

            using (var undo = Document.OpenUndoGroup())
            {
                Gtk.Clipboard.Get(ClipboardActions.CopyOperation.CLIPBOARD_ATOM).RequestText
                    (delegate(Gtk.Clipboard cb, string contents)
                {
                    if (contents == null)
                    {
                        return;
                    }
                    if (contents.EndsWith("\r") || contents.EndsWith("\n"))
                    {
                        // Line mode paste
                        if (data.IsSomethingSelected)
                        {
                            // Replace selection
                            RunAction(ClipboardActions.Cut);
                            data.InsertAtCaret(data.EolMarker);
                            int offset = data.Caret.Offset;
                            data.InsertAtCaret(contents);
                            if (linemode)
                            {
                                // Existing selection was also in line mode
                                data.Caret.Offset = offset;
                                RunAction(DeleteActions.FromMoveAction(CaretMoveActions.Left));
                            }
                            RunAction(CaretMoveActions.LineStart);
                        }
                        else
                        {
                            // Paste on new line
                            RunAction(ViActions.NewLineBelow);
                            RunAction(DeleteActions.FromMoveAction(CaretMoveActions.LineStart));
                            data.InsertAtCaret(contents);
                            RunAction(DeleteActions.FromMoveAction(CaretMoveActions.Left));
                            RunAction(CaretMoveActions.LineStart);
                        }
                    }
                    else
                    {
                        // Inline paste
                        if (data.IsSomethingSelected)
                        {
                            RunAction(ClipboardActions.Cut);
                        }
                        else
                        {
                            RunAction(CaretMoveActions.Right);
                        }
                        data.InsertAtCaret(contents);
                        RunAction(ViActions.Left);
                    }
                    Reset(string.Empty);
                });
            }
        }
 public DeleteAllNotesCommand(string arg)
 {
     if (arg == "true")
     {
         DeleteActions deleteActions = new DeleteActions();
         deleteActions.DeleteAllNotes(true);
     }
 }
        public void TestBackspaceDeleteCase1()
        {
            TextEditorData data = CaretMoveActionTests.Create(@"1234567890$");

            DeleteActions.Delete(data);
            Assert.AreEqual(new DocumentLocation(0, 10), data.Caret.Location);
            Assert.AreEqual("1234567890", data.Document.Text);
        }
예제 #12
0
 public ForeignKey(int id, DatabaseObject table, string name, DeleteActions deleteAction, IList <TableColumn> columns)
 {
     ID           = id;
     Table        = table;
     Name         = name;
     DeleteAction = deleteAction;
     Columns      = columns;
 }
예제 #13
0
        public void TestSmartExistingLineBackspace()
        {
            var data = CreateData("\n\t\t\n\t\tTest");

            data.Caret.Location = new DocumentLocation(3, 3);
            DeleteActions.Backspace(data);
            Assert.AreEqual(new DocumentLocation(2, 3), data.Caret.Location);
            Assert.AreEqual("\n\t\tTest", data.Document.Text);
        }
        public void TestDelete()
        {
            TextEditorData data = CaretMoveActionTests.Create(@"1234$567890");

            Assert.AreEqual(new DocumentLocation(0, 4), data.Caret.Location);
            DeleteActions.Delete(data);
            Assert.AreEqual(new DocumentLocation(0, 4), data.Caret.Location);
            Assert.AreEqual("123467890", data.Document.Text);
        }
예제 #15
0
        public void TestSmartBackspaceBehaviorCase2()
        {
            var data = CreateData("\n\t\tTest\n\t\t");

            data.Caret.Location = new DocumentLocation(3, 3);
            DeleteActions.Backspace(data);
            Assert.AreEqual(new DocumentLocation(2, 7), data.Caret.Location);
            Assert.AreEqual("\n\t\tTest", data.Document.Text);
        }
예제 #16
0
        public void TestBug5956()
        {
            var data = CreateData("\t\tfoo\n\n\t\tbar");

            data.Caret.Location = new DocumentLocation(3, 1);
            DeleteActions.Backspace(data);
            Assert.AreEqual(new DocumentLocation(2, 3), data.Caret.Location);
            Assert.AreEqual("\t\tfoo\n\t\t\t\tbar", data.Document.Text);
        }
예제 #17
0
        public void TestRemoveExistingIndentWithBackspace()
        {
            var data = CreateData("\n\t\t\t\n\n");

            data.Caret.Location = new DocumentLocation(2, 4);
            DeleteActions.Backspace(data);
            Assert.AreEqual(3, data.Caret.Column);
            Assert.AreEqual("\n\n\n", data.Document.Text);
        }
예제 #18
0
        public void TestBackspaceRightBehavior()
        {
            var data = CreateData("test\n\n\n");

            data.Caret.Location = new DocumentLocation(2, data.GetVirtualIndentationColumn(2, 1));
            DeleteActions.Backspace(data);
            Assert.AreEqual(new DocumentLocation(1, 5), data.Caret.Location);
            Assert.AreEqual("test\n\n", data.Document.Text);
        }
예제 #19
0
        public void TestSmartDeleteBehaviorBug1()
        {
            var data = CreateData("\n\t\tFoo\n\t\t Bar");

            data.Caret.Location = new DocumentLocation(2, 6);
            DeleteActions.Delete(data);
            Assert.AreEqual(new DocumentLocation(2, 6), data.Caret.Location);
            Assert.AreEqual("\n\t\tFooBar", data.Document.Text);
        }
예제 #20
0
        public void TestRemoveLastTabInLine()
        {
            var data = CreateData("\n\t\n\n");

            data.Caret.Location = new DocumentLocation(2, 2);
            DeleteActions.Backspace(data);
            Assert.AreEqual("\n\n\n", data.Document.Text);
            Assert.AreEqual(1, data.Caret.Offset);
        }
예제 #21
0
        public void TestBug5402()
        {
            var data = CreateData("\t");

            data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker("\t");
            data.Caret.Location     = new DocumentLocation(1, 2);
            DeleteActions.Backspace(data);
            Assert.AreEqual("", data.Document.Text);
            Assert.AreEqual(0, data.Caret.Offset);
        }
예제 #22
0
        public void TestBug5067()
        {
            var data = CreateData("\n\n\t\tFoo ();\n");

            data.Caret.Location = new DocumentLocation(2, 3);
            SelectionActions.MoveDown(data);
            DeleteActions.Delete(data);

            Assert.AreEqual("\n\t\tFoo ();\n", data.Document.Text);
        }
예제 #23
0
        public void TestDeleteBehavior()
        {
            var data = CreateData("\n\t\ttest");

            data.Caret.Location = new DocumentLocation(2, 3);
            CaretMoveActions.Up(data);
            Assert.AreEqual(new DocumentLocation(1, 3), data.Caret.Location);
            DeleteActions.Delete(data);
            Assert.AreEqual("\t\ttest", data.Document.Text);
        }
        public void TestDeleteCaretLine()
        {
            TextEditorData data = CaretMoveActionTests.Create(@"1234567890
1234$67890
1234567890");

            DeleteActions.CaretLine(data);
            Assert.AreEqual(@"1234567890
1234567890", data.Document.Text);
        }
예제 #25
0
        public void TestDeleteCaretLine()
        {
            var data = Create(@"1234567890
1234$67890
1234567890");

            DeleteActions.CaretLine(data);
            Assert.AreEqual(@"1234567890
1234567890", data.Document.Text);
        }
예제 #26
0
        public void TestBug15476()
        {
            var data = CreateData("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n\t\t\r\n\r\n");

            data.Options.DefaultEolMarker = "\r\n";
            data.IndentationTracker       = new DefaultIndentationTracker(data.Document);
            data.Caret.Location           = new DocumentLocation(4, 3);

            DeleteActions.Backspace(data);
            Assert.AreEqual(new DocumentLocation(3, 3), data.Caret.Location);
        }
예제 #27
0
        public void TestDeleteNextWord()
        {
            var data = Create(@"      $word1 word2 word3");

            DeleteActions.NextWord(data);
            Check(data, @"      $ word2 word3");
            DeleteActions.NextWord(data);
            Check(data, @"      $ word3");
            DeleteActions.NextWord(data);
            Check(data, @"      $");
        }
예제 #28
0
 /// <summary>
 /// The Delete menu handler
 /// </summary>
 /// <param name="sender">The sending object</param>
 /// <param name="e">The event arguments</param>
 private void OnDelete(object sender, EventArgs e)
 {
     try
     {
         DeleteActions.Delete(textEditor.TextArea.GetTextEditorData());
     }
     catch (Exception err)
     {
         ShowError(err);
     }
 }
        public void TestBug5402()
        {
            var data = new TextEditorData();

            data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker("\t");
            data.Document.Text      = "\t";
            data.Caret.Location     = new DocumentLocation(1, 2);
            DeleteActions.Backspace(data);
            Assert.AreEqual("", data.Document.Text);
            Assert.AreEqual(new DocumentLocation(1, 1), data.Caret.Location);
        }
예제 #30
0
        public void TestDeleteNextSubword()
        {
            var data = Create(@"      $SomeLongWord");

            DeleteActions.NextSubword(data);
            Check(data, @"      $LongWord");
            DeleteActions.NextSubword(data);
            Check(data, @"      $Word");
            DeleteActions.NextSubword(data);
            Check(data, @"      $");
        }