Exemplo n.º 1
0
        public HostFactory(
            IVim vim,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            ITextManager textManager,
            IVsAdapter adapter,
            IVimProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil,
            IEditorToSettingsSynchronizer editorToSettingSynchronizer,
            [ImportMany] IEnumerable<Lazy<ICommandTargetFactory, IOrderable>> commandTargetFactoryList)
        {
            _vim = vim;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory = adaptersFactory;
            _textManager = textManager;
            _adapter = adapter;
            _protectedOperations = protectedOperations;
            _bufferCoordinatorFactory = bufferCoordinatorFactory;
            _keyUtil = keyUtil;
            _editorToSettingSynchronizer = editorToSettingSynchronizer;
            _commandTargetFactoryList = Orderer.Order(commandTargetFactoryList).Select(x => x.Value).ToReadOnlyCollection();

            #if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
            #endif
        }
Exemplo n.º 2
0
 internal VsKeyProcessorProvider(IVim vim, IVsAdapter adapter, IVimBufferCoordinatorFactory bufferCoordinatorFactory, IKeyUtil keyUtil)
 {
     _vim     = vim;
     _adapter = adapter;
     _bufferCoordinatorFactory = bufferCoordinatorFactory;
     _keyUtil = keyUtil;
 }
Exemplo n.º 3
0
        protected VimTestBase()
        {
            _vim = CompositionContainer.GetExportedValue <IVim>();
            _vimBufferFactory        = CompositionContainer.GetExportedValue <IVimBufferFactory>();
            _vimErrorDetector        = CompositionContainer.GetExportedValue <IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue <ICommonOperationsFactory>();
            _wordUtilFactory         = CompositionContainer.GetExportedValue <IWordUtilFactory>();
            _bufferTrackingService   = CompositionContainer.GetExportedValue <IBufferTrackingService>();
            _foldManagerFactory      = CompositionContainer.GetExportedValue <IFoldManagerFactory>();
            _bulkOperations          = CompositionContainer.GetExportedValue <IBulkOperations>();
            _clipboardDevice         = CompositionContainer.GetExportedValue <IClipboardDevice>();
            _keyUtil = CompositionContainer.GetExportedValue <IKeyUtil>();

            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interferring
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
Exemplo n.º 4
0
        public HostFactory(
            IVim vim,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IResharperUtil resharperUtil,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            ITextManager textManager,
            IVsAdapter adapter,
            [EditorUtilsImport] IProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil,
            IEditorToSettingsSynchronizer editorToSettingSynchronizer)
        {
            _vim           = vim;
            _resharperUtil = resharperUtil;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory             = adaptersFactory;
            _textManager                 = textManager;
            _adapter                     = adapter;
            _protectedOperations         = protectedOperations;
            _bufferCoordinatorFactory    = bufferCoordinatorFactory;
            _keyUtil                     = keyUtil;
            _editorToSettingSynchronizer = editorToSettingSynchronizer;

#if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
#endif
        }
Exemplo n.º 5
0
        public HostFactory(
            IVim vim,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            ITextManager textManager,
            IVsAdapter adapter,
            IVimProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil,
            IEditorToSettingsSynchronizer editorToSettingSynchronizer,
            [ImportMany] IEnumerable <Lazy <ICommandTargetFactory, IOrderable> > commandTargetFactoryList)
        {
            _vim = vim;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory             = adaptersFactory;
            _textManager                 = textManager;
            _adapter                     = adapter;
            _protectedOperations         = protectedOperations;
            _bufferCoordinatorFactory    = bufferCoordinatorFactory;
            _keyUtil                     = keyUtil;
            _editorToSettingSynchronizer = editorToSettingSynchronizer;
            _commandTargetFactoryList    = Orderer.Order(commandTargetFactoryList).Select(x => x.Value).ToReadOnlyCollection();

#if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
#endif
        }
Exemplo n.º 6
0
        protected VimTestBase()
        {
            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtilFactory = CompositionContainer.GetExportedValue<IWordUtilFactory>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _bulkOperations = CompositionContainer.GetExportedValue<IBulkOperations>();
            _clipboardDevice = CompositionContainer.GetExportedValue<IClipboardDevice>();
            _keyUtil = CompositionContainer.GetExportedValue<IKeyUtil>();

            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interferring
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
Exemplo n.º 7
0
        public HostFactory(
            IVim vim,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IReSharperUtil resharperUtil,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            ITextManager textManager,
            IVsAdapter adapter,
            IVimProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil,
            IEditorToSettingsSynchronizer editorToSettingSynchronizer)
        {
            _vim = vim;
            _resharperUtil = resharperUtil;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory = adaptersFactory;
            _textManager = textManager;
            _adapter = adapter;
            _protectedOperations = protectedOperations;
            _bufferCoordinatorFactory = bufferCoordinatorFactory;
            _keyUtil = keyUtil;
            _editorToSettingSynchronizer = editorToSettingSynchronizer;

            #if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
            #endif
        }
Exemplo n.º 8
0
        internal static Result <VsCommandTarget> Create(
            IVimBufferCoordinator vimBufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IKeyUtil keyUtil,
            IVimApplicationSettings vimApplicationSettings,
            ReadOnlyCollection <ICommandTargetFactory> commandTargetFactoryList)
        {
            var vsCommandTarget = new VsCommandTarget(vimBufferCoordinator, textManager, adapter, broker, keyUtil, vimApplicationSettings);

            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out IOleCommandTarget nextCommandTarget);

            if (ErrorHandler.Failed(hresult))
            {
                return(Result.CreateError(hresult));
            }

            var commandTargets = commandTargetFactoryList
                                 .Select(x => x.CreateCommandTarget(nextCommandTarget, vimBufferCoordinator))
                                 .Where(x => x != null)
                                 .ToReadOnlyCollection();

            vsCommandTarget.CompleteInit(nextCommandTarget, commandTargets);
            return(Result.CreateSuccess(vsCommandTarget));
        }
Exemplo n.º 9
0
 internal VsKeyProcessorProvider(IVim vim, IVsAdapter adapter, IVimBufferCoordinatorFactory bufferCoordinatorFactory, IKeyUtil keyUtil)
 {
     _vim = vim;
     _adapter = adapter;
     _bufferCoordinatorFactory = bufferCoordinatorFactory;
     _keyUtil = keyUtil;
 }
Exemplo n.º 10
0
        public HostFactory(
            IVim vim,
            ITextBufferFactoryService bufferFactoryService,
            ITextEditorFactoryService editorFactoryService,
            IEditorOptionsFactoryService editorOptionsFactoryService,
            IKeyBindingService keyBindingService,
            SVsServiceProvider serviceProvider,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IResharperUtil resharperUtil,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            IVsAdapter adapter,
            [EditorUtilsImport] IProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil)
        {
            _vim = vim;
            _keyBindingService           = keyBindingService;
            _bufferFactoryService        = bufferFactoryService;
            _editorFactoryService        = editorFactoryService;
            _editorOptionsFactoryService = editorOptionsFactoryService;
            _resharperUtil = resharperUtil;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory          = adaptersFactory;
            _adapter                  = adapter;
            _protectedOperations      = protectedOperations;
            _bufferCoordinatorFactory = bufferCoordinatorFactory;
            _keyUtil                  = keyUtil;

            _vim.AutoLoadVimRc = false;

#if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
#endif
        }
Exemplo n.º 11
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil)
     : base(bufferCoordinator.VimBuffer, keyUtil)
 {
     _adapter = adapter;
     _bufferCoordinator = bufferCoordinator;
     _searchInProgressInfo = new Lazy<PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
Exemplo n.º 12
0
        public HostFactory(
            IVim vim,
            ITextBufferFactoryService bufferFactoryService,
            ITextEditorFactoryService editorFactoryService,
            IEditorOptionsFactoryService editorOptionsFactoryService,
            IKeyBindingService keyBindingService,
            SVsServiceProvider serviceProvider,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IResharperUtil resharperUtil,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            ITextManager textManager,
            IVsAdapter adapter,
            [EditorUtilsImport] IProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil)
        {
            _vim = vim;
            _keyBindingService = keyBindingService;
            _bufferFactoryService = bufferFactoryService;
            _editorFactoryService = editorFactoryService;
            _editorOptionsFactoryService = editorOptionsFactoryService;
            _resharperUtil = resharperUtil;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory = adaptersFactory;
            _textManager = textManager;
            _adapter = adapter;
            _protectedOperations = protectedOperations;
            _bufferCoordinatorFactory = bufferCoordinatorFactory;
            _keyUtil = keyUtil;

            #if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
            #endif
        }
Exemplo n.º 13
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil, IWpfTextView wpfTextView)
     : base(bufferCoordinator.VimBuffer, keyUtil, wpfTextView)
 {
     _adapter = adapter;
     _reportDesignerUtil = reportDesignerUtil;
     _bufferCoordinator = bufferCoordinator;
     _searchInProgressInfo = new Lazy<PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
 internal VsVimKeyProcessorProvider(IVim vim, IVsAdapter adapter, IVimBufferCoordinatorFactory bufferCoordinatorFactory, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil)
 {
     _vim     = vim;
     _adapter = adapter;
     _bufferCoordinatorFactory = bufferCoordinatorFactory;
     _keyUtil            = keyUtil;
     _reportDesignerUtil = reportDesignerUtil;
 }
Exemplo n.º 15
0
 internal VsVimKeyProcessorProvider(IVim vim, IVsAdapter adapter, IVimBufferCoordinatorFactory bufferCoordinatorFactory, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil)
 {
     _vim = vim;
     _adapter = adapter;
     _bufferCoordinatorFactory = bufferCoordinatorFactory;
     _keyUtil = keyUtil;
     _reportDesignerUtil = reportDesignerUtil;
 }
Exemplo n.º 16
0
        internal FallbackKeyProcessorProvider(SVsServiceProvider serviceProvider, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, IVim vim)
        {
            _dte     = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vim = vim;

            _vsShell   = (IVsShell)serviceProvider.GetService(typeof(SVsShell));
            _scopeData = new ScopeData(_vsShell);
        }
Exemplo n.º 17
0
        internal FallbackKeyProcessorProvider(SVsServiceProvider serviceProvider, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, IVim vim)
        {
            _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vim = vim;

            var vsShell = (IVsShell)serviceProvider.GetService(typeof(SVsShell));
            _scopeData = new ScopeData(vsShell);
        }
Exemplo n.º 18
0
 internal VsCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IKeyUtil keyUtil,
     IOleCommandTarget nextTarget,
     ReadOnlyCollection<ICommandTarget> commandTargets)
     : this(vimBufferCoordinator, textManager, vsAdapter, broker, keyUtil)
 {
     CompleteInit(nextTarget, commandTargets);
 }
