public WpfTextViewHost(IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IDsWpfTextView 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; grid = CreateGrid(); TextView = wpfTextView; Focusable = false; Content = grid; UpdateBackground(); TextView.BackgroundBrushChanged += TextView_BackgroundBrushChanged; 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 WpfTextViewHost(IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IDsWpfTextView wpfTextView, IEditorOperationsFactoryService editorOperationsFactoryService, bool setFocus) { if (wpfTextViewMarginProviderCollectionProvider == null) { throw new ArgumentNullException(nameof(wpfTextViewMarginProviderCollectionProvider)); } this.editorOperationsFactoryService = editorOperationsFactoryService ?? throw new ArgumentNullException(nameof(editorOperationsFactoryService)); grid = CreateGrid(); TextView = wpfTextView ?? throw new ArgumentNullException(nameof(wpfTextView)); Focusable = false; Content = grid; UpdateBackground(); TextView.BackgroundBrushChanged += TextView_BackgroundBrushChanged; 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 LogEditor(LogEditorOptions options, IDsTextEditorFactoryService dsTextEditorFactoryService, 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 = dsTextEditorFactoryService.CreateTextViewRoleSet(rolesList); var textView = dsTextEditorFactoryService.CreateTextView(textBuffer, roles, editorOptionsFactoryService.GlobalOptions, options); var wpfTextViewHost = dsTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; this.wpfTextView = wpfTextViewHost.TextView; wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.DragDropEditingId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.AutoScrollId, true); SetNewDocument(); }
public bool TryGetTextViewUndoManager(IDsWpfTextView textView, out ITextViewUndoManager manager) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } return(textView.Properties.TryGetProperty(textViewUndoManagerKey, out manager)); }
public ITextViewUndoManager GetTextViewUndoManager(IDsWpfTextView textView) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } return(textView.Properties.GetOrCreateSingletonProperty(textViewUndoManagerKey, () => new TextViewUndoManager(textView, this, textBufferUndoManagerProvider))); }
public IDsWpfTextViewHost CreateTextViewHost(IDsWpfTextView wpfTextView, bool setFocus) { if (wpfTextView is null) { throw new ArgumentNullException(nameof(wpfTextView)); } return(new WpfTextViewHost(wpfTextViewMarginProviderCollectionProvider, wpfTextView, editorOperationsFactoryService, themeService, setFocus)); }
public void RemoveTextViewUndoManager(IDsWpfTextView textView) { if (textView == null) throw new ArgumentNullException(nameof(textView)); TextViewUndoManager manager; if (!textView.Properties.TryGetProperty(textViewUndoManagerKey, out manager)) return; textView.Properties.RemoveProperty(textViewUndoManagerKey); manager.Dispose(); }
public TextViewUndoManager(IDsWpfTextView textView, ITextViewUndoManagerProvider textViewUndoManagerProvider, ITextBufferUndoManagerProvider textBufferUndoManagerProvider) { TextView = textView ?? throw new ArgumentNullException(nameof(textView)); this.textViewUndoManagerProvider = textViewUndoManagerProvider ?? throw new ArgumentNullException(nameof(textViewUndoManagerProvider)); this.textBufferUndoManagerProvider = textBufferUndoManagerProvider ?? throw new ArgumentNullException(nameof(textBufferUndoManagerProvider)); textBufferUndoManager = textBufferUndoManagerProvider.GetTextBufferUndoManager(TextView.TextBuffer); undoRedoCommandTargetFilter = new UndoRedoCommandTargetFilter(this); TextView.CommandTarget.AddFilter(undoRedoCommandTargetFilter, CommandTargetFilterOrder.UndoRedo); TextView.Closed += TextView_Closed; }
public CompletionSessionCommandTargetFilter(ICompletionSession completionSession) { if (completionSession == null) throw new ArgumentNullException(nameof(completionSession)); this.completionSession = completionSession; dsWpfTextView = completionSession.TextView as IDsWpfTextView; Debug.Assert(dsWpfTextView != null); dsWpfTextView?.CommandTarget.AddFilter(this, CommandTargetFilterOrder.IntellisenseDefaultStatmentCompletion); 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 == null ? 0 : span.Value.Start.Position; }
public CompletionSessionCommandTargetFilter(ICompletionSession completionSession) { this.completionSession = completionSession ?? throw new ArgumentNullException(nameof(completionSession)); dsWpfTextView = completionSession.TextView as IDsWpfTextView; Debug.Assert(dsWpfTextView != null); dsWpfTextView?.CommandTarget.AddFilter(this, CommandTargetFilterOrder.IntellisenseDefaultStatmentCompletion); 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 == null ? 0 : span.Value.Start.Position; }
public void RemoveTextViewUndoManager(IDsWpfTextView textView) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } TextViewUndoManager manager; if (!textView.Properties.TryGetProperty(textViewUndoManagerKey, out manager)) { return; } textView.Properties.RemoveProperty(textViewUndoManagerKey); manager.Dispose(); }
public TextViewUndoManager(IDsWpfTextView textView, ITextViewUndoManagerProvider textViewUndoManagerProvider, ITextBufferUndoManagerProvider textBufferUndoManagerProvider) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (textViewUndoManagerProvider == null) throw new ArgumentNullException(nameof(textViewUndoManagerProvider)); if (textBufferUndoManagerProvider == null) throw new ArgumentNullException(nameof(textBufferUndoManagerProvider)); TextView = textView; this.textViewUndoManagerProvider = textViewUndoManagerProvider; this.textBufferUndoManagerProvider = textBufferUndoManagerProvider; textBufferUndoManager = textBufferUndoManagerProvider.GetTextBufferUndoManager(TextView.TextBuffer); undoRedoCommandTargetFilter = new UndoRedoCommandTargetFilter(this); TextView.CommandTarget.AddFilter(undoRedoCommandTargetFilter, CommandTargetFilterOrder.UndoRedo); TextView.Closed += TextView_Closed; }
public CompletionSessionCommandTargetFilter(ICompletionSession completionSession) { if (completionSession == null) { throw new ArgumentNullException(nameof(completionSession)); } this.completionSession = completionSession; this.dsWpfTextView = completionSession.TextView as IDsWpfTextView; Debug.Assert(dsWpfTextView != null); dsWpfTextView?.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 == null ? 0 : span.Value.Start.Position; }
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 ITextViewUndoManager GetTextViewUndoManager(IDsWpfTextView textView) { if (textView == null) throw new ArgumentNullException(nameof(textView)); return textView.Properties.GetOrCreateSingletonProperty(textViewUndoManagerKey, () => new TextViewUndoManager(textView, this, textBufferUndoManagerProvider)); }
public bool TryGetTextViewUndoManager(IDsWpfTextView textView, out ITextViewUndoManager manager) { if (textView == null) throw new ArgumentNullException(nameof(textView)); return textView.Properties.TryGetProperty(textViewUndoManagerKey, out manager); }
public CommandTargetFilter(IntellisenseSessionStack owner) { this.owner = owner; wpfTextView = owner.wpfTextView as IDsWpfTextView; Debug.Assert(wpfTextView != null); }
public ReplEditor(ReplEditorOptions options, IDsTextEditorFactoryService dsTextEditorFactoryService, IContentTypeRegistryService contentTypeRegistryService, ITextBufferFactoryService textBufferFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, IClassificationTypeRegistryService classificationTypeRegistryService, IThemeClassificationTypeService themeClassificationTypeService, IPickSaveFilename pickSaveFilename, ITextViewUndoManagerProvider textViewUndoManagerProvider) { dispatcher = Dispatcher.CurrentDispatcher; this.pickSaveFilename = pickSaveFilename; options = options?.Clone() ?? new ReplEditorOptions(); options.CreateGuidObjects = CommonGuidObjectsProvider.Create(options.CreateGuidObjects, new GuidObjectsProvider(this)); PrimaryPrompt = options.PrimaryPrompt; SecondaryPrompt = options.SecondaryPrompt; subBuffers = new List<ReplSubBuffer>(); 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; wpfTextView = wpfTextViewHost.TextView; textViewUndoManager = textViewUndoManagerProvider.GetTextViewUndoManager(wpfTextView); ReplEditorUtils.AddInstance(this, wpfTextView); wpfTextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.TextEditor); 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; 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 LogEditor(LogEditorOptions options, IDsTextEditorFactoryService dsTextEditorFactoryService, IContentTypeRegistryService contentTypeRegistryService, ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService) { dispatcher = Dispatcher.CurrentDispatcher; 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 = dsTextEditorFactoryService.CreateTextViewRoleSet(rolesList); var textView = dsTextEditorFactoryService.CreateTextView(textBuffer, roles, editorOptionsFactoryService.GlobalOptions, options); var wpfTextViewHost = dsTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; wpfTextView = wpfTextViewHost.TextView; wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.DragDropEditingId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.AutoScrollId, true); SetNewDocument(); }
public IDsWpfTextViewHost CreateTextViewHost(IDsWpfTextView wpfTextView, bool setFocus) { if (wpfTextView == null) throw new ArgumentNullException(nameof(wpfTextView)); return new WpfTextViewHost(wpfTextViewMarginProviderCollectionProvider, wpfTextView, editorOperationsFactoryService, setFocus); }