Ejemplo n.º 1
0
 private void OnSettingChanged(IVimBuffer buffer, Setting args)
 {
     if (args.Name == WindowSettingNames.CursorLineName && buffer.TextView.Options != null)
     {
         buffer.TextView.Options.SetOptionValue(DefaultWpfViewOptions.EnableHighlightCurrentLineId, buffer.WindowSettings.CursorLine);
     }
 }
Ejemplo n.º 2
0
 protected VimMouseProcessorTest()
 {
     _vimBuffer = CreateVimBuffer("");
     _keyboardDevice = new Mock<IKeyboardDevice>(MockBehavior.Loose);
     _keyboardDevice.SetupGet(x => x.KeyModifiers).Returns(VimKeyModifiers.None);
     _vimMouseProcessor = new VimMouseProcessor(_vimBuffer, _keyboardDevice.Object);
 }
Ejemplo n.º 3
0
        internal CommandMarginController(IVimBuffer buffer, FrameworkElement parentVisualElement, CommandMarginControl control, IEditorFormatMap editorFormatMap, IFontProperties fontProperties, IEnumerable<Lazy<IOptionsProviderFactory>> optionsProviderFactory)
        {
            _vimBuffer = buffer;
            _margin = control;
            _parentVisualElement = parentVisualElement;
            _editorFormatMap = editorFormatMap;
            _fontProperties = fontProperties;
            _optionsProviderFactory = optionsProviderFactory.ToList().AsReadOnly();

            _vimBuffer.SwitchedMode += OnSwitchMode;
            _vimBuffer.KeyInputStart += OnKeyInputStart;
            _vimBuffer.KeyInputEnd += OnKeyInputEnd;
            _vimBuffer.StatusMessage += OnStatusMessage;
            _vimBuffer.ErrorMessage += OnErrorMessage;
            _vimBuffer.WarningMessage += OnWarningMessage;
            _vimBuffer.CommandMode.CommandChanged += OnCommandChanged;
            _vimBuffer.Vim.MacroRecorder.RecordingStarted += OnRecordingStarted;
            _vimBuffer.Vim.MacroRecorder.RecordingStopped += OnRecordingStopped;
            _margin.Loaded += OnCommandMarginLoaded;
            _margin.Unloaded += OnCommandMarginUnloaded;
            _margin.OptionsButton.Click += OnOptionsClicked;
            _margin.CommandLineTextBox.PreviewKeyDown += OnCommandLineTextBoxPreviewKeyDown;
            _margin.CommandLineTextBox.TextChanged += OnCommandLineTextBoxTextChanged;
            _margin.CommandLineTextBox.SelectionChanged += OnCommandLineTextBoxSelectionChanged;
            _margin.CommandLineTextBox.LostKeyboardFocus += OnCommandLineTextBoxLostKeyboardFocus;
            _margin.CommandLineTextBox.PreviewMouseDown += OnCommandLineTextBoxPreviewMouseDown;
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            UpdateForRecordingChanged();
            UpdateTextColor();
        }
Ejemplo n.º 4
0
        public void VimBufferCreated(IVimBuffer vimBuffer)
        {
            var taggerList = new List<ITagger<ITag>>();
            var bufferAdapterList = new List<IExternalEditAdapter>();
            var textView = vimBuffer.TextView;

            foreach (var adapter in _adapterList)
            {
                ITagger<ITag> tagger;
                if (adapter.IsInterested(textView, out tagger))
                {
                    bufferAdapterList.Add(adapter);
                    if (tagger != null)
                    {
                        taggerList.Add(tagger);
                    }
                }
            }

            if (bufferAdapterList.Count > 0)
            {
                _monitorMap[vimBuffer] = new ExternalEditMonitor(
                    vimBuffer,
                    _protectedOperations,
                    _vsAdapter.GetTextLines(vimBuffer.TextBuffer),
                    taggerList.ToReadOnlyCollectionShallow(),
                    bufferAdapterList.ToReadOnlyCollectionShallow());
                vimBuffer.Closed += delegate { _monitorMap.Remove(vimBuffer); };
            }
        }
