void InternalMoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition, bool captureVerticalPosition, bool raiseEvent)
        {
            int requestedPosition          = bufferPosition.Position;
            ITextSnapshotLine snapshotLine = TextEditor.TextSnapshot.GetLineFromPosition(requestedPosition);
            int line = snapshotLine.LineNumber + 1;

            int col;

            if (bufferPosition.IsInVirtualSpace)
            {
                col = bufferPosition.VirtualSpaces;

                if (!TextEditor.Options.TabsToSpaces)
                {
                    col = col / TextEditor.Options.TabSize;
                }
            }
            else
            {
                col = requestedPosition - snapshotLine.Start;
            }

            col += 1;

            TextEditor.SetCaretTo(line, col, false, false);
        }
Esempio n. 2
0
 /// <summary>
 /// Instantiates a new Selection with a zero-width extent at the provided insertion point.
 /// </summary>
 /// <param name="insertionPoint">The location where a caret should be rendered and edits performed.</param>
 /// <param name="insertionPointAffinity">
 /// The affinity of the insertion point. This is used in places like word-wrap where one buffer position can represent both the
 /// end of one line and the beginning of the next.
 /// </param>
 public Selection(SnapshotPoint insertionPoint, PositionAffinity insertionPointAffinity = PositionAffinity.Successor)
     : this(new VirtualSnapshotPoint(insertionPoint),
            new VirtualSnapshotPoint(insertionPoint),
            new VirtualSnapshotPoint(insertionPoint),
            insertionPointAffinity)
 {
 }
Esempio n. 3
0
 public SingleSelection(IMapEditToData map, Selection selection)
 {
     this.Anchor    = new VirtualPoint(map, selection.AnchorPoint);
     this.Active    = new VirtualPoint(map, selection.ActivePoint);
     this.Insertion = new VirtualPoint(map, selection.InsertionPoint);
     this.Affinity  = selection.InsertionPointAffinity;
 }
