/// <summary>
		/// Initializes a new instance of the <see cref="VersionedTextSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="buffer"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		public VersionedTextSpan(TextBuffer buffer, Span span)
		{
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			this.Construct(buffer, buffer.Version, span.Start, span.Length, SpanTrackingMode.EdgeExclusive);
		}
示例#2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Span"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="span"/> is <see langword="null"/>.
		/// </exception>
		public Span(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}

			_start = span._start;
			_length = span._length;
		}
示例#3
0
		/*
		 * Intersects
		 */

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		public virtual Boolean Intersects(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}

			if (this == span)
			{
				return true;
			}

			if (span.Start < this.End)
			{
				return (span.End > this.Start);
			}

			return false;
		}
示例#4
0
		/*
		 * Intersection
		 */

		/// <summary>
		/// </summary>
		public Span Intersection(Span span)
		{
			if (this.Intersects(span))
			{
				Int32 start = Math.Max(this.Start, span.Start);
				Int32 num2 = Math.Min(this.End, span.End);
				return new Span(start, num2 - start);
			}

			return null;
		}
示例#5
0
		/*
		 * Contains
		 */

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="span"/> is <see langword="null"/>.
		/// </exception>
		public Boolean Contains(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}

			if (span.Start >= this.Start)
			{
				return (span.End <= this.End);
			}

			return false;
		}
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="span"/> is less than zero or greater than the buffer length for the associated <see cref="ISourceEditorView"/>.</para>
		/// </exception>
		public Geometry GetMarkerGeometry(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			if ((span.Start < 0) || (span.End > _editorView.TextBuffer.Length))
			{
				throw new ArgumentOutOfRangeException("span");
			}
			if (span.IsEmpty)
			{
				return null;
			}
			PathGeometry geometry = new PathGeometry();
			geometry.FillRule = FillRule.Nonzero;
			IList<ITextLine> textLines = _editorView.TextLines;
			if (textLines.Count == 0)
			{
				return null;
			}
			if ((span.Start > base.LastRenderedCharacter) || (span.End < base.FirstRenderedCharacter))
			{
				return null;
			}
			ITextLine item = null;
			ITextLine textLineClosestTo = null;
			if (span.Start < base.FirstRenderedCharacter)
			{
				item = textLines[0];
			}
			if (span.End > base.LastRenderedCharacter)
			{
				textLineClosestTo = textLines[textLines.Count - 1];
			}
			if (item == null)
			{
				item = base.GetTextLineClosestTo(span.Start);
			}
			if (textLineClosestTo == null)
			{
				textLineClosestTo = base.GetTextLineClosestTo(span.End);
			}
			if (item == textLineClosestTo)
			{
				foreach (TextBounds bounds in item.GetTextBounds(span))
				{
					RectangleGeometry geometry2 = new RectangleGeometry(new Rect(bounds.Left - 0.2, bounds.Top - 1, bounds.Width + 0.4, bounds.Height + 1), 0.6, 0.6);
					geometry2.Freeze();
					geometry.AddGeometry(geometry2);
				}
			}
			else
			{
				foreach (TextBounds bounds2 in item.GetTextBounds(span))
				{
					RectangleGeometry geometry3 = new RectangleGeometry(new Rect(bounds2.Left - 0.2, bounds2.Top - 1, bounds2.Width + 0.4, bounds2.Height + 1), 0.6, 0.6);
					geometry3.Freeze();
					geometry.AddGeometry(geometry3);
				}
				Int32 num = textLines.IndexOf(item) + 1;
				Int32 index = textLines.IndexOf(textLineClosestTo);
				for (Int32 i = num; i < index; i++)
				{
					ITextLine line3 = textLines[i];
					RectangleGeometry geometry4 = new RectangleGeometry(new Rect(-0.2, line3.VerticalOffset - 0.2, line3.Width, line3.Height + 0.4), 0.6, 0.6);
					geometry4.Freeze();
					geometry.AddGeometry(geometry4);
				}
				foreach (TextBounds bounds3 in textLineClosestTo.GetTextBounds(span))
				{
					RectangleGeometry geometry5 = new RectangleGeometry(new Rect(bounds3.Left - 0.2, bounds3.Top - 1, bounds3.Width + 0.4, bounds3.Height + 1), 0.6, 0.6);
					geometry5.Freeze();
					geometry.AddGeometry(geometry5);
				}
			}
			geometry.Freeze();
			return geometry.GetOutlinedPathGeometry();
		}
