Пример #1
0
        public InformationBarMargin(IWpfTextView textView, ITextDocument document, IEditorOperations editorOperations, ITextUndoHistory undoHistory, DTE dte)
        {
            _textView = textView;
            _document = document;
            _operations = editorOperations;
            _undoHistory = undoHistory;
            _dte = dte;

            _informationBarControl = new InformationBarControl();
            _informationBarControl.Hide.Click += Hide;
            _informationBarControl.DontShowAgain.Click += DontShowAgain;
            var format = new Action(() => this.FormatDocument());
            _informationBarControl.Tabify.Click += (s, e) => this.Dispatcher.Invoke(format);

            this.Height = 0;
            this.Content = _informationBarControl;
            this.Name = MarginName;

            document.FileActionOccurred += FileActionOccurred;
            textView.Closed += TextViewClosed;

            // Delay the initial check until the view gets focus
            textView.GotAggregateFocus += GotAggregateFocus;

            this._tabDirectiveParser = new TabDirectiveParser(textView, document, dte);
            this._fileHeuristics = new FileHeuristics(textView, document, dte);

            var fix = new Action(() => this.FixFile());
            this._tabDirectiveParser.Change += (s, e) => this.Dispatcher.Invoke(fix);
        }
Пример #2
0
 public void CreateLines(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     _view = tuple.Item1;
     _buffer = _view.TextBuffer;
     _operations = tuple.Item2;
 }
Пример #3
0
		public OutputBufferVM(IEditorOperationsFactoryService editorOperationsFactoryService, Guid guid, string name, ILogEditor logEditor) {
			editorOperations = editorOperationsFactoryService.GetEditorOperations(logEditor.TextView);
			Guid = guid;
			Name = name;
			this.logEditor = logEditor;
			index = -1;
			needTimestamp = true;
		}
Пример #4
0
        public TemplateTypingCommandHandler(
            ITextView textView,
            ITextBuffer textBuffer,
            IEditorOptions editorOptions,
            IEditorOperations editorOperations)
#if DEV14_OR_LATER
            : base(textView, _ => textBuffer)
#else
            : base(textView, textBuffer)
 /// <summary>
 /// Attaches events for invoking Statement completion 
 /// </summary>
 public IntellisenseController(IntellisenseControllerProvider provider, ITextView textView) {
     _textView = textView;
     _provider = provider;
     _classifier = _provider._classifierAgg.GetClassifier(_textView.TextBuffer);
     _editOps = provider._EditOperationsFactory.GetEditorOperations(textView);
     _incSearch = provider._IncrementalSearch.GetIncrementalSearch(textView);
     _textView.MouseHover += TextViewMouseHover;
     textView.Properties.AddProperty(typeof(IntellisenseController), this);  // added so our key processors can get back to us
 }
Пример #6
0
 /// <summary>
 /// Attaches events for invoking Statement completion 
 /// </summary>
 public IntellisenseController(IntellisenseControllerProvider provider, ITextView textView)
 {
     _textView = textView;
     _provider = provider;
     _editOps = provider._EditOperationsFactory.GetEditorOperations(textView);
     _incSearch = provider._IncrementalSearch.GetIncrementalSearch(textView);
     _textView.MouseHover += new EventHandler<MouseHoverEventArgs>(TextViewMouseHover);
     textView.Properties.AddProperty(typeof(IntellisenseController), this);  // added so our key processors can get back to us
 }
Пример #7
0
        public void Initialize(ITextView view, IEditorOperations editorOperations, ITextBufferUndoManager undoManager) {
            Debug.Assert(view != null, "view must not be null");
            Debug.Assert(editorOperations != null, "editor operations must not be null");

            _view = view;
            _editorOperations = editorOperations;
            _undoManager = undoManager;
            _braceCompletionTarget = new BraceCompletionCommandTarget(view);
        }
Пример #8
0
        public CompoundUndoAction(ITextView textView, IEditorShell editorShell, bool addRollbackOnCancel = true) {
            if (!editorShell.IsUnitTestEnvironment) {
                IEditorOperationsFactoryService operationsService = editorShell.ExportProvider.GetExportedValue<IEditorOperationsFactoryService>();
                ITextBufferUndoManagerProvider undoProvider = editorShell.ExportProvider.GetExportedValue<ITextBufferUndoManagerProvider>();

                _editorOperations = operationsService.GetEditorOperations(textView);
                _undoManager = undoProvider.GetTextBufferUndoManager(_editorOperations.TextView.TextBuffer);
                _addRollbackOnCancel = addRollbackOnCancel;
            }
        }