Esempio n. 4
0
        private SnapshotPoint?MapUpToBufferGuts(SnapshotPoint currentPoint, PositionAffinity affinity, Predicate <ITextSnapshot> match)
        {
            if (match(currentPoint.Snapshot))
            {
                return(currentPoint);
            }
            FrugalList <IProjectionBufferBase> targetBuffers = this.importingProjectionBufferMap[currentPoint.Snapshot.TextBuffer];

            if (targetBuffers != null)  // targetBuffers will be null if we fell off the top
            {
                foreach (IProjectionBufferBase projBuffer in targetBuffers)
                {
                    SnapshotPoint?position = projBuffer.CurrentSnapshot.MapFromSourceSnapshot(currentPoint, affinity);
                    if (position.HasValue)
                    {
                        position = MapUpToBufferGuts(position.Value, affinity, match);
                        if (position.HasValue)
                        {
                            return(position);
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 5
0
        public CaretPosition MoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity) {
            _position = bufferPosition.Position.Position;

            return new CaretPosition(bufferPosition,
                  new MappingPointMock(bufferPosition.Position.Snapshot.TextBuffer, bufferPosition.Position),
                  PositionAffinity.Successor);
        }
        public void MoveTo(VirtualSnapshotPoint point, bool select, PositionAffinity insertionPointAffinity)
        {
            this.CheckIsValid();

            if (_selection.ActivePoint != point ||
                _selection.InsertionPoint != point ||
                (!select && _selection.AnchorPoint != point) ||
                _selection.InsertionPointAffinity != insertionPointAffinity)
            {
                var newSelection = new Selection(point, select ? _selection.AnchorPoint : point, point, insertionPointAffinity);

                if (_broker.IsOldEditor)
                {
                    _selection = newSelection;
                }
                else
                {
                    // Using the ternary here to shortcut out if the snapshots are the same. There's a similar check in the
                    // MapSelectionToCurrentSnapshot method to avoid doing unneeded work, but even spinning up the method call can be expensive.
                    _selection = (newSelection.InsertionPoint.Position.Snapshot == this.CurrentSnapshot)
                        ? newSelection
                        : MapSelectionToCurrentSnapshot(newSelection);
                }

                _broker.QueueCaretUpdatedEvent(this);
            }
        }
 public SnapshotPoint? GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity) {
     try {
         return _trackingPoint.GetPoint(targetSnapshot);
     } catch (ArgumentException) {
         return null;
     }
 }
Esempio n. 8
0
		public SnapshotPoint? GetPoint(Predicate<ITextBuffer> match, PositionAffinity affinity) {
			if (match == null)
				throw new ArgumentNullException(nameof(match));
			if (match(AnchorBuffer))
				return GetPoint(AnchorBuffer.CurrentSnapshot, affinity);
			return null;
		}
Esempio n. 9
0
 public StubTextCaret(StubWpfTextView wpfTextView)
 {
     _wpfTextView         = wpfTextView;
     this._textBuffer     = wpfTextView.TextBuffer;
     this._insertionPoint = new VirtualSnapshotPoint(new SnapshotPoint(_textBuffer.CurrentSnapshot, 0));
     this._caretAffinity  = PositionAffinity.Successor;
 }
Esempio n. 10
0
 public SnapshotPoint?GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity)
 {
     if (targetSnapshot == null)
     {
         throw new ArgumentNullException(nameof(targetSnapshot));
     }
     return(snapshotPoint.TranslateTo(targetSnapshot, trackingMode));
 }
Esempio n. 11
0
 public SnapshotPoint?GetPoint(ITextBuffer targetBuffer, PositionAffinity affinity)
 {
     if (targetBuffer == null)
     {
         throw new ArgumentNullException(nameof(targetBuffer));
     }
     return(GetPoint(targetBuffer.CurrentSnapshot, affinity));
 }
Esempio n. 12
0
 public SnapshotPoint?GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity)
 {
     try {
         return(_trackingPoint.GetPoint(targetSnapshot));
     } catch (ArgumentException) {
         return(null);
     }
 }
Esempio n. 13
0
        public CaretPosition MoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity)
        {
            _position = bufferPosition.Position.Position;

            return(new CaretPosition(bufferPosition,
                                     new MappingPointMock(bufferPosition.Position.Snapshot.TextBuffer, bufferPosition.Position),
                                     PositionAffinity.Successor));
        }
Esempio n. 14
0
		public EditorPositionState(PositionAffinity caretAffinity, int caretVirtualSpaces, int caretPosition, double viewportLeft, int topLinePosition, double topLineVerticalDistance) {
			CaretAffinity = caretAffinity;
			CaretVirtualSpaces = caretVirtualSpaces;
			CaretPosition = caretPosition;
			ViewportLeft = viewportLeft;
			TopLinePosition = topLinePosition;
			TopLineVerticalDistance = topLineVerticalDistance;
		}
Esempio n. 15
0
 public EditorPositionState(PositionAffinity caretAffinity, int caretVirtualSpaces, int caretPosition, double viewportLeft, int topLinePosition, double topLineVerticalDistance)
 {
     CaretAffinity           = caretAffinity;
     CaretVirtualSpaces      = caretVirtualSpaces;
     CaretPosition           = caretPosition;
     ViewportLeft            = viewportLeft;
     TopLinePosition         = topLinePosition;
     TopLineVerticalDistance = topLineVerticalDistance;
 }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of a <see cref="CaretPosition"/>.
        /// </summary>
        /// <param name="bufferPosition">The index of the caret. This corresponds to a gap between two characters in the underlying <see cref="ITextBuffer"/>.</param>
        /// <param name="mappingPoint">A mapping point for the caret that can be used to find its position in any buffer.</param>
        /// <param name="caretAffinity">The <see cref="PositionAffinity"/> of the caret. The caret can have an affinity with
        /// the preceding edge of the gap or the following edge of the gap.</param>
        public CaretPosition(VirtualSnapshotPoint bufferPosition, IMappingPoint mappingPoint, PositionAffinity caretAffinity)
        {
            if (mappingPoint == null)
            {
                throw new ArgumentNullException("mappingPoint");
            }

            _bufferPosition = bufferPosition;
            _mappingPoint   = mappingPoint;
            _affinity       = caretAffinity;
        }