Exemplo n.º 19
0
 internal VsCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IKeyUtil keyUtil,
     IOleCommandTarget nextTarget,
     ReadOnlyCollection <ICommandTarget> commandTargets)
     : this(vimBufferCoordinator, textManager, vsAdapter, broker, keyUtil)
 {
     CompleteInit(nextTarget, commandTargets);
 }
Exemplo n.º 20
0
 internal DefaultKeyProcessorProvider(
     IVim vim,
     IKeyUtil keyUtil,
     ICompletionBroker completionBroker,
     ISignatureHelpBroker signatureHelpBroker,
     InlineRenameListenerFactory inlineRenameListenerFactory)
 {
     _vim                         = vim;
     _keyUtil                     = keyUtil;
     _completionBroker            = completionBroker;
     _signatureHelpBroker         = signatureHelpBroker;
     _inlineRenameListenerFactory = inlineRenameListenerFactory;
 }
Exemplo n.º 21
0
        public VimKeyProcessor(
            IVimBuffer vimBuffer,
            IKeyUtil keyUtil,
            ICompletionBroker completionBroker,
            ISignatureHelpBroker signatureHelpBroker,
            InlineRenameListenerFactory inlineRenameListenerFactory)

        {
            VimBuffer                    = vimBuffer;
            _keyUtil                     = keyUtil;
            _completionBroker            = completionBroker;
            _signatureHelpBroker         = signatureHelpBroker;
            _inlineRenameListenerFactory = inlineRenameListenerFactory;
        }
