Пример #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);
        }
Пример #2
0
 protected override void DoOperation()
 {
     match = strategy.FindNext();
 }