Esempio n. 17
0
        public TextCaret(TextEditor textEditor, ITextView textView)
        {
            _textEditor = textEditor;
            _textView   = textView;

            // Set up initial values
            _caretAffinity  = PositionAffinity.Successor;
            _insertionPoint = new VirtualSnapshotPoint(new SnapshotPoint(_textView.TextSnapshot, 0));

            textEditor.Carets[0].PositionChanged += ImmediateCaretPositionChanged;
        }
 /// <param name="adornmentAffinity">Determines whether adornments based on data tags with zero-length spans
 /// will stick with preceding or succeeding text characters.</param>
 protected IntraTextAdornmentTagTransformer(
     IWpfTextView textView, ITagAggregator <TDataTag> dataTagger,
     IntraTextAdornmentTaggerDisplayMode mode,
     PositionAffinity adornmentAffinity = PositionAffinity.Successor)
     : base(textView)
 {
     this.AdornmentAffinity       = adornmentAffinity;
     this.DataTagger              = dataTagger;
     this.DataTagger.TagsChanged += HandleDataTagsChanged;
     Mode = mode;
 }
Esempio n. 19
0
		public SnapshotPoint? MapDownToSnapshot(SnapshotPoint position, PointTrackingMode trackingMode, ITextSnapshot targetSnapshot, PositionAffinity affinity) {
			if (position.Snapshot == null)
				throw new ArgumentException();
			if (targetSnapshot == null)
				throw new ArgumentNullException(nameof(targetSnapshot));

			var res = MapDownToBuffer(position, trackingMode, targetSnapshot.TextBuffer, affinity);
			if (res == null)
				return null;
			return res.Value.TranslateTo(targetSnapshot, trackingMode);
		}
Esempio n. 20
0
 public override SnapshotPoint MapToSourceSnapshot(int position, PositionAffinity affinity)
 {
     if (position < 0 || position > this.totalLength)
     {
         throw new ArgumentOutOfRangeException("position");
     }
     if (affinity < PositionAffinity.Predecessor || affinity > PositionAffinity.Successor)
     {
         throw new ArgumentOutOfRangeException("affinity");
     }
     return(this.content.MapToSourceSnapshot(this.sourceSnapshot, position, affinity));
 }
Esempio n. 21
0
 public override SnapshotPoint?MapFromSourceSnapshot(SnapshotPoint point, PositionAffinity affinity)
 {
     if (point.Snapshot != this.sourceSnapshot)
     {
         throw new ArgumentException("The point does not belong to a source snapshot of the projection snapshot");
     }
     if (affinity < PositionAffinity.Predecessor || affinity > PositionAffinity.Successor)
     {
         throw new ArgumentOutOfRangeException("affinity");
     }
     return(this.content.MapFromSourceSnapshot(this, point.Position));
 }
        private SnapshotPoint?MapUpToBufferNoTrack(ITextBuffer targetBuffer, PositionAffinity affinity)
        {
            ITextSnapshot targetSnapshot = MappingHelper.FindCorrespondingSnapshot(_root, targetBuffer);

            if (targetSnapshot != null)
            {
                //Map _anchor up to targetSnapshot (they should be concurrent snapshots)
                return(MapUpToSnapshotNoTrack(targetSnapshot, affinity));
            }

            return(null);
        }
Esempio n. 23
0
		public SnapshotPoint? MapDownToBuffer(SnapshotPoint position, PointTrackingMode trackingMode, ITextBuffer targetBuffer, PositionAffinity affinity) {
			if (position.Snapshot == null)
				throw new ArgumentException();
			if (targetBuffer == null)
				throw new ArgumentNullException(nameof(targetBuffer));

			if (position.Snapshot.TextBuffer != TopBuffer)
				return null;
			if (TopBuffer != targetBuffer)
				return null;
			return position.TranslateTo(targetBuffer.CurrentSnapshot, trackingMode);
		}
