public SharpDevelopTextEditor()
        {
            AvalonEditDisplayBinding.RegisterAddInHighlightingDefinitions();

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Print, OnPrint));
            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.PrintPreview, OnPrintPreview));

            options = ICSharpCode.AvalonEdit.AddIn.Options.CodeEditorOptions.Instance;
            options.BindToTextEditor(this);
        }
Ejemplo n.º 2
0
        RoslynCodeDocument CreateDocument(ProjectId projectId, string nameNoExtension)
        {
            var options = new CodeEditorOptions();

            options.ContentTypeString = ContentType;
            var codeEditor = codeEditorProvider.Create(options);

            codeEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategory);
            codeEditor.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true);

            var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectId), nameNoExtension + FileExtension, null, SourceCodeKind.Regular, TextLoader.From(codeEditor.TextBuffer.AsTextContainer(), VersionStamp.Default));

            return(new RoslynCodeDocument(codeEditor, documentInfo, nameNoExtension));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        RoslynCodeDocument CreateDocument(ProjectId projectId, CompilerDocumentInfo doc)
        {
            var options = new CodeEditorOptions();

            options.ContentTypeString = ContentType;
            options.Roles.Add(PredefinedDsTextViewRoles.RoslynCodeEditor);
            options.Roles.Add(TextViewRole);
            var codeEditor = codeEditorProvider.Create(options);

            codeEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategory);
            codeEditor.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true);

            var textBuffer = codeEditor.TextView.TextBuffer;

            textBuffer.Replace(new Span(0, textBuffer.CurrentSnapshot.Length), doc.Code);

            var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectId), doc.Name, null, SourceCodeKind.Regular, TextLoader.From(codeEditor.TextBuffer.AsTextContainer(), VersionStamp.Create()));

            return(new RoslynCodeDocument(codeEditor, documentInfo));
        }
Ejemplo n.º 5
0
 public ICodeEditor Create(CodeEditorOptions options) => new CodeEditor(options, dsTextEditorFactoryService, contentTypeRegistryService, textBufferFactoryService, editorOptionsFactoryService);