public LogEditor(LogEditorOptions options, IDnSpyTextEditorFactoryService dnSpyTextEditorFactoryService, IContentTypeRegistryService contentTypeRegistryService, ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService) { this.dispatcher = Dispatcher.CurrentDispatcher; this.cachedColorsList = new CachedColorsList(); options = options?.Clone() ?? new LogEditorOptions(); options.CreateGuidObjects = CommonGuidObjectsProvider.Create(options.CreateGuidObjects, new GuidObjectsProvider(this)); var contentType = contentTypeRegistryService.GetContentType(options.ContentType, options.ContentTypeString) ?? textBufferFactoryService.TextContentType; var textBuffer = textBufferFactoryService.CreateTextBuffer(contentType); CachedColorsListTaggerProvider.AddColorizer(textBuffer, cachedColorsList); var rolesList = new List <string>(defaultRoles); rolesList.AddRange(options.ExtraRoles); var roles = dnSpyTextEditorFactoryService.CreateTextViewRoleSet(rolesList); var textView = dnSpyTextEditorFactoryService.CreateTextView(textBuffer, roles, editorOptionsFactoryService.GlobalOptions, options); var wpfTextViewHost = dnSpyTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; this.wpfTextView = wpfTextViewHost.TextView; wpfTextView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.DragDropEditingId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStylesConstants.DefaultValue); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.AutoScrollId, true); SetNewDocument(); }
public IDnSpyWpfTextViewHost CreateTextViewHost(IDnSpyWpfTextView wpfTextView, bool setFocus) { if (wpfTextView == null) { throw new ArgumentNullException(nameof(wpfTextView)); } return(new WpfTextViewHost(wpfTextViewMarginProviderCollectionProvider, wpfTextView, editorOperationsFactoryService, setFocus)); }
public CompletionSessionCommandTargetFilter(ICompletionSession completionSession) { if (completionSession == null) { throw new ArgumentNullException(nameof(completionSession)); } this.completionSession = completionSession; this.dnSpyWpfTextView = completionSession.TextView as IDnSpyWpfTextView; Debug.Assert(dnSpyWpfTextView != null); dnSpyWpfTextView?.CommandTarget.AddFilter(this, CommandConstants.CMDTARGETFILTER_ORDER_DEFAULT_STATEMENTCOMPLETION); completionSession.TextView.Caret.PositionChanged += Caret_PositionChanged; // Make sure that pressing backspace at start pos dismisses the session var span = completionSession.SelectedCompletionSet.ApplicableTo.GetSpan(completionSession.TextView.TextSnapshot); minimumCaretPosition = span.Start.Position; }
public WpfTextViewHost(IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IDnSpyWpfTextView wpfTextView, IEditorOperationsFactoryService editorOperationsFactoryService, bool setFocus) { if (wpfTextViewMarginProviderCollectionProvider == null) { throw new ArgumentNullException(nameof(wpfTextViewMarginProviderCollectionProvider)); } if (wpfTextView == null) { throw new ArgumentNullException(nameof(wpfTextView)); } if (editorOperationsFactoryService == null) { throw new ArgumentNullException(nameof(editorOperationsFactoryService)); } this.editorOperationsFactoryService = editorOperationsFactoryService; this.grid = CreateGrid(); TextView = wpfTextView; Focusable = false; Content = this.grid; UpdateBackground(); TextView.BackgroundBrushChanged += TextView_BackgroundBrushChanged; this.containerMargins = new IWpfTextViewMargin[5]; containerMargins[0] = CreateContainerMargin(wpfTextViewMarginProviderCollectionProvider, PredefinedMarginNames.Top, true, 0, 0, 3); containerMargins[1] = CreateContainerMargin(wpfTextViewMarginProviderCollectionProvider, PredefinedMarginNames.Bottom, true, 2, 0, 2); containerMargins[2] = CreateContainerMargin(wpfTextViewMarginProviderCollectionProvider, PredefinedMarginNames.BottomRightCorner, true, 2, 2, 1); containerMargins[3] = CreateContainerMargin(wpfTextViewMarginProviderCollectionProvider, PredefinedMarginNames.Left, false, 1, 0, 1); containerMargins[4] = CreateContainerMargin(wpfTextViewMarginProviderCollectionProvider, PredefinedMarginNames.Right, false, 1, 2, 1); Add(TextView.VisualElement, 1, 1, 1); Debug.Assert(!containerMargins.Any(a => a == null)); if (setFocus) { Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => { if (!TextView.IsClosed) { TextView.VisualElement.Focus(); } })); } }
public CommandTargetFilter(IntellisenseSessionStack owner) { this.owner = owner; this.wpfTextView = owner.wpfTextView as IDnSpyWpfTextView; Debug.Assert(wpfTextView != null); }