Esempio n. 24
0
 public SnapshotPoint?GetPoint(Predicate <ITextBuffer> match, PositionAffinity affinity)
 {
     if (match == null)
     {
         throw new ArgumentNullException(nameof(match));
     }
     if (match(AnchorBuffer))
     {
         return(GetPoint(AnchorBuffer.CurrentSnapshot, affinity));
     }
     return(null);
 }
Esempio n. 25
0
        private void InternalMoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition, bool captureVerticalPosition, bool raiseEvent)
        {
            if (bufferPosition.Position.Snapshot != this._wpfTextView.TextSnapshot)
            {
                throw new ArgumentException(nameof(bufferPosition));
            }
            _insertionPoint = bufferPosition;
            _caretAffinity  = caretAffinity;

            //ITextViewLine containingTextViewLine = this.GetContainingTextViewLine(bufferPosition.Position, caretAffinity);
            //VirtualSnapshotPoint bufferPosition1 = CaretElement.NormalizePosition(bufferPosition, containingTextViewLine);
            //if (bufferPosition1 != bufferPosition)
            //    raiseEvent = true;
            //this.InternalMoveCaret(bufferPosition1, caretAffinity, containingTextViewLine, captureHorizontalPosition, captureVerticalPosition, raiseEvent);
        }
Esempio n. 26
0
        /// <summary>
        /// Instantiates a new Selection.
        /// </summary>
        /// <param name="insertionPoint">The location where a caret should be rendered and edits performed.</param>
        /// <param name="anchorPoint">The location of the fixed selection endpoint, meaning if a user were to hold shift and click,
        /// this point would remain where it is.</param>
        /// <param name="activePoint">location of the movable selection endpoint, meaning if a user were to hold shift and click,
        /// this point would be changed to the location of the click.</param>
        /// <param name="insertionPointAffinity">
        /// The affinity of the insertion point. This is used in places like word-wrap where one buffer position can represent both the
        /// end of one line and the beginning of the next.
        /// </param>
        public Selection(VirtualSnapshotPoint insertionPoint,
                         VirtualSnapshotPoint anchorPoint,
                         VirtualSnapshotPoint activePoint,
                         PositionAffinity insertionPointAffinity = PositionAffinity.Successor)
        {
            if (insertionPoint.Position.Snapshot != anchorPoint.Position.Snapshot || insertionPoint.Position.Snapshot != activePoint.Position.Snapshot)
            {
                throw new ArgumentException("All points must be on the same snapshot.");
            }

            InsertionPoint         = insertionPoint;
            AnchorPoint            = anchorPoint;
            ActivePoint            = activePoint;
            InsertionPointAffinity = insertionPointAffinity;
        }
