Exemplo n.º 1
0
        private static IEnumerable <(int b, int e, Color a)> FindSearchMatches(
            IMessage msg, MessageTextGetter textGetter, IFiltersList filters,
            bool skipWholeLines)
        {
            IFiltersListBulkProcessing processing;

            try
            {
                processing = filters.StartBulkProcessing(textGetter, reverseMatchDirection: false);
            }
            catch (Search.TemplateException)
            {
                yield break;
            }
            using (processing)
            {
                for (int?startPos = null; ;)
                {
                    var rslt = processing.ProcessMessage(msg, startPos);
                    if (rslt.Action == FilterAction.Exclude || rslt.MatchedRange == null)
                    {
                        yield break;
                    }
                    var r = rslt.MatchedRange.Value;
                    if (skipWholeLines && r.WholeTextMatched)
                    {
                        yield break;
                    }
                    if (r.MatchBegin == r.MatchEnd)
                    {
                        yield break;
                    }
                    yield return(r.MatchBegin, r.MatchEnd, new Color());

                    startPos = r.MatchEnd;
                }
            }
        }
Exemplo n.º 2
0
 public SearchResultHandler(IFiltersList filters, bool matchRawMessages)
 {
     this.filter     = filters;
     this.processing = filters.StartBulkProcessing(matchRawMessages, reverseMatchDirection: false);
 }