Beispiel #1
0
        public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget)
        {
            EditorView.Create(textView);
            var target = textView.GetService <IOleCommandTarget>();

            if (target == null)
            {
                var controller = ReplCommandController.Attach(textView, textView.TextBuffer, _shell.Services);
                var es         = _shell.GetService <IEditorSupport>();
                // Wrap controller into OLE command target
                target = es.TranslateToHostCommandTarget(textView.ToEditorView(), controller) as IOleCommandTarget;
                Debug.Assert(target != null);

                textView.AddService(target);

                // Wrap next OLE target in the chain into ICommandTarget so we can have
                // chain like: OLE Target -> Shim -> ICommandTarget -> Shim -> Next OLE target
                var nextCommandTarget = es.TranslateCommandTarget(textView.ToEditorView(), nextTarget);
                controller.ChainedController = nextCommandTarget;

                // We need to listed when R projected buffer is attached and
                // create R editor document over it.
                textView.BufferGraph.GraphBuffersChanged += OnGraphBuffersChanged;
                var pb = textView.TextBuffer as IProjectionBuffer;
                if (pb != null)
                {
                    pb.SourceBuffersChanged += OnSourceBuffersChanged;
                }

                textView.Closed += TextView_Closed;
            }
            return(target);
        }
Beispiel #2
0
        public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget)
        {
            IOleCommandTarget target = ServiceManager.GetService <IOleCommandTarget>(textView);

            if (target == null)
            {
                ReplCommandController controller = ReplCommandController.Attach(textView, textView.TextBuffer);

                // Wrap controller into OLE command target
                target = VsAppShell.Current.TranslateToHostCommandTarget(textView, controller) as IOleCommandTarget;
                Debug.Assert(target != null);

                ServiceManager.AddService(target, textView, _shell);

                // Wrap next OLE target in the chain into ICommandTarget so we can have
                // chain like: OLE Target -> Shim -> ICommandTarget -> Shim -> Next OLE target
                ICommandTarget nextCommandTarget = VsAppShell.Current.TranslateCommandTarget(textView, nextTarget);
                controller.ChainedController = nextCommandTarget;

                // We need to listed when R projected buffer is attached and
                // create R editor document over it.
                textView.BufferGraph.GraphBuffersChanged += OnGraphBuffersChanged;
                IProjectionBuffer pb = textView.TextBuffer as IProjectionBuffer;
                if (pb != null)
                {
                    pb.SourceBuffersChanged += OnSourceBuffersChanged;
                }

                textView.Closed += TextView_Closed;
            }

            return(target);
        }