Esempio n. 27
0
        /// <summary>
        /// Constructs a new selection Element that is bound to the specified editor canvas
        /// </summary>
        /// <param name="wpfTextView">
        /// The WPF Text View that hosts this caret
        /// </param>
        public SkiaTextCaret(
            SkiaTextView wpfTextView, SkiaTextSelection selection,
            ISmartIndentationService smartIndentationService,
            IEditorFormatMap editorFormatMap,
            //IClassificationFormatMap classificationFormatMap,
            GuardedOperations guardedOperations)
        {
            // Verify
            Debug.Assert(wpfTextView != null);
            _regularBrush = new SKPaint()
            {
                Color = SKColors.Red, Typeface = wpfTextView.Typeface, TextSize = 24, LcdRenderText = true, IsAntialias = true, SubpixelText = true
            };
            _wpfTextView       = wpfTextView;
            _selection         = selection;
            _guardedOperations = guardedOperations;

            _smartIndentationService = smartIndentationService;

            // Set up initial values
            _caretAffinity  = PositionAffinity.Successor;
            _insertionPoint = new VirtualSnapshotPoint(new SnapshotPoint(_wpfTextView.TextSnapshot, 0));

            //// Set the regular caret brush
            //_editorFormatMap = editorFormatMap;

            //// store information related to classifications
            //_classificationFormatMap = classificationFormatMap;

            this.SubscribeEvents();

            this.UpdateDefaultBrushes();
            this.UpdateRegularCaretBrush();
            this.UpdateOverwriteCaretBrush();

            //Set the default values for the caret to be what they should be for a hidden caret that is not in overwrite mode.
            _caretBrush = _regularBrush;

            // Get the caret blink time from the system.  If the caret is set not to flash, the return value
            // will be -1
            _blinkInterval = CaretBlinkTimeManager.GetCaretBlinkTime();
            if (_blinkInterval > 0)
            {
                _blinkTimer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, _blinkInterval), OnTimerElapsed);
            }

            this.UpdateBlinkTimer();
        }
        private void SelectRange(int selectionStart, int selectionEnd)
        {
            SnapshotPoint startPoint = new SnapshotPoint(TextView.AdvancedTextView.TextSnapshot, selectionStart);
            SnapshotPoint endPoint   = new SnapshotPoint(TextView.AdvancedTextView.TextSnapshot, selectionEnd);

            TextSelection.Select(new VirtualSnapshotPoint(startPoint), new VirtualSnapshotPoint(endPoint));

            ITextViewLine    textViewLine = TextView.AdvancedTextView.GetTextViewLineContainingBufferPosition(endPoint);
            PositionAffinity affinity     = (textViewLine.IsLastTextViewLineForSnapshotLine || (endPoint != textViewLine.End)) ? PositionAffinity.Successor : PositionAffinity.Predecessor;

            Caret.MoveTo(endPoint, affinity);
            TextView.AdvancedTextView.ViewScroller.EnsureSpanVisible(TextSelection.StreamSelectionSpan.SnapshotSpan,
                                                                     (selectionStart <= selectionEnd)
                                                                     ? EnsureSpanVisibleOptions.MinimumScroll
                                                                     : (EnsureSpanVisibleOptions.MinimumScroll | EnsureSpanVisibleOptions.ShowStart));
        }
Esempio n. 29
0
        public SnapshotPoint?GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity)
        {
            if (targetSnapshot == null)
            {
                throw new ArgumentNullException("targetSnapshot");
            }

            SnapshotPoint?result = GetPoint(targetSnapshot.TextBuffer, affinity);

            if (result.HasValue && (result.Value.Snapshot != targetSnapshot))
            {
                result = result.Value.TranslateTo(targetSnapshot, this.trackingMode);
            }

            return(result);
        }
Esempio n. 30
0
        private void InternalMoveCaretToTextViewLine(ITextViewLine textLine, double xCoordinate, bool allowPlacementInVirtualSpace, bool captureHorizontalPosition, bool captureVerticalPosition, bool raiseEvent)
        {
            VirtualSnapshotPoint bufferPosition = textLine.GetInsertionBufferPositionFromXCoordinate(xCoordinate);

            // if placement in virtual space is not allowed, then pin the point to the closest
            // real position
            if (!allowPlacementInVirtualSpace)
            {
                bufferPosition = new VirtualSnapshotPoint(bufferPosition.Position);
            }

            //determine caret affinity. In general this is successor affinity unless the caret is at the end of a line that is word wrapped (in which case it is predecessor affinity so
            //it will be placed at the end of the word wrapped line).
            PositionAffinity caretAffinity = ((!textLine.IsLastTextViewLineForSnapshotLine) && bufferPosition.Position == textLine.End) ? PositionAffinity.Predecessor : PositionAffinity.Successor;

            this.InternalMoveCaret(bufferPosition, caretAffinity, textLine, captureHorizontalPosition, captureVerticalPosition, raiseEvent);
        }
