Exemple #1
0
        // Token: 0x06003C68 RID: 15464 RVA: 0x0011745C File Offset: 0x0011565C
        internal void InternalOnSelectionChanged()
        {
            ITextPointer textPointer;

            if (!this._selection.IsInterimSelection)
            {
                textPointer = this._selection.Start;
            }
            else
            {
                textPointer = this._selection.End;
            }
            ITextPointer end = this._selection.End;
            ITextPointer textPointer2;
            ITextPointer textPointer3;

            if (this._oldStart.CompareTo(textPointer) < 0)
            {
                textPointer2 = this._oldStart;
                textPointer3 = TextPointerBase.Min(textPointer, this._oldEnd);
            }
            else
            {
                textPointer2 = textPointer;
                textPointer3 = TextPointerBase.Min(end, this._oldStart);
            }
            ITextPointer textPointer4;
            ITextPointer textPointer5;

            if (this._oldEnd.CompareTo(end) < 0)
            {
                textPointer4 = TextPointerBase.Max(textPointer, this._oldEnd);
                textPointer5 = end;
            }
            else
            {
                textPointer4 = TextPointerBase.Max(end, this._oldStart);
                textPointer5 = this._oldEnd;
            }
            this._oldStart = textPointer;
            this._oldEnd   = end;
            if (this.Changed != null && (textPointer2.CompareTo(textPointer3) != 0 || textPointer4.CompareTo(textPointer5) != 0))
            {
                TextSelectionHighlightLayer.TextSelectionHighlightChangedEventArgs args = new TextSelectionHighlightLayer.TextSelectionHighlightChangedEventArgs(textPointer2, textPointer3, textPointer4, textPointer5);
                this.Changed(this, args);
            }
        }
Exemple #2
0
        // Token: 0x060035A5 RID: 13733 RVA: 0x000F37E4 File Offset: 0x000F19E4
        internal void GetFirstDirtyRange(ITextPointer searchStart, out ITextPointer start, out ITextPointer end)
        {
            start = null;
            end   = null;
            int num = this.FindIndex(searchStart.CreateStaticPointer(), LogicalDirection.Forward);

            while (num >= 0 && num < this._runList.Count)
            {
                SpellerStatusTable.Run run = this.GetRun(num);
                if (run.RunType == SpellerStatusTable.RunType.Dirty)
                {
                    start = TextPointerBase.Max(searchStart, run.Position);
                    end   = this.GetRunEndPositionDynamic(num);
                    return;
                }
                num++;
            }
        }
        // Returns the first dirty run following a specified position in the document.
        // start/end will be left null if no dirty ranges are found.
        internal void GetFirstDirtyRange(ITextPointer searchStart, out ITextPointer start, out ITextPointer end)
        {
            int index;
            Run run;

            start = null;
            end   = null;

            // If this is ever slow enough to matter, we could cache the value.
            for (index = FindIndex(searchStart.CreateStaticPointer(), LogicalDirection.Forward); index >= 0 && index < _runList.Count; index++)
            {
                run = GetRun(index);

                if (run.RunType == RunType.Dirty)
                {
                    // We might get a hit in the first run, in which case start <= searchStart.
                    // Always return searchStart as a minimum.
                    start = TextPointerBase.Max(searchStart, run.Position);
                    end   = GetRunEndPositionDynamic(index);
                    break;
                }
            }
        }
        // This is actual implementation to make highlight change notification.
        // This is called when highlight needs to be changed without public TextSelection change event.
        internal void InternalOnSelectionChanged()
        {
            ITextPointer newStart;
            ITextPointer newEnd;
            ITextPointer invalidRangeLeftStart;
            ITextPointer invalidRangeLeftEnd;
            ITextPointer invalidRangeRightStart;
            ITextPointer invalidRangeRightEnd;
            TextSelectionHighlightChangedEventArgs args;

            // If the current seleciton is interim selection, we do not highlight it
            // and we make newStart == newEnd.
            if (!_selection.IsInterimSelection)
            {
                newStart = _selection.Start;
            }
            else
            {
                newStart = _selection.End;
            }

            newEnd = _selection.End;

            // We want to raise an event that tracks the change tightly --
            // only identifying content where the selection status actually changed.
            // This is important for render performance.
            //
            // Ex:
            // Old selection: 012<selection>345</selection>678
            // New selection: 0123<selection>456</selection>78
            //
            // Should raise (3-3), (6-6) as deltas, not (3-6).
            //

            // Get the left side invalid range.
            if (_oldStart.CompareTo(newStart) < 0)
            {
                invalidRangeLeftStart = _oldStart;
                invalidRangeLeftEnd   = TextPointerBase.Min(newStart, _oldEnd);
            }
            else
            {
                invalidRangeLeftStart = newStart;
                invalidRangeLeftEnd   = TextPointerBase.Min(newEnd, _oldStart);
            }

            // Get the right side invalid range.
            if (_oldEnd.CompareTo(newEnd) < 0)
            {
                invalidRangeRightStart = TextPointerBase.Max(newStart, _oldEnd);
                invalidRangeRightEnd   = newEnd;
            }
            else
            {
                invalidRangeRightStart = TextPointerBase.Max(newEnd, _oldStart);
                invalidRangeRightEnd   = _oldEnd;
            }

            _oldStart = newStart;
            _oldEnd   = newEnd;

            if (this.Changed != null)
            {
                if (invalidRangeLeftStart.CompareTo(invalidRangeLeftEnd) != 0 || invalidRangeRightStart.CompareTo(invalidRangeRightEnd) != 0)
                {
                    args = new TextSelectionHighlightChangedEventArgs(invalidRangeLeftStart, invalidRangeLeftEnd, invalidRangeRightStart, invalidRangeRightEnd);

                    this.Changed(this, args);
                }
            }
        }