public static void Undo(EditorViewController controller)
        {
            // Bridge into the new command controller subsystem.
            var commandReference = new CommandFactoryReference(UndoCommandFactory.Key);

            controller.CommandFactory.Do(controller, commandReference);
        }
        public void Do(
            object context,
            CommandFactoryReference commandFactoryReference,
            CommandFactoryManager <OperationContext> controller)
        {
            // Pull out some useful variables for processing.
            var             editViewController = (EditorViewController)context;
            IDisplayContext displayContext     = editViewController.DisplayContext;
            TextPosition    position           = displayContext.Caret.Position;

            // Set up the operation context for this request.
            var textPosition =
                new TextPosition(
                    displayContext.Caret.Position.LinePosition,
                    displayContext.Caret.Position.CharacterPosition);
            var operationContext = new OperationContext(
                displayContext.LineBuffer, textPosition);

            // Create the commands and execute them.
            Do(
                context,
                controller,
                commandFactoryReference.Data,
                operationContext,
                editViewController,
                displayContext,
                position);
        }
Exemple #3
0
        public void DeleteMiddleOfSentenceUndo()
        {
            // Arrange
            EditorViewController controller;
            Caret      caret;
            LineBuffer lineBuffer;

            SetupTests(out controller, out caret, out lineBuffer);

            var factory   = new DeleteRightWordCommandFactory();
            var undo      = new UndoCommandFactory();
            var reference = new CommandFactoryReference(factory.FactoryKey);

            caret.Position = new TextPosition(2, 9);

            factory.Do(controller, reference, controller.CommandFactory);

            // Act
            undo.Do(controller, reference, controller.CommandFactory);

            // Assert
            Assert.AreEqual(
                2, caret.Position.LinePosition, "Caret was on an unexpected line.");
            Assert.AreEqual(
                9, caret.Position.CharacterPosition, "Caret was on an unexpected character.");

            Assert.AreEqual(3, lineBuffer.LineCount);
            Assert.AreEqual(DefaultLine, lineBuffer.GetLineText(0));
            Assert.AreEqual(DefaultLine, lineBuffer.GetLineText(1));
            Assert.AreEqual("one, two three, four five. Six.", lineBuffer.GetLineText(2));
        }
        public static void InsertParagraph(EditorViewController controller)
        {
            // Bridge into the new command controller subsystem.
            var commandReference =
                new CommandFactoryReference(SplitParagraphCommandFactory.Key);

            controller.CommandFactory.Do(controller, commandReference);
        }
        public static void DeleteRightWord(EditorViewController controller)
        {
            // Bridge into the new command controller subsystem.
            var commandReference =
                new CommandFactoryReference(LargeDeleteRightCommandFactory.Key);

            controller.CommandFactory.Do(controller, commandReference);
        }
        /// <summary>
        /// Moves the caret down one line.
        /// </summary>
        /// <param name="controller">The display context.</param>
        /// <param name="unicode">The Unicode character.</param>
        public static void InsertText(
            EditorViewController controller,
            char unicode)
        {
            // Bridge into the new command controller subsystem.
            var commandReference =
                new CommandFactoryReference(InsertCharacterCommandFactory.Key, unicode);

            controller.CommandFactory.Do(controller, commandReference);
        }
        protected override void Do(
            object context,
            CommandFactoryManager <OperationContext> commandFactory,
            object commandData,
            OperationContext operationContext,
            EditorViewController controller,
            IDisplayContext displayContext,
            TextPosition position)
        {
            // Figure out which command we'll be passing the operation to.
            HierarchicalPath key;

            if (!displayContext.Caret.Selection.IsEmpty)
            {
                // If we have a selection, then we use the Delete Selection command.
                key = DeleteSelectionCommandFactory.Key;
            }
            else if (position.IsBeginningOfBuffer(controller.DisplayContext))
            {
                // If we are the beginning of the buffer, then we can't delete anything.
                return;
            }
            else if (position.CharacterPosition == 0)
            {
                // If we are at the beginning of the line, then we are combining paragraphs.
                key = JoinPreviousParagraphCommandFactory.Key;
            }
            else
            {
                // Delete the next character only.
                key = DeleteLeftWordCommandFactory.Key;
            }

            // Execute the command and pass the results to calling method.
            var nextCommand = new CommandFactoryReference(key);

            commandFactory.Do(context, nextCommand);
        }
 public abstract string GetTitle(
     CommandFactoryReference commandFactoryReference);
Exemple #9
0
 public override string GetTitle(
     CommandFactoryReference commandFactoryReference)
 {
     return("Join Previous Paragraph");
 }
 public override string GetTitle(
     CommandFactoryReference commandFactoryReference)
 {
     return("Delete Right Word");
 }
 public override string GetTitle(
     CommandFactoryReference commandFactoryReference)
 {
     return("Split Paragraph");
 }
 public override string GetTitle(
     CommandFactoryReference commandFactoryReference)
 {
     return("Delete Left Large");
 }
Exemple #13
0
 public override string GetTitle(
     CommandFactoryReference commandFactoryReference)
 {
     return("Undo");
 }
Exemple #14
0
 public override string GetTitle(
     CommandFactoryReference commandFactoryReference)
 {
     return("Insert Character");
 }