Esempio n. 31
0
        public CaretPosition MoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition)
        {
            if (bufferPosition.Position.Snapshot != textView.TextSnapshot)
            {
                throw new ArgumentException();
            }

            Affinity = caretAffinity;
            // Don't call FilterColumn() or pressing END on an empty line won't indent it to a virtual column
            //bufferPosition = FilterColumn(bufferPosition);
            SetExplicitPosition(bufferPosition);
            if (captureHorizontalPosition)
            {
                preferredXCoordinate = Left;
            }
            SavePreferredYCoordinate();
            return(Position);
        }
 public GeneralBeforeTextBufferChangeUndoPrimitive(ITextUndoHistory undoHistory,
                                                   int oldCaretIndex,
                                                   PositionAffinity oldCaretAffinity,
                                                   int oldCaretVirtualSpaces,
                                                   int oldSelectionAnchorIndex,
                                                   int oldSelectionAnchorVirtualSpaces,
                                                   int oldSelectionActiveIndex,
                                                   int oldSelectionActiveVirtualSpaces,
                                                   TextSelectionMode oldSelectionMode)
     : base(undoHistory, oldCaretIndex, oldCaretAffinity)
 {
     _oldCaretVirtualSpaces           = oldCaretVirtualSpaces;
     _oldSelectionAnchorIndex         = oldSelectionAnchorIndex;
     _oldSelectionAnchorVirtualSpaces = oldSelectionAnchorVirtualSpaces;
     _oldSelectionActiveIndex         = oldSelectionActiveIndex;
     _oldSelectionActiveVirtualSpaces = oldSelectionActiveVirtualSpaces;
     _oldSelectionMode = oldSelectionMode;
 }
Esempio n. 33
0
 public GeneralAfterTextBufferChangeUndoPrimitive(ITextUndoHistory undoHistory,
                                                  int newCaretIndex,
                                                  PositionAffinity newCaretAffinity,
                                                  int newCaretVirtualSpaces,
                                                  int newSelectionAnchorIndex,
                                                  int newSelectionAnchorVirtualSpaces,
                                                  int newSelectionActiveIndex,
                                                  int newSelectionActiveVirtualSpaces,
                                                  TextSelectionMode newSelectionMode)
     : base(undoHistory, newCaretIndex, newCaretAffinity)
 {
     _newCaretVirtualSpaces           = newCaretVirtualSpaces;
     _newSelectionAnchorIndex         = newSelectionAnchorIndex;
     _newSelectionAnchorVirtualSpaces = newSelectionAnchorVirtualSpaces;
     _newSelectionActiveIndex         = newSelectionActiveIndex;
     _newSelectionActiveVirtualSpaces = newSelectionActiveVirtualSpaces;
     _newSelectionMode = newSelectionMode;
 }
Esempio n. 34
0
        private void InternalMoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition, bool captureVerticalPosition, bool raiseEvent)
        {
            int requestedPosition          = bufferPosition.Position;
            ITextSnapshotLine snapshotLine = _textView.TextSnapshot.GetLineFromPosition(requestedPosition);
            int line = snapshotLine.LineNumber + 1;

            int col;

            if (bufferPosition.IsInVirtualSpace)
            {
                col = bufferPosition.VirtualSpaces;
            }
            else
            {
                col = requestedPosition - snapshotLine.Start + 1;
            }

            _textEditor.SetCaretLocation(line, col, false, false);
        }
        public SnapshotPoint?GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity)
        {
            if (targetSnapshot == null)
            {
                throw new ArgumentNullException(nameof(targetSnapshot));
            }
            if (_unmappable)
            {
                return(null);
            }

            SnapshotPoint?mappedPoint = this.GetPoint(targetSnapshot.TextBuffer, affinity);

            if (mappedPoint.HasValue && (mappedPoint.Value.Snapshot != targetSnapshot))
            {
                mappedPoint = mappedPoint.Value.TranslateTo(targetSnapshot, _trackingMode);
            }

            return(mappedPoint);
        }