Пример #9
0
        public EditFilter(ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider)
        {
            _textView = textView;
            _textView.Properties[typeof(EditFilter)] = this;
            _editorOps = editorOps;
            _serviceProvider = serviceProvider;
            //_componentModel = _serviceProvider.GetComponentModel();

            //BraceMatcher.WatchBraceHighlights(textView, _componentModel);
        }
Пример #10
0
 public TemplateTypingCommandHandler(
     ITextView textView,
     ITextBuffer textBuffer,
     IEditorOptions editorOptions,
     IEditorOperations editorOperations)
     : base(textView, _ => textBuffer)
 {
     _editorOperations = editorOperations;
     _editorOptions = editorOptions;
 }
Пример #11
0
        public RenameTrackingTestState(
            string markup,
            string languageName,
            bool onBeforeGlobalSymbolRenamedReturnValue = true,
            bool onAfterGlobalSymbolRenamedReturnValue = true)
        {
            this.Workspace = CreateTestWorkspace(markup, languageName, TestExportProvider.CreateExportProviderWithCSharpAndVisualBasic());

            _hostDocument = Workspace.Documents.First();
            _view = _hostDocument.GetTextView();
            _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, _hostDocument.CursorPosition.Value));
            _editorOperations = Workspace.GetService<IEditorOperationsFactoryService>().GetEditorOperations(_view);
            _historyRegistry = Workspace.ExportProvider.GetExport<ITextUndoHistoryRegistry>().Value;
            _mockRefactorNotifyService = new MockRefactorNotifyService
            {
                OnBeforeSymbolRenamedReturnValue = onBeforeGlobalSymbolRenamedReturnValue,
                OnAfterSymbolRenamedReturnValue = onAfterGlobalSymbolRenamedReturnValue
            };

            var optionService = this.Workspace.Services.GetService<IOptionService>();

            // Mock the action taken by the workspace INotificationService
            var notificationService = Workspace.Services.GetService<INotificationService>() as INotificationServiceCallback;
            var callback = new Action<string, string, NotificationSeverity>((message, title, severity) => _notificationMessage = message);
            notificationService.NotificationCallback = callback;

            var tracker = new RenameTrackingTaggerProvider(
                _historyRegistry,
                Workspace.ExportProvider.GetExport<Host.IWaitIndicator>().Value,
                Workspace.ExportProvider.GetExport<IInlineRenameService>().Value,
                Workspace.ExportProvider.GetExport<IDiagnosticAnalyzerService>().Value,
                SpecializedCollections.SingletonEnumerable(_mockRefactorNotifyService),
                Workspace.ExportProvider.GetExports<IAsynchronousOperationListener, FeatureMetadata>());

            _tagger = tracker.CreateTagger<RenameTrackingTag>(_hostDocument.GetTextBuffer());

            if (languageName == LanguageNames.CSharp)
            {
                _codeFixProvider = new CSharpRenameTrackingCodeFixProvider(
                    Workspace.ExportProvider.GetExport<Host.IWaitIndicator>().Value,
                    _historyRegistry,
                    SpecializedCollections.SingletonEnumerable(_mockRefactorNotifyService));
            }
            else if (languageName == LanguageNames.VisualBasic)
            {
                _codeFixProvider = new VisualBasicRenameTrackingCodeFixProvider(
                    Workspace.ExportProvider.GetExport<Host.IWaitIndicator>().Value,
                    _historyRegistry,
                    SpecializedCollections.SingletonEnumerable(_mockRefactorNotifyService));
            }
            else
            {
                throw new ArgumentException("Invalid langauge name: " + languageName, "languageName");
            }
        }
Пример #12
0
 /// <summary>
 /// Attaches events for invoking Statement completion 
 /// </summary>
 /// <param name="subjectBuffers"></param>
 /// <param name="textView"></param>
 /// <param name="completionBrokerMap"></param>
 public IntellisenseController(IntellisenseControllerProvider provider, IList<ITextBuffer> subjectBuffers, ITextView textView)
 {
     _subjectBuffers = subjectBuffers;
     _textView = textView;
     _provider = provider;
     _editOps = provider._EditOperationsFactory.GetEditorOperations(textView);
     #if FEATURE_INTELLISENSE
     _textView.MouseHover += new EventHandler<MouseHoverEventArgs>(TextViewMouseHover);
     #endif
     textView.Properties.AddProperty(typeof(IntellisenseController), this);  // added so our key processors can get back to us
 }
