Beispiel #1
0
        private static IHighlightingHandler MakeSelectionInplaceHighlightingHander(
            SelectionInfo selection, MessageTextGetter displayTextGetter, IWordSelection wordSelection, int cacheSize)
        {
            IHighlightingHandler newHandler = null;

            if (selection?.IsSingleLine == true)
            {
                var normSelection = selection.Normalize();
                var text          = displayTextGetter(normSelection.First.Message);
                var line          = text.GetNthTextLine(normSelection.First.TextLineIndex);
                int beginIdx      = normSelection.First.LineCharIndex;
                int endIdx        = normSelection.Last.LineCharIndex;
                var selectedPart  = line.SubString(beginIdx, endIdx - beginIdx);
                if (selectedPart.Any(c => !char.IsWhiteSpace(c)))
                {
                    var options = new Search.Options()
                    {
                        Template          = selectedPart,
                        MessageTextGetter = displayTextGetter,
                    };
                    var optionsPreprocessed = options.BeginSearch();
                    newHandler = new CachingHighlightingHandler(msg => GetSelectionHighlightingRanges(msg, optionsPreprocessed, wordSelection,
                                                                                                      (normSelection.First.Message, beginIdx + line.StartIndex - text.Text.StartIndex)), cacheSize);
                }
            }

            return(newHandler);
        }
Beispiel #2
0
 public IEnumerable <int> GetDisplayIndexesRange()
 {
     if (IsEmpty)
     {
         yield return(first.DisplayIndex);
     }
     else
     {
         SelectionInfo norm = Normalize();
         for (int i = norm.first.DisplayIndex; i <= norm.last.DisplayIndex; ++i)
         {
             yield return(i);
         }
     }
 }