Exemplo n.º 1
0
        /// <summary>
        /// Adds pattern match highlights to an area group before it is rendered
        /// </summary>
        protected virtual void BeforeRender(AreaGroup ag)
        {
            if (!active)
            {
                return;
            }

            Util.Range sel = ag.Selection;

            if (sel.IsEmpty() || sel.Size > 512)
            {
                return;
            }

            int nrows;

            Util.Range view = ag.GetViewRange(out nrows);

            findStrategy.Buffer   = ag.Buffer;
            findStrategy.Position = view.Start;
            findStrategy.Pattern  = ag.Buffer.RangeToByteArray(sel);

            // Merge overlapping matches
            Util.Range match;
            Util.Range currentHighlight = new Util.Range();

            while ((match = findStrategy.FindNext(view.End)) != null)
            {
                if (currentHighlight.End >= match.Start)
                {
                    currentHighlight.End = match.End;
                }
                else
                {
                    ag.AddHighlight(currentHighlight.Start, currentHighlight.End, Drawer.HighlightType.PatternMatch);
                    currentHighlight = match;
                }
            }

            ag.AddHighlight(currentHighlight.Start, currentHighlight.End, Drawer.HighlightType.PatternMatch);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds pattern match highlights to an area group before it is rendered
        /// </summary>
        protected override void BeforeRender(AreaGroup ag)
        {
            if (!active)
            {
                return;
            }

            int nrows;

            Util.Range view = ag.GetViewRange(out nrows);

            if (view.Start < 0 || view.End < 0)
            {
                return;
            }

            findStrategy.Buffer   = ag.Buffer;
            findStrategy.Position = view.Start;

            // Merge overlapping matches
            Util.Range match;
            Util.Range currentHighlight = new Util.Range();

            while ((match = findStrategy.FindNext(view.End)) != null)
            {
                if (currentHighlight.End >= match.Start)
                {
                    currentHighlight.End = match.End;
                }
                else
                {
                    ag.AddHighlight(currentHighlight.Start, currentHighlight.End, Drawer.HighlightType.Unfocus);
                    currentHighlight = match;
                }
            }

            ag.AddHighlight(currentHighlight.Start, currentHighlight.End, Drawer.HighlightType.Unfocus);
        }