Пример #13
0
		public LeftSelectionMargin(IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IWpfTextViewHost wpfTextViewHost, IEditorOperations editorOperations)
			: base(wpfTextViewMarginProviderCollectionProvider, wpfTextViewHost, PredefinedMarginNames.LeftSelection, false) {
			if (editorOperations == null)
				throw new ArgumentNullException(nameof(editorOperations));
			Cursor = Cursors.Arrow;//TODO: Use an arrow pointing to the right
			this.wpfTextViewHost = wpfTextViewHost;
			this.editorOperations = editorOperations;
			wpfTextViewHost.TextView.ZoomLevelChanged += TextView_ZoomLevelChanged;
			// Make sure that the user can click anywhere in this margin so we'll get mouse events
			Background = Brushes.Transparent;
		}
Пример #14
0
		public IncrementalSearch(ITextView textView, ITextSearchService textSearchService, IEditorOperationsFactoryService editorOperationsFactoryService) {
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			if (textSearchService == null)
				throw new ArgumentNullException(nameof(textSearchService));
			if (editorOperationsFactoryService == null)
				throw new ArgumentNullException(nameof(editorOperationsFactoryService));
			TextView = textView;
			this.textSearchService = textSearchService;
			editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
			SearchString = string.Empty;
		}
Пример #15
0
        public VisualRustAutoindent(
            IVsTextView textViewAdapter,
            IWpfTextView textView,
            IEditorOperations operations,
            ITextUndoHistory undoHistory)
        {
            _textView = textView;
            _operations = operations;
            _undoHistory = undoHistory;

            textViewAdapter.AddCommandFilter(this, out _nextCommandHandler);
        }
        internal DefaultKeyProcessor(IWpfTextView textView, IEditorOperations editorOperations, ITextUndoHistoryRegistry undoHistoryRegistry) {
            if (textView == null)
                throw new ArgumentNullException("textView");

            if (editorOperations == null)
                throw new ArgumentNullException("editorOperations");

            if (undoHistoryRegistry == null)
                throw new ArgumentNullException("undoHistoryRegistry");

            _textView = textView;
            _editorOperations = editorOperations;
            _undoHistoryRegistry = undoHistoryRegistry;
        }
 public BraceCompletionSession(
     ITextView textView, ITextBuffer subjectBuffer,
     SnapshotPoint openingPoint, char openingBrace, char closingBrace, ITextUndoHistory undoHistory,
     IEditorOperationsFactoryService editorOperationsFactoryService, IEditorBraceCompletionSession session)
 {
     this.TextView = textView;
     this.SubjectBuffer = subjectBuffer;
     this.OpeningBrace = openingBrace;
     this.ClosingBrace = closingBrace;
     this.ClosingPoint = SubjectBuffer.CurrentSnapshot.CreateTrackingPoint(openingPoint.Position, PointTrackingMode.Positive);
     _undoHistory = undoHistory;
     _editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
     _session = session;
 }
Пример #18
0
        internal EmacsCommandContext(
            EmacsCommandsManager manager,
            ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService,
            IEditorOperations editorOperations,
            ITextView view,
            CommandRouter commandRouter)
        {
            this.Manager = manager;
            this.EditorOperations = editorOperations;
            this.TextView = view;
            this.CommandRouter = commandRouter;

            this.TextStructureNavigator = textStructureNavigatorSelectorService.GetTextStructureNavigator(view.TextBuffer);
            this.MarkSession = MarkSession.GetSession(view);
        }
