Example #1
0
        /// <summary>
        /// Check and see if we should start an external edit operation
        /// </summary>
        private void CheckForExternalEditStart(CheckKind kind)
        {
            Contract.Assert(_buffer.ModeKind != ModeKind.ExternalEdit);

            var externalEditSpans = GetExternalEditSpans(kind);

            // If at some point all of the external edit spans dissapear then we 
            // don't need to track them anymore.  Very important to clear the cache 
            // here as the user could fire up an external edit at the exact same location
            // and we want that to register as an external edit
            if (externalEditSpans.Count == 0)
            {
                _ignoredExternalEditSpans.Clear();
                return;
            }

            // If we should ignore all of the spans then we've not entered an external 
            // edit
            if (externalEditSpans.All(ShouldIgnore))
            {
                return;
            }

            // Clear out the ignored markers.  Everything is fair game again when we restart
            // the external edit
            _ignoredExternalEditSpans.Clear();

            // Not in an external edit and there are edit markers we need to consider.  Time to enter
            // external edit mode
            _buffer.SwitchMode(ModeKind.ExternalEdit, ModeArgument.None);
        }
Example #2
0
        internal List <SnapshotSpan> GetExternalEditSpans(CheckKind kind)
        {
            var list = new List <SnapshotSpan>();

            GetExternalEditSpans(list, kind);
            return(list);
        }
Example #3
0
        private bool IsExternalEditStart(CheckKind kind)
        {
            Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit);

            if (GetAnyExternalEditActive())
            {
                return(true);
            }

            var externalEditSpans = GetExternalEditSpans(kind);

            if (externalEditSpans.Count == 0)
            {
                // If at some point all of the external edit spans dissapear then we
                // don't need to track them anymore.  Very important to clear the cache
                // here as the user could fire up an external edit at the exact same location
                // and we want that to register as an external edit
                _ignoredExternalEditSpans.Clear();
                return(false);
            }

            // If we should ignore all of the spans then we've not entered an external
            // edit
            if (externalEditSpans.All(ShouldIgnore))
            {
                return(false);
            }

            return(true);
        }
Example #4
0
        /// <summary>
        /// Perform the specified check against the ITextBuffer
        /// </summary>
        internal void PerformCheck(CheckKind kind)
        {
            if (!_vimApplicationSettings.EnableExternalEditMonitoring || _vimBuffer.ModeKind == ModeKind.Disabled)
            {
                return;
            }

            if (kind == CheckKind.None)
            {
                return;
            }

            // If we're in the middle of a layout then there is no sense in checking now as the values
            // will all be invalidated when the layout ends.  Queue one up for later
            if (_vimBuffer.TextView.InLayout)
            {
                QueueCheck(kind);
                return;
            }

            if (_vimBuffer.ModeKind == ModeKind.ExternalEdit)
            {
                CheckForExternalEditEnd();
            }
            else
            {
                CheckForExternalEditStart(kind);
            }
        }
Example #5
0
        /// <summary>
        /// Queue up a check for the specified type here.  If there is already check queued 
        /// this wont' have any effect other than to ensure the specified check is included
        /// in the existing queue
        /// </summary>
        private void QueueCheck(CheckKind kind)
        {
            if (_queuedCheckKind.HasValue)
            {
                _queuedCheckKind |= kind;
                return;
            }

            Action doCheck =
                () =>
                {
                    var saved = _queuedCheckKind ?? kind;
                    _queuedCheckKind = null;

                    // The ITextView can close in between the time of dispatch and the actual 
                    // execution of the call.  
                    //
                    // In addition to being the right thing to do by bailing out early, there are parts 
                    // of the SHIM layer which can't handle being called after the ITextView is 
                    // called.  EnumMarkers for example will throw a NullReferenceException.
                    if (_textView.IsClosed)
                    {
                        return;
                    }
                    PerformCheck(saved);
                };

            _protectedOperations.BeginInvoke(doCheck, DispatcherPriority.Loaded);
        }
Example #6
0
        /// <summary>
        /// Check and see if we should start an external edit operation
        /// </summary>
        private void CheckForExternalEditStart(CheckKind kind)
        {
            Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit);

            if (IsExternalEditStart(kind))
            {
                // Clear out the ignored markers.  Everything is fair game again when we restart
                // the external edit
                _ignoredExternalEditSpans.Clear();

                // Not in an external edit and there are edit markers we need to consider.  Time to enter
                // external edit mode
                _controlExternalEdit = true;
                _vimBuffer.SwitchMode(ModeKind.ExternalEdit, ModeArgument.None);
            }
        }
Example #7
0
        private void GetExternalEditSpans(List<SnapshotSpan> list, CheckKind kind)
        {
            var collection = _buffer.TextView.GetLikelyVisibleSnapshotSpans();
            foreach (var span in collection)
            {
                if (0 != (kind & CheckKind.Markers))
                {
                    GetExternalEditSpansFromMarkers(span, list);
                }

                if (0 != (kind & CheckKind.Tags))
                {
                    GetExternalEditSpansFromTags(span, list);
                }
            }
        }
Example #8
0
 public StringCheck(string expected, CheckKind check = CheckKind.Equals)
 {
     Expected = expected;
     Kind     = check;
     Custom   = null;
 }
        /// <summary>
        /// Queue up a check for the specified type here.  If there is already check queued 
        /// this wont' have any effect other than to ensure the specified check is included
        /// in the existing queue
        /// </summary>
        private void QueueCheck(CheckKind kind)
        {
            if (_queuedCheckKind.HasValue)
            {
                _queuedCheckKind |= kind;
                return;
            }

            Action doCheck =
                () =>
                {
                    var saved = _queuedCheckKind ?? kind;
                    _queuedCheckKind = null;
                    PerformCheck(saved);
                };

            Dispatcher.CurrentDispatcher.BeginInvoke(doCheck, DispatcherPriority.Loaded);
        }