Ejemplo n.º 5
0
 public MouseProcessor(IVimBuffer buffer, IMouseDevice mouseDevice)
 {
     _buffer = buffer;
     _selection = buffer.TextView.Selection;
     _mouseDevice = mouseDevice;
     _selection.SelectionChanged += OnSelectionChanged;
 }
Ejemplo n.º 6
0
 public void CreateBuffer(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     _textView = tuple.Item1;
     var service = EditorUtil.FactoryService;
     _buffer = service.vim.CreateBuffer(_textView);
 }
Ejemplo n.º 7
0
        internal CommandMarginController(IVimBuffer buffer, FrameworkElement parentVisualElement, CommandMarginControl control, IEditorFormatMap editorFormatMap, IEnumerable<Lazy<IOptionsProviderFactory>> optionsProviderFactory)
        {
            _vimBuffer = buffer;
            _margin = control;
            _parentVisualElement = parentVisualElement;
            _editorFormatMap = editorFormatMap;
            _optionsProviderFactory = optionsProviderFactory.ToList().AsReadOnly();

            _vimBuffer.SwitchedMode += OnSwitchMode;
            _vimBuffer.KeyInputStart += OnKeyInputStart;
            _vimBuffer.KeyInputEnd += OnKeyInputEnd;
            _vimBuffer.StatusMessage += OnStatusMessage;
            _vimBuffer.ErrorMessage += OnErrorMessage;
            _vimBuffer.WarningMessage += OnWarningMessage;
            _vimBuffer.CommandMode.CommandChanged += OnCommandChanged;
            _vimBuffer.Vim.MacroRecorder.RecordingStarted += OnRecordingStarted;
            _vimBuffer.Vim.MacroRecorder.RecordingStopped += OnRecordingStopped;
            _margin.OptionsClicked += OnOptionsClicked;
            _margin.CancelCommandEdition += OnCancelCommandEdition;
            _margin.RunCommandEdition += OnRunCommandEdition;
            _margin.HistoryGoPrevious += OnHistoryGoPrevious;
            _margin.HistoryGoNext += OnHistoryGoNext;
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            UpdateForRecordingChanged();
            UpdateTextColor();
        }
Ejemplo n.º 8
0
 void IVimBufferCreationListener.VimBufferCreated(IVimBuffer vimBuffer)
 {
     // Let the command margin get into a known state before we disable it.  
     _vimProtectedOperations.BeginInvoke(
         () => _commandMarginUtil.SetMarginVisibility(vimBuffer, _vimApplicationSettings.UseEditorCommandMargin),
         DispatcherPriority.ApplicationIdle);
 }
Ejemplo n.º 9
0
 internal VsCommandFilter(IVimBuffer buffer, IVsTextView view, IServiceProvider provider)
 {
     _buffer = buffer;
     _textView = view;
     _serviceProvider = provider;
     var hr = view.AddCommandFilter(this, out _nextTarget);
 }
