public override VisualLineElement ConstructElement(int offset)
        {
            char c = CurrentContext.Document.GetCharAt(offset);

            if (ShowSpaces && c == ' ')
            {
                return(new SpaceTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter("\u00B7", CurrentContext)));
            }
            else if (ShowTabs && c == '\t')
            {
                return(new TabTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter("\u00BB", CurrentContext)));
            }
            else if (ShowBoxForControlCharacters && char.IsControl(c))
            {
                var p = new VisualLineElementTextRunProperties(CurrentContext.GlobalTextRunProperties);
                p.SetForegroundBrush(Brushes.White);
                var textFormatter = TextFormatterFactory.Create(CurrentContext.TextView);
                var text          = FormattedTextElement.PrepareText(textFormatter,
                                                                     TextUtilities.GetControlCharacterName(c), p);
                return(new SpecialCharacterBoxElement(text));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public TextLine GetTextForNonPrintableCharacter(string text, ITextRunConstructionContext context)
        {
            if (nonPrintableCharacterTexts == null)
            {
                nonPrintableCharacterTexts = new Dictionary <string, TextLine>();
            }
            TextLine textLine;

            if (!nonPrintableCharacterTexts.TryGetValue(text, out textLine))
            {
                var p = new VisualLineElementTextRunProperties(context.GlobalTextRunProperties);
                p.SetForegroundBrush(context.TextView.NonPrintableCharacterBrush);
                if (formatter == null)
                {
                    formatter = TextFormatterFactory.Create(context.TextView);
                }
                textLine = FormattedTextElement.PrepareText(formatter, text, p);
                nonPrintableCharacterTexts[text] = textLine;
            }
            return(textLine);
        }
Ejemplo n.º 3
0
 internal void SetTextRunProperties(VisualLineElementTextRunProperties p)
 {
     this.TextRunProperties = p;
 }