Ejemplo n.º 1
0
        /// <summary>
        /// Removes any highlighting associated with this selection.
        /// </summary>
        public void RemoveHighlighter()
        {
            if (_SelectionHighlighter == null)
                return;

            _SelectionHighlighter.DisposeSelectionAdornment();
            _SelectionHighlighter = null;
        }
Ejemplo n.º 2
0
    private void Update()
    {
        if (!FeatureToggles.Get().biomes)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            BlockHighlighter.Highlight(_biomes[0].GetBlocks());
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            BlockHighlighter.Highlight(_biomes[1].GetBlocks());
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            BlockHighlighter.Highlight(_biomes[2].GetBlocks());
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            BlockHighlighter.Highlight(_biomes[3].GetBlocks());
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            EstablishBiomePerk();
        }
        return;

        if (_delta > 2 * 60)
        {
            EstablishBiomePerk();

            _delta = 0;
        }

        _delta += Time.deltaTime;
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a selection highlighter to the specified TextView (removing any previous highlighting associated with this selection).
 /// </summary>
 public void AddHighlighter(TextView textView)
 {
     RemoveHighlighter();
     _SelectionHighlighter = new BlockHighlighter() { DrawSelectionBars = true, FillRange = true, OutlineRange = true, SelectionBarStyle = SelectionBarStyle.Thin };
     _SelectionHighlighter.Select(textView, HighlightRange, CodeRushPlaceholder.MultiSelect.HighlightColor, 0.1, 0.3);
 }
Ejemplo n.º 4
0
        protected override void ColorizeLine(DocumentLine line)
        {
            var ast = _abstractSyntaxTree;

            if (ast is null)
            {
                return;
            }

            var theme = _theme;

            if (theme is null)
            {
                return;
            }

            var start         = line.Offset;
            var end           = line.EndOffset;
            var leadingSpaces = CurrentContext.GetText(start, end - start).Text.TakeWhile(char.IsWhiteSpace).Count();

            foreach (var block in EnumerateSpanningBlocks(ast, start, end))
            {
                if (BlockHighlighter.TryGetValue(block.Tag, out Func <Theme, Highlight> highlighter))
                {
                    var magnify = double.NaN;
                    //if (block.Heading.Level == 1) magnify = theme.Header1Height;
                    //if (block.Heading.Level == 2) magnify = theme.Header2Height;

                    var length = block.Tag == BlockTag.ListItem
                        ? Math.Min(block.SourceLength, block.ListData.Padding)
                        : block.SourceLength;

                    if (block.Tag == BlockTag.HtmlBlock &&
                        block.HtmlBlockType == HtmlBlockType.Comment)
                    {
                        highlighter = t => t.HighlightComment;
                    }


                    ApplyLinePart(highlighter(theme), block.SourcePosition, length, start, end, leadingSpaces, magnify);
                }

                foreach (var inline in EnumerateInlines(block.InlineContent)
                         .TakeWhile(il => il.SourcePosition < end)
                         .Where(il => InlineHighlighter.TryGetValue(il.Tag, out highlighter)))
                {
                    var position = inline.SourcePosition;
                    var length   = inline.SourceLength;

                    //if ((inline.Tag == InlineTag.Link || inline.Tag == InlineTag.Image)
                    //    && inline.FirstChild?.LiteralContent != null
                    //    && inline.FirstChild.LiteralContent != inline.TargetUrl)
                    //{
                    //    var literal = inline.FirstChild.LastSibling;
                    //    var urlPosition = literal.SourcePosition + literal.SourceLength + 1;
                    //    var urlLength = inline.SourcePosition + inline.SourceLength - urlPosition;
                    //    if (urlLength > 0) // check for <*****@*****.**> style links
                    //    {
                    //        position = urlPosition;
                    //        length = urlLength;
                    //    }
                    //}

                    // inlines don't magnify
                    ApplyLinePart(highlighter(theme), position, length, start, end, leadingSpaces, double.NaN);
                }
            }
        }