Example #1
0
        override public void Redo()
        {
            eraseCommand.Redo();
            int lastILine = -1;

            foreach (Selection selection in selections)
            {
                Place place = lines.PlaceOf(selection.caret);
                if (place.iLine == lastILine)
                {
                    continue;
                }
                lastILine = place.iLine;
                if (place.iLine > 0)
                {
                    Line line = lines[place.iLine];
                    if (line.NormalCount > 0 && line.IsOnlySpaces())
                    {
                        Line prevLine = lines[place.iLine - 1];
                        int  iChar;
                        int  prevSpacesSize = prevLine.GetFirstSpaceSize(out iChar);
                        if (prevSpacesSize % lines.tabSize == 0)
                        {
                            int  spacesSize       = line.GetFirstSpaceSize(out iChar);
                            char lastPrevNotSpace = prevLine.GetLastNotSpace();
                            if (lastPrevNotSpace != '{' && prevSpacesSize == spacesSize)
                            {
                                int newPos   = spacesSize - lines.tabSize;
                                int newIChar = line.IndexOfPos(newPos);
                                int newPos2  = line.PosOfIndex(newIChar);
                                if (newPos2 == newPos)
                                {
                                    selection.anchor += newIChar - place.iChar;
                                }
                            }
                            else if (lastPrevNotSpace == '{' && prevSpacesSize == spacesSize - lines.tabSize)
                            {
                                int newPos   = prevSpacesSize;
                                int newIChar = line.IndexOfPos(newPos);
                                int newPos2  = line.PosOfIndex(newIChar);
                                if (newPos2 == newPos)
                                {
                                    selection.anchor += newIChar - place.iChar;
                                }
                            }
                        }
                    }
                }
            }
            insertText            = new InsertTextCommand("}", null, true);
            insertText.lines      = lines;
            insertText.selections = selections;
            insertText.Init();
            insertText.Redo();
        }
Example #2
0
        override public void Redo()
        {
            eraseCommand.Redo();
            int lastILine = -1;

            string[] texts = new string[selections.Count];
            for (int i = 0; i < selections.Count; ++i)
            {
                Selection selection = selections[i];
                texts[i] = "";
                Place place = lines.PlaceOf(selection.caret);
                if (place.iLine == lastILine)
                {
                    continue;
                }
                lastILine = place.iLine;
                if (place.iLine + 1 < lines.LinesCount)
                {
                    Line line = lines[place.iLine];
                    if (line.NormalCount > 0 && line.IsOnlySpaces())
                    {
                        Line nextLine = lines[place.iLine + 1];
                        int  iChar;
                        int  nextSpacesSize = nextLine.GetFirstSpaceSize(out iChar);
                        if (nextSpacesSize > 0 && nextSpacesSize % lines.tabSize == 0)
                        {
                            int  spacesSize       = line.GetFirstSpaceSize(out iChar);
                            char nextPrevNotSpace = nextLine.GetLastNotSpace();
                            if (nextPrevNotSpace == '}' && nextSpacesSize == spacesSize)
                            {
                                texts[i] = lines.TabSettings.Tab;
                            }
                        }
                    }
                }
            }
            insertText            = new InsertTextCommand(null, texts, true);
            insertText.lines      = lines;
            insertText.selections = selections;
            insertText.Init();
            insertText.Redo();
        }
        override public void Redo()
        {
            lines.ResizeSelections(ranges.Count);
            for (int i = ranges.Count; i-- > 0;)
            {
                SimpleRange range     = ranges[i];
                Selection   selection = selections[i];
                selection.anchor = lines.IndexOf(new Place(0, range.index));
                Line endLine = lines[range.index + range.count - 1];
                selection.caret = lines.IndexOf(new Place(endLine.charsCount, range.index + range.count - 1));
            }

            EraseSelectionCommand eraseCommand = new EraseSelectionCommand();

            eraseCommand.lines      = lines;
            eraseCommand.selections = lines.selections;
            if (eraseCommand.Init())
            {
                eraseCommand.Redo();
                this.eraseCommand = eraseCommand;
            }
        }
Example #4
0
        override public void Redo()
        {
            lines.ResizeSelections(ranges.Count);
            for (int i = ranges.Count; i-- > 0;)
            {
                SimpleRange range     = ranges[i];
                Line        endLine   = lines[range.index + range.count - 1];
                Selection   selection = selections[i];
                if (range.index > 0 && range.index + range.count == lines.LinesCount)
                {
                    Line startLine = lines[range.index - 1];
                    selection.anchor = lines.IndexOf(new Place(startLine.NormalCount, range.index - 1));
                    selection.caret  = lines.IndexOf(new Place(endLine.charsCount, range.index + range.count - 1));
                }
                else
                {
                    selection.anchor = lines.IndexOf(new Place(0, range.index));
                    selection.caret  = lines.IndexOf(new Place(endLine.charsCount, range.index + range.count - 1));
                }
            }

            EraseSelectionCommand eraseCommand = new EraseSelectionCommand();

            eraseCommand.lines      = lines;
            eraseCommand.selections = lines.selections;
            if (eraseCommand.Init())
            {
                eraseCommand.Redo();
                this.eraseCommand = eraseCommand;
            }
            else
            {
                this.eraseCommand = null;
            }
            controller.ViMoveHome(false, true);
        }