Exemplo n.º 22
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(_DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _dte     = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer           = vimBuffer;
            _scopeData           = scopeData;
            _fallbackCommandList = new List <FallbackCommand>();

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Exemplo n.º 23
0
 private VsCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IKeyUtil keyUtil)
 {
     _vimBuffer            = vimBufferCoordinator.VimBuffer;
     _vim                  = _vimBuffer.Vim;
     _vimBufferCoordinator = vimBufferCoordinator;
     _textBuffer           = _vimBuffer.TextBuffer;
     _vsAdapter            = vsAdapter;
     _broker               = broker;
     _keyUtil              = keyUtil;
 }
Exemplo n.º 24
0
 private VsCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IKeyUtil keyUtil)
 {
     _vimBuffer = vimBufferCoordinator.VimBuffer;
     _vim = _vimBuffer.Vim;
     _vimBufferCoordinator = vimBufferCoordinator;
     _textBuffer = _vimBuffer.TextBuffer;
     _vsAdapter = vsAdapter;
     _broker = broker;
     _keyUtil = keyUtil;
 }
Exemplo n.º 25
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(_DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _dte = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer = vimBuffer;
            _scopeData = scopeData;
            _fallbackCommandList = new List<FallbackCommand>();

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Exemplo n.º 26
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(IVsShell vsShell, _DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _vsShell = vsShell;
            _dte     = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer           = vimBuffer;
            _scopeData           = scopeData;
            _fallbackCommandList = Enumerable.Empty <FallbackCommand>().ToLookup(x => 'a');

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Exemplo n.º 27
0
 private VsCommandTarget(
     IVimBufferCoordinator bufferCoordinator,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IResharperUtil resharperUtil,
     IKeyUtil keyUtil)
 {
     _vimBuffer         = bufferCoordinator.VimBuffer;
     _vim               = _vimBuffer.Vim;
     _bufferCoordinator = bufferCoordinator;
     _textBuffer        = _vimBuffer.TextBuffer;
     _vsAdapter         = vsAdapter;
     _broker            = broker;
     _resharperUtil     = resharperUtil;
     _keyUtil           = keyUtil;
 }
Exemplo n.º 28
0
 private VsCommandTarget(
     IVimBufferCoordinator bufferCoordinator,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IResharperUtil resharperUtil,
     IKeyUtil keyUtil)
 {
     _vimBuffer = bufferCoordinator.VimBuffer;
     _vim = _vimBuffer.Vim;
     _bufferCoordinator = bufferCoordinator;
     _textBuffer = _vimBuffer.TextBuffer;
     _vsAdapter = vsAdapter;
     _broker = broker;
     _resharperUtil = resharperUtil;
     _keyUtil = keyUtil;
 }
Exemplo n.º 29
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(IVsShell vsShell, _DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _vsShell = vsShell;
            _dte = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer = vimBuffer;
            _scopeData = scopeData;
            _fallbackCommandList = Enumerable.Empty<FallbackCommand>().ToLookup(x => 'a');

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Exemplo n.º 30
0
        public VimEditorHost(CompositionContainer compositionContainer) : base(compositionContainer)
        {
            _vim = CompositionContainer.GetExportedValue <IVim>();
            _vimBufferFactory        = CompositionContainer.GetExportedValue <IVimBufferFactory>();
            _vimErrorDetector        = CompositionContainer.GetExportedValue <IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue <ICommonOperationsFactory>();
            _bufferTrackingService   = CompositionContainer.GetExportedValue <IBufferTrackingService>();
            _foldManagerFactory      = CompositionContainer.GetExportedValue <IFoldManagerFactory>();
            _bulkOperations          = CompositionContainer.GetExportedValue <IBulkOperations>();
            _keyUtil             = CompositionContainer.GetExportedValue <IKeyUtil>();
            _protectedOperations = CompositionContainer.GetExportedValue <IProtectedOperations>();

            _keyboardDevice                 = CompositionContainer.GetExportedValue <IKeyboardDevice>();
            _mouseDevice                    = CompositionContainer.GetExportedValue <IMouseDevice>();
            _clipboardDevice                = CompositionContainer.GetExportedValue <IClipboardDevice>();
            _editorFormatMapService         = CompositionContainer.GetExportedValue <IEditorFormatMapService>();
            _classificationFormatMapService = CompositionContainer.GetExportedValue <IClassificationFormatMapService>();
        }
Exemplo n.º 31
0
        public VimEditorHost(CompositionContainer compositionContainer)
            : base(compositionContainer)
        {
            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtil = CompositionContainer.GetExportedValue<IWordUtil>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _bulkOperations = CompositionContainer.GetExportedValue<IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue<IKeyUtil>();
            _vimProtectedOperations = CompositionContainer.GetExportedValue<IVimProtectedOperations>();

            _keyboardDevice = CompositionContainer.GetExportedValue<IKeyboardDevice>();
            _mouseDevice = CompositionContainer.GetExportedValue<IMouseDevice>();
            _clipboardDevice = CompositionContainer.GetExportedValue<IClipboardDevice>();
        }
Exemplo n.º 32
0
        public VimKeyProcessor(IVimBuffer vimBuffer, IKeyUtil keyUtil, IWpfTextView wpfTextView)
        {
            _vimBuffer = vimBuffer;
            _keyUtil = keyUtil;
            wpfTextView.VisualElement.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
                    {
                        var position = e.GetPosition(wpfTextView.VisualElement);
                        var viewLine = wpfTextView.TextViewLines.GetTextViewLineContainingYCoordinate(position.Y + wpfTextView.ViewportTop);
                        wpfTextView.Caret.MoveTo(viewLine, position.X + wpfTextView.ViewportLeft);

                        // Run the 'put' command directly here.  Don't try to run 'P' because a key mapping could
                        // prevent it from running correctly
                        var command = Command.NewNormalCommand(NormalCommand.NewPutBeforeCaret(false), CommandData.Default);
                        _vimBuffer.CommandUtil.RunCommand(command);
                    }
                };
        }
Exemplo n.º 33
0
        internal static Result <VsCommandTarget> Create(
            IVimBufferCoordinator bufferCoordinator,
            IVsTextView vsTextView,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IResharperUtil resharperUtil,
            IKeyUtil keyUtil)
        {
            var vsCommandTarget = new VsCommandTarget(bufferCoordinator, adapter, broker, resharperUtil, keyUtil);
            var hresult         = vsTextView.AddCommandFilter(vsCommandTarget, out vsCommandTarget._nextTarget);
            var result          = Result.CreateSuccessOrError(vsCommandTarget, hresult);

            if (result.IsSuccess)
            {
                bufferCoordinator.VimBuffer.TextView.Properties[Key] = vsCommandTarget;
            }

            return(result);
        }
Exemplo n.º 34
0
        public VimKeyProcessor(IVimBuffer vimBuffer, IKeyUtil keyUtil, IWpfTextView wpfTextView)
        {
            _vimBuffer = vimBuffer;
            _keyUtil   = keyUtil;
            wpfTextView.VisualElement.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
                {
                    var position = e.GetPosition(wpfTextView.VisualElement);
                    var viewLine = wpfTextView.TextViewLines.GetTextViewLineContainingYCoordinate(position.Y + wpfTextView.ViewportTop);
                    wpfTextView.Caret.MoveTo(viewLine, position.X + wpfTextView.ViewportLeft);

                    // Run the 'put' command directly here.  Don't try to run 'P' because a key mapping could
                    // prevent it from running correctly
                    var command = Command.NewNormalCommand(NormalCommand.NewPutBeforeCaret(false), CommandData.Default);
                    _vimBuffer.CommandUtil.RunCommand(command);
                }
            };
        }
Exemplo n.º 35
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            _vim = CompositionContainer.GetExportedValue <IVim>();
            _vimBufferFactory        = CompositionContainer.GetExportedValue <IVimBufferFactory>();
            _vimErrorDetector        = CompositionContainer.GetExportedValue <IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue <ICommonOperationsFactory>();
            _wordUtilFactory         = CompositionContainer.GetExportedValue <IWordUtilFactory>();
            _bufferTrackingService   = CompositionContainer.GetExportedValue <IBufferTrackingService>();
            _foldManagerFactory      = CompositionContainer.GetExportedValue <IFoldManagerFactory>();
            _bulkOperations          = CompositionContainer.GetExportedValue <IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue <IKeyUtil>();
            _vimProtectedOperations = CompositionContainer.GetExportedValue <IVimProtectedOperations>();

            _keyboardDevice       = CompositionContainer.GetExportedValue <IKeyboardDevice>();
            _mouseDevice          = CompositionContainer.GetExportedValue <IMouseDevice>();
            _clipboardDevice      = CompositionContainer.GetExportedValue <IClipboardDevice>();
            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
Exemplo n.º 36
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtil = CompositionContainer.GetExportedValue<IWordUtil>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _bulkOperations = CompositionContainer.GetExportedValue<IBulkOperations>();
            _keyUtil = CompositionContainer.GetExportedValue<IKeyUtil>();
            _vimProtectedOperations = CompositionContainer.GetExportedValue<IVimProtectedOperations>();

            _keyboardDevice = CompositionContainer.GetExportedValue<IKeyboardDevice>();
            _mouseDevice = CompositionContainer.GetExportedValue<IMouseDevice>();
            _clipboardDevice = CompositionContainer.GetExportedValue<IClipboardDevice>();
            _clipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
Exemplo n.º 37
0
        public HostFactory(
            IVim vim,
            IVsEditorAdaptersFactoryService adaptersFactory,
            IDisplayWindowBrokerFactoryService displayWindowBrokerFactoryService,
            ITextManager textManager,
            IVsAdapter adapter,
            IProtectedOperations protectedOperations,
            IVimBufferCoordinatorFactory bufferCoordinatorFactory,
            IKeyUtil keyUtil,
            IEditorToSettingsSynchronizer editorToSettingSynchronizer,
            IVimApplicationSettings vimApplicationSettings,
            [ImportMany] IEnumerable <Lazy <ICommandTargetFactory, IOrderable> > commandTargetFactoryList)
        {
            _vim = vim;
            _displayWindowBrokerFactoryServcie = displayWindowBrokerFactoryService;
            _adaptersFactory             = adaptersFactory;
            _textManager                 = textManager;
            _adapter                     = adapter;
            _protectedOperations         = protectedOperations;
            _bufferCoordinatorFactory    = bufferCoordinatorFactory;
            _keyUtil                     = keyUtil;
            _editorToSettingSynchronizer = editorToSettingSynchronizer;
            _vimApplicationSettings      = vimApplicationSettings;
            _commandTargetFactoryList    = Orderer.Order(commandTargetFactoryList).Select(x => x.Value).ToReadOnlyCollection();

#if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Verbose;
#endif

            // Make sure that for this
            _editorToSettingSynchronizer.SyncSetting(SettingSyncData.Create(
                                                         DefaultWpfViewOptions.EnableHighlightCurrentLineId,
                                                         WindowSettingNames.CursorLineName,
                                                         false,
                                                         x => SettingValue.NewToggle(x),
                                                         s => s.GetToggle()));
        }
Exemplo n.º 38
0
 internal DefaultKeyProcessorProvider(IVim vim, IKeyUtil keyUtil)
 {
     _vim = vim;
     _keyUtil = keyUtil;
 }
Exemplo n.º 39
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil)
     : base(bufferCoordinator.VimBuffer, keyUtil)
 {
     _adapter              = adapter;
     _bufferCoordinator    = bufferCoordinator;
     _searchInProgressInfo = new Lazy <PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
Exemplo n.º 40
0
        internal static Result<VsCommandTarget> Create(
            IVimBufferCoordinator vimBufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IKeyUtil keyUtil,
            IVimApplicationSettings vimApplicationSettings,
            ReadOnlyCollection<ICommandTargetFactory> commandTargetFactoryList)
        {
            var vsCommandTarget = new VsCommandTarget(vimBufferCoordinator, textManager, adapter, broker, keyUtil, vimApplicationSettings);

            IOleCommandTarget nextCommandTarget;
            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out nextCommandTarget);
            if (ErrorHandler.Failed(hresult))
            {
                return Result.CreateError(hresult);
            }

            var commandTargets = commandTargetFactoryList
                .Select(x => x.CreateCommandTarget(nextCommandTarget, vimBufferCoordinator))
                .Where(x => x != null)
                .ToReadOnlyCollection();
            vsCommandTarget.CompleteInit(nextCommandTarget, commandTargets);
            return Result.CreateSuccess(vsCommandTarget);
        }