示例#7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TextSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException"><paramref name="span"/> is <see langword="null"/>.</exception>
		public TextSpan(TextBuffer textBuffer, Span span, SpanTrackingMode trackingMode)
			: base(span)
		{
			this.Initialize(textBuffer, trackingMode);
		}
示例#8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TextSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException"><paramref name="span"/> is <see langword="null"/>.</exception>
		public TextSpan(TextBuffer textBuffer, Span span)
			: this(textBuffer, span, SpanTrackingMode.EdgeExclusive)
		{
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="TextViewLayoutChangedEventArgs"/> class.
		/// </summary>
		public TextViewLayoutChangedEventArgs(Span changeSpan)
		{
			_changeSpan = changeSpan;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="VersionedTextSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="buffer"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="version"/> is <see langword="null"/>.</para>
		/// </exception>
		public VersionedTextSpan(TextBuffer buffer, ITextVersion version, Span span, SpanTrackingMode trackingMode)
		{
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (version == null)
			{
				throw new ArgumentNullException("version");
			}
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			this.Construct(buffer, buffer.Version, span.Start, span.Length, trackingMode);
		}
示例#11
0
		private void ExpandBounds(ITextLine line, Span span, ref Double leftEdge, ref Double rightEdge)
		{
			foreach (TextBounds bounds in line.GetTextBounds(span))
			{
				if (bounds.Left < leftEdge)
				{
					leftEdge = bounds.Left;
				}
				if (bounds.Right > rightEdge)
				{
					rightEdge = bounds.Right;
				}
			}
		}
示例#12
0
		/// <summary>
		/// </summary>
		/// <param name="span"></param>
		/// <param name="horizontalPadding"></param>
		/// <param name="verticalPadding"></param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="span"/> is <see langword="null"/>.
		/// </exception>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para>
		///		<paramref name="verticalPadding"/> is not a number of is less than zero.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="horizontalPadding"/> is not a number or is less than zero.
		/// </para>
		/// -or-
		/// <para>
		///		span.End > textView.TextBuffer.Length
		/// </para>
		/// </exception>
		public Boolean EnsureSpanVisible(Span span, Double horizontalPadding, Double verticalPadding)
		{
			if (Double.IsNaN(horizontalPadding) || (horizontalPadding < 0))
			{
				throw new ArgumentOutOfRangeException("horizontalPadding");
			}
			if (Double.IsNaN(verticalPadding) || (verticalPadding < 0))
			{
				throw new ArgumentOutOfRangeException("verticalPadding");
			}
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			if (span.End > _textView.TextBuffer.Length)
			{
				throw new ArgumentOutOfRangeException("span");
			}
			IList<ITextLine> textLines = _textView.TextLines;
			if (textLines.Count == 0)
			{
				return false;
			}
			Boolean flag = span.Start < textLines[0].LineSpan.Start;
			ITextLine line = textLines[textLines.Count - 1];
			Boolean flag2 = (span.End > line.LineSpan.End) || ((span.End == line.LineSpan.End) && ((span.End != _textView.TextBuffer.Length) || (line.NewlineLength != 0)));
			if (flag)
			{
				if (flag2)
				{
					return false;
				}
				_textView.DisplayLine(_textView.TextBuffer.GetLineNumberFromPosition(span.Start), verticalPadding, ViewRelativePosition.Top);
			}
			else if (flag2)
			{
				_textView.DisplayLine(_textView.TextBuffer.GetLineNumberFromPosition(span.End), verticalPadding, ViewRelativePosition.Bottom);
			}
			else if (this.GetTextLineContaining(span.Start).VerticalOffset < verticalPadding)
			{
				_textView.DisplayLine(_textView.TextBuffer.GetLineNumberFromPosition(span.Start), verticalPadding, ViewRelativePosition.Top);
			}
			else
			{
				ITextLine line3 = this.GetTextLineContaining(span.End);
				if (((line3.VerticalOffset + line3.Height) + verticalPadding) > _textView.ViewportHeight)
				{
					_textView.DisplayLine(_textView.TextBuffer.GetLineNumberFromPosition(span.End), verticalPadding, ViewRelativePosition.Bottom);
				}
			}
			Boolean flag3 = false;
			ITextLine textLineContaining = this.GetTextLineContaining(span.Start);
			if (textLineContaining == null)
			{
				return flag3;
			}
			ITextLine line5 = this.GetTextLineContaining(span.End);
			if (line5 == null)
			{
				return flag3;
			}
			flag3 = (textLineContaining.VerticalOffset >= verticalPadding) && (((line5.VerticalOffset + line5.Height) + verticalPadding) <= _textView.ViewportHeight);
			Double maxValue = Double.MaxValue;
			Double minValue = Double.MinValue;
			if (textLineContaining == line5)
			{
				this.ExpandBounds(textLineContaining, span, ref maxValue, ref minValue);
			}
			else
			{
				this.ExpandBounds(textLineContaining, new Span(span.Start, textLineContaining.LineSpan.End - span.Start), ref maxValue, ref minValue);
				this.ExpandBounds(line5, new Span(line5.LineSpan.Start, span.End - line5.LineSpan.Start), ref maxValue, ref minValue);
				Int32 indexOfTextLine = this.GetIndexOfTextLine(textLineContaining);
				Int32 num4 = this.GetIndexOfTextLine(line5);
				for (Int32 i = indexOfTextLine + 1; i < num4; i++)
				{
					ITextLine line6 = textLines[i];
					this.ExpandBounds(line6, new Span(line6.LineSpan.Start, line6.LineSpan.Length), ref maxValue, ref minValue);
				}
			}
			if (maxValue == Double.MaxValue)
			{
				return (flag3 && (horizontalPadding == 0));
			}
			Double viewportHorizontalOffset = _textView.ViewportHorizontalOffset;
			Double num7 = viewportHorizontalOffset - (maxValue - horizontalPadding);
			Double num8 = (minValue + horizontalPadding) - (viewportHorizontalOffset + _textView.ViewportWidth);
			if (num7 > 0)
			{
				if (num8 <= 0)
				{
					_textView.ScrollViewportHorizontally((viewportHorizontalOffset - num7) - _textView.ViewportHorizontalOffset);
				}
			}
			else if (num8 > 0)
			{
				_textView.ScrollViewportHorizontally((viewportHorizontalOffset + num8) - _textView.ViewportHorizontalOffset);
			}
			Double num9 = _textView.ViewportHorizontalOffset - viewportHorizontalOffset;
			maxValue += num9;
			minValue += num9;
			return ((flag3 && (maxValue >= horizontalPadding)) && ((_textView.ViewportWidth - minValue) >= horizontalPadding));
		}
		private void CreateNormalizedSpans()
		{
			Int32 startCharacterIndex = _startCharacterIndex;
			Int32 length = _text.Length;
			NormalizedSpan span = new NormalizedSpan("", "_gap_", _startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
			_startNode = span;
			for (Int32 i = 0; i < _classificationSpanList.Count; i++)
			{
				ClassificationSpan span2 = _classificationSpanList[i];
				Span span3 = span2.Span();
				if (span3.Start >= (_startCharacterIndex + length))
				{
					break;
				}
				Int32 num4 = span3.Start - startCharacterIndex;
				if (num4 > 0)
				{
					NormalizedSpan span4 = new NormalizedSpan(_text.Substring(startCharacterIndex - _startCharacterIndex, span3.Start - startCharacterIndex), "_gap_", startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
					span = span.AddNode(span4);
					startCharacterIndex += num4;
				}
				else if (num4 < 0)
				{
					Int32 num5 = span3.Length + num4;
					if (num5 <= 0)
					{
						continue;
					}
					span3 = new Span(startCharacterIndex, num5);
				}
				if (span3.Length > 0)
				{
					Int32 num6 = startCharacterIndex - _startCharacterIndex;
					TextFormattingRunProperties textProperties = _classificationFormatMap.GetTextProperties(span2.Classification);
					if ((span3.Length + num6) > length)
					{
						Int32 num7 = length - num6;
						NormalizedSpan span5 = new NormalizedSpan(_text.Substring(span3.Start - _startCharacterIndex, num7), span2.Classification, span3.Start, textProperties);
						span = span.AddNode(span5);
						startCharacterIndex = _startCharacterIndex + length;
						break;
					}
					NormalizedSpan span6 = new NormalizedSpan(_text.Substring(span3.Start - _startCharacterIndex, span3.Length), span2.Classification, span3.Start, textProperties);
					span = span.AddNode(span6);
					startCharacterIndex += span3.Length;
				}
			}
			if (startCharacterIndex < (_startCharacterIndex + length))
			{
				Int32 num8 = length - (startCharacterIndex - _startCharacterIndex);
				NormalizedSpan span7 = new NormalizedSpan(_text.Substring(startCharacterIndex - _startCharacterIndex, num8), "_gap_", startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
				span = span.AddNode(span7);
			}
			if (_startNode.Next != null)
			{
				_startNode = _startNode.Next;
				_startNode.Previous = null;
			}
		}
示例#14
0
		public ReadOnlyCollection<textView.TextBounds> GetTextBounds(Span span)
		{
			var list = new List<textView.TextBounds>();
			Span span2 = span;
			if (!this.LineSpan.Contains(span))
			{
				span2 = this.LineSpan.Intersection(span);
			}
			if (span2 != null)
			{
				Int32 lineRelativePosition = this.GetLineRelativePosition(span2.Start);
				Int32 num2 = this.GetLineRelativePosition(span2.End);
				for (Int32 i = this.GetIndexOfLineContaining(lineRelativePosition); i < _textLines.Count; i++)
				{
					TextLine textLine = _textLines[i];
					Int32 num5 = _textLineStartIndices[i];
					Double horizontalOffset = _textLineDistances[i];
					Int32 startIndex = lineRelativePosition;
					if (startIndex < num5)
					{
						startIndex = num5;
					}
					Int32 endIndex = num2;
					if (endIndex > (num5 + textLine.Length))
					{
						endIndex = num5 + textLine.Length;
					}
					list.AddRange(this.GetTextBoundsOnLine(textLine, horizontalOffset, startIndex, endIndex));
					if (num2 <= (num5 + textLine.Length))
					{
						break;
					}
				}
				if ((span.End >= this.LineSpan.End) && (this.NewlineLength > 0))
				{
					list.Add(new textView.TextBounds((this.HorizontalOffset + this.Width) - 7, this.VerticalOffset, 7, this.Height));
				}
			}
			return list.AsReadOnly();
		}
示例#15
0
		/// <summary>
		/// </summary>
		public void EnsureVisible(Double verticalPadding, ViewRelativePosition relativeTo)
		{
			if (_editorView.TextLines.Count == 0)
			{
				_ensureVisiblePending = true;
			}
			else
			{
				Span span = new Span(this.Position.TextInsertionIndex, 0);
				if (!_textViewHelper.EnsureSpanVisible(span, 2 + base.Width, verticalPadding))
				{
					_textViewHelper.EnsureSpanVisible(span, 0, 0);
				}
			}
		}