Exemplo n.º 1
0
 private void MoveCaretToNextTabStop()
 {
     while (CaretColumn % IndentSize != 0 && CaretCharIsASpace)
     {
         Caret.MoveToNextCaretPosition();
     }
     Caret.EnsureVisible();
 }
Exemplo n.º 2
0
 private void MoveCaretToPreviousTabStop()
 {
     Caret.MoveToPreviousCaretPosition();
     while (CaretColumn % IndentSize != (IndentSize - 1) && CaretCharIsASpace)
     {
         Caret.MoveToPreviousCaretPosition();
     }
     Caret.MoveToNextCaretPosition();
     Caret.EnsureVisible();
 }
Exemplo n.º 3
0
        private void MoveCaretToPreviousTabStop()
        {
            var caretStartingPosition = Caret.Position.VirtualBufferPosition;
            var caretStartingColumn   = CaretColumn;

            Caret.MoveToPreviousCaretPosition();
            var lastCaretColumn = -1;

            while (CaretColumn % IndentSize != (IndentSize - 1) && CaretCharIsASpace)
            {
                if (CaretColumn >= lastCaretColumn && lastCaretColumn != -1)
                {
                    break;                     // Prevent infinite loop on first char of first line or in box selection
                }
                lastCaretColumn = CaretColumn;
                Caret.MoveToPreviousCaretPosition();
            }

            if (Caret.Position.BufferPosition.Position != 0)
            {             // Do this for all cases except the first char of the document
                Caret.MoveToNextCaretPosition();
            }

            VirtualSnapshotPoint?caretNewPosition = Caret.Position.VirtualBufferPosition;
            int movedBy = caretStartingColumn - CaretColumn;

            if (movedBy % IndentSize != 0)
            {
                // We moved less than a full tab stop length. Only allow this if the cursor started in the middle of a full tab
                for (int i = 0; i < IndentSize; i++)
                {
                    if (Caret.Position.BufferPosition.Add(i).GetChar() != ' ')
                    {
                        caretNewPosition = null;
                        Caret.MoveTo(caretStartingPosition);                         // Do not align on non-exact tab stops
                        break;
                    }
                }
                if (caretNewPosition != null)
                {
                    Caret.MoveTo(caretNewPosition.Value);                     // Go back to original new position
                }
            }

            Caret.EnsureVisible();
        }
Exemplo n.º 4
0
        private void MoveCaretToNextTabStop()
        {
            var caretStartingPosition = Caret.Position.VirtualBufferPosition;
            var caretStartingColumn   = CaretColumn;
            var lastCaretColumn       = -1;

            while (CaretColumn % IndentSize != 0 && CaretCharIsASpace)
            {
                if (CaretColumn <= lastCaretColumn)
                {
                    break;                     // Prevent infinite loop in box selection
                }
                lastCaretColumn = CaretColumn;
                Caret.MoveToNextCaretPosition();
            }

            if (CaretColumn % IndentSize != 0)
            {
                Caret.MoveTo(caretStartingPosition);                 // Do not align on non-exact tab stops
            }
            Caret.EnsureVisible();
        }
Exemplo n.º 5
0
 private void MoveCaretToVirtualPosition(int pos)
 {
     Caret.MoveTo(new VirtualSnapshotPoint(_snapshotLine, pos));
     Caret.EnsureVisible();
 }