Exemplo n.º 41
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil, IWpfTextView wpfTextView)
     : base(bufferCoordinator.VimBuffer, keyUtil, wpfTextView)
 {
     _adapter              = adapter;
     _reportDesignerUtil   = reportDesignerUtil;
     _bufferCoordinator    = bufferCoordinator;
     _searchInProgressInfo = new Lazy <PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
Exemplo n.º 42
0
 public KeyUtilTest()
 {
     _keyUtilRaw = new KeyUtil();
     _keyUtil    = _keyUtilRaw;
 }
Exemplo n.º 43
0
 public KeyUtilTest()
 {
     _keyUtilRaw = new KeyUtil();
     _keyUtil = _keyUtilRaw;
 }
Exemplo n.º 44
0
 protected AlternateKeyUtilTest()
 {
     _keyUtilRaw = new AlternateKeyUtil();
     _keyUtil    = _keyUtilRaw;
 }
Exemplo n.º 45
0
 public VimKeyProcessor(IVimBuffer vimBuffer, IKeyUtil keyUtil)
 {
     _vimBuffer = vimBuffer;
     _keyUtil = keyUtil;
 }
Exemplo n.º 46
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory = new MockRepository(MockBehavior.Strict);
            _vsKeyProcessorSimulation = new VsKeyProcessorSimulation(this, _wpfTextView);
            _testableSynchronizationContext = new TestableSynchronizationContext();
            _simulateStandardKeyMappings = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyProcessorSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _resharperUtil = _factory.Create<IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(simulateResharper);

            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _defaultCommandTarget = new DefaultCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            var vsTextView = _factory.Create<IVsTextView>();
            IOleCommandTarget nextCommandTarget = _defaultCommandTarget;
            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK);
            var vsCommandTarget = VsCommandTarget.Create(
                bufferCoordinator,
                vsTextView.Object,
                _factory.Create<ITextManager>().Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _resharperUtil.Object,
                _keyUtil).Value;

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget);
                _commandTarget = resharperCommandTarget;
            }
            else
            {
                _commandTarget = vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input.
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            _vsKeyProcessorSimulation.KeyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil));
            _vsKeyProcessorSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
