示例#1
0
        protected override void OnBeforeQueryStatus(object sender, EventArgs e)
        {
            base.OnBeforeQueryStatus(sender, e);
            ITextView view = TextEditor.GetCurrentView();

            if (view == null)
            {
                return;
            }
            ITextCaret caret = view.Caret;

            if (caret == null)
            {
                return;
            }
            var point = TextEditor.MapCaretToPrimaryBuffer(view);

            //SnapshotPoint? point = caret.Position.BufferPosition;

            if (point != null)
            {
                IUserOutlining outlining =
                    OutliningManager.Get(point.Value.Snapshot.TextBuffer);
                Command.Enabled = outlining.IsInOutliningRegion(point.Value);
            }
        }
示例#2
0
        protected override void OnInvoke(object sender, EventArgs e)
        {
            base.OnInvoke(sender, e);
            ITextView view = TextEditor.GetCurrentView();

            if (view == null)
            {
                return;
            }
            ITextCaret caret = view.Caret;

            if (caret == null)
            {
                return;
            }

            var point = TextEditor.MapCaretToPrimaryBuffer(view);

            //SnapshotPoint? point = caret.Position.BufferPosition;
            if (point != null)
            {
                IUserOutlining outlining =
                    OutliningManager.Get(point.Value.Snapshot.TextBuffer);
                outlining.RemoveAt(point.Value);
            }
        }
示例#3
0
        private IUserOutlining GetOutlining(out ITextBuffer buffer)
        {
            buffer = null;
            ITextView view = TextEditor.GetCurrentView();

            if (view != null)
            {
                buffer = TextEditor.GetPrimaryBuffer(view);
                //buffer = view.TextBuffer;
                return(OutliningManager.Get(buffer));
            }
            return(null);
        }
示例#4
0
        private void AddOutlining(ITextBuffer buffer, SnapshotSpan span)
        {
            var outlines = OutliningManager.Get(buffer);

            outlines.Add(span);
        }