Ejemplo n.º 10
0
        public VsCommandTargetTest()
        {
            _textView = CreateTextView("");
            _buffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_buffer);
            _vim = _buffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            // By default Resharper isn't loaded
            _resharperUtil = _factory.Create<IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(false);

            _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict);
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
            _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.InDebugMode).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);

            _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose);

            var oldCommandFilter = _nextTarget.Object;
            var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose);
            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0);
            var result = VsCommandTarget.Create(
                _bufferCoordinator,
                vsTextView.Object,
                _vsAdapter.Object,
                _broker.Object,
                _resharperUtil.Object,
                KeyUtil);
            Assert.True(result.IsSuccess);
            _targetRaw = result.Value;
            _target = _targetRaw;
        }
        void IVimBufferCreationListener.VimBufferCreated(IVimBuffer vimBuffer)
        {
            // If the notification has occured then there is nothing else to do.  We are done
            if (_vimApplicationSettings.HaveNotifiedVimRcLoad)
            {
                return;
            }

            if (!_vim.VimRcState.IsLoadSucceeded)
            {
                return;
            }

            var vimRcPath = ((VimRcState.LoadSucceeded)_vim.VimRcState).Item;
            if (vimRcPath.VimRcKind != VimRcKind.VimRc)
            {
                return;
            }

            var wpfTextView = vimBuffer.TextView as IWpfTextView;
            if (wpfTextView == null)
            {
                return;
            }

            var linkBanner = new LinkBanner();
            linkBanner.LinkAddress = "https://github.com/jaredpar/VsVim/wiki/FAQ#vimrc";
            linkBanner.LinkText = "FAQ";
            linkBanner.BannerText = "VsVim automatically loaded an existing _vimrc file";
            _toastNotificationServiceProvider.GetToastNoficationService(wpfTextView).Display(_toastKey, linkBanner, OnToastNotificationClosed);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create a Visual Studio simulation with the specified set of lines
        /// </summary>
        private void CreateCore(bool simulateResharper, bool usePeekRole, params string[] lines)
        {
            if (usePeekRole)
            {
                _textBuffer = CreateTextBuffer(lines);
                _textView = TextEditorFactoryService.CreateTextView(
                    _textBuffer,
                    TextEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Editable, Constants.TextViewRoleEmbeddedPeekTextView));
            }
            else
            {
                _textView = CreateTextView(lines);
                _textBuffer = _textView.TextBuffer;
            }
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
            _vsSimulation = new VsSimulation(
                _bufferCoordinator,
                simulateResharper: simulateResharper,
                simulateStandardKeyMappings: false,
                editorOperationsFactoryService: EditorOperationsFactoryService,
                keyUtil: KeyUtil);

            VimHost.TryCustomProcessFunc = (textView, insertCommand) =>
                {
                    if (textView == _textView)
                    {
                        return _vsSimulation.VsCommandTarget.TryCustomProcess(insertCommand);
                    }

                    return false;
                };
        }
        void IVimBufferCreationListener.VimBufferCreated(IVimBuffer vimBuffer)
        {
            if (!_vim.VimRcState.IsLoadSucceeded)
            {
                return;
            }

            var wpfTextView = vimBuffer.TextView as IWpfTextView;
            if (wpfTextView == null)
            {
                return;
            }

            var state = ((VimRcState.LoadSucceeded)_vim.VimRcState);

            // If the notification has occured then there is nothing else to do.  We are done
            if (!_vimApplicationSettings.HaveNotifiedVimRcLoad && state.Item1.VimRcKind == VimRcKind.VimRc)
            {
                var linkBanner = new LinkBanner();
                linkBanner.LinkAddress = "https://github.com/jaredpar/VsVim/wiki/FAQ#vimrc";
                linkBanner.LinkText = "FAQ";
                linkBanner.BannerText = "VsVim automatically loaded an existing _vimrc file";
                _toastNotificationServiceProvider.GetToastNoficationService(wpfTextView).Display(_notifyToastKey, linkBanner, OnNotifyClosed);
            }

            if (!_vimApplicationSettings.HaveNotifiedVimRcErrors && state.Item2.Length != 0)
            {
                var errorBanner = new ErrorBanner();
                errorBanner.ViewClick += (sender, e) => OnViewClick(state.Item2);
                _toastNotificationServiceProvider.GetToastNoficationService(wpfTextView).Display(_errorToastKey, errorBanner, OnErrorClosed);
            }
        }