Пример #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommenterFilter"/> class for
        /// the specified text view and commenter.
        /// </summary>
        /// <param name="textViewAdapter"></param>
        /// <param name="textView">The text view.</param>
        /// <param name="commenter">The commenter implementation.</param>
        /// <param name="editorOperations">The <see cref="IEditorOperations"/> instance for the text view.</param>
        /// <param name="textUndoHistoryRegistry">The global <see cref="ITextUndoHistoryRegistry"/> service provided by
        /// Visual Studio.</param>
        /// <exception cref="ArgumentNullException">
        /// <para>If <paramref name="textViewAdapter"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="textView"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="commenter"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="editorOperations"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="textUndoHistoryRegistry"/> is <see langword="null"/>.</para>
        /// </exception>
        public CommenterFilter(IVsTextView textViewAdapter, ITextView textView, ICommenter commenter, IEditorOperations editorOperations, ITextUndoHistoryRegistry textUndoHistoryRegistry)
            : base(textViewAdapter)
        {
            Contract.Requires(textViewAdapter != null);
            Contract.Requires<ArgumentNullException>(textView != null, "textView");
            Contract.Requires<ArgumentNullException>(commenter != null, "commenter");
            Contract.Requires<ArgumentNullException>(editorOperations != null, "editorOperations");
            Contract.Requires<ArgumentNullException>(textUndoHistoryRegistry != null, "textUndoHistoryRegistry");

            this.TextView = textView;
            this.Commenter = commenter;
            this.EditorOperations = editorOperations;
            this.TextUndoHistoryRegistry = textUndoHistoryRegistry;
            textView.Closed += (sender, e) => Dispose();
        }
        public BraceCompleterCommandHandler(IVsTextView textViewAdapter,
			IWpfTextView textView, IEditorOperations operations, ITextUndoHistory undoHistory)
        {
            _textView = textView;
            _operations = operations;
            _undoHistory = undoHistory;

            _textView.GotAggregateFocus += TextView_GotFocus;

            // add the command to the command chain
            textViewAdapter.AddCommandFilter(this, out _nextCommandHandler);

            // load language and indentation settings
            LoadSettings();
        }
        public CaretPreservingEditTransaction(
            string description,
            ITextView textView,
            ITextUndoHistoryRegistry undoHistoryRegistry,
            IEditorOperationsFactoryService editorOperationsFactoryService)
        {
            _editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
            _undoHistory = undoHistoryRegistry.GetHistory(textView.TextBuffer);
            _active = true;

            if (_undoHistory != null)
            {
                _transaction = new HACK_TextUndoTransactionThatRollsBackProperly(_undoHistory.CreateTransaction(description));
                _editorOperations.AddBeforeTextBufferChangePrimitive();
            }
        }
Пример #22
0
		public ZoomControlMargin(IWpfTextViewHost wpfTextViewHost, IEditorOperations editorOperations) {
			if (wpfTextViewHost == null)
				throw new ArgumentNullException(nameof(wpfTextViewHost));
			if (editorOperations == null)
				throw new ArgumentNullException(nameof(editorOperations));
			this.wpfTextViewHost = wpfTextViewHost;
			this.editorOperations = editorOperations;

			IsVisibleChanged += ZoomControlMargin_IsVisibleChanged;
			wpfTextViewHost.TextView.Options.OptionChanged += Options_OptionChanged;

			// Need to set these explicitly so our themed styles are used
			SetResourceReference(StyleProperty, typeof(ComboBox));
			SetResourceReference(ItemContainerStyleProperty, typeof(ComboBoxItem));
			MinHeight = 0;
			Margin = new Thickness(0);
			Width = 60;
			UpdateVisibility();
		}
Пример #23
0
        /// <summary>
        /// Attaches events for invoking Statement completion 
        /// </summary>
        public IntellisenseController(IntellisenseControllerProvider provider, ITextView textView, IServiceProvider serviceProvider) {
            _textView = textView;
            _provider = provider;
            _editOps = provider._EditOperationsFactory.GetEditorOperations(textView);
            _incSearch = provider._IncrementalSearch.GetIncrementalSearch(textView);
            _textView.MouseHover += TextViewMouseHover;
            _serviceProvider = serviceProvider;
            if (textView.TextBuffer.IsPythonContent()) {
                try {
                    _expansionClient = new ExpansionClient(textView, provider._adaptersFactory, provider._ServiceProvider);
                    var textMgr = (IVsTextManager2)_serviceProvider.GetService(typeof(SVsTextManager));
                    textMgr.GetExpansionManager(out _expansionMgr);
                } catch (ArgumentException) {
                    // No expansion client for this buffer, but we can continue without it
                }
            }

            textView.Properties.AddProperty(typeof(IntellisenseController), this);  // added so our key processors can get back to us
            _textView.Closed += TextView_Closed;
        }
Пример #24
0
        public InformationBarMargin(IWpfTextView textView, ITextDocument document, IEditorOperations editorOperations, ITextUndoHistory undoHistory)
        {
            _textView = textView;
            _document = document;
            _operations = editorOperations;
            _undoHistory = undoHistory;

            var informationBar = new InformationBarControl();
            informationBar.Tabify.Click += Tabify;
            informationBar.Untabify.Click += Untabify;
            informationBar.Hide.Click += Hide;
            informationBar.DontShowAgain.Click += DontShowAgain;

            this.Height = 0;
            this.Content = informationBar;
            this.Name = MarginName;

            document.FileActionOccurred += FileActionOccurred;

            // Delay the initial check until the view gets focus
            textView.GotAggregateFocus += GotAggregateFocus;
        }
