Пример #1
0
        //find all the segments in a specific range
        //used to clear out a section when it is getting rechecked
        //need to expand selection from these bounds out around full words
        public IHighlightSegmentRaw[] GetSegments(IMarkupPointerRaw start, IMarkupPointerRaw end)
        {
            if (list.Count == 0)
            {
                return(null);
            }
            int  firstSegmentInd = -1;
            int  lastSegmentInd  = list.Count;
            bool test;

            //find the first segment after the start pointer
            do
            {
                firstSegmentInd++;
                //check if we have gone through the whole selection
                if (firstSegmentInd >= lastSegmentInd)
                {
                    return(null);
                }
                SegmentDef x = (SegmentDef)list.GetByIndex(firstSegmentInd);
                start.IsRightOf(x.startPtr, out test);
            } while (test);
            do
            {
                lastSegmentInd--;
                //check if we have gone through the whole selection
                if (lastSegmentInd < firstSegmentInd)
                {
                    return(null);
                }
                SegmentDef x = (SegmentDef)list.GetByIndex(lastSegmentInd);
                end.IsLeftOf(x.startPtr, out test);
            } while (test);
            return(Subarray(firstSegmentInd, lastSegmentInd));
        }
Пример #2
0
 public SegmentDef(IHighlightSegmentRaw seg, IMarkupPointerRaw start, IMarkupPointerRaw end, string wd)
 {
     segment  = seg;
     startPtr = start;
     endPtr   = end;
     word     = wd;
 }
Пример #3
0
        /// <summary>
        /// Creates an instance of a MarkupPointer object from a pointer raw.
        /// </summary>
        /// <returns></returns>
        public MarkupPointer CreateMarkupPointer(IMarkupPointerRaw rawPtr)
        {
            IMarkupPointerRaw pointer;

            MarkupServices.CreateMarkupPointer(out pointer);
            pointer.MoveToPointer(rawPtr);
            return(new MarkupPointer(this, pointer));
        }
Пример #4
0
        public MisspelledWordInfo FindSegment(MshtmlMarkupServices markupServices, IMarkupPointerRaw current)
        {
            //binary search
            int start = 0;
            int end   = list.Count - 1;
            int i     = Middle(start, end);

            while (-1 != i)
            {
                SegmentDef x = (SegmentDef)list.GetByIndex(i);
                bool       startTest;
                current.IsRightOfOrEqualTo(x.startPtr, out startTest);
                if (startTest)
                {
                    bool endTest;
                    current.IsLeftOfOrEqualTo(x.endPtr, out endTest);
                    if (endTest)
                    {
                        MarkupPointer pStart = markupServices.CreateMarkupPointer(x.startPtr);
                        MarkupPointer pEnd   = markupServices.CreateMarkupPointer(x.endPtr);
                        MarkupRange   range  = markupServices.CreateMarkupRange(pStart, pEnd);
                        //this could be a "phantom" range...no more content due to uncommitted damage or other reasons
                        //if it is phantom, remove it from the tracker and return null
                        if (range.Text == null)
                        {
                            list.RemoveAt(i);
                            return(null);
                        }
                        return(new MisspelledWordInfo(range, x.word));
                    }
                    start = i + 1;
                }
                else
                {
                    end = i - 1;
                }
                i = Middle(start, end);
            }
            return(null);
        }
Пример #5
0
 internal MarkupPointer(MshtmlMarkupServices markupServices, IMarkupPointerRaw pointer)
 {
     MarkupServices = markupServices;
     _pointerRaw    = pointer;
 }
 /// <summary>
 /// Creates an instance of a MarkupPointer object from a pointer raw.
 /// </summary>
 /// <returns></returns>
 public MarkupPointer CreateMarkupPointer(IMarkupPointerRaw rawPtr)
 {
     IMarkupPointerRaw pointer;
     MarkupServices.CreateMarkupPointer(out pointer);
     pointer.MoveToPointer(rawPtr);
     return new MarkupPointer(this, pointer);
 }
Пример #7
0
 internal MarkupPointer(MshtmlMarkupServices markupServices, IMarkupPointerRaw pointer)
 {
     MarkupServices = markupServices;
     _pointerRaw = pointer;
 }
Пример #8
0
 public MatchingSegment(IHighlightSegmentRaw seg, IMarkupPointerRaw pointer)
 {
     _segment = seg;
     _pointer = pointer;
 }
Пример #9
0
 public void RemoveSegment(IMarkupPointerRaw pointer)
 {
     list.Remove(pointer);
 }