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 CodeEditor(CodeEditorOptions options, IDnSpyTextEditorFactoryService dnSpyTextEditorFactoryService, IContentTypeRegistryService contentTypeRegistryService, ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService) { options = options?.Clone() ?? new CodeEditorOptions(); options.CreateGuidObjects = CommonGuidObjectsProvider.Create(options.CreateGuidObjects, new GuidObjectsProvider(this)); var contentType = contentTypeRegistryService.GetContentType(options.ContentType, options.ContentTypeString) ?? textBufferFactoryService.TextContentType; var textBuffer = options.TextBuffer; if (textBuffer == null) { textBuffer = textBufferFactoryService.CreateTextBuffer(contentType); } var roles = dnSpyTextEditorFactoryService.CreateTextViewRoleSet(defaultRoles); var textView = dnSpyTextEditorFactoryService.CreateTextView(textBuffer, roles, editorOptionsFactoryService.GlobalOptions, options); TextViewHost = dnSpyTextEditorFactoryService.CreateTextViewHost(textView, false); TextViewHost.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.CodeEditor); TextViewHost.TextView.Options.SetOptionValue(DefaultDnSpyTextViewOptions.RefreshScreenOnChangeId, true); }
public ReplEditor(ReplEditorOptions options, IDsTextEditorFactoryService dsTextEditorFactoryService, IContentTypeRegistryService contentTypeRegistryService, ITextBufferFactoryService textBufferFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, IClassificationTypeRegistryService classificationTypeRegistryService, IThemeClassificationTypeService themeClassificationTypeService, IPickSaveFilename pickSaveFilename) { this.dispatcher = Dispatcher.CurrentDispatcher; this.pickSaveFilename = pickSaveFilename; options = options?.Clone() ?? new ReplEditorOptions(); options.CreateGuidObjects = CommonGuidObjectsProvider.Create(options.CreateGuidObjects, new GuidObjectsProvider(this)); this.PrimaryPrompt = options.PrimaryPrompt; this.SecondaryPrompt = options.SecondaryPrompt; this.subBuffers = new List <ReplSubBuffer>(); this.cachedColorsList = new CachedColorsList(); TextClassificationType = classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.Text); ReplPrompt1ClassificationType = classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.ReplPrompt1); ReplPrompt2ClassificationType = classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.ReplPrompt2); var contentType = contentTypeRegistryService.GetContentType(options.ContentType, options.ContentTypeString) ?? textBufferFactoryService.TextContentType; var textBuffer = textBufferFactoryService.CreateTextBuffer(contentType); CachedColorsListTaggerProvider.AddColorizer(textBuffer, cachedColorsList); var roles = dsTextEditorFactoryService.CreateTextViewRoleSet(options.Roles); var textView = dsTextEditorFactoryService.CreateTextView(textBuffer, roles, editorOptionsFactoryService.GlobalOptions, options); var wpfTextViewHost = dsTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; this.wpfTextView = wpfTextViewHost.TextView; ReplEditorUtils.AddInstance(this, wpfTextView); wpfTextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.REPL); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.DragDropEditingId, false); //TODO: ReplEditorOperations doesn't support virtual space wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.UseVirtualSpaceId, false); //TODO: Support box selection wpfTextView.Options.SetOptionValue(DefaultDsTextViewOptions.AllowBoxSelectionId, false); wpfTextView.Options.OptionChanged += Options_OptionChanged; wpfTextView.TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority; wpfTextView.Closed += WpfTextView_Closed; this.wpfTextView.TextBuffer.Changed += TextBuffer_Changed; AddNewDocument(); WriteOffsetOfPrompt(null, true); ReplEditorOperations = new ReplEditorOperations(this, wpfTextView, editorOperationsFactoryService); wpfTextView.VisualElement.Loaded += WpfTextView_Loaded; UpdateRefreshScreenOnChange(); CustomLineNumberMargin.SetOwner(wpfTextView, new ReplCustomLineNumberMarginOwner(this, themeClassificationTypeService)); }