public ReplEditorUI(ReplEditorOptions options, IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings) { this.dispatcher = Dispatcher.CurrentDispatcher; this.options = (options ?? new ReplEditorOptions()).Clone(); this.textEditor = new NewTextEditor(themeManager, textEditorSettings); this.textEditor.TextArea.Document = new TextDocument(); this.textEditor.TextArea.Document.UndoStack.SizeLimit = 100; this.textEditor.TextArea.LeftMargins.Insert(0, new FrameworkElement { Margin = new Thickness(LEFT_MARGIN, 0, 0, 0) }); this.textEditor.TextArea.TextEntering += TextArea_TextEntering; this.textEditor.TextArea.PreviewKeyDown += TextArea_PreviewKeyDown; AddBinding(ApplicationCommands.Paste, (s, e) => Paste(), (s, e) => e.CanExecute = CanPaste && IsAtEditingPosition); AddBinding(ApplicationCommands.Cut, (s, e) => CutSelection(), (s, e) => e.CanExecute = CanCutSelection && IsAtEditingPosition); if (this.options.TextEditorCommandGuid != null) { wpfCommandManager.Add(this.options.TextEditorCommandGuid.Value, textEditor); } if (this.options.TextAreaCommandGuid != null) { wpfCommandManager.Add(this.options.TextAreaCommandGuid.Value, textEditor.TextArea); } if (this.options.MenuGuid != null) { menuManager.InitializeContextMenu(this.textEditor, this.options.MenuGuid.Value, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditor, textEditor)); } }
static ReplEditorOptions CreateReplEditorOptions() { var options = new ReplEditorOptions { MenuGuid = new Guid(MenuConstants.GUIDOBJ_REPL_TEXTEDITORCONTROL_GUID), ContentTypeString = ContentTypes.ReplVisualBasicRoslyn, }; options.Roles.Add(PredefinedDnSpyTextViewRoles.VisualBasicRepl); return(options); }
protected ScriptContent(IReplEditorProvider replEditorProvider, ReplEditorOptions replOpts, ReplSettings replSettings, IServiceLocator serviceLocator, string appearanceCategory) { replOpts.Roles.Add(PredefinedDsTextViewRoles.RoslynRepl); replEditor = replEditorProvider.Create(replOpts); replEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, appearanceCategory); scriptControl = new ScriptControl(); scriptControl.SetTextEditorObject(replEditor.UIObject); scriptControlVM = CreateScriptControlVM(replEditor, serviceLocator, replSettings); scriptControlVM.OnCommandExecuted += ScriptControlVM_OnCommandExecuted; RoslynReplEditorUtils.AddInstance(scriptControlVM, replEditor.TextView); replEditor.Tag = this; scriptControl.DataContext = scriptControlVM; }
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)); }
public IReplEditorUI Create(ReplEditorOptions options) { return(new ReplEditorUI(options, themeManager, wpfCommandManager, menuManager, textEditorSettings)); }
public IReplEditor Create(ReplEditorOptions options) => new ReplEditor(options, dsTextEditorFactoryService, contentTypeRegistryService, textBufferFactoryService, editorOperationsFactoryService, editorOptionsFactoryService, classificationTypeRegistryService, themeClassificationTypeService, pickSaveFilename, textViewUndoManagerProvider);
public IReplEditor Create(ReplEditorOptions options) => new ReplEditor(options, dnSpyTextEditorFactoryService, contentTypeRegistryService, textBufferFactoryService, editorOperationsFactoryService, editorOptionsFactoryService, classificationTypeRegistryService, themeClassificationTypes, pickSaveFilename);
protected ScriptContent(IThemeManager themeManager, IReplEditorCreator replEditorCreator, ReplEditorOptions replOpts, IServiceLocator serviceLocator) { this.replEditorUI = replEditorCreator.Create(replOpts); this.scriptControl = new ScriptControl(); this.scriptControl.SetTextEditorObject(this.replEditorUI.UIObject); this.scriptControlVM = CreateScriptControlVM(this.replEditorUI, serviceLocator); this.scriptControlVM.OnCommandExecuted += ScriptControlVM_OnCommandExecuted; this.replEditorUI.Tag = this; this.scriptControl.DataContext = this.scriptControlVM; themeManager.ThemeChanged += ThemeManager_ThemeChanged; }