Exemple #1
0
 internal MergedTextRunProperties(
     TextRunProperties runProperties,
     TextDecorationCollection textDecorations)
 {
     _runProperties   = runProperties;
     _textDecorations = textDecorations;
 }
Exemple #2
0
 /// <summary>
 /// Creates WPF Run instances that can be used for TextBlock.Inlines.
 /// </summary>
 public TextRunProperties[] CreateRuns()
 {
     TextRunProperties[] runs = new TextRunProperties[stateChanges.Count];
     for (int i = 0; i < runs.Length; i++)
     {
         int               startOffset = stateChangeOffsets[i];
         int               endOffset   = i + 1 < stateChangeOffsets.Count ? stateChangeOffsets[i + 1] : text.Length;
         string            runString   = text.Substring(startOffset, endOffset - startOffset);
         TextRunProperties r           = new TextRunProperties();
         HighlightingState state       = stateChanges[i];
         r.Foreground = state.Foreground;
         r.Background = state.Background;
         if (state.Weight != null)
         {
             r.FontWeight = state.Weight.Value;
         }
         if (state.Family != null)
         {
             r.FontFamily = state.Family.Value;
         }
         if (state.Style != null)
         {
             r.FontStyle = state.Style.Value;
         }
         runs[i] = r;
     }
     return(runs);
 }
Exemple #3
0
 public void AddContents(string text, TextRunProperties props)
 {
     for (int i = 0; i < text.Length; i++)
     {
         AddContents(new TextCharacters(text, i, text.Length - i, props));
     }
 }
 public ListParagraphProperties(TextMarkerProperties textMarkerProperties, TextRunProperties textRunProperties, bool firstLineInParagraph)
 {
     TextMarkerProperties     = textMarkerProperties;
     DefaultTextRunProperties = textRunProperties;
     FirstLineInParagraph     = firstLineInParagraph;
     TextDecorations          = new TextDecorationCollection();
 }
Exemple #5
0
        public TextLayer(TextView parent, TextDocument textDocument) : base(parent)
        {
            Document = textDocument;

            elementGenerators = new ObserveAddRemoveCollection <VisualLineElementGenerator>(ElementGenerator_Added, ElementGenerator_Removed);
            lineTransformers  = new ObserveAddRemoveCollection <IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed);

            heightTree = new HeightTree(textDocument, Skin.DefaultFont.Size);
            lines      = new Dictionary <DocumentLine, VisualLine>();

            GlobalTextRunProperties = new TextRunProperties {
                Foreground = Color.Black
            };

            lineTransformers = new ObserveAddRemoveCollection <IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed);

            HighlightingDefinition = HighlightingManager.DefaultHighlightingManager.Instance.GetDefinition("C#");

            var colorizer = new HighlightingColorizer(highlightingDefinition.MainRuleSet);

            lineTransformers.Add(colorizer);

            weakLineTracker = WeakLineTracker.Register(textDocument, this);

            RebuildDocument();
        }
Exemple #6
0
 public LinePart(int column, Span span, IAdornmentElement adornmentElement)
 {
     this.Column            = column;
     this.Span              = span;
     this.AdornmentElement  = adornmentElement;
     this.TextRunProperties = null;
 }
 // Token: 0x06006A2C RID: 27180 RVA: 0x001E3B87 File Offset: 0x001E1D87
 internal InlineObjectRun(int cch, UIElement element, TextRunProperties textProps, TextParagraph host)
 {
     this._cch               = cch;
     this._textProps         = textProps;
     this._host              = host;
     this._inlineUIContainer = (InlineUIContainer)LogicalTreeHelper.GetParent(element);
 }