Exemplo n.º 47
0
        internal static Result<VsCommandTarget> Create(
            IVimBufferCoordinator bufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IResharperUtil resharperUtil,
            IKeyUtil keyUtil)
        {
            var vsCommandTarget = new VsCommandTarget(bufferCoordinator, textManager, adapter, broker, resharperUtil, keyUtil);
            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out vsCommandTarget._nextTarget);
            var result = Result.CreateSuccessOrError(vsCommandTarget, hresult);
            if (result.IsSuccess)
            {
                bufferCoordinator.VimBuffer.TextView.Properties[Key] = vsCommandTarget;
            }

            return result;
        }
Exemplo n.º 48
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil     = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory     = new MockRepository(MockBehavior.Strict);
            _vsKeyboardInputSimulation   = new VsKeyboardInputSimulation(this, _wpfTextView);
            _simulateStandardKeyMappings = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyboardInputSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _reportDesignerUtil = _factory.Create <IReportDesignerUtil>();
            _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false);

            _displayWindowBroker = _factory.Create <IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);

            _vimApplicationSettings = _factory.Create <IVimApplicationSettings>();
            _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorIndent).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorTabAndBackspace).Returns(true);

            _commonOperations = _factory.Create <ICommonOperations>();

            _vsSimulationCommandTarget = new SimulationCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            var textManager    = _factory.Create <ITextManager>();
            var commandTargets = new List <ICommandTarget>();

            if (simulateResharper)
            {
                commandTargets.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            commandTargets.Add(new StandardCommandTarget(
                                   bufferCoordinator,
                                   textManager.Object,
                                   _commonOperations.Object,
                                   _displayWindowBroker.Object,
                                   _vsSimulationCommandTarget));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            _vsCommandTarget = new VsCommandTarget(
                bufferCoordinator,
                textManager.Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _keyUtil,
                _vimApplicationSettings.Object,
                _vsSimulationCommandTarget,
                commandTargets.ToReadOnlyCollectionShallow());

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                _reSharperCommandTarget = new ReSharperCommandTargetSimulation(_wpfTextView, _vsCommandTarget);
                _commandTarget          = _reSharperCommandTarget;
            }
            else
            {
                _commandTarget = _vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input.
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            if (simulateResharper)
            {
                _vsKeyboardInputSimulation.KeyProcessors.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            _vsKeyboardInputSimulation.KeyProcessors.Add(new VsVimKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil, _reportDesignerUtil.Object));
            _vsKeyboardInputSimulation.KeyProcessors.Add((KeyProcessor)bufferCoordinator);
            _vsKeyboardInputSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
Exemplo n.º 49
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil)
     : base(bufferCoordinator.VimBuffer, keyUtil)
 {
     _adapter = adapter;
     _bufferCoordinator = bufferCoordinator;
 }
