public TextCaret(IWpfTextView textView, IAdornmentLayer caretLayer, ISmartIndentationService smartIndentationService, IClassificationFormatMap classificationFormatMap) { if (caretLayer == null) { throw new ArgumentNullException(nameof(caretLayer)); } if (classificationFormatMap == null) { throw new ArgumentNullException(nameof(classificationFormatMap)); } this.textView = textView ?? throw new ArgumentNullException(nameof(textView)); imeState = new ImeState(); this.smartIndentationService = smartIndentationService ?? throw new ArgumentNullException(nameof(smartIndentationService)); preferredXCoordinate = 0; __preferredYCoordinate = 0; Affinity = PositionAffinity.Successor; currentPosition = new VirtualSnapshotPoint(textView.TextSnapshot, 0); textView.TextBuffer.ChangedHighPriority += TextBuffer_ChangedHighPriority; textView.TextBuffer.ContentTypeChanged += TextBuffer_ContentTypeChanged; textView.Options.OptionChanged += Options_OptionChanged; textView.VisualElement.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_GotKeyboardFocus), true); textView.VisualElement.AddHandler(UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_LostKeyboardFocus), true); textView.LayoutChanged += TextView_LayoutChanged; textCaretLayer = new TextCaretLayer(this, caretLayer, classificationFormatMap); InputMethod.SetIsInputMethodSuspended(textView.VisualElement, true); }
public InteractiveWindowProvider( IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextBufferUndoManagerProvider textBufferUndoManagerProvider, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveWindowEditorFactoryService windowFactoryService, IWaitIndicator waitIndicator) { _contentTypeRegistry = contentTypeRegistry; _bufferFactory = bufferFactory; _projectionBufferFactory = projectionBufferFactory; _editorOperationsFactory = editorOperationsFactory; _textBufferUndoManagerProvider = textBufferUndoManagerProvider; _editorFactory = editorFactory; _rtfBuilderService = rtfBuilderService; _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; _windowFactoryService = windowFactoryService; _waitIndicator = waitIndicator; }
public TextCaret(IWpfTextView textView, IAdornmentLayer caretLayer, ISmartIndentationService smartIndentationService, IClassificationFormatMap classificationFormatMap) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (caretLayer == null) throw new ArgumentNullException(nameof(caretLayer)); if (smartIndentationService == null) throw new ArgumentNullException(nameof(smartIndentationService)); if (classificationFormatMap == null) throw new ArgumentNullException(nameof(classificationFormatMap)); this.textView = textView; imeState = new ImeState(); this.smartIndentationService = smartIndentationService; preferredXCoordinate = 0; __preferredYCoordinate = 0; Affinity = PositionAffinity.Successor; currentPosition = new VirtualSnapshotPoint(textView.TextSnapshot, 0); textView.TextBuffer.ChangedHighPriority += TextBuffer_ChangedHighPriority; textView.TextBuffer.ContentTypeChanged += TextBuffer_ContentTypeChanged; textView.Options.OptionChanged += Options_OptionChanged; textView.VisualElement.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_GotKeyboardFocus), true); textView.VisualElement.AddHandler(UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_LostKeyboardFocus), true); textView.LayoutChanged += TextView_LayoutChanged; textCaretLayer = new TextCaretLayer(this, caretLayer, classificationFormatMap); InputMethod.SetIsInputMethodSuspended(textView.VisualElement, true); }
TextEditorFactoryService(ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, [ImportMany] IEnumerable <Lazy <IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata> > wpfTextViewCreationListeners, [ImportMany] IEnumerable <Lazy <ITextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata> > textViewCreationListeners, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IMenuService menuService, IEditorOperationsFactoryService editorOperationsFactoryService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, [ImportMany] IEnumerable <Lazy <ITextViewModelProvider, IContentTypeAndTextViewRoleMetadata> > textViewModelProviders, IContentTypeRegistryService contentTypeRegistryService, IThemeService themeService, Lazy <ITextViewUndoManagerProvider> textViewUndoManagerProvider) { this.textBufferFactoryService = textBufferFactoryService; this.editorOptionsFactoryService = editorOptionsFactoryService; this.commandService = commandService; this.smartIndentationService = smartIndentationService; this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.ToArray(); this.textViewCreationListeners = textViewCreationListeners.ToArray(); this.formattedTextSourceFactoryService = formattedTextSourceFactoryService; this.viewClassifierAggregatorService = viewClassifierAggregatorService; this.textAndAdornmentSequencerFactoryService = textAndAdornmentSequencerFactoryService; this.classificationFormatMapService = classificationFormatMapService; this.editorFormatMapService = editorFormatMapService; this.adornmentLayerDefinitionService = adornmentLayerDefinitionService; this.lineTransformProviderService = lineTransformProviderService; this.wpfTextViewMarginProviderCollectionProvider = wpfTextViewMarginProviderCollectionProvider; this.menuService = menuService; this.editorOperationsFactoryService = editorOperationsFactoryService; this.spaceReservationStackProvider = spaceReservationStackProvider; this.wpfTextViewConnectionListenerServiceProvider = wpfTextViewConnectionListenerServiceProvider; this.bufferGraphFactoryService = bufferGraphFactoryService; this.textViewModelProviders = textViewModelProviders.ToArray(); this.contentTypeRegistryService = contentTypeRegistryService; this.themeService = themeService; this.textViewUndoManagerProvider = textViewUndoManagerProvider; }
/// <summary> /// Gets the desired indentation /// </summary> /// <param name="textView">Text view</param> /// <param name="smartIndentationService">Smart indentation service</param> /// <param name="line">Line</param> /// <returns></returns> public static int?GetDesiredIndentation(ITextView textView, ISmartIndentationService smartIndentationService, ITextSnapshotLine line) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } if (smartIndentationService == null) { throw new ArgumentNullException(nameof(smartIndentationService)); } if (line == null) { throw new ArgumentNullException(nameof(line)); } var indentStyle = textView.Options.GetIndentStyle(); switch (indentStyle) { case IndentStyle.None: return(0); case IndentStyle.Block: return(GetDesiredBlockIndentation(textView, line)); case IndentStyle.Smart: var indentSize = smartIndentationService.GetDesiredIndentation(textView, line); Debug.Assert(indentSize == null || indentSize.Value >= 0); return(indentSize); default: Debug.Fail($"Invalid {nameof(IndentStyle)}: {indentStyle}"); return(null); } }
public InteractiveWindowProvider( IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextBufferUndoManagerProvider textBufferUndoManagerProvider, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveWindowEditorFactoryService windowFactoryService, IUIThreadOperationExecutor uiThreadOperationExecutor) { _contentTypeRegistry = contentTypeRegistry; _bufferFactory = bufferFactory; _projectionBufferFactory = projectionBufferFactory; _editorOperationsFactory = editorOperationsFactory; _textBufferUndoManagerProvider = textBufferUndoManagerProvider; _editorFactory = editorFactory; _rtfBuilderService = rtfBuilderService; _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; _windowFactoryService = windowFactoryService; _uiThreadOperationExecutor = uiThreadOperationExecutor; }
public InteractiveWindow( IInteractiveWindowEditorFactoryService host, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } _uiOnly = new UIThreadOnly( this, host, contentTypeRegistry, bufferFactory, projectionBufferFactory, editorOperationsFactory, editorFactory, rtfBuilderService, intellisenseSessionStackMap, smartIndenterService, evaluator); evaluator.CurrentWindow = this; RequiresUIThread(); }
public BraceCompletionContext(ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager, HlslClassificationService classificationService, IOptionsService optionsService) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; _classificationService = classificationService; _optionsService = optionsService; }
internal VsVimHost( IVsAdapter adapter, ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, ITextDocumentFactoryService textDocumentFactoryService, ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, ISmartIndentationService smartIndentationService, ITextManager textManager, ISharedServiceFactory sharedServiceFactory, IVimApplicationSettings vimApplicationSettings, IExtensionAdapterBroker extensionAdapterBroker, SVsServiceProvider serviceProvider, ITelemetryProvider telemetryProvider) : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService) { _vsAdapter = adapter; _editorAdaptersFactoryService = editorAdaptersFactoryService; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility)); _textManager = textManager; _sharedService = sharedServiceFactory.Create(); _vsMonitorSelection = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>(); _vimApplicationSettings = vimApplicationSettings; _smartIndentationService = smartIndentationService; _extensionAdapterBroker = extensionAdapterBroker; _vsMonitorSelection.AdviseSelectionEvents(this, out uint cookie); InitTelemetry(telemetryProvider.GetOrCreate(vimApplicationSettings, _dte), vimApplicationSettings); }
/// <summary> /// Gets the desired indentation /// </summary> /// <param name="textView">Text view</param> /// <param name="smartIndentationService">Smart indentation service</param> /// <param name="line">Line</param> /// <returns></returns> public static int? GetDesiredIndentation(ITextView textView, ISmartIndentationService smartIndentationService, ITextSnapshotLine line) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (smartIndentationService == null) throw new ArgumentNullException(nameof(smartIndentationService)); if (line == null) throw new ArgumentNullException(nameof(line)); var indentStyle = textView.Options.GetIndentStyle(); switch (indentStyle) { case IndentStyle.None: return 0; case IndentStyle.Block: return GetDesiredBlockIndentation(textView, line); case IndentStyle.Smart: var indentSize = smartIndentationService.GetDesiredIndentation(textView, line); Debug.Assert(indentSize == null || indentSize.Value >= 0); return indentSize; default: Debug.Fail($"Invalid {nameof(IndentStyle)}: {indentStyle}"); return null; } }
internal VsVimHost( IVsAdapter adapter, ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, ITextDocumentFactoryService textDocumentFactoryService, ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, ISmartIndentationService smartIndentationService, ITextManager textManager, ISharedServiceFactory sharedServiceFactory, IVimApplicationSettings vimApplicationSettings, SVsServiceProvider serviceProvider) : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService) { _vsAdapter = adapter; _editorAdaptersFactoryService = editorAdaptersFactoryService; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility)); _textManager = textManager; _sharedService = sharedServiceFactory.Create(); _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>(); _fontProperties = new TextEditorFontProperties(serviceProvider); _vimApplicationSettings = vimApplicationSettings; _smartIndentationService = smartIndentationService; uint cookie; _vsMonitorSelection.AdviseSelectionEvents(this, out cookie); }
public BraceCompletionContext( ISmartIndentationService smartIndentationService, ITextBufferUndoManager undoManager, IEditorBraceCompletionSession editorSession) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; _editorSession = editorSession; }
// From https://github.com/dotnet/roslyn/blob/e39a3aeb1185ef0b349cad96a105969423065eac/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.cs#L278 public static int? GetDesiredIndentation(this ITextView textView, ISmartIndentationService smartIndentService, ITextSnapshotLine line) { var pointInView = textView.BufferGraph.MapUpToSnapshot(line.Start, PointTrackingMode.Positive, PositionAffinity.Successor, textView.TextSnapshot); if (!pointInView.HasValue) return null; var lineInView = textView.TextSnapshot.GetLineFromPosition(pointInView.Value.Position); return smartIndentService.GetDesiredIndentation(textView, lineInView); }
internal static CommandUtil CreateCommandUtil( ITextView textView, ICommonOperations operations = null, IMotionUtil motionUtil = null, IStatusUtil statusUtil = null, IRegisterMap registerMap = null, IMarkMap markMap = null, IVimData vimData = null, IVimLocalSettings localSettings = null, IUndoRedoOperations undoRedOperations = null, ISmartIndentationService smartIndentationService = null, IFoldManager foldManager = null, IVimHost vimHost = null, IMacroRecorder recorder = null, ISearchService searchService = null, ITextStructureNavigator wordNavigator = null, IJumpList jumpList = null) { statusUtil = statusUtil ?? new StatusUtil(); undoRedOperations = undoRedOperations ?? VimUtil.CreateUndoRedoOperations(statusUtil); localSettings = localSettings ?? new LocalSettings(new GlobalSettings()); registerMap = registerMap ?? CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object); markMap = markMap ?? new MarkMap(new TrackingLineColumnService()); vimData = vimData ?? new VimData(); motionUtil = motionUtil ?? CreateTextViewMotionUtil(textView, markMap: markMap, vimData: vimData, settings: localSettings); operations = operations ?? CreateCommonOperations(textView, localSettings, vimData: vimData, statusUtil: statusUtil); smartIndentationService = smartIndentationService ?? CreateSmartIndentationService(); foldManager = foldManager ?? CreateFoldManager(textView.TextBuffer); searchService = searchService ?? CreateSearchService(localSettings.GlobalSettings); wordNavigator = wordNavigator ?? CreateTextStructureNavigator(textView.TextBuffer, WordKind.NormalWord); jumpList = jumpList ?? CreateJumpList(); vimHost = vimHost ?? new MockVimHost(); var vim = MockObjectFactory.CreateVim( registerMap: registerMap, map: markMap, host: vimHost, vimData: vimData, recorder: recorder, searchService: searchService); var buffer = MockObjectFactory.CreateVimBuffer( textView: textView, settings: localSettings, motionUtil: motionUtil, vim: vim.Object, wordNavigator: wordNavigator, jumpList: jumpList); return(new CommandUtil( buffer.Object, operations, statusUtil, undoRedOperations, smartIndentationService, foldManager)); }
public BraceCompletionContext( ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager, HlslClassificationService classificationService, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; _classificationService = classificationService; _optionsService = optionsService; _sourceTextFactory = sourceTextFactory; }
// From https://github.com/dotnet/roslyn/blob/e39a3aeb1185ef0b349cad96a105969423065eac/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.cs#L278 public static int?GetDesiredIndentation(this ITextView textView, ISmartIndentationService smartIndentService, ITextSnapshotLine line) { var pointInView = textView.BufferGraph.MapUpToSnapshot(line.Start, PointTrackingMode.Positive, PositionAffinity.Successor, textView.TextSnapshot); if (!pointInView.HasValue) { return(null); } var lineInView = textView.TextSnapshot.GetLineFromPosition(pointInView.Value.Position); return(smartIndentService.GetDesiredIndentation(textView, lineInView)); }
public VimCocoaHost( ITextBufferFactoryService textBufferFactoryService, ICocoaTextEditorFactoryService textEditorFactoryService, ISmartIndentationService smartIndentationService, IExtensionAdapterBroker extensionAdapterBroker) { VimTrace.TraceSwitch.Level = System.Diagnostics.TraceLevel.Verbose; Console.WriteLine("Loaded"); _textBufferFactoryService = textBufferFactoryService; _textEditorFactoryService = textEditorFactoryService; _smartIndentationService = smartIndentationService; _extensionAdapterBroker = extensionAdapterBroker; }
public TestTextCaret(ITextView textView, ISmartIndentationService indentService, IMultiSelectionBroker multiSelectionBroker) { this.textView = textView; this.indentService = indentService; this.multiSelectionBroker = multiSelectionBroker; multiSelectionBroker.MultiSelectionSessionChanged += MultiSelectionSessionChanged; var point = new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, 0); Position = new CaretPosition( new VirtualSnapshotPoint(point), textView.BufferGraph.CreateMappingPoint(point, PointTrackingMode.Positive), PositionAffinity.Successor ); }
/// <summary> /// Constructs a new selection Element that is bound to the specified editor canvas /// </summary> /// <param name="wpfTextView"> /// The WPF Text View that hosts this caret /// </param> public SkiaTextCaret( SkiaTextView wpfTextView, SkiaTextSelection selection, ISmartIndentationService smartIndentationService, IEditorFormatMap editorFormatMap, //IClassificationFormatMap classificationFormatMap, GuardedOperations guardedOperations) { // Verify Debug.Assert(wpfTextView != null); _regularBrush = new SKPaint() { Color = SKColors.Red, Typeface = wpfTextView.Typeface, TextSize = 24, LcdRenderText = true, IsAntialias = true, SubpixelText = true }; _wpfTextView = wpfTextView; _selection = selection; _guardedOperations = guardedOperations; _smartIndentationService = smartIndentationService; // Set up initial values _caretAffinity = PositionAffinity.Successor; _insertionPoint = new VirtualSnapshotPoint(new SnapshotPoint(_wpfTextView.TextSnapshot, 0)); //// Set the regular caret brush //_editorFormatMap = editorFormatMap; //// store information related to classifications //_classificationFormatMap = classificationFormatMap; this.SubscribeEvents(); this.UpdateDefaultBrushes(); this.UpdateRegularCaretBrush(); this.UpdateOverwriteCaretBrush(); //Set the default values for the caret to be what they should be for a hidden caret that is not in overwrite mode. _caretBrush = _regularBrush; // Get the caret blink time from the system. If the caret is set not to flash, the return value // will be -1 _blinkInterval = CaretBlinkTimeManager.GetCaretBlinkTime(); if (_blinkInterval > 0) { _blinkTimer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, _blinkInterval), OnTimerElapsed); } this.UpdateBlinkTimer(); }
public void SetupBase() { _compositionContainer = GetOrCreateCompositionContainer(); _vim = _compositionContainer.GetExportedValue <IVim>(); _vimBufferFactory = _compositionContainer.GetExportedValue <IVimBufferFactory>(); _textBufferFactoryService = _compositionContainer.GetExportedValue <ITextBufferFactoryService>(); _textEditorFactoryService = _compositionContainer.GetExportedValue <ITextEditorFactoryService>(); _vimErrorDetector = _compositionContainer.GetExportedValue <IVimErrorDetector>(); _commonOperationsFactory = _compositionContainer.GetExportedValue <ICommonOperationsFactory>(); _wordUtilFactory = _compositionContainer.GetExportedValue <IWordUtilFactory>(); _bufferTrackingService = _compositionContainer.GetExportedValue <IBufferTrackingService>(); _foldManagerFactory = _compositionContainer.GetExportedValue <IFoldManagerFactory>(); _smartIndentationService = _compositionContainer.GetExportedValue <ISmartIndentationService>(); _editorOperationsFactoryService = _compositionContainer.GetExportedValue <IEditorOperationsFactoryService>(); _vimErrorDetector.Clear(); _protectedOperations = new ProtectedOperations(_vimErrorDetector); }
/// <summary> /// Remaps a given x-coordinate to a valid point. If the provided x-coordinate is past the right end of the line, it will /// be clipped to the correct position depending on the virtual space settings. If the ISmartIndent is providing indentation /// settings, the x-coordinate will be changed based on that. /// </summary> public static double MapXCoordinate(this ITextViewLine textLine, ITextView textView, double xCoordinate, ISmartIndentationService smartIndentationService, bool userSpecifiedXCoordinate) { if (textLine == null) { throw new ArgumentNullException(nameof(textLine)); } if (textView == null) { throw new ArgumentNullException(nameof(textView)); } // if the clicked point is to the right of the text and virtual space is disabled, the coordinate // needs to be fixed if ((xCoordinate > textLine.TextRight) && !textView.IsVirtualSpaceOrBoxSelectionEnabled()) { double indentationWidth = 0.0; // ask the ISmartIndent to see if any indentation is necessary for empty lines if (textLine.End == textLine.Start) { int?indentation = smartIndentationService?.GetDesiredIndentation(textView, textLine.Start.GetContainingLine()); if (indentation.HasValue) { //The indentation specified by the smart indent service is desired column position of the caret. Find out how much virtual space //need to be at the end of the line to satisfy that. // TODO: need a way to determine column width in xplat scenarios, bug https://devdiv.visualstudio.com/DevDiv/_workitems/edit/637741 double columnWidth = (textView is ITextView3 textView3) ? textView3.FormattedLineSource.ColumnWidth : throw new NotSupportedException(); indentationWidth = Math.Max(0.0, (((double)indentation.Value) * columnWidth - textLine.TextWidth)); // if the coordinate is specified by the user and the user has selected a coordinate to the left // of the indentation suggested by ISmartIndent, overrule the ISmartIndent provided value and // do not use any indentation. if (userSpecifiedXCoordinate && (xCoordinate < (textLine.TextRight + indentationWidth))) { indentationWidth = 0.0; } } } xCoordinate = textLine.TextRight + indentationWidth; } return(xCoordinate); }
internal VsVimHost( IVsAdapter adapter, ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, ITextDocumentFactoryService textDocumentFactoryService, ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, ISmartIndentationService smartIndentationService, ITextManager textManager, ISharedServiceFactory sharedServiceFactory, IVimApplicationSettings vimApplicationSettings, IExtensionAdapterBroker extensionAdapterBroker, IProtectedOperations protectedOperations, IMarkDisplayUtil markDisplayUtil, IControlCharUtil controlCharUtil, ICommandDispatcher commandDispatcher, SVsServiceProvider serviceProvider, IClipboardDevice clipboardDevice) : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService) { _vsAdapter = adapter; _editorAdaptersFactoryService = editorAdaptersFactoryService; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility)); _textManager = textManager; _sharedService = sharedServiceFactory.Create(); _vsMonitorSelection = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>(); _vimApplicationSettings = vimApplicationSettings; _smartIndentationService = smartIndentationService; _extensionAdapterBroker = extensionAdapterBroker; _runningDocumentTable = serviceProvider.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>(); _vsShell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); _protectedOperations = protectedOperations; _commandDispatcher = commandDispatcher; _clipboardDevice = clipboardDevice; _vsMonitorSelection.AdviseSelectionEvents(this, out uint selectionCookie); _runningDocumentTable.AdviseRunningDocTableEvents(this, out uint runningDocumentTableCookie); InitOutputPane(); _settingsSync = new SettingsSync(vimApplicationSettings, markDisplayUtil, controlCharUtil, _clipboardDevice); _settingsSync.SyncFromApplicationSettings(); }
/// <summary> /// Remaps a given x-coordinate to a valid point. If the provided x-coordinate is past the right end of the line, it will /// be clipped to the correct position depending on the virtual space settings. If the ISmartIndent is providing indentation /// settings, the x-coordinate will be changed based on that. /// </summary> public static double MapXCoordinate(this ITextViewLine textLine, ITextView textView, double xCoordinate, ISmartIndentationService smartIndentationService, bool userSpecifiedXCoordinate) { if (textLine == null) { throw new ArgumentNullException(nameof(textLine)); } if (textView == null) { throw new ArgumentNullException(nameof(textView)); } // if the clicked point is to the right of the text and virtual space is disabled, the coordinate // needs to be fixed if ((xCoordinate > textLine.TextRight) && !textView.IsVirtualSpaceOrBoxSelectionEnabled()) { double indentationWidth = 0.0; // ask the ISmartIndent to see if any indentation is necessary for empty lines if (textLine.End == textLine.Start) { int?indentation = smartIndentationService?.GetDesiredIndentation(textView, textLine.Start.GetContainingLine()); if (indentation.HasValue) { //The indentation specified by the smart indent service is desired column position of the caret. Find out how much virtual space //need to be at the end of the line to satisfy that. double columnWidth = (textView.ViewScroller is IViewScroller2 viewScroller) ? viewScroller.ColumnWidth : 7; indentationWidth = Math.Max(0.0, (((double)indentation.Value) * columnWidth - textLine.TextWidth)); // if the coordinate is specified by the user and the user has selected a coordinate to the left // of the indentation suggested by ISmartIndent, overrule the ISmartIndent provided value and // do not use any indentation. if (userSpecifiedXCoordinate && (xCoordinate < (textLine.TextRight + indentationWidth))) { indentationWidth = 0.0; } } } xCoordinate = textLine.TextRight + indentationWidth; } return(xCoordinate); }
TextEditorFactoryService(ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandManager commandManager, ISmartIndentationService smartIndentationService, [ImportMany] IEnumerable <Lazy <IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata> > wpfTextViewCreationListeners, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IMenuManager menuManager, IEditorOperationsFactoryService editorOperationsFactoryService) { this.textBufferFactoryService = textBufferFactoryService; this.editorOptionsFactoryService = editorOptionsFactoryService; this.commandManager = commandManager; this.smartIndentationService = smartIndentationService; this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.ToArray(); this.formattedTextSourceFactoryService = formattedTextSourceFactoryService; this.viewClassifierAggregatorService = viewClassifierAggregatorService; this.textAndAdornmentSequencerFactoryService = textAndAdornmentSequencerFactoryService; this.classificationFormatMapService = classificationFormatMapService; this.editorFormatMapService = editorFormatMapService; this.adornmentLayerDefinitionService = adornmentLayerDefinitionService; this.lineTransformProviderService = lineTransformProviderService; this.wpfTextViewMarginProviderCollectionProvider = wpfTextViewMarginProviderCollectionProvider; this.menuManager = menuManager; this.editorOperationsFactoryService = editorOperationsFactoryService; }
public InteractiveWindowProvider( IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveWindowEditorFactoryService windowFactoryService) { this.contentTypeRegistry = contentTypeRegistry; this.bufferFactory = bufferFactory; this.projectionBufferFactory = projectionBufferFactory; this.editorOperationsFactory = editorOperationsFactory; this.editorFactory = editorFactory; this.intellisenseSessionStackMap = intellisenseSessionStackMap; this.smartIndenterService = smartIndenterService; this.windowFactoryService = windowFactoryService; }
public InteractiveWindowProvider( IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveWindowEditorFactoryService windowFactoryService) { _contentTypeRegistry = contentTypeRegistry; _bufferFactory = bufferFactory; _projectionBufferFactory = projectionBufferFactory; _editorOperationsFactory = editorOperationsFactory; _editorFactory = editorFactory; _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; _windowFactoryService = windowFactoryService; }
public EditorHost(CompositionContainer compositionContainer) { _compositionContainer = compositionContainer; _textBufferFactoryService = _compositionContainer.GetExportedValue <ITextBufferFactoryService>(); _textEditorFactoryService = _compositionContainer.GetExportedValue <ITextEditorFactoryService>(); _projectionBufferFactoryService = _compositionContainer.GetExportedValue <IProjectionBufferFactoryService>(); _smartIndentationService = _compositionContainer.GetExportedValue <ISmartIndentationService>(); _editorOperationsFactoryService = _compositionContainer.GetExportedValue <IEditorOperationsFactoryService>(); _editorOptionsFactoryService = _compositionContainer.GetExportedValue <IEditorOptionsFactoryService>(); _textSearchService = _compositionContainer.GetExportedValue <ITextSearchService>(); _outliningManagerService = _compositionContainer.GetExportedValue <IOutliningManagerService>(); _textBufferUndoManagerProvider = _compositionContainer.GetExportedValue <ITextBufferUndoManagerProvider>(); _contentTypeRegistryService = _compositionContainer.GetExportedValue <IContentTypeRegistryService>(); _classificationTypeRegistryService = _compositionContainer.GetExportedValue <IClassificationTypeRegistryService>(); var errorHandlers = _compositionContainer.GetExportedValues <IExtensionErrorHandler>(); _protectedOperations = EditorUtilsFactory.CreateProtectedOperations(errorHandlers); _basicUndoHistoryRegistry = _compositionContainer.GetExportedValue <IBasicUndoHistoryRegistry>(); }
public InteractiveWindowProvider( IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveWindowEditorFactoryService windowFactoryService, IWaitIndicator waitIndicator) { _contentTypeRegistry = contentTypeRegistry; _bufferFactory = bufferFactory; _projectionBufferFactory = projectionBufferFactory; _editorOperationsFactory = editorOperationsFactory; _editorFactory = editorFactory; _rtfBuilderService = rtfBuilderService; _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; _windowFactoryService = windowFactoryService; _waitIndicator = waitIndicator; }
public CommandFilter(IWpfTextView view, ISmartIndentationService smartIndentation) { View = view; SmartIndentation = smartIndentation; }
public CSharpEditorBraceCompletionSessionFactory(ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; }
public InteractiveWindow( IInteractiveWindowEditorFactoryService host, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } _dangerous_uiOnly = new UIThreadOnly(this, host); this.Properties = new PropertyCollection(); _history = new History(); _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); _outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); _standardInputBuffer = bufferFactory.CreateTextBuffer(); _promptBuffer = bufferFactory.CreateTextBuffer(); _secondaryPromptBuffer = bufferFactory.CreateTextBuffer(); _standardInputPromptBuffer = bufferFactory.CreateTextBuffer(); _outputLineBreakBuffer = bufferFactory.CreateTextBuffer(); var projBuffer = projectionBufferFactory.CreateProjectionBuffer( new EditResolver(this), Array.Empty <object>(), ProjectionBufferOptions.None, replContentType); projBuffer.Properties.AddProperty(typeof(InteractiveWindow), this); _projectionBuffer = projBuffer; _dangerous_uiOnly.AppendNewOutputProjectionBuffer(); // Constructor runs on UI thread. projBuffer.Changed += new EventHandler <TextContentChangedEventArgs>(ProjectionBufferChanged); var roleSet = editorFactory.CreateTextViewRoleSet( PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); _textView = host.CreateTextView(this, projBuffer, roleSet); _textView.Caret.PositionChanged += CaretPositionChanged; _textView.Options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStyles.WordWrap); _lineBreakString = _textView.Options.GetNewLineCharacter(); _dangerous_uiOnly.EditorOperations = editorOperationsFactory.GetEditorOperations(_textView); // Constructor runs on UI thread. _buffer = new OutputBuffer(this); _outputWriter = new InteractiveWindowWriter(this, spans: null); SortedSpans errorSpans = new SortedSpans(); _errorOutputWriter = new InteractiveWindowWriter(this, errorSpans); OutputClassifierProvider.AttachToBuffer(_outputBuffer, errorSpans); _rtfBuilderService = rtfBuilderService; RequiresUIThread(); evaluator.CurrentWindow = this; _evaluator = evaluator; }
public CSharpEditorBraceCompletionSessionFactory(IThreadingContext threadingContext, ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager) : base(threadingContext) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; }
public UIThreadOnly( InteractiveWindow window, IInteractiveWindowEditorFactoryService factory, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator, IWaitIndicator waitIndicator) { _window = window; _factory = factory; _rtfBuilderService = (IRtfBuilderService2)rtfBuilderService; _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; _waitIndicator = waitIndicator; Evaluator = evaluator; var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); OutputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); StandardInputBuffer = bufferFactory.CreateTextBuffer(); _inertType = bufferFactory.InertContentType; _projectionBuffer = projectionBufferFactory.CreateProjectionBuffer( new EditResolver(window), Array.Empty<object>(), ProjectionBufferOptions.None, replContentType); _projectionBuffer.Properties.AddProperty(typeof(InteractiveWindow), window); AppendNewOutputProjectionBuffer(); _projectionBuffer.Changed += new EventHandler<TextContentChangedEventArgs>(ProjectionBufferChanged); var roleSet = editorFactory.CreateTextViewRoleSet( PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); TextView = factory.CreateTextView(window, _projectionBuffer, roleSet); TextView.Caret.PositionChanged += CaretPositionChanged; var options = TextView.Options; options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, true); options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false); options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStyles.None); _lineBreakString = options.GetNewLineCharacter(); EditorOperations = editorOperationsFactory.GetEditorOperations(TextView); _buffer = new OutputBuffer(window); OutputWriter = new InteractiveWindowWriter(window, spans: null); SortedSpans errorSpans = new SortedSpans(); ErrorOutputWriter = new InteractiveWindowWriter(window, errorSpans); OutputClassifierProvider.AttachToBuffer(OutputBuffer, errorSpans); }
TextEditorFactoryService(ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, [ImportMany] IEnumerable<Lazy<IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata>> wpfTextViewCreationListeners, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IMenuService menuService, IEditorOperationsFactoryService editorOperationsFactoryService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, [ImportMany] IEnumerable<Lazy<ITextViewModelProvider, IContentTypeAndTextViewRoleMetadata>> textViewModelProviders, IContentTypeRegistryService contentTypeRegistryService, Lazy<ITextViewUndoManagerProvider> textViewUndoManagerProvider) { this.textBufferFactoryService = textBufferFactoryService; this.editorOptionsFactoryService = editorOptionsFactoryService; this.commandService = commandService; this.smartIndentationService = smartIndentationService; this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.ToArray(); this.formattedTextSourceFactoryService = formattedTextSourceFactoryService; this.viewClassifierAggregatorService = viewClassifierAggregatorService; this.textAndAdornmentSequencerFactoryService = textAndAdornmentSequencerFactoryService; this.classificationFormatMapService = classificationFormatMapService; this.editorFormatMapService = editorFormatMapService; this.adornmentLayerDefinitionService = adornmentLayerDefinitionService; this.lineTransformProviderService = lineTransformProviderService; this.wpfTextViewMarginProviderCollectionProvider = wpfTextViewMarginProviderCollectionProvider; this.menuService = menuService; this.editorOperationsFactoryService = editorOperationsFactoryService; this.spaceReservationStackProvider = spaceReservationStackProvider; this.wpfTextViewConnectionListenerServiceProvider = wpfTextViewConnectionListenerServiceProvider; this.bufferGraphFactoryService = bufferGraphFactoryService; this.textViewModelProviders = textViewModelProviders.ToArray(); this.contentTypeRegistryService = contentTypeRegistryService; this.textViewUndoManagerProvider = textViewUndoManagerProvider; }
public EditorOperations(ITextView textView, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService, ISmartIndentationService smartIndentationService, IHtmlBuilderService htmlBuilderService) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (textStructureNavigatorSelectorService == null) throw new ArgumentNullException(nameof(textStructureNavigatorSelectorService)); if (htmlBuilderService == null) throw new ArgumentNullException(nameof(htmlBuilderService)); TextView = textView; TextView.Closed += TextView_Closed; TextView.TextViewModel.DataModel.ContentTypeChanged += OnContentTypeChanged; this.textStructureNavigatorSelectorService = textStructureNavigatorSelectorService; this.smartIndentationService = smartIndentationService; this.htmlBuilderService = htmlBuilderService; }
public InteractiveWindow( IInteractiveWindowEditorFactoryService host, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } _dangerous_uiOnly = new UIThreadOnly(this, host); this.Properties = new PropertyCollection(); _history = new History(); _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; var textContentType = contentTypeRegistry.GetContentType("text"); var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); _outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); _standardInputBuffer = bufferFactory.CreateTextBuffer(); var projBuffer = projectionBufferFactory.CreateProjectionBuffer( new EditResolver(this), Array.Empty<object>(), ProjectionBufferOptions.None, replContentType); // we need to set IReplPromptProvider property before TextViewHost is instantiated so that ReplPromptTaggerProvider can bind to it projBuffer.Properties.AddProperty(typeof(InteractiveWindow), this); _projectionBuffer = projBuffer; _dangerous_uiOnly.AppendNewOutputProjectionBuffer(); // Constructor runs on UI thread. projBuffer.Changed += new EventHandler<TextContentChangedEventArgs>(ProjectionBufferChanged); var roleSet = editorFactory.CreateTextViewRoleSet( PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); _textView = host.CreateTextView(this, projBuffer, roleSet); _textView.Caret.PositionChanged += CaretPositionChanged; _textView.Options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStyles.WordWrap); _lineBreakString = _textView.Options.GetNewLineCharacter(); _dangerous_uiOnly.EditorOperations = editorOperationsFactory.GetEditorOperations(_textView); // Constructor runs on UI thread. _buffer = new OutputBuffer(this); _outputWriter = new InteractiveWindowWriter(this, spans: null); SortedSpans errorSpans = new SortedSpans(); _errorOutputWriter = new InteractiveWindowWriter(this, errorSpans); OutputClassifierProvider.AttachToBuffer(_outputBuffer, errorSpans); RequiresUIThread(); evaluator.CurrentWindow = this; _evaluator = evaluator; }
public CurlyBraceCompletionSession(ISyntaxFactsService syntaxFactsService, ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager) : base(syntaxFactsService, (int)SyntaxKind.OpenBraceToken, (int)SyntaxKind.CloseBraceToken) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; }
EditorOperationsFactoryService(ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService, ISmartIndentationService smartIndentationService, IHtmlBuilderService htmlBuilderService) { this.textStructureNavigatorSelectorService = textStructureNavigatorSelectorService; this.smartIndentationService = smartIndentationService; this.htmlBuilderService = htmlBuilderService; }
public BraceCompletionContextProvider(ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider textBufferUndoManagerProvider) { _smartIndentationService = smartIndentationService; _textBufferUndoManagerProvider = textBufferUndoManagerProvider; }
public void SetupBase() { _compositionContainer = GetOrCreateCompositionContainer(); _vim = _compositionContainer.GetExportedValue<IVim>(); _vimBufferFactory = _compositionContainer.GetExportedValue<IVimBufferFactory>(); _textBufferFactoryService = _compositionContainer.GetExportedValue<ITextBufferFactoryService>(); _textEditorFactoryService = _compositionContainer.GetExportedValue<ITextEditorFactoryService>(); _vimErrorDetector = _compositionContainer.GetExportedValue<IVimErrorDetector>(); _commonOperationsFactory = _compositionContainer.GetExportedValue<ICommonOperationsFactory>(); _wordUtilFactory = _compositionContainer.GetExportedValue<IWordUtilFactory>(); _bufferTrackingService = _compositionContainer.GetExportedValue<IBufferTrackingService>(); _foldManagerFactory = _compositionContainer.GetExportedValue<IFoldManagerFactory>(); _smartIndentationService = _compositionContainer.GetExportedValue<ISmartIndentationService>(); _vimErrorDetector.Clear(); _protectedOperations = new ProtectedOperations(_vimErrorDetector); }
public CSharpIndentationTracker(Ide.Editor.TextEditor editor, DocumentContext context) { this.editor = editor; this.context = context; smartIndentationService = CompositionManager.Instance.ExportProvider.GetExportedValue <ISmartIndentationService> (); }
#pragma warning restore 0169 public WpfTextView(ITextViewModel textViewModel, ITextViewRoleSet roles, IEditorOptions parentOptions, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandManager commandManager, ISmartIndentationService smartIndentationService, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, Lazy <IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata>[] wpfTextViewCreationListeners) { if (textViewModel == null) { throw new ArgumentNullException(nameof(textViewModel)); } if (roles == null) { throw new ArgumentNullException(nameof(roles)); } if (parentOptions == null) { throw new ArgumentNullException(nameof(parentOptions)); } if (editorOptionsFactoryService == null) { throw new ArgumentNullException(nameof(editorOptionsFactoryService)); } if (commandManager == null) { throw new ArgumentNullException(nameof(commandManager)); } if (smartIndentationService == null) { throw new ArgumentNullException(nameof(smartIndentationService)); } if (formattedTextSourceFactoryService == null) { throw new ArgumentNullException(nameof(formattedTextSourceFactoryService)); } if (viewClassifierAggregatorService == null) { throw new ArgumentNullException(nameof(viewClassifierAggregatorService)); } if (textAndAdornmentSequencerFactoryService == null) { throw new ArgumentNullException(nameof(textAndAdornmentSequencerFactoryService)); } if (classificationFormatMapService == null) { throw new ArgumentNullException(nameof(classificationFormatMapService)); } if (editorFormatMapService == null) { throw new ArgumentNullException(nameof(editorFormatMapService)); } if (adornmentLayerDefinitionService == null) { throw new ArgumentNullException(nameof(adornmentLayerDefinitionService)); } if (lineTransformProviderService == null) { throw new ArgumentNullException(nameof(lineTransformProviderService)); } if (wpfTextViewCreationListeners == null) { throw new ArgumentNullException(nameof(wpfTextViewCreationListeners)); } this.mouseHoverHelper = new MouseHoverHelper(this); this.physicalLineCache = new PhysicalLineCache(32); this.visiblePhysicalLines = new List <PhysicalLine>(); this.invalidatedRegions = new List <SnapshotSpan>(); this.formattedTextSourceFactoryService = formattedTextSourceFactoryService; this.zoomLevel = ZoomConstants.DefaultZoom; this.adornmentLayerDefinitionService = adornmentLayerDefinitionService; this.lineTransformProviderService = lineTransformProviderService; this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.Where(a => roles.ContainsAny(a.Metadata.TextViewRoles)).ToArray(); this.recreateLineTransformProvider = true; this.normalAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Normal); this.overlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Overlay); this.underlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Underlay); Properties = new PropertyCollection(); TextViewModel = textViewModel; Roles = roles; Options = editorOptionsFactoryService.GetOptions(this); Options.Parent = parentOptions; ViewScroller = new ViewScroller(this); hasKeyboardFocus = this.IsKeyboardFocusWithin; oldViewState = new ViewState(this); this.aggregateClassifier = viewClassifierAggregatorService.GetClassifier(this); this.textAndAdornmentSequencer = textAndAdornmentSequencerFactoryService.Create(this); this.classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(this); this.editorFormatMap = editorFormatMapService.GetEditorFormatMap(this); this.textLayer = new TextLayer(GetAdornmentLayer(PredefinedAdornmentLayers.Text)); Selection = new TextSelection(this, GetAdornmentLayer(PredefinedAdornmentLayers.Selection), editorFormatMap); TextCaret = new TextCaret(this, GetAdornmentLayer(PredefinedAdornmentLayers.Caret), smartIndentationService, classificationFormatMap); Children.Add(underlayAdornmentLayerCollection); Children.Add(normalAdornmentLayerCollection); Children.Add(overlayAdornmentLayerCollection); this.Cursor = Cursors.IBeam; this.Focusable = true; this.FocusVisualStyle = null; InitializeOptions(); Options.OptionChanged += EditorOptions_OptionChanged; TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority; TextViewModel.DataModel.ContentTypeChanged += DataModel_ContentTypeChanged; aggregateClassifier.ClassificationChanged += AggregateClassifier_ClassificationChanged; textAndAdornmentSequencer.SequenceChanged += TextAndAdornmentSequencer_SequenceChanged; classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged; editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged; UpdateBackground(); CreateFormattedLineSource(ViewportWidth); InitializeZoom(); UpdateRemoveExtraTextLineVerticalPixels(); if (Roles.Contains(PredefinedTextViewRoles.Interactive)) { RegisteredCommandElement = commandManager.Register(VisualElement, this); } else { RegisteredCommandElement = NullRegisteredCommandElement.Instance; } NotifyTextViewCreated(TextViewModel.DataModel.ContentType, null); }
public virtual void SetupBase() { _compositionContainer = GetOrCreateCompositionContainer(); _textBufferFactoryService = _compositionContainer.GetExportedValue<ITextBufferFactoryService>(); _textEditorFactoryService = _compositionContainer.GetExportedValue<ITextEditorFactoryService>(); _smartIndentationService = _compositionContainer.GetExportedValue<ISmartIndentationService>(); _editorOperationsFactoryService = _compositionContainer.GetExportedValue<IEditorOperationsFactoryService>(); _editorOptionsFactoryService = _compositionContainer.GetExportedValue<IEditorOptionsFactoryService>(); _textSearchService = _compositionContainer.GetExportedValue<ITextSearchService>(); _outliningManagerService = _compositionContainer.GetExportedValue<IOutliningManagerService>(); _textBufferUndoManagerProvider = _compositionContainer.GetExportedValue<ITextBufferUndoManagerProvider>(); _contentTypeRegistryService = _compositionContainer.GetExportedValue<IContentTypeRegistryService>(); _adhocOutlinerFactory = _compositionContainer.GetExportedValue<IAdhocOutlinerFactory>(); _taggerFactory = _compositionContainer.GetExportedValue<ITaggerFactory>(); }
#pragma warning restore 0169 public WpfTextView(ITextViewModel textViewModel, ITextViewRoleSet roles, IEditorOptions parentOptions, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, Lazy<IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata>[] wpfTextViewCreationListeners) { if (textViewModel == null) throw new ArgumentNullException(nameof(textViewModel)); if (roles == null) throw new ArgumentNullException(nameof(roles)); if (parentOptions == null) throw new ArgumentNullException(nameof(parentOptions)); if (editorOptionsFactoryService == null) throw new ArgumentNullException(nameof(editorOptionsFactoryService)); if (commandService == null) throw new ArgumentNullException(nameof(commandService)); if (smartIndentationService == null) throw new ArgumentNullException(nameof(smartIndentationService)); if (formattedTextSourceFactoryService == null) throw new ArgumentNullException(nameof(formattedTextSourceFactoryService)); if (viewClassifierAggregatorService == null) throw new ArgumentNullException(nameof(viewClassifierAggregatorService)); if (textAndAdornmentSequencerFactoryService == null) throw new ArgumentNullException(nameof(textAndAdornmentSequencerFactoryService)); if (classificationFormatMapService == null) throw new ArgumentNullException(nameof(classificationFormatMapService)); if (editorFormatMapService == null) throw new ArgumentNullException(nameof(editorFormatMapService)); if (adornmentLayerDefinitionService == null) throw new ArgumentNullException(nameof(adornmentLayerDefinitionService)); if (lineTransformProviderService == null) throw new ArgumentNullException(nameof(lineTransformProviderService)); if (spaceReservationStackProvider == null) throw new ArgumentNullException(nameof(spaceReservationStackProvider)); if (wpfTextViewCreationListeners == null) throw new ArgumentNullException(nameof(wpfTextViewCreationListeners)); if (wpfTextViewConnectionListenerServiceProvider == null) throw new ArgumentNullException(nameof(wpfTextViewConnectionListenerServiceProvider)); if (bufferGraphFactoryService == null) throw new ArgumentNullException(nameof(bufferGraphFactoryService)); mouseHoverHelper = new MouseHoverHelper(this); physicalLineCache = new PhysicalLineCache(32); visiblePhysicalLines = new List<PhysicalLine>(); invalidatedRegions = new List<SnapshotSpan>(); this.formattedTextSourceFactoryService = formattedTextSourceFactoryService; zoomLevel = ZoomConstants.DefaultZoom; DsImage.SetZoom(VisualElement, zoomLevel / 100); this.adornmentLayerDefinitionService = adornmentLayerDefinitionService; this.lineTransformProviderService = lineTransformProviderService; this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.Where(a => roles.ContainsAny(a.Metadata.TextViewRoles)).ToArray(); recreateLineTransformProvider = true; normalAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Normal); overlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Overlay); underlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Underlay); IsVisibleChanged += WpfTextView_IsVisibleChanged; Properties = new PropertyCollection(); TextViewModel = textViewModel; BufferGraph = bufferGraphFactoryService.CreateBufferGraph(TextViewModel.VisualBuffer); Roles = roles; Options = editorOptionsFactoryService.GetOptions(this); Options.Parent = parentOptions; ViewScroller = new ViewScroller(this); hasKeyboardFocus = IsKeyboardFocusWithin; oldViewState = new ViewState(this); aggregateClassifier = viewClassifierAggregatorService.GetClassifier(this); textAndAdornmentSequencer = textAndAdornmentSequencerFactoryService.Create(this); classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(this); editorFormatMap = editorFormatMapService.GetEditorFormatMap(this); spaceReservationStack = spaceReservationStackProvider.Create(this); textLayer = new TextLayer(GetAdornmentLayer(PredefinedAdornmentLayers.Text)); Selection = new TextSelection(this, GetAdornmentLayer(PredefinedAdornmentLayers.Selection), editorFormatMap); TextCaret = new TextCaret(this, GetAdornmentLayer(PredefinedAdornmentLayers.Caret), smartIndentationService, classificationFormatMap); Children.Add(underlayAdornmentLayerCollection); Children.Add(normalAdornmentLayerCollection); Children.Add(overlayAdornmentLayerCollection); Cursor = Cursors.IBeam; Focusable = true; FocusVisualStyle = null; InitializeOptions(); Options.OptionChanged += EditorOptions_OptionChanged; TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority; TextViewModel.DataModel.ContentTypeChanged += DataModel_ContentTypeChanged; aggregateClassifier.ClassificationChanged += AggregateClassifier_ClassificationChanged; textAndAdornmentSequencer.SequenceChanged += TextAndAdornmentSequencer_SequenceChanged; classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged; editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged; spaceReservationStack.GotAggregateFocus += SpaceReservationStack_GotAggregateFocus; spaceReservationStack.LostAggregateFocus += SpaceReservationStack_LostAggregateFocus; UpdateBackground(); CreateFormattedLineSource(ViewportWidth); InitializeZoom(); UpdateRemoveExtraTextLineVerticalPixels(); if (Roles.Contains(PredefinedTextViewRoles.Interactive)) RegisteredCommandElement = commandService.Register(VisualElement, this); else RegisteredCommandElement = NullRegisteredCommandElement.Instance; wpfTextViewConnectionListenerServiceProvider.Create(this); NotifyTextViewCreated(TextViewModel.DataModel.ContentType, null); }