public CommandRouter GetCommandRouter(ITextView view) { return(view.Properties.GetOrCreateSingletonProperty(() => { var ppNextCmdTarg = (IOleCommandTarget)null; IVsTextView viewAdapter = EditorAdapterFactoryService.GetViewAdapter(view); var service = ServiceProvider.GetService <DTE>(); var commandRouter = new CommandRouter(view, viewAdapter as IOleCommandTarget, CompletionBroker, service); Marshal.ThrowExceptionForHR(viewAdapter.AddCommandFilter(commandRouter, out ppNextCmdTarg)); commandRouter.Next = ppNextCmdTarg; return commandRouter; })); }
public void VsTextViewCreated(IVsTextView textViewAdapter) { IWpfTextView wpfTextView = EditorAdaptersFactory.GetWpfTextView(textViewAdapter); wpfTextView.Options.OptionChanged += OnOptionsChanged; if (wpfTextView.Roles.Contains("PRIMARYDOCUMENT")) { CommandRouter commandRouter = CommandRouterProvider.GetCommandRouter(wpfTextView); commandRouter.AddCommandTarget(new EmacsCommandsFilter(wpfTextView, Manager, commandRouter)); commandRouter.AddCommandTarget(Manager.GetOrCreateMarkSession(wpfTextView)); commandRouter.AddCommandTarget(Manager.GetOrCreateUniversalArgumentSession(wpfTextView)); commandRouter.AddCommandTarget(Manager.GetOrCreateKillClipboardSession(wpfTextView)); } else { var workAroundFilter = new InteractiveRoleWorkAroundFilter(wpfTextView, Manager); IOleCommandTarget ppNextCmdTarg; textViewAdapter.AddCommandFilter(workAroundFilter, out ppNextCmdTarg); workAroundFilter.NextCommandTarget = ppNextCmdTarg; } }
public EmacsCommandsFilter(ITextView view, EmacsCommandsManager manager, CommandRouter router) { this.view = view; this.manager = manager; this.router = router; }