Ejemplo n.º 14
0
 public void Create(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     _textView = tuple.Item1;
     _textBuffer = _textView.TextBuffer;
     var service = EditorUtil.FactoryService;
     _buffer = service.Vim.CreateBuffer(_textView);
     _buffer.ErrorMessage +=
         (_, message) =>
         {
             if (_assertOnErrorMessage)
             {
                 Assert.Fail("Error Message: " + message);
             }
         };
     _buffer.WarningMessage +=
         (_, message) =>
         {
             if (_assertOnWarningMessage)
             {
                 Assert.Fail("Warning Message: " + message);
             }
         };
     _keyMap = _buffer.Vim.KeyMap;
     _globalSettings = _buffer.Settings.GlobalSettings;
     _jumpList = _buffer.JumpList;
 }
        protected FallbackKeyProcessorTest(bool useVimBuffer = false)
        {
            _keyboardDevice = new MockKeyboardDevice();
            _commands = new Mock<Commands>(MockBehavior.Strict);
            _dte = new Mock<_DTE>(MockBehavior.Loose);
            _dte.SetupGet(x => x.Commands).Returns(_commands.Object);
            _vsShell = new Mock<IVsShell>(MockBehavior.Loose);
            _removedBindingList = new List<CommandKeyBinding>();
            _vimApplicationSettings = new Mock<IVimApplicationSettings>(MockBehavior.Loose);
            _vimApplicationSettings
                .SetupGet(x => x.RemovedBindings)
                .Returns(() => _removedBindingList.AsReadOnly());

            var textView = CreateTextView("");
            _vimBuffer = useVimBuffer
                ? Vim.GetOrCreateVimBuffer(textView)
                : null;
            _keyProcessor = new FallbackKeyProcessor(
                _vsShell.Object,
                _dte.Object,
                CompositionContainer.GetExportedValue<IKeyUtil>(),
                _vimApplicationSettings.Object,
                textView,
                _vimBuffer,
                new ScopeData());
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Compute the set of keys that conflict with and have been already been removed.
        /// </summary>
        internal CommandKeyBindingSnapshot CreateCommandKeyBindingSnapshot(IVimBuffer buffer)
        {
            // Get the list of all KeyInputs that are the first key of a VsVim command
            var hashSet = new HashSet<KeyInput>(
                buffer.AllModes
                .Select(x => x.CommandNames)
                .SelectMany(x => x)
                .Where(x => x.KeyInputs.Length > 0)
                .Select(x => x.KeyInputs.First()));

            // Need to get the custom key bindings in the list.  It's very common for users
            // to use for example function keys (<F2>, <F3>, etc ...) in their mappings which
            // are often bound to other Visual Studio commands.
            var keyMap = buffer.Vim.KeyMap;
            foreach (var keyRemapMode in KeyRemapMode.All)
            {
                foreach (var keyMapping in keyMap.GetKeyMappingsForMode(keyRemapMode))
                {
                    keyMapping.Left.KeyInputs.ForEach(keyInput => hashSet.Add(keyInput));
                }
            }

            // Include the key used to disable VsVim
            hashSet.Add(buffer.LocalSettings.GlobalSettings.DisableAllCommand);

            return CreateCommandKeyBindingSnapshot(hashSet);
        }
Ejemplo n.º 17
0
 protected void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
     _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
     VimHost.FocusedTextView = _textView;
 }
Ejemplo n.º 18
0
 private void OnSettingChanged(IVimBuffer vimBuffer, SettingEventArgs args)
 {
     var setting = args.Setting;
     if (setting.Name == WindowSettingNames.CursorLineName)
     {
         SyncVimToEditor(vimBuffer);
     }
 }
Ejemplo n.º 19
0
 public void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _buffer = EditorUtil.FactoryService.Vim.CreateBuffer(_textView);
     _search = _buffer.IncrementalSearch;
     _taggerRaw = new IncrementalSearchTagger(_buffer);
     _tagger = _taggerRaw;
 }
Ejemplo n.º 20
0
 private void OnSettingChanged(IVimBuffer buffer, Setting args)
 {
     if (args.Name == LocalSettingNames.CursorLineName)
     {
         var options = _editorOptionsFatoryService.GetOptions(buffer.TextView);
         options.SetOptionValue(DefaultWpfViewOptions.EnableHighlightCurrentLineId, buffer.Settings.CursorLine);
     }
 }