Example #10
0
        private void GetExternalEditSpans(List<SnapshotSpan> list, CheckKind kind)
        {
            var collection = _buffer.TextView.GetLikelyVisibleSnapshotSpans();
            foreach (var span in collection)
            {
                if (0 != (kind & CheckKind.Markers))
                {
                    GetExternalEditSpansFromMarkers(span, list);
                }

                if (0 != (kind & CheckKind.Tags))
                {
                    GetExternalEditSpansFromTags(span, list);
                }
            }
        }
Example #11
0
        /// <summary>
        /// Check and see if we should start an external edit operation
        /// </summary>
        private void CheckForExternalEditStart(CheckKind kind)
        {
            Contract.Assert(_buffer.ModeKind != ModeKind.ExternalEdit);

            var externalEditSpans = GetExternalEditSpans(kind);

            // If at some point all of the external edit spans dissapear then we
            // don't need to track them anymore.  Very important to clear the cache
            // here as the user could fire up an external edit at the exact same location
            // and we want that to register as an external edit
            if (externalEditSpans.Count == 0)
            {
                _ignoredExternalEditSpans.Clear();
                return;
            }

            // If we should ignore all of the spans then we've not entered an external
            // edit
            if (externalEditSpans.All(ShouldIgnore))
            {
                return;
            }

            // Clear out the ignored markers.  Everything is fair game again when we restart
            // the external edit
            _ignoredExternalEditSpans.Clear();

            // Not in an external edit and there are edit markers we need to consider.  Time to enter
            // external edit mode
            _buffer.SwitchMode(ModeKind.ExternalEdit, ModeArgument.None);
        }
Example #12
0
        private bool IsExternalEditStart(CheckKind kind)
        {
            Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit);

            if (GetAnyExternalEditActive())
            {
                return true;
            }

            var externalEditSpans = GetExternalEditSpans(kind);

            if (externalEditSpans.Count == 0)
            {
                // If at some point all of the external edit spans dissapear then we 
                // don't need to track them anymore.  Very important to clear the cache 
                // here as the user could fire up an external edit at the exact same location
                // and we want that to register as an external edit
                _ignoredExternalEditSpans.Clear();
                return false;
            }

            // If we should ignore all of the spans then we've not entered an external 
            // edit
            if (externalEditSpans.All(ShouldIgnore))
            {
                return false;
            }

            return true;
        }
Example #13
0
 internal List<SnapshotSpan> GetExternalEditSpans(CheckKind kind)
 {
     var list = new List<SnapshotSpan>();
     GetExternalEditSpans(list, kind);
     return list;
 }
Example #14
0
        /// <summary>
        /// Queue up a check for the specified type here.  If there is already check queued 
        /// this wont' have any effect other than to ensure the specified check is included
        /// in the existing queue
        /// </summary>
        private void QueueCheck(CheckKind kind)
        {
            if (_queuedCheckKind.HasValue)
            {
                _queuedCheckKind |= kind;
                return;
            }

            Action doCheck =
                () =>
                {
                    var saved = _queuedCheckKind ?? kind;
                    _queuedCheckKind = null;

                    // The ITextView can close in between the time of dispatch and the actual
                    // execution of the call.
                    //
                    // In addition to being the right thing to do by bailing out early, there are parts
                    // of the SHIM layer which can't handle being called after the ITextView is
                    // called.  EnumMarkers for example will throw a NullReferenceException.
                    if (_textView.IsClosed)
                    {
                        return;
                    }
                    PerformCheck(saved);
                };

            _protectedOperations.BeginInvoke(doCheck, DispatcherPriority.Loaded);
        }
Example #15
0
 private void startRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (startRadioButton.Checked)
         checkKind = CheckKind.Star;
 }
Example #16
0
 private void crossRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (crossRadioButton.Checked)
         checkKind = CheckKind.Cross;
 }
Example #17
0
        /// <summary>
        /// Perform the specified check against the ITextBuffer
        /// </summary>
        internal void PerformCheck(CheckKind kind)
        {
            if (kind == CheckKind.None)
            {
                return;
            }

            // If we're in the middle of a layout then there is no sense in checking now as the values
            // will all be invalidated when the layout ends.  Queue one up for later
            if (_buffer.TextView.InLayout)
            {
                QueueCheck(kind);
                return;
            }

            if (_buffer.ModeKind == ModeKind.ExternalEdit)
            {
                CheckForExternalEditEnd();
            }
            else
            {
                CheckForExternalEditStart(kind);
            }
        }
Example #18
0
        /// <summary>
        /// Check and see if we should start an external edit operation
        /// </summary>
        private void CheckForExternalEditStart(CheckKind kind)
        {
            Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit);

            if (IsExternalEditStart(kind))
            {
                // Clear out the ignored markers.  Everything is fair game again when we restart
                // the external edit
                _ignoredExternalEditSpans.Clear();

                // Not in an external edit and there are edit markers we need to consider.  Time to enter
                // external edit mode
                _controlExternalEdit = true;
                _vimBuffer.SwitchMode(ModeKind.ExternalEdit, ModeArgument.None);
            }
        }