Exemplo n.º 50
0
 public VimKeyProcessor(IVimBuffer vimBuffer, IKeyUtil keyUtil)
 {
     _vimBuffer = vimBuffer;
     _keyUtil   = keyUtil;
 }
Exemplo n.º 51
0
 internal DefaultKeyProcessorProvider(IVim vim, IKeyUtil keyUtil)
 {
     _vim     = vim;
     _keyUtil = keyUtil;
 }
Exemplo n.º 52
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil     = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory     = new MockRepository(MockBehavior.Strict);
            _vsKeyProcessorSimulation       = new VsKeyProcessorSimulation(this, _wpfTextView);
            _testableSynchronizationContext = new TestableSynchronizationContext();
            _simulateStandardKeyMappings    = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyProcessorSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _resharperUtil = _factory.Create <IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(simulateResharper);

            _displayWindowBroker = _factory.Create <IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _defaultCommandTarget = new DefaultCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            var vsTextView = _factory.Create <IVsTextView>();
            IOleCommandTarget nextCommandTarget = _defaultCommandTarget;

            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK);
            var vsCommandTarget = VsCommandTarget.Create(
                bufferCoordinator,
                vsTextView.Object,
                _factory.Create <ITextManager>().Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _resharperUtil.Object,
                _keyUtil).Value;

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget);
                _commandTarget = resharperCommandTarget;
            }
            else
            {
                _commandTarget = vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input.
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            _vsKeyProcessorSimulation.KeyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil));
            _vsKeyProcessorSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
Exemplo n.º 53
0
 internal KeyboardDeviceImpl(IKeyUtil keyUtil)
 {
     _keyUtil = keyUtil;
 }
Exemplo n.º 54
0
 protected AlternateKeyUtilTest()
 {
     _keyUtilRaw = new AlternateKeyUtil();
     _keyUtil = _keyUtilRaw;
 }