Ejemplo n.º 21
0
 public void Create(params string[] lines)
 {
     _vimBuffer = CreateVimBuffer(lines);
     _vimBuffer.StatusMessage += (sender, args) => { _lastStatus = args.Message; };
     _textView = _vimBuffer.TextView;
     _textBuffer = _textView.TextBuffer;
     _vimHost = VimHost;
 }
 public void Setup()
 {
     _synchronizer = new EditorToSettingSynchronizer(EditorUtil.FactoryService.Vim);
     _buffer = EditorUtil.FactoryService.Vim.CreateBuffer(EditorUtil.CreateTextView(""));
     _localSettings = _buffer.LocalSettings;
     _globalSettings = _localSettings.GlobalSettings;
     _editorOptions = _localSettings.EditorOptions.Value;
 }
Ejemplo n.º 23
0
 public void CreateBuffer(params string[] lines)
 {
     var tuple = Utils.EditorUtil.CreateViewAndOperations(lines);
     m_view = tuple.Item1;
     var service = EditorUtil.FactoryService;
     m_buffer = service.vim.CreateBuffer(m_view);
     m_host = (FakeVimHost)service.vim.Host;
 }
Ejemplo n.º 24
0
 protected void Create(params string[] lines)
 {
     _vimBuffer = CreateVimBuffer(lines);
     _textBuffer = _vimBuffer.TextBuffer;
     _vimKeyProcessor = new VimKeyProcessor(_vimBuffer, KeyUtil);
     _simulation = new KeyboardInputSimulation((IWpfTextView)_vimBuffer.TextView);
     _simulation.KeyProcessors.Add(_vimKeyProcessor);
 }
Ejemplo n.º 25
0
 public void CreateBuffer(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     _textView = tuple.Item1;
     var service = EditorUtil.FactoryService;
     _buffer = service.vim.CreateBuffer(_textView);
     _buffer.SwitchMode(ModeKind.Insert, ModeArgument.None);
 }
Ejemplo n.º 26
0
        protected void Create(bool insertMode, params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _factory.DefaultValue = DefaultValue.Mock;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vim = _factory.Create<IVim>(MockBehavior.Loose);
            _editorOptions = _factory.Create<IEditorOptions>(MockBehavior.Loose);
            _textChangeTracker = _factory.Create<ITextChangeTracker>(MockBehavior.Loose);
            _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption<TextChange>.None);
            _undoRedoOperations = CreateUndoRedoOperations();
            _wordCompletionSessionFactoryService = _factory.Create<IWordCompletionSessionFactoryService>();

            var localSettings = new LocalSettings(Vim.GlobalSettings);
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _globalSettings = _vimBuffer.GlobalSettings;
            var vimTextBuffer = Vim.GetOrCreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            _operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _broker = _factory.Create<IDisplayWindowBroker>();
            _broker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _broker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _insertUtil = _factory.Create<IInsertUtil>();
            _motionUtil = _factory.Create<IMotionUtil>();
            _commandUtil = _factory.Create<ICommandUtil>();
            _capture = _factory.Create<IMotionCapture>();

            // Setup the mouse.  By default we say it has no buttons down as that's the normal state
            _mouseDevice = _factory.Create<IMouseDevice>();
            _mouseDevice.SetupGet(x => x.IsLeftButtonPressed).Returns(false);

            // Setup the keyboard.  By default we don't say that any button is pressed.  Insert mode is usually
            // only concerned with arrow keys and we will set those up as appropriate for the typing tests
            _keyboardDevice = _factory.Create<IKeyboardDevice>();
            _keyboardDevice.Setup(x => x.IsArrowKeyDown).Returns(false);

            _modeRaw = new global::Vim.Modes.Insert.InsertMode(
                _vimBuffer,
                _operations,
                _broker.Object,
                _editorOptions.Object,
                _undoRedoOperations,
                _textChangeTracker.Object,
                _insertUtil.Object,
                _motionUtil.Object,
                _commandUtil.Object,
                _capture.Object,
                !insertMode,
                _keyboardDevice.Object,
                _mouseDevice.Object,
                WordUtil,
                _wordCompletionSessionFactoryService.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
            _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; };
        }
