示例#1
0
        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();
        }
示例#2
0
        IOutputTextPane Create(Guid guid, string name, object contentTypeObj)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var vm = OutputBuffers.FirstOrDefault(a => a.Guid == guid);

            Debug.Assert(vm == null || vm.Name == name);
            if (vm != null)
            {
                return(vm);
            }

            var logEditorOptions = new LogEditorOptions {
                MenuGuid          = new Guid(MenuConstants.GUIDOBJ_LOG_TEXTEDITORCONTROL_GUID),
                ContentType       = contentTypeObj as IContentType,
                ContentTypeString = contentTypeObj as string,
                CreateGuidObjects = args => CreateGuidObjects(args),
            };

            logEditorOptions.ExtraRoles.Add(PredefinedDsTextViewRoles.OutputTextPane);
            var logEditor = logEditorProvider.Create(logEditorOptions);

            logEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.OutputWindow);

            // Prevent toolwindow's ctx menu from showing up when right-clicking in the left margin
            menuService.InitializeContextMenu(logEditor.TextViewHost.HostControl, Guid.NewGuid());

            vm = new OutputBufferVM(editorOperationsFactoryService, guid, name, logEditor);
            int index = GetSortedInsertIndex(vm);

            OutputBuffers.Insert(index, vm);
            while (index < OutputBuffers.Count)
            {
                OutputBuffers[index].Index = index++;
            }

            OutputTextPaneUtils.AddInstance(vm, logEditor.TextView);
            return(vm);
        }
示例#3
0
 public ILogEditor Create(LogEditorOptions options) => new LogEditor(options, dnSpyTextEditorFactoryService, contentTypeRegistryService, textBufferFactoryService, editorOptionsFactoryService);