Пример #25
0
        public CommandFilter(
            IVsTextView textView,
            IWpfTextView wpfTextView,
            IHtmlBuilderService htmlBuilderService,
            IRtfBuilderService rtfBuilderService,
            IEditorOperations editorOperations,
            ITextUndoHistory undoHistory,
            IEditorOptions editorOptions,
            IViewPrimitives viewPrimitives,
            ITelemetrySession telemetrySession)
        {
            _htmlBuilderService = htmlBuilderService;
            _rtfBuilderService = rtfBuilderService;
            _undoHistory = undoHistory;
            _textView = wpfTextView;
            _editorOperations = editorOperations;
            _editorOptions = editorOptions;
            _viewPrimitives = viewPrimitives;
            _telemetrySession = telemetrySession;

            textView.AddCommandFilter(this, out _nextCommandTargetInChain);
        }
Пример #26
0
        private ReplEditFilter(
            IVsTextView vsTextView,
            ITextView textView,
            IEditorOperations editorOps,
            IServiceProvider serviceProvider,
            IOleCommandTarget next
        ) {
            _vsTextView = vsTextView;
            _textView = textView;
            _editorOps = editorOps;
            _serviceProvider = serviceProvider;
            _componentModel = _serviceProvider.GetComponentModel();
            _pyService = _serviceProvider.GetPythonToolsService();
            _interactive = _textView.TextBuffer.GetInteractiveWindow();
            _next = next;

            if (_interactive != null) {
                _selectEval = _interactive.Evaluator as SelectableReplEvaluator;
            }

            if (_selectEval != null) {
                _selectEval.EvaluatorChanged += EvaluatorChanged;
                _selectEval.AvailableEvaluatorsChanged += AvailableEvaluatorsChanged;
            }

            var mse = _interactive?.Evaluator as IMultipleScopeEvaluator;
            if (mse != null) {
                _scopeListVisible = mse.EnableMultipleScopes;
                mse.AvailableScopesChanged += AvailableScopesChanged;
                mse.MultipleScopeSupportChanged += MultipleScopeSupportChanged;
            }

            if (_next == null && _interactive != null) {
                ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
            }
        }
Пример #27
0
 internal DefaultCommandTarget(ITextView textView, IEditorOperations editorOperations)
 {
     _textView = textView;
     _editorOperatins = editorOperations;
 }
Пример #28
0
 internal OperationsImpl(ITextView view, IEditorOperations opts, IVimHost host, IJumpList jumpList)
     : base(view, opts, host, jumpList)
 {
 }
Пример #29
0
		public SearchService(IWpfTextView wpfTextView, ITextSearchService2 textSearchService2, ISearchSettings searchSettings, IMessageBoxService messageBoxService, ITextStructureNavigator textStructureNavigator, Lazy<IReplaceListenerProvider>[] replaceListenerProviders, IEditorOperationsFactoryService editorOperationsFactoryService) {
			if (wpfTextView == null)
				throw new ArgumentNullException(nameof(wpfTextView));
			if (textSearchService2 == null)
				throw new ArgumentNullException(nameof(textSearchService2));
			if (searchSettings == null)
				throw new ArgumentNullException(nameof(searchSettings));
			if (messageBoxService == null)
				throw new ArgumentNullException(nameof(messageBoxService));
			if (textStructureNavigator == null)
				throw new ArgumentNullException(nameof(textStructureNavigator));
			if (replaceListenerProviders == null)
				throw new ArgumentNullException(nameof(replaceListenerProviders));
			this.wpfTextView = wpfTextView;
			editorOperations = editorOperationsFactoryService.GetEditorOperations(wpfTextView);
			this.textSearchService2 = textSearchService2;
			this.searchSettings = searchSettings;
			this.messageBoxService = messageBoxService;
			this.textStructureNavigator = textStructureNavigator;
			this.replaceListenerProviders = replaceListenerProviders;
			listeners = new List<ITextMarkerListener>();
			searchString = string.Empty;
			replaceString = string.Empty;
			searchKind = SearchKind.None;
			searchControlPosition = SearchControlPosition.Default;
			wpfTextView.VisualElement.CommandBindings.Add(new CommandBinding(ApplicationCommands.Find, (s, e) => ShowFind()));
			wpfTextView.VisualElement.CommandBindings.Add(new CommandBinding(ApplicationCommands.Replace, (s, e) => ShowReplace()));
			wpfTextView.Closed += WpfTextView_Closed;
			UseGlobalSettings(true);
		}
 protected override void NextAction(IEditorOperations editorOperation, Action nextAction)
 {
     editorOperation.InsertNewLine();
 }