Ejemplo n.º 27
0
 public void CreateBuffer(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     view = tuple.Item1;
     host = new MockVimHost();
     var service = EditorUtil.FactoryService;
     buffer = service.vim.CreateBuffer(view);
     host = (MockVimHost)service.vim.VimHost;
 }
 private void Create(params string[] lines)
 {
     _globalSettings = Vim.GlobalSettings;
     _vimBuffer = CreateVimBuffer(lines);
     _textView = (IWpfTextView)_vimBuffer.TextView;
     _textBuffer = _vimBuffer.TextBuffer;
     _commonOperationsRaw = (CommonOperations)CommonOperationsFactory.GetCommonOperations(_vimBuffer.VimBufferData);
     _commonOperations = _commonOperationsRaw;
 }
Ejemplo n.º 29
0
 void IVimBufferCreationListener.VimBufferCreated(IVimBuffer buffer)
 {
     var textView = buffer.TextView;
     textView.Closed += (x, y) =>
     {
         buffer.Close();
         _bufferMap.Remove(buffer);
     };
 }
Ejemplo n.º 30
0
        internal static string GetStatus(IVimBuffer vimBuffer, IMode currentMode, bool forModeSwitch)
        {
            if (forModeSwitch)
            {
                return GetStatusCommon(vimBuffer, currentMode);
            }

            return GetStatusOther(vimBuffer, currentMode);
        }
Ejemplo n.º 31
0
        public static Register GetRegister(this IVimBuffer buffer, char c)
        {
            var name = RegisterNameUtil.CharToRegister(c).Value;

            return(buffer.RegisterMap.GetRegister(name));
        }
Ejemplo n.º 32
0
 public SettingsTest()
 {
     _vimBuffer = CreateVimBuffer("hello world");
     _textView  = _vimBuffer.TextView;
 }
Ejemplo n.º 33
0
 public static bool Process(this IVimBuffer buf, char c)
 {
     return(buf.Process(KeyInputUtil.CharToKeyInput(c)).IsAnyHandled);
 }
Ejemplo n.º 34
0
 public DisabledModeIntegrationTest()
 {
     _vimBuffer1 = CreateVimBuffer("vim buffer 1");
     _vimBuffer2 = CreateVimBuffer("vim buffer 2");
 }
Ejemplo n.º 35
0
        void ICSharpScriptExecutor.Execute(IVimBuffer vimBuffer, CallInfo callInfo, bool createEachTime)
        {
            var task = ExecuteAsync(vimBuffer, callInfo, createEachTime);

            VimTrace.TraceInfo("CSharptScript:Execute {0}", callInfo.Name);
        }
Ejemplo n.º 36
0
 string ICommandMarginUtil.GetStatus(IVimBuffer vimBuffer)
 {
     return(GetStatus(vimBuffer, vimBuffer.Mode, forModeSwitch: false));
 }
Ejemplo n.º 37
0
 CommandKeyBindingSnapshot IKeyBindingService.CreateCommandKeyBindingSnapshot(IVimBuffer vimBuffer)
 {
     return(CreateCommandKeyBindingSnapshot(vimBuffer));
 }
Ejemplo n.º 38
0
 protected virtual void Create(params string[] lines)
 {
     _vimBuffer  = CreateVimBuffer(lines);
     _textView   = _vimBuffer.TextView;
     _textBuffer = _textView.TextBuffer;
 }
Ejemplo n.º 39
0
 public CommandMargin(IVimBuffer buffer, IEditorFormatMap editorFormatMap, IEnumerable <Lazy <IOptionsProviderFactory> > optionsProviderFactories)
 {
     _margin.StatusLine = "Welcome to Vim";
     _controller        = new CommandMarginController(buffer, _margin, editorFormatMap, optionsProviderFactories);
 }
Ejemplo n.º 40
0
 void IVimBufferCreationListener.VimBufferCreated(IVimBuffer vimBuffer)
 {
     OnVimBufferCreated(vimBuffer);
 }
Ejemplo n.º 41
0
 internal void AddViewInfo(IVimBuffer vimBuffer, IWpfTextViewHost textViewHost)
 {
     _viewInfoList.Add(new ViewInfo(vimBuffer, textViewHost));
 }