Exemple #8
0
        /// <summary>
        /// Updates properties from a change to the format map. Also forces a redraw of all the time stamped lines.
        /// </summary>
        private void SetFontFromClassification()
        {
            var font = _formatMap.GetTextProperties(_lineNumberClassification);

            _showHours        = _textView.Options.GetOptionValue(TimeStampMarginShowHours.StaticKey);
            _showMilliseconds = _textView.Options.GetOptionValue(TimeStampMarginShowMilliseconds.StaticKey);

            // In the line number margin, we always enforce a 100% opacity.
            // This is to prevent mixing of the line number's background color
            // with its parent's background when the background brush of the
            // line number classified item is not opaque.
            Brush backgroundBrush = font.BackgroundBrush;

            if (backgroundBrush.Opacity != 1.0)
            {
                backgroundBrush         = backgroundBrush.Clone();
                backgroundBrush.Opacity = 1.0;
                backgroundBrush.Freeze();

                font = font.SetBackgroundBrush(backgroundBrush);
            }

            base.Background = backgroundBrush;
            _formatting     = font;
            this.SetClearTypeHint(font);
            this.DetermineMarginWidth();

            // Reformat all the lines
            _translatedCanvas.Children.Clear();
            this.UpdateLineNumbers();
        }
        /// <inheritdoc />
        public override TextRunProperties ModifyProperties(TextRunProperties properties)

        {
            Debug.Write($"KFT: {nameof(ModifyProperties)} called with ");
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (properties != null)
            {
                PropertiesDesc(s => Debug.Write("KFT " + s), properties);
            }
            Debug.WriteLine("");
            if (properties != null)
            {
                return(new TextRunProperties1(
                           properties.BackgroundBrush ?? Properties.BackgroundBrush,
                           properties.BaselineAlignment,
                           properties.CultureInfo ?? Properties.CultureInfo,
                           properties.FontHintingEmSize, properties.FontRenderingEmSize,
                           properties.ForegroundBrush ?? Properties.ForegroundBrush,
                           properties.TextDecorations ?? Properties.TextDecorations,
                           properties.TextEffects ?? properties.TextEffects,
                           properties.Typeface ?? Properties.Typeface));
            }

            return(Properties);
        }
        public FrameworkElement Context(BlockColoring coloring, TextRunProperties properties)
        {
            Genero4glCodeBlock         item  = this;
            Stack <Genero4glCodeBlock> stack = new Stack <Genero4glCodeBlock>();

            do
            {
                if (item.type == BlockType.Root)
                {
                    break;
                }
                if (item.type != BlockType.Unknown)
                {
                    stack.Push(item);
                }
                item = item.parent;
            }while (item.type != BlockType.Namespace);
            int           repeatCount = 0;
            StringBuilder builder     = new StringBuilder();

            while (stack.Count != 0)
            {
                item = stack.Pop();
                builder.Append(item.Statement(repeatCount));

                repeatCount += 2;
                if (stack.Count != 0)
                {
                    builder.Append('\r');
                    builder.Append(' ', repeatCount);
                }
            }
            return(new TextBlob(FormatStatements(builder.ToString(), coloring, properties)));
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="characterString"></param>
        /// <param name="length"></param>
        /// <param name="textRunProperties"></param>
        /// <param name="token"></param>
        /// <param name="node"></param>
        /// <exception cref="InvalidOperationException"></exception>
        public SyntaxTokenTextCharacters(string characterString, int length,
                                         TextRunProperties textRunProperties, SyntaxToken token, SyntaxNode node) : base(characterString, 0, length, textRunProperties, token.Span)
        {
            Token = token;
#if SUPPORTVB
            Microsoft.CodeAnalysis.VisualBasic.SyntaxKind kind;
#endif
            SyntaxKind csKind;
            switch (token.Language)
            {
#if SUPPORTVB
            case LanguageNames.VisualBasic:
                kind = VisualBasicExtensions.Kind(token);
                if (kind == Microsoft.CodeAnalysis.VisualBasic.SyntaxKind.None)
                {
                    throw new AppInvalidOperationException(token.Span.ToString());
                }
                break;
#endif
            case LanguageNames.CSharp:
                csKind = Token.Kind();
                if (csKind == SyntaxKind.None)
                {
                    throw new InvalidOperationException(token.Span.ToString());
                }
                break;
            }

            Node = node;
        }
Exemple #12
0
 /// <summary>
 /// Constructs a TextLine from a simple text.
 /// </summary>
 public static TextLine PrepareText(TextFormatter formatter, string text, TextRunProperties properties)
 {
     if (formatter == null)
     {
         throw new ArgumentNullException("formatter");
     }
     if (text == null)
     {
         throw new ArgumentNullException("text");
     }
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     return(formatter.FormatLine(
                new SimpleTextSource(text, properties),
                0,
                32000,
                new VisualLineTextParagraphProperties {
         defaultTextRunProperties = properties,
         textWrapping = TextWrapping.NoWrap,
         tabSize = 40
     },
                null));
 }
Exemple #13
0
        internal void Update(
            string text,
            ITextViewLine line,
            IWpfTextView view,
            TextRunProperties formatting,
            double marginWidth,
            double verticalOffset)
        {
            LineTag = line.IdentityTag;

            if (_text == null || !string.Equals(_text, text, StringComparison.Ordinal))
            {
                _text          = text;
                _formattedText = new FormattedText(
                    _text,
                    CultureInfo.InvariantCulture,
                    FlowDirection.LeftToRight,
                    formatting.Typeface,
                    formatting.FontRenderingEmSize,
                    formatting.ForegroundBrush);

                _horizontalOffset = Math.Round(marginWidth - _formattedText.Width);
                InvalidateVisual();
            }

            var num = line.TextTop - view.ViewportTop + verticalOffset;

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (num == _verticalOffset)
            {
                return;
            }
            _verticalOffset = num;
            InvalidateVisual();
        }
Exemple #14
0
 public LinePart(int column, Span span, TextRunProperties textRunProperties)
 {
     this.Column            = column;
     this.Span              = span;
     this.AdornmentElement  = null;
     this.TextRunProperties = textRunProperties;
 }
Exemple #15
0
        private static CultureInfo GetNumberCulture(TextRunProperties properties, out NumberSubstitutionMethod method, out bool ignoreUserOverride)
        {
            ignoreUserOverride = true;
            NumberSubstitution sub = properties.NumberSubstitution;

            if (sub == null)
            {
                method = NumberSubstitutionMethod.AsCulture;
                return(CultureMapper.GetSpecificCulture(properties.CultureInfo));
            }

            method = sub.Substitution;

            switch (sub.CultureSource)
            {
            case NumberCultureSource.Text:
                return(CultureMapper.GetSpecificCulture(properties.CultureInfo));

            case NumberCultureSource.User:
                ignoreUserOverride = false;
                return(CultureInfo.CurrentCulture);

            case NumberCultureSource.Override:
                return(sub.CultureOverride);
            }

            return(null);
        }
 /// <summary>
 /// Constructs a TextLine from a simple text.
 /// </summary>
 internal static TextLine PrepareText(TextFormatter formatter, string text, TextRunProperties properties)
 {
     if (formatter == null)
     {
         throw new ArgumentNullException(nameof(formatter));
     }
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     if (properties == null)
     {
         throw new ArgumentNullException(nameof(properties));
     }
     return(formatter.FormatLine(
                new SimpleTextSource(text, properties),
                0,
                32000,
                new TextParagraphProperties
     {
         DefaultTextRunProperties = properties,
         TextWrapping = TextWrapping.NoWrap,
         DefaultIncrementalTab = 40
     }));
 }
Exemple #17
0
 public FormattedTextSource(ReadOnlySlice <char> text, TextRunProperties defaultProperties,
                            IReadOnlyList <ValueSpan <TextRunProperties> > textModifier)
 {
     _text = text;
     _defaultProperties = defaultProperties;
     _textModifier      = textModifier;
 }
        public TextRunProperties GetHighlightedTextRunProperties(TextRunProperties defaultHighlightedTextRunProperties)
        {
            var item = (CompletionItem as DescriptionModifyingCompletionItem)?.CompletionItem ?? CompletionItem;

            return((item.CompletionProvider as ICustomCompletionItemFormatter)?.GetHighlightedTextRunProperties(item, defaultHighlightedTextRunProperties)
                   ?? defaultHighlightedTextRunProperties);
        }
Exemple #19
0
 /// <summary>
 /// Creates a new VisualLineElementTextRunProperties instance that copies its values
 /// from the specified <paramref name="textRunProperties"/>.
 /// For the <see cref="TextDecorations"/> and <see cref="TextEffects"/> collections, deep copies
 /// are created if those collections are not frozen.
 /// </summary>
 public VisualLineElementTextRunProperties(TextRunProperties textRunProperties)
 {
     if (textRunProperties == null)
     {
         throw new ArgumentNullException("textRunProperties");
     }
     backgroundBrush     = textRunProperties.BackgroundBrush;
     baselineAlignment   = textRunProperties.BaselineAlignment;
     cultureInfo         = textRunProperties.CultureInfo;
     fontHintingEmSize   = textRunProperties.FontHintingEmSize;
     fontRenderingEmSize = textRunProperties.FontRenderingEmSize;
     foregroundBrush     = textRunProperties.ForegroundBrush;
     typeface            = textRunProperties.Typeface;
     textDecorations     = textRunProperties.TextDecorations;
     if (textDecorations != null && !textDecorations.IsFrozen)
     {
         textDecorations = textDecorations.Clone();
     }
     textEffects = textRunProperties.TextEffects;
     if (textEffects != null && !textEffects.IsFrozen)
     {
         textEffects = textEffects.Clone();
     }
     typographyProperties = textRunProperties.TypographyProperties;
     numberSubstitution   = textRunProperties.NumberSubstitution;
 }
Exemple #20
0
 static VisualElement()
 {
     Symbol        = GetSymbol();
     runProperties = TextConfiguration.GetGlobalTextRunProperties();
     textSource    = new SimpleTextSource(Symbol, runProperties);
     charSize      = TextConfiguration.GetCharSize();
 }
Exemple #21
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dcp">Text position of the inline object in the text array.</param>
 /// <param name="cch">Number of text position in the text array occupied by the inline object.</param>
 /// <param name="element">UIElement representing the inline object.</param>
 /// <param name="textProps">Text run properties for the inline object.</param>
 /// <param name="host">TextBlock element - the host of the inline object.</param>
 internal InlineObject(int dcp, int cch, UIElement element, TextRunProperties textProps, System.Windows.Controls.TextBlock host)
 {
     _dcp       = dcp;
     _cch       = cch;
     _element   = element;
     _textProps = textProps;
     _host      = host;
 }
Exemple #22
0
 internal MergedTextRunProperties(
     TextRunProperties runProperties,
     TextDecorationCollection textDecorations)
 {
     _runProperties   = runProperties;
     _textDecorations = textDecorations;
     PixelsPerDip     = _runProperties.PixelsPerDip;
 }
Exemple #23
0
 // Token: 0x0600661F RID: 26143 RVA: 0x001CB699 File Offset: 0x001C9899
 internal InlineObject(int dcp, int cch, UIElement element, TextRunProperties textProps, TextBlock host)
 {
     this._dcp       = dcp;
     this._cch       = cch;
     this._element   = element;
     this._textProps = textProps;
     this._host      = host;
 }
Exemple #24
0
 public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
 {
     if (ForegroundBrush != null)
     {
         TextRunProperties.SetForegroundBrush(ForegroundBrush);
     }
     return(base.CreateTextRun(startVisualColumn, context));
 }
Exemple #25
0
        public static bool Equals(TextRunProperties a, TextRunProperties b)
        {
            if (a == b)
            {
                return(true);
            }
            if (a == null || b == null)
            {
                return(false);
            }

            if (a.FontHintingEmSize != b.FontHintingEmSize)
            {
                return(false);
            }
            if (a.FontRenderingEmSize != b.FontRenderingEmSize)
            {
                return(false);
            }
            if (a.TextDecorations != b.TextDecorations)                 // We don't use it so this is enough
            {
                return(false);
            }
            if (a.TextEffects != b.TextEffects)             // We don't use it so this is enough
            {
                return(false);
            }
            if (!a.CultureInfo.Equals(b.CultureInfo))
            {
                return(false);
            }
            if (!a.Typeface.Equals(b.Typeface))
            {
                return(false);
            }
            if (!Equals(a.BackgroundBrush, b.BackgroundBrush))
            {
                return(false);
            }
            if (!Equals(a.ForegroundBrush, b.ForegroundBrush))
            {
                return(false);
            }
            if (a.BaselineAlignment != b.BaselineAlignment)
            {
                return(false);
            }
            if (!Equals(a.NumberSubstitution, b.NumberSubstitution))
            {
                return(false);
            }
            if (!Equals(a.TypographyProperties, b.TypographyProperties))
            {
                return(false);
            }

            return(true);
        }
 public TextEmbeddedObject1(CharacterBufferReference characterBufferReference, int length, TextRunProperties properties,
                            bool hasFixedSize, UIElement uiElement)
 {
     CharacterBufferReference = characterBufferReference;
     Length       = length;
     Properties   = properties;
     HasFixedSize = hasFixedSize;
     UiElement    = uiElement;
 }
Exemple #27
0
        public static TextRunProperties GetGlobalTextRunProperties()
        {
            if (textRunProperties == null)
            {
                textRunProperties = CreateGlobalTextRunProperties();
            }

            return(textRunProperties);
        }
 public TabGlyphRun(TabTextElement element, TextRunProperties properties)
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.properties = properties;
     this.element    = element;
 }
        public FormattableTextSource(string text, TextRunProperties defaultStyle,
                                     ReadOnlySlice <ValueSpan <TextRunProperties> > styleSpans)
        {
            _text = text.AsMemory();

            _defaultStyle = defaultStyle;

            _styleSpans = styleSpans;
        }
