예제 #1
0
        private void StopRainbowHighlight(ITextView view)
        {
            RainbowHighlight highlight = RainbowHighlight.Get(view);

            if (highlight != null)
            {
                highlight.Stop();
            }
            this.startedEffect = false;
        }
예제 #2
0
        private void StartRainbowHighlight(ITextView view, RainbowHighlightMode mode)
        {
            if (startedEffect)
            {
                return;
            }
            startedEffect = true;

            SnapshotPoint bufferPos;

            if (!RainbowProvider.TryMapCaretToBuffer(view, out bufferPos))
            {
                return;
            }

            ITextBuffer     buffer   = bufferPos.Snapshot.TextBuffer;
            RainbowProvider provider = buffer.Get <RainbowProvider>();

            if (provider == null)
            {
                return;
            }
            var braces = provider.BufferBraces.GetBracePairFromPosition(bufferPos, mode);

            if (braces == null)
            {
                return;
            }
            SnapshotPoint opening = braces.Item1.ToPoint(bufferPos.Snapshot);
            SnapshotPoint closing = braces.Item2.ToPoint(bufferPos.Snapshot);

            if (RainbowProvider.TryMapToView(view, opening, out opening) &&
                RainbowProvider.TryMapToView(view, closing, out closing))
            {
                RainbowHighlight highlight = RainbowHighlight.Get(view);
                if (highlight != null)
                {
                    highlight.Start(opening, closing, braces.Item1.Depth);
                }
            }
        }