Esempio n. 36
0
        public SnapshotPoint?GetPoint(Predicate <ITextBuffer> match, PositionAffinity affinity)
        {
            if (match == null)
            {
                throw new ArgumentNullException("match");
            }
            ITextBuffer   anchorBuffer = this.AnchorBuffer;
            SnapshotPoint currentPoint = this.anchorPoint.TranslateTo(anchorBuffer.CurrentSnapshot, this.trackingMode);

            if (match(anchorBuffer))
            {
                return(currentPoint);
            }

            if (anchorBuffer == this.bufferGraph.TopBuffer)
            {
                // the only way to go is down
                return(this.bufferGraph.MapDownToFirstMatch(currentPoint, this.trackingMode, snapshot => (match(snapshot.TextBuffer)), affinity));
            }
            else
            {
                // guess which way to go
                if (anchorBuffer is IProjectionBufferBase)
                {
                    SnapshotPoint?tentative = this.bufferGraph.MapDownToFirstMatch(currentPoint, this.trackingMode, snapshot => (match(snapshot.TextBuffer)), affinity);
                    if (tentative.HasValue)
                    {
                        return(tentative);
                    }
                }
                // go the other way.
                if (match(this.bufferGraph.TopBuffer))
                {
                    return(this.bufferGraph.MapUpToBuffer(currentPoint, this.trackingMode, affinity, this.bufferGraph.TopBuffer));
                }
                else
                {
                    return(this.bufferGraph.MapUpToFirstMatch(currentPoint, this.trackingMode, snapshot => (match(snapshot.TextBuffer)), affinity));
                }
            }
        }
Esempio n. 37
0
		public SnapshotPoint? GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity) {
			if (targetSnapshot == null)
				throw new ArgumentNullException(nameof(targetSnapshot));
			return snapshotPoint.TranslateTo(targetSnapshot, trackingMode);
		}
Esempio n. 38
0
		ITextViewLine GetLine(SnapshotPoint bufferPosition, PositionAffinity affinity) {
			bufferPosition = bufferPosition.TranslateTo(textView.TextSnapshot, GetPointTrackingMode(affinity));
			var line = textView.GetTextViewLineContainingBufferPosition(bufferPosition);
			if (line == null)
				return null;
			if (affinity == PositionAffinity.Successor)
				return line;
			if (line.Start.Position == 0 || line.Start != bufferPosition)
				return line;
			if (bufferPosition.GetContainingLine().Start == bufferPosition)
				return line;
			return textView.GetTextViewLineContainingBufferPosition(bufferPosition - 1);
		}
Esempio n. 39
0
 public SnapshotPoint? MapUpToSnapshot(SnapshotPoint point, PointTrackingMode trackingMode, PositionAffinity affinity, ITextSnapshot targetSnapshot) {
     return point;
 }
Esempio n. 40
0
 public SnapshotPoint? MapDownToBuffer(SnapshotPoint position, PointTrackingMode trackingMode, ITextBuffer targetBuffer, PositionAffinity affinity) {
     throw new NotImplementedException();
 }
Esempio n. 41
0
 public SnapshotPoint? MapUpToFirstMatch(SnapshotPoint point, PointTrackingMode trackingMode, Predicate<ITextSnapshot> match, PositionAffinity affinity) {
     throw new NotImplementedException();
 }
 public SnapshotPoint? GetPoint(ITextBuffer targetBuffer, PositionAffinity affinity) {
     return GetPoint(targetBuffer.CurrentSnapshot, affinity);
 }
Esempio n. 43
0
		public CaretPosition MoveTo(SnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition) =>
			MoveTo(new VirtualSnapshotPoint(bufferPosition), caretAffinity, captureHorizontalPosition);
 public SnapshotPoint? GetPoint(Predicate<ITextBuffer> match, PositionAffinity affinity) {
     throw new NotImplementedException();
 }
Esempio n. 45
0
		public bool IsPointInVisualBuffer(SnapshotPoint editBufferPoint, PositionAffinity affinity) => true;