Ejemplo n.º 42
0
 protected void UpdateTabStop(IVimBuffer vimBuffer, int tabStop)
 {
     vimBuffer.LocalSettings.TabStop   = tabStop;
     vimBuffer.LocalSettings.ExpandTab = false;
     UpdateLayout(vimBuffer.TextView);
 }
Ejemplo n.º 43
0
 public static bool Process(this IVimBuffer buf, VimKey key)
 {
     return(buf.Process(KeyInputUtil.VimKeyToKeyInput(key)));
 }
Ejemplo n.º 44
0
 private ReSharperKeyUtil(IVimBufferCoordinator vimBufferCoordinator)
 {
     _vimBufferCoordinator = vimBufferCoordinator;
     _vimBuffer            = vimBufferCoordinator.VimBuffer;
 }
Ejemplo n.º 45
0
        private static string GetStatusCommon(IVimBuffer vimBuffer, IMode currentMode)
        {
            // Calculate the argument string if we are in one time command mode
            string oneTimeArgument = null;

            if (vimBuffer.InOneTimeCommand.IsSome())
            {
                if (vimBuffer.InOneTimeCommand.Is(ModeKind.Insert))
                {
                    oneTimeArgument = "insert";
                }
                else if (vimBuffer.InOneTimeCommand.Is(ModeKind.Replace))
                {
                    oneTimeArgument = "replace";
                }
            }

            // Check if we can enable the command line to accept user input
            var    search = vimBuffer.IncrementalSearch;
            string status;

            switch (currentMode.ModeKind)
            {
            case ModeKind.Normal:
                status = string.IsNullOrEmpty(oneTimeArgument)
                        ? string.Empty
                        : string.Format(Resources.NormalOneTimeCommandBanner, oneTimeArgument);
                break;

            case ModeKind.Command:
                status = ":" + vimBuffer.CommandMode.Command;
                break;

            case ModeKind.Insert:
                status = Resources.InsertBanner;
                break;

            case ModeKind.Replace:
                status = Resources.ReplaceBanner;
                break;

            case ModeKind.VisualBlock:
                status = string.IsNullOrEmpty(oneTimeArgument)
                        ? Resources.VisualBlockBanner
                        : string.Format(Resources.VisualBlockOneTimeCommandBanner, oneTimeArgument);
                break;

            case ModeKind.VisualCharacter:
                status = string.IsNullOrEmpty(oneTimeArgument)
                        ? Resources.VisualCharacterBanner
                        : string.Format(Resources.VisualCharacterOneTimeCommandBanner, oneTimeArgument);
                break;

            case ModeKind.VisualLine:
                status = string.IsNullOrEmpty(oneTimeArgument)
                        ? Resources.VisualLineBanner
                        : string.Format(Resources.VisualLineOneTimeCommandBanner, oneTimeArgument);
                break;

            case ModeKind.SelectBlock:
                status = Resources.SelectBlockBanner;
                break;

            case ModeKind.SelectCharacter:
                status = Resources.SelectCharacterBanner;
                break;

            case ModeKind.SelectLine:
                status = Resources.SelectLineBanner;
                break;

            case ModeKind.ExternalEdit:
                status = Resources.ExternalEditBanner;
                break;

            case ModeKind.Disabled:
                status = vimBuffer.DisabledMode.HelpMessage;
                break;

            case ModeKind.SubstituteConfirm:
                status = GetStatusSubstituteConfirm(vimBuffer.SubstituteConfirmMode);
                break;

            default:
                status = string.Empty;
                break;
            }

            return(status);
        }
Ejemplo n.º 46
0
 public static BlockSpan GetSelectionBlockSpan(this IVimBuffer vimBuffer)
 {
     return(GetSelectionBlockSpan(vimBuffer.TextView, vimBuffer.LocalSettings.TabStop));
 }
