コード例 #1
0
        public Boolean AddTextModifiers()
        {
            if (!_canSplitOrMerge || !TextFormattingSource.ContainsBiDiCharacters(_text))
            {
                return(false);
            }
            NormalizedSpan span = new NormalizedSpan(new TextFormattingModifier(_properties), this.StartCharacterIndex);

            span.Next     = this;
            span.Previous = this.Previous;
            if (this.Previous != null)
            {
                this.Previous.Next = span;
            }
            this.Previous = span;
            NormalizedSpan span2 = new NormalizedSpan(new TextEndOfSegment(1), this.StartCharacterIndex + this.Length);

            span2.Next     = this.Next;
            span2.Previous = this;
            if (this.Next != null)
            {
                this.Next.Previous = span2;
            }
            this.Next = span2;
            return(true);
        }
コード例 #2
0
        public IList <TextLineVisual> CreateLineVisual(Int32 lineNumber, IList <SpaceNegotiation> spaceNegotiations)
        {
            IList <ClassificationSpan> classificationSpans;
            Int32 startOfLineFromLineNumber   = _textView.TextBuffer.GetStartOfLineFromLineNumber(lineNumber);
            Int32 startOfNextLineFromPosition = _textView.TextBuffer.GetStartOfNextLineFromPosition(startOfLineFromLineNumber);
            Int32 lengthOfLineFromLineNumber  = _textView.TextBuffer.GetLengthOfLineFromLineNumber(lineNumber);
            Int32 length = 0;

            if (startOfNextLineFromPosition == startOfLineFromLineNumber)
            {
                length = _textView.TextBuffer.GetEndOfLineFromPosition(startOfLineFromLineNumber) - startOfLineFromLineNumber;
            }
            else
            {
                length = startOfNextLineFromPosition - startOfLineFromLineNumber;
            }
            if (length > 0)
            {
                classificationSpans = _classifier.GetClassificationSpans(new VersionedTextSpan(_textView.TextBuffer, startOfLineFromLineNumber, length));
            }
            else
            {
                classificationSpans = new List <ClassificationSpan>(0);
            }
            TextFormattingSource textSource = new TextFormattingSource(_textView.TextBuffer, _classificationFormatMap, startOfLineFromLineNumber, length, classificationSpans, spaceNegotiations);

            if (_textFormatter == null)
            {
                _textFormatter = TextFormatter.Create();
            }
            List <TextLine> textLines         = new List <TextLine>();
            Int32           firstCharIndex    = 0;
            TextLineBreak   previousLineBreak = null;

            while (firstCharIndex <= length)
            {
                TextLine item = _textFormatter.FormatLine(textSource, firstCharIndex, this.MaxLineWidth, _paragraphProperties, previousLineBreak);
                firstCharIndex   += item.Length;
                previousLineBreak = item.GetTextLineBreak();
                textLines.Add(item);
            }
            List <TextLineVisual> list3 = new List <TextLineVisual>();

            list3.Add(new TextLineVisual(_textView, textLines, new TextSpan(_textView.TextBuffer, startOfLineFromLineNumber, length), length - lengthOfLineFromLineNumber, textSource.VirtualCharacterPositions));
            return(list3);
        }
コード例 #3
0
		public IList<TextLineVisual> CreateLineVisual(Int32 lineNumber, IList<SpaceNegotiation> spaceNegotiations)
		{
			IList<ClassificationSpan> classificationSpans;
			Int32 startOfLineFromLineNumber = _textView.TextBuffer.GetStartOfLineFromLineNumber(lineNumber);
			Int32 startOfNextLineFromPosition = _textView.TextBuffer.GetStartOfNextLineFromPosition(startOfLineFromLineNumber);
			Int32 lengthOfLineFromLineNumber = _textView.TextBuffer.GetLengthOfLineFromLineNumber(lineNumber);
			Int32 length = 0;
			if (startOfNextLineFromPosition == startOfLineFromLineNumber)
			{
				length = _textView.TextBuffer.GetEndOfLineFromPosition(startOfLineFromLineNumber) - startOfLineFromLineNumber;
			}
			else
			{
				length = startOfNextLineFromPosition - startOfLineFromLineNumber;
			}
			if (length > 0)
			{
				classificationSpans = _classifier.GetClassificationSpans(new VersionedTextSpan(_textView.TextBuffer, startOfLineFromLineNumber, length));
			}
			else
			{
				classificationSpans = new List<ClassificationSpan>(0);
			}
			TextFormattingSource textSource = new TextFormattingSource(_textView.TextBuffer, _classificationFormatMap, startOfLineFromLineNumber, length, classificationSpans, spaceNegotiations);
			if (_textFormatter == null)
			{
				_textFormatter = TextFormatter.Create();
			}
			List<TextLine> textLines = new List<TextLine>();
			Int32 firstCharIndex = 0;
			TextLineBreak previousLineBreak = null;
			while (firstCharIndex <= length)
			{
				TextLine item = _textFormatter.FormatLine(textSource, firstCharIndex, this.MaxLineWidth, _paragraphProperties, previousLineBreak);
				firstCharIndex += item.Length;
				previousLineBreak = item.GetTextLineBreak();
				textLines.Add(item);
			}
			List<TextLineVisual> list3 = new List<TextLineVisual>();
			list3.Add(new TextLineVisual(_textView, textLines, new TextSpan(_textView.TextBuffer, startOfLineFromLineNumber, length), length - lengthOfLineFromLineNumber, textSource.VirtualCharacterPositions));
			return list3;
		}