Esempio n. 46
0
		public SnapshotPoint? MapDownToFirstMatch(SnapshotPoint position, PointTrackingMode trackingMode, Predicate<ITextSnapshot> match, PositionAffinity affinity) {
			if (position.Snapshot == null)
				throw new ArgumentException();
			if (match == null)
				throw new ArgumentNullException(nameof(match));

			if (position.Snapshot.TextBuffer != TopBuffer)
				return null;
			if (!match(TopBuffer.CurrentSnapshot))
				return null;
			return position.TranslateTo(TopBuffer.CurrentSnapshot, trackingMode);
		}
Esempio n. 47
0
		public CaretPosition MoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity) =>
			MoveTo(bufferPosition, caretAffinity, true);
Esempio n. 48
0
		public SnapshotPoint? GetPoint(ITextBuffer targetBuffer, PositionAffinity affinity) {
			if (targetBuffer == null)
				throw new ArgumentNullException(nameof(targetBuffer));
			return GetPoint(targetBuffer.CurrentSnapshot, affinity);
		}
Esempio n. 49
0
 public SnapshotPoint? MapUpToBuffer(SnapshotPoint point, PointTrackingMode trackingMode, PositionAffinity affinity, ITextBuffer targetBuffer) {
     int position = 0;
     for (int i = 0; i < _buffers.Count; i++) {
         if (_buffers[i] == targetBuffer) {
             return new SnapshotPoint(point.Snapshot, position + point.Position);
         }
         position += _buffers[i].CurrentSnapshot.Length;
     }
     return null;
 }
Esempio n. 50
0
		public CaretPosition MoveTo(SnapshotPoint bufferPosition, PositionAffinity caretAffinity) =>
			MoveTo(new VirtualSnapshotPoint(bufferPosition), caretAffinity);
Esempio n. 51
0
 public SnapshotPoint? MapUpToSnapshot(SnapshotPoint point, PointTrackingMode trackingMode, PositionAffinity affinity, ITextSnapshot targetSnapshot) {
     throw new NotImplementedException();
 }
 public bool IsPointInVisualBuffer(SnapshotPoint editBufferPoint, PositionAffinity affinity) {
     throw new NotImplementedException();
 }
Esempio n. 53
0
 public SnapshotPoint? MapDownToFirstMatch(SnapshotPoint position, PointTrackingMode trackingMode, Predicate<ITextSnapshot> match, PositionAffinity affinity) {
     return position;
 }
Esempio n. 54
0
 public CaretPosition MoveTo(SnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition) {
     return MoveTo(bufferPosition, caretAffinity);
 }
Esempio n. 55
0
 public SnapshotPoint? MapUpToBuffer(SnapshotPoint point, PointTrackingMode trackingMode, PositionAffinity affinity, ITextBuffer targetBuffer) {
     return point;
 }
 public SnapshotPoint? GetPoint(ITextBuffer targetBuffer, PositionAffinity affinity)
 {
     return point;
 }
 public SnapshotPoint? GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity)
 {
     return point;
 }
 public SnapshotPoint? GetPoint(Predicate<ITextBuffer> match, PositionAffinity affinity)
 {
     return point;
 }
Esempio n. 59
0
		public CaretPosition MoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity, bool captureHorizontalPosition) {
			if (bufferPosition.Position.Snapshot != textView.TextSnapshot)
				throw new ArgumentException();

			Affinity = caretAffinity;
			// Don't call FilterColumn() or pressing END on an empty line won't indent it to a virtual column
			//bufferPosition = FilterColumn(bufferPosition);
			SetExplicitPosition(bufferPosition);
			if (captureHorizontalPosition)
				preferredXCoordinate = Left;
			SavePreferredYCoordinate();
			return Position;
		}
Esempio n. 60
0
		static PointTrackingMode GetPointTrackingMode(PositionAffinity affinity) => affinity == PositionAffinity.Predecessor ? PointTrackingMode.Negative : PointTrackingMode.Positive;