Ejemplo n.º 47
0
 void ICommandMarginUtil.SetMarginVisibility(IVimBuffer vimBuffer, bool commandMarginVisible)
 {
     SetMarginVisibility(vimBuffer, commandMarginVisible);
 }
Ejemplo n.º 48
0
 public static BlockSpan GetBlockSpan(this IVimBuffer vimBuffer, int column, int length, int startLine = 0, int lineCount = 1)
 {
     return(GetBlockSpan(vimBuffer.TextBuffer, column, length, startLine, lineCount, vimBuffer.LocalSettings.TabStop));
 }
Ejemplo n.º 49
0
        /// <summary>
        /// Compute the set of keys that conflict with and have been already been removed.
        /// </summary>
        internal CommandKeyBindingSnapshot CreateCommandKeyBindingSnapshot(IVimBuffer vimBuffer)
        {
            var hashSet = CreateVimFirstKeyInputSet(vimBuffer);

            return(CreateCommandKeyBindingSnapshot(hashSet));
        }
Ejemplo n.º 50
0
 public void RunCSharpScript(IVimBuffer vimBuffer, CallInfo callInfo, bool createEachTime)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 51
0
 void IKeyBindingService.RunConflictingKeyBindingStateCheck(IVimBuffer buffer)
 {
     RunConflictingKeyBindingStateCheck(buffer);
 }
Ejemplo n.º 52
0
 void IVimBufferCreationListener.VimBufferCreated(IVimBuffer vimBuffer)
 {
     Count++;
     VimBuffer = vimBuffer;
 }
Ejemplo n.º 53
0
 public VimKeyProcessor(IVimBuffer vimBuffer, IKeyUtil keyUtil)
 {
     _vimBuffer = vimBuffer;
     _keyUtil   = keyUtil;
 }
Ejemplo n.º 54
0
 protected VimMouseProcessorTest()
 {
     _vimBuffer         = CreateVimBuffer("");
     _vimMouseProcessor = new VimMouseProcessor(_vimBuffer);
 }
Ejemplo n.º 55
0
 internal ViewInfo(IVimBuffer vimBuffer, IWpfTextViewHost textViewHost)
 {
     _vimBuffer    = vimBuffer;
     _textViewHost = textViewHost;
 }
Ejemplo n.º 56
0
 public CommandMargin(FrameworkElement parentVisualElement, IVimBuffer buffer, IEditorFormatMap editorFormatMap, IClassificationFormatMap classificationFormatMap, ICommonOperations commonOperations, IClipboardDevice clipboardDevice, bool isFirstCommandMargin)
 {
     _margin.CommandLineTextBox.Text = isFirstCommandMargin ? $"Welcome to VsVim Version {VimConstants.VersionNumber}" : string.Empty;
     _controller = new CommandMarginController(buffer, parentVisualElement, _margin, editorFormatMap, classificationFormatMap, commonOperations, clipboardDevice);
     _enabled    = true;
 }
Ejemplo n.º 57
0
 internal VimMouseProcessor(IVimBuffer vimBuffer)
 {
     _vimBuffer = vimBuffer;
 }
Ejemplo n.º 58
0
        /// <summary>
        /// Helper for the CanProcessAsCommand function which maps the char to a KeyInput value
        /// </summary>
        public static bool CanProcessAsCommand(this IVimBuffer buffer, char c)
        {
            var keyInput = KeyInputUtil.CharToKeyInput(c);

            return(buffer.CanProcessAsCommand(keyInput));
        }
Ejemplo n.º 59
0
        /// <summary>
        /// Helper for the CanProcessAsCommand function which maps the VimKey to a KeyInput value
        /// </summary>
        public static bool CanProcessAsCommand(this IVimBuffer buffer, VimKey key)
        {
            var keyInput = KeyInputUtil.VimKeyToKeyInput(key);

            return(buffer.CanProcessAsCommand(keyInput));
        }
Ejemplo n.º 60
0
        private void RaiseVimBufferCreated(IVimBuffer vimBuffer)
        {
            var listener = (IVimBufferCreationListener)_hostFactory;

            listener.VimBufferCreated(vimBuffer);
        }