Ejemplo n.º 1
0
        public HexFormattedLineSourceImpl(TF.ITextFormatterProvider textFormatterProvider, double baseIndent, bool useDisplayMode, HexClassifier aggregateClassifier, HexAndAdornmentSequencer sequencer, VSTC.IClassificationFormatMap classificationFormatMap)
        {
            if (textFormatterProvider == null)
            {
                throw new ArgumentNullException(nameof(textFormatterProvider));
            }
            if (aggregateClassifier == null)
            {
                throw new ArgumentNullException(nameof(aggregateClassifier));
            }
            if (sequencer == null)
            {
                throw new ArgumentNullException(nameof(sequencer));
            }
            if (classificationFormatMap == null)
            {
                throw new ArgumentNullException(nameof(classificationFormatMap));
            }

            textFormatter                  = textFormatterProvider.Create(useDisplayMode);
            formattedTextCache             = new TF.FormattedTextCache(useDisplayMode);
            UseDisplayMode                 = useDisplayMode;
            BaseIndentation                = baseIndent;
            ColumnWidth                    = formattedTextCache.GetColumnWidth(classificationFormatMap.DefaultTextProperties);
            LineHeight                     = HexFormattedLineImpl.DEFAULT_TOP_SPACE + HexFormattedLineImpl.DEFAULT_BOTTOM_SPACE + formattedTextCache.GetLineHeight(classificationFormatMap.DefaultTextProperties);
            TextHeightAboveBaseline        = formattedTextCache.GetTextHeightAboveBaseline(classificationFormatMap.DefaultTextProperties);
            TextHeightBelowBaseline        = formattedTextCache.GetTextHeightBelowBaseline(classificationFormatMap.DefaultTextProperties);
            HexAndAdornmentSequencer       = sequencer;
            this.aggregateClassifier       = aggregateClassifier;
            this.classificationFormatMap   = classificationFormatMap;
            defaultTextParagraphProperties = new VSTF.TextFormattingParagraphProperties(classificationFormatMap.DefaultTextProperties, ColumnWidth * TabSize);
        }
Ejemplo n.º 2
0
        public override HexFormattedLine FormatLineInVisualBuffer(HexBufferLine line)
        {
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }

            var seqColl             = HexAndAdornmentSequencer.CreateHexAndAdornmentCollection(line);
            var linePartsCollection = CreateLinePartsCollection(seqColl, line);
            var textSource          = new HexLinePartsTextSource(linePartsCollection);

            TextLineBreak previousLineBreak = null;
            double        autoIndent        = BaseIndentation;
            int           column            = 0;
            int           linePartsIndex    = 0;
            var           lineParts         = linePartsCollection.LineParts;

            textSource.SetMaxLineLength(MAX_LINE_LENGTH);
            var textLine = textFormatter.FormatLine(textSource, column, 0, defaultTextParagraphProperties, previousLineBreak);

            int startColumn = column;
            int length      = TF.TextLineExtensions.GetLength(textLine, textSource.EndOfLine);

            column += length;

            int linePartsEnd = linePartsIndex;

            Debug.Assert(lineParts.Count == 0 || linePartsEnd < lineParts.Count);
            while (linePartsEnd < lineParts.Count)
            {
                var part = lineParts[linePartsEnd];
                linePartsEnd++;
                if (column <= part.Column + part.ColumnLength)
                {
                    break;
                }
            }
            linePartsEnd--;

            var startPos = textSource.ConvertColumnToLinePosition(startColumn);
            var endPos   = textSource.ConvertColumnToLinePosition(column);

            if (column >= textSource.Length)
            {
                endPos       = line.TextSpan.End;
                linePartsEnd = lineParts.Count - 1;
            }

            var lineSpan      = VST.Span.FromBounds(startPos, endPos);
            var formattedLine = new HexFormattedLineImpl(linePartsCollection, linePartsIndex, linePartsEnd - linePartsIndex + 1, startColumn, column, line, lineSpan, textLine, autoIndent, ColumnWidth);

            Debug.Assert(column == textSource.Length);

            return(formattedLine);
        }
Ejemplo n.º 3
0
 public HexAndAdornmentCollectionImpl(HexAndAdornmentSequencer sequencer, HexSequenceElement[] elements)
 {
     if (sequencer == null)
     {
         throw new ArgumentNullException(nameof(sequencer));
     }
     if (elements == null)
     {
         throw new ArgumentNullException(nameof(elements));
     }
     Sequencer     = sequencer;
     this.elements = elements;
 }
Ejemplo n.º 4
0
 public override HexFormattedLineSource Create(double baseIndent, bool useDisplayMode, HexClassifier aggregateClassifier, HexAndAdornmentSequencer sequencer, VSTC.IClassificationFormatMap classificationFormatMap)
 {
     if (aggregateClassifier == null)
     {
         throw new ArgumentNullException(nameof(aggregateClassifier));
     }
     if (sequencer == null)
     {
         throw new ArgumentNullException(nameof(sequencer));
     }
     if (classificationFormatMap == null)
     {
         throw new ArgumentNullException(nameof(classificationFormatMap));
     }
     return(new HexFormattedLineSourceImpl(textFormatterProvider, baseIndent, useDisplayMode, aggregateClassifier, sequencer, classificationFormatMap));
 }