Exemple #30
0
 /// <inheritdoc/>
 public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
 {
     TextRunProperties.SetForegroundBrush(context.TextView.LinkTextForegroundBrush);
     TextRunProperties.SetBackgroundBrush(context.TextView.LinkTextBackgroundBrush);
     if (context.TextView.LinkTextUnderline)
     {
         TextRunProperties.SetTextDecorations(TextDecorations.Underline);
     }
     return(base.CreateTextRun(startVisualColumn, context));
 }
Exemple #31
0
        public TextRunProperties Apply(TextRunProperties textRunProperties)
        {
             if (Foreground != null)
                textRunProperties.Foreground = Foreground.Value;

            if (Background != null)
                textRunProperties.Background = Background.Value;

            if (FontWeight != null)
                textRunProperties.FontWeight = FontWeight.Value;

            if (FontStyle != null)
                textRunProperties.FontStyle = FontStyle.Value;

            return textRunProperties;
        }
Exemple #32
0
        public TextLayer(TextView parent, TextDocument textDocument)
            : base(parent)
        {
            Document = textDocument;

            elementGenerators = new ObserveAddRemoveCollection<VisualLineElementGenerator>(ElementGenerator_Added, ElementGenerator_Removed);
            lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed);

            heightTree = new HeightTree(textDocument, 16); //TODO Skin.DefaultFont.Size
            lines = new Dictionary<DocumentLine, VisualLine>();

            GlobalTextRunProperties = new TextRunProperties { Foreground = Color.Black};

            lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added,LineTransformer_Removed);

            HighlightingDefinition = HighlightingManager.DefaultHighlightingManager.Instance.GetDefinition("C#");

            var colorizer = new HighlightingColorizer(highlightingDefinition.MainRuleSet);
            lineTransformers.Add(colorizer);

            weakLineTracker = WeakLineTracker.Register(textDocument, this);

            RebuildDocument();
        }
 /// <summary>
 /// Creates WPF Run instances that can be used for TextBlock.Inlines.
 /// </summary>
 public TextRunProperties[] CreateRuns()
 {
     TextRunProperties[] runs = new TextRunProperties[stateChanges.Count];
     for (int i = 0; i < runs.Length; i++) {
         int startOffset = stateChangeOffsets[i];
         int endOffset = i + 1 < stateChangeOffsets.Count ? stateChangeOffsets[i + 1] : text.Length;
         string runString = text.Substring(startOffset, endOffset - startOffset);
         TextRunProperties r = new TextRunProperties();
         HighlightingState state = stateChanges[i];
         r.Foreground = state.Foreground;
         r.Background = state.Background;
         if (state.Weight != null)
             r.FontWeight = state.Weight.Value;
         if (state.Family != null)
             r.FontFamily = state.Family.Value;
         if (state.Style != null)
             r.FontStyle = state.Style.Value;
         runs[i] = r;
     }
     return runs;
 }