protected override void CreateControls(IWpfTextViewHost host, string source) { int width = WESettings.GetInt(SettingsKey); width = width == -1 ? 400 : width; _browser = new WebBrowser(); _browser.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Pixel) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(width) }); grid.RowDefinitions.Add(new RowDefinition()); grid.Children.Add(_browser); this.Children.Add(grid); Grid.SetColumn(_browser, 2); Grid.SetRow(_browser, 0); GridSplitter splitter = new GridSplitter(); splitter.Width = 5; splitter.ResizeDirection = GridResizeDirection.Columns; splitter.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; splitter.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; splitter.DragCompleted += splitter_DragCompleted; grid.Children.Add(splitter); Grid.SetColumn(splitter, 1); Grid.SetRow(splitter, 0); }
/// <summary> /// Constructor for the OverviewChangeTrackingMargin. /// </summary> private OverviewMarkMargin( IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, OverviewMarkMarginProvider provider) { _markMarginElement = new MarkMarginElement(textViewHost.TextView, scrollBar, provider); }
IWpfTextViewMargin IWpfTextViewMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { // If the notification has occured then there is nothing else to do. We are done if (_vimApplicationSettings.HaveNotifiedBackspaceSetting) { return null; } // On the very first IVimBuffer creation the vimrc will be loaded. Go ahead and // attempt to get / create the buffer to ensure the vimrc load has been attempted var wpfTextView = wpfTextViewHost.TextView; IVimBuffer vimBuffer; if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out vimBuffer)) { return null; } // If there is no vimrc or the load does allow backspace over start then there // is no need to display the warning if (_vim.GlobalSettings.IsBackspaceStart || _vimApplicationSettings.UseEditorTabAndBackspace) { return null; } var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(wpfTextView); var linkBanner = new LinkBanner(); linkBanner.MarginName = Name; linkBanner.LinkAddress = "https://github.com/jaredpar/VsVim/wiki/FAQ#wiki-backspace"; linkBanner.LinkText = "FAQ"; linkBanner.BannerText = "You may want to change the backspace setting in your vimrc"; linkBanner.Background = editorFormatMap.GetBackgroundBrush(EditorFormatDefinitionNames.Margin, MarginFormatDefinition.DefaultColor); linkBanner.CloseClicked += (sender, e) => { _vimApplicationSettings.HaveNotifiedBackspaceSetting = true; }; return linkBanner; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost view_host, IWpfTextViewMargin container_margin) { IWpfTextView text_view = view_host.TextView; try { Utils.VSVersion = Assembly.GetCallingAssembly().GetName().Version.Major.ToString(); } catch { } if (!PresenceSent) { PresenceSent = true; MonitoringService.SendPresense(); } if (!SettingsLoaded) ReadSettings(OptionsService.GlobalOptions); RemoveVerticalScrollBar(container_margin); var navigator = TextStructureNavigatorService.GetTextStructureNavigator(text_view.TextBuffer); var format = FormatMapService.GetEditorFormatMap(text_view); var tagger = HighlightWordTagger.Instance(text_view, format, TextSearchService, navigator); var marks_enumerator = new MarksEnumerator(AggregatorFactoryService, text_view); var change_enumerator = new ChangeEnumerator(AggregatorFactoryService, text_view); var words_enumerator = new HighlightedWordsEnumerator(text_view, tagger); return new RockMargin(text_view, marks_enumerator, change_enumerator, words_enumerator, tagger); }
public IMouseProcessor GetAssociatedMouseProcessor(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin) { return new GlyphMouseProcessor( wpfTextViewHost, margin, aggregatorFactory.CreateTagAggregator<IGlyphTag>(wpfTextViewHost.TextView.TextBuffer) ); }
public PlayMouseProcessor(IWpfTextViewHost wpfTextViewHost, IViewTagAggregatorFactoryService viewTagAggregatorFactoryService) { _wpfTextViewHost = wpfTextViewHost; _viewTagAggregatorFactoryService = viewTagAggregatorFactoryService; _createTagAggregator = _viewTagAggregatorFactoryService.CreateTagAggregator<PlayGlyphTag>(_wpfTextViewHost.TextView); }
public GlyphMouseProcessor(IWpfTextViewHost host, IWpfTextViewMargin margin, ITagAggregator<IGlyphTag> aggregator) { this.theHost = host; this.theMargin = margin; this.tagAggregator = aggregator; this.theHost.Closed += OnTextViewHostClosed; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { string source = textViewHost.TextView.TextBuffer.CurrentSnapshot.GetText(); ITextDocument document; if (textViewHost.TextView.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document)) { switch (textViewHost.TextView.TextBuffer.ContentType.DisplayName) { case "LESS": bool showLess = WESettings.GetBoolean(WESettings.Keys.ShowLessPreviewWindow); return new LessMargin("CSS", source, showLess, document); //case "scss": // return new ScssMargin("CSS", source, true, document); case "CoffeeScript": bool showCoffee = WESettings.GetBoolean(WESettings.Keys.ShowCoffeeScriptPreviewWindow); return new CoffeeScriptMargin("JavaScript", source, showCoffee, document); //case "TypeScript": // if (!document.FilePath.EndsWith(".d.ts")) // { // bool showType = WESettings.GetBoolean(WESettings.Keys.ShowTypeScriptPreviewWindow); // return new TypeScriptMargin("TypeScript", source, showType, document); // } // break; case "markdown": return new MarkdownMargin("text", source, true, document); } } return null; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { string source = textViewHost.TextView.TextBuffer.CurrentSnapshot.GetText(); ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textViewHost.TextView.TextDataModel.DocumentBuffer, out document)) { switch (textViewHost.TextView.TextBuffer.ContentType.DisplayName.ToLowerInvariant()) { case "less": bool showLess = WESettings.GetBoolean(WESettings.Keys.ShowLessPreviewWindow); return new LessMargin("CSS", source, showLess, document); case "coffeescript": bool showCoffee = WESettings.GetBoolean(WESettings.Keys.ShowCoffeeScriptPreviewWindow); return new CoffeeScriptMargin("JavaScript", source, showCoffee, document); case "markdown": bool showMarkdown = WESettings.GetBoolean(WESettings.Keys.MarkdownShowPreviewWindow); return new MarkdownMargin("text", source, showMarkdown, document); } } return null; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { IWpfTextView view = textViewHost.TextView; // Files larger than 1 MB should be skipped to avoid hangs. if (view.TextSnapshot.Length > (1024 * 1024)) return null; ITextDocument document; if (!_TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document)) return null; IVsExtensionManager manager = _serviceProvider.GetService(typeof(SVsExtensionManager)) as IVsExtensionManager; if (manager == null) return null; IInstalledExtension extension; manager.TryGetInstalledExtension("FixMixedTabs", out extension); if (extension != null) return null; ITextUndoHistory history; if (!_UndoHistoryRegistry.TryGetHistory(view.TextBuffer, out history)) { Debug.Fail("Unexpected: couldn't get an undo history for the given text buffer"); return null; } return new InformationBarMargin(view, document, _OperationsFactory.GetEditorOperations(view), history); }
protected IMarginCore TryGetMarginCore(IWpfTextViewHost textViewHost) { MarginCore marginCore; if (textViewHost.TextView.Properties.TryGetProperty(typeof(MarginCore), out marginCore)) return marginCore; // play nice with other source control providers ITextView textView = textViewHost.TextView; ITextDataModel textDataModel = textView != null ? textView.TextDataModel : null; ITextBuffer documentBuffer = textDataModel != null ? textDataModel.DocumentBuffer : null; if (documentBuffer == null) return null; ITextDocument textDocument; if (!TextDocumentFactoryService.TryGetTextDocument(documentBuffer, out textDocument)) return null; //var filename = textDocument.FilePath; //var repositoryPath = GitCommands.GetGitRepository(Path.GetFullPath(filename)); //if (repositoryPath == null) // return null; return textViewHost.TextView.Properties.GetOrCreateSingletonProperty( () => new MarginCore(textViewHost.TextView, ClassificationFormatMapService, EditorFormatMapService)); }
public GlyphTextMarkerServiceMouseProcessor(IGlyphTextMarkerServiceImpl glyphTextMarkerServiceImpl, IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin) { if (glyphTextMarkerServiceImpl == null) throw new ArgumentNullException(nameof(glyphTextMarkerServiceImpl)); if (wpfTextViewHost == null) throw new ArgumentNullException(nameof(wpfTextViewHost)); if (margin == null) throw new ArgumentNullException(nameof(margin)); glyphTextViewMarkerService = GlyphTextViewMarkerService.GetOrCreate(glyphTextMarkerServiceImpl, wpfTextViewHost.TextView); this.wpfTextViewHost = wpfTextViewHost; this.margin = margin; toolTipDispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal, margin.VisualElement.Dispatcher); popup = new Popup { AllowsTransparency = true }; var list = new List<IGlyphTextMarkerMouseProcessor>(); foreach (var lazy in glyphTextMarkerServiceImpl.GlyphTextMarkerMouseProcessorProviders) { if (lazy.Metadata.TextViewRoles != null && !wpfTextViewHost.TextView.Roles.ContainsAny(lazy.Metadata.TextViewRoles)) continue; var mouseProcessor = lazy.Value.GetAssociatedMouseProcessor(wpfTextViewHost, margin); if (mouseProcessor != null) list.Add(mouseProcessor); } glyphTextMarkerMouseProcessors = list.ToArray(); wpfTextViewHost.TextView.Closed += TextView_Closed; wpfTextViewHost.TextView.LayoutChanged += TextView_LayoutChanged; toolTipDispatcherTimer.Tick += ToolTipDispatcherTimer_Tick; popup.Closed += Popup_Closed; glyphTextViewMarkerService.AddGlyphTextMarkerListener(this); }
public VsInteractiveWindowCommandFilter(IVsEditorAdaptersFactoryService adapterFactory, IInteractiveWindow window, IVsTextView textViewAdapter, IVsTextBuffer bufferAdapter, IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders, IContentTypeRegistryService contentTypeRegistry) { _window = window; _oleCommandTargetProviders = oleCommandTargetProviders; _contentTypeRegistry = contentTypeRegistry; this.textViewAdapter = textViewAdapter; // make us a code window so we'll have the same colors as a normal code window. IVsTextEditorPropertyContainer propContainer; ErrorHandler.ThrowOnFailure(((IVsTextEditorPropertyCategoryContainer)textViewAdapter).GetPropertyCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidEditPropCategoryViewMasterSettings, out propContainer)); propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewComposite_AllCodeWindowDefaults, true); propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewGlobalOpt_AutoScrollCaretOnTextEntry, true); // editor services are initialized in textViewAdapter.Initialize - hook underneath them: _preEditorCommandFilter = new CommandFilter(this, CommandFilterLayer.PreEditor); ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preEditorCommandFilter, out _editorCommandFilter)); textViewAdapter.Initialize( (IVsTextLines)bufferAdapter, IntPtr.Zero, (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT, new[] { new INITVIEW { fSelectionMargin = 0, fWidgetMargin = 0, fVirtualSpace = 0, fDragDropMove = 1 } }); // disable change tracking because everything will be changed var textViewHost = adapterFactory.GetWpfTextViewHost(textViewAdapter); _preLanguageCommandFilter = new CommandFilter(this, CommandFilterLayer.PreLanguage); ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preLanguageCommandFilter, out _editorServicesCommandFilter)); _textViewHost = textViewHost; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { int iErrStat; //_contentTypeRegistryService = ContentTypeRegistryService; //_textBufferFactoryService = TextBufferFactoryService; //DTE2 dte = (DTE2)serviceProvider.GetService(typeof(DTE)); //iErrStat = GetHiddenTextManager(serviceProvider); //IComponentModel componentModel = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)); //IVsEditorAdaptersFactoryService adapterFactoryService = componentModel.GetService<IVsEditorAdaptersFactoryService>(); ////System.Diagnostics.Trace.WriteLine(":" + _textBufferFactoryService.TextContentType.ToString()); //_curTextBuf = _textBufferFactoryService.CreateTextBuffer("test", _textBufferFactoryService.PlaintextContentType); foreach (IViewTaggerProvider vtp in viewTaggerProviderCollection) { if (vtp is TextInvisTaggerProvider) { _titp = vtp as TextInvisTaggerProvider; break; } } if (_titp == null) { System.Diagnostics.Trace.WriteLine("no valid tagger, exit"); return null; } return new TestMargin(textViewHost.TextView, _titp.GetThyTagger()); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { if (!ExtensibilityToolsPackage.Options.ShowBottomMargin) return null; return new BottomMargin(wpfTextViewHost.TextView, _classifierService, _documentService); }
public SimpleScrollBar(IWpfTextViewHost host, IWpfTextViewMargin containerMargin, FrameworkElement container, IScrollMapFactoryService scrollMapFactoryService) { _textView = host.TextView; _realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin; if (_realScrollBarMargin != null) { _realScrollBar = _realScrollBarMargin as IVerticalScrollBar; if (_realScrollBar != null) { _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged; _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged; } } ResetTrackSpan(); _scrollMapFactory = scrollMapFactoryService; _useElidedCoordinates = false; ResetScrollMap(); _scrollMap.MappingChanged += delegate { RaiseTrackChangedEvent(); }; container.SizeChanged += OnContainerSizeChanged; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { string fileName = GetFileNameFromTextBuffer(wpfTextViewHost.TextView.TextBuffer); IEnumerable<SonarIssue> issues = _sonarIssuesService.GetIssuesForFile(fileName); return new SonarIssueTextViewMargin(issues, wpfTextViewHost, marginContainer, _scrollMapFactoryService); }
public BottomRightCornerMargin(IWpfTextViewHost wpfTextViewHost) { if (wpfTextViewHost == null) throw new ArgumentNullException(nameof(wpfTextViewHost)); this.wpfTextViewHost = wpfTextViewHost; wpfTextViewHost.TextView.Options.OptionChanged += Options_OptionChanged; SetResourceReference(BackgroundProperty, "EnvironmentScrollBarBackground"); UpdateVisibility(); }
/// <summary> /// Factory for the ChangeTrackingMargin. /// </summary> public static OverviewChangeTrackingMargin Create(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, OverviewChangeTrackingMarginProvider provider) { // Validate if (textViewHost == null) throw new ArgumentNullException("textViewHost"); return new OverviewChangeTrackingMargin(textViewHost, scrollBar, provider); }
/// <summary> /// Constructor for the CaretMargin. /// </summary> /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param> /// <param name="navigator">Instance of an ITextStructureNavigator used to define words in the host's TextView. Created from the /// ITextStructureNavigatorFactory service.</param> public CaretMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, CaretMarginFactory factory) { // Validate if (textViewHost == null) throw new ArgumentNullException("textViewHost"); this.caretMarginElement = new CaretMarginElement(textViewHost.TextView, factory, scrollBar); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { return new RelativeNumber( textViewHost.TextView, FormatMapService.GetEditorFormatMap(textViewHost.TextView), containerMargin, OutliningManagerService.GetOutliningManager(textViewHost.TextView)); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { if (!VisualDHelper.setFactory(editorFactory)) return null; //MessageBox.Show("CreateMargin"); return new CoverageMargin(textViewHost.TextView, FormatMapService.GetEditorFormatMap(textViewHost.TextView)); }
public override IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { var marginCore = TryGetMarginCore(textViewHost); if (marginCore == null) return null; return new EditorDiffMargin(textViewHost.TextView, marginCore); }
/// <summary> /// Constructor for the StructureMargin. /// </summary> /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param> public StructureMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, StructureMarginFactory factory) { // Validate if (textViewHost == null) throw new ArgumentNullException("textViewHost"); this.structureMarginElement = new StructureMarginElement(textViewHost.TextView, scrollBar, factory); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { if (!(textViewHost.TextView.TextBuffer is IProjectionBuffer)) { return null; } return new VenusMargin(textViewHost.TextView, _textEditorFactory); }
IVimViewInfo IVimWindow.AddVimViewInfo(IWpfTextViewHost textViewHost) { var vimBuffer = _vim.GetOrCreateVimBuffer(textViewHost.TextView); var vimViewInfo = new VimViewInfo() { VimBuffer = vimBuffer, TextViewHost = textViewHost, VimWindow = this }; _vimViewInfoList.Add(vimViewInfo); textViewHost.TextView.Closed += OnTextViewClosed; RaiseChanged(); return vimViewInfo; }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { var generalOptions = Utils.GetGeneralOptionsPage(serviceProvider); if (!generalOptions.UnusedDeclarationsEnabled) return null; var textView = wpfTextViewHost.TextView; return new UnusedDeclarationMargin(textView, marginContainer, classifierAggregatorService.GetClassifier(textView.TextBuffer)); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { var generalOptions = Setting.getGeneralOptions(_serviceProvider); if (generalOptions == null || !(generalOptions.UnusedReferencesEnabled || generalOptions.UnusedOpensEnabled)) return null; var textView = wpfTextViewHost.TextView; var tagAggregator = _viewTagAggregatorFactoryService.CreateTagAggregator<UnusedDeclarationTag>(textView); return new UnusedDeclarationMargin(textView, marginContainer, tagAggregator); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { var generalOptions = Setting.getGeneralOptions(serviceProvider); if (generalOptions == null || !(generalOptions.UnusedReferencesEnabled || generalOptions.UnusedOpensEnabled)) return null; var textView = wpfTextViewHost.TextView; return new UnusedDeclarationMargin(textView, marginContainer, classifierAggregatorService.GetClassifier(textView.TextBuffer)); }
public IWpfTextViewMarginProviderCollection Create(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer, string marginContainerName) { if (wpfTextViewHost == null) throw new ArgumentNullException(nameof(wpfTextViewHost)); if (marginContainer == null) throw new ArgumentNullException(nameof(marginContainer)); if (marginContainerName == null) throw new ArgumentNullException(nameof(marginContainerName)); return new WpfTextViewMarginProviderCollection(wpfTextViewMarginProviders, wpfTextViewHost, marginContainer, marginContainerName); }
public PasteToTargetOperationUI(PasteToTargetOperation op, IWpfTextViewHost targetHost) { _op = op; _op.StateChanged += _op_StateChanged; m_targetHost = targetHost; m_adornment = new PasteToTargetStatusAdornment(m_targetHost.TextView); m_adornment.Cancel += adornment_Cancel; m_highlightTarget = m_targetHost.TextView.Properties.GetOrCreateSingletonProperty <PasteToTargetHighlight>(delegate { throw new Exception("Unexpected: ITagger PasteToTargetHighlight was not created"); }); m_highlightTarget.FireTagsChanged( PasteToTargetState.CaptureMode, _op.SelectionState.GetSelectedSpans(m_targetHost.TextView.TextBuffer.CurrentSnapshot)); }
/// <summary> /// Helper method for getting a IWpfTextView from a IVsTextView object /// </summary> /// <param name="textView"></param> /// <returns></returns> private IWpfTextView GetWpfTextView(IVsTextView textView) { IWpfTextViewHost textViewHost = null; IVsUserData userData = textView as IVsUserData; if (userData != null) { Guid guid = Microsoft.VisualStudio.Editor.DefGuidList.guidIWpfTextViewHost; object wpfTextViewHost = null; userData.GetData(ref guid, out wpfTextViewHost); textViewHost = wpfTextViewHost as IWpfTextViewHost; } if (textViewHost == null) { return null; } return textViewHost.TextView; }
//</Snippet12> //<Snippet13> static public void Execute(IWpfTextViewHost host) { IWpfTextView view = host.TextView; //Add a comment on the selected text. if (!view.Selection.IsEmpty) { //Get the provider for the comment adornments in the property bag of the view. CommentAdornmentProvider provider = view.Properties.GetProperty <CommentAdornmentProvider>(typeof(CommentAdornmentProvider)); //Add some arbitrary author and comment text. string author = System.Security.Principal.WindowsIdentity.GetCurrent().Name; string comment = "Four score...."; //Add the comment adornment using the provider. provider.Add(view.Selection.SelectedSpans[0], author, comment); } }
public WpfTextViewMarginProviderCollection(Lazy<IWpfTextViewMarginProvider, IWpfTextViewMarginMetadata>[] wpfTextViewMarginProviders, IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer, string marginContainerName) { if (wpfTextViewMarginProviders is null) throw new ArgumentNullException(nameof(wpfTextViewMarginProviders)); if (wpfTextViewHost is null) throw new ArgumentNullException(nameof(wpfTextViewHost)); if (marginContainerName is null) throw new ArgumentNullException(nameof(marginContainerName)); this.wpfTextViewMarginProviders = wpfTextViewMarginProviders.Where(a => StringComparer.OrdinalIgnoreCase.Equals(marginContainerName, a.Metadata.MarginContainer) && wpfTextViewHost.TextView.Roles.ContainsAny(a.Metadata.TextViewRoles) ).ToArray(); this.wpfTextViewHost = wpfTextViewHost; this.marginContainer = marginContainer ?? throw new ArgumentNullException(nameof(marginContainer)); currentMargins = Array.Empty<WpfTextViewMarginInfo>(); wpfTextViewHost.Closed += WpfTextViewHost_Closed; wpfTextViewHost.TextView.TextDataModel.ContentTypeChanged += TextDataModel_ContentTypeChanged; UpdateMargins(); }
/// <summary> /// Shows the regex editor. /// </summary> /// <param name="pattern">The regular expression to be edited.</param> /// <returns>The regular expression.</returns> internal RegexEditorResult ShowEditor(string pattern) { // Create the regex editor IContentType regexContentType = this.ContentTypeRegistryService.GetContentType(RegexContentType.ContentTypeName); ITextBuffer textBuffer = this.TextBufferFactoryService.CreateTextBuffer(pattern, regexContentType); // TODO: RC1 IWpfTextView view = this.TextEditorFactoryService.CreateTextView(textBuffer); IWpfTextViewHost editor = this.TextEditorFactoryService.CreateTextViewHost(view, true); editor.TextView.Properties.AddProperty(TextViewEventManager.Key, new TextViewEventManager(editor.TextView)); HideTextViewMargins(editor); string result = pattern; bool? dialogResult = RegexEditorDialog.ShowDialog(pattern, editor, out result); return(new RegexEditorResult(result, dialogResult)); }
public IWpfTextViewHost GetCurrentViewHost(Func <string, bool> predicate) { IWpfTextViewHost viewHost = VisualStudioInteraction.GetCurrentViewHost(_serviceProvider); if (viewHost == null) { return(null); } ITextDocument textDocument = viewHost.GetTextDocument(); if (textDocument == null || !predicate(textDocument.FilePath)) { return(null); } return(viewHost); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { Func <ITextDocument, IWpfTextView, IWpfTextViewMargin> creator; if (!marginFactories.TryGetValue(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer.ContentType.TypeName, out creator)) { return(null); } ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer, out document)) { return(null); } return(creator(document, wpfTextViewHost.TextView)); }
public static IWpfTextViewHost GetCurrentViewHost(IServiceProvider serviceProvider, Func <string, bool> predicate) { IWpfTextViewHost viewHost = GetCurrentViewHost(serviceProvider); if (viewHost == null) { return(null); } ITextDocument textDocument = viewHost.GetTextDocument(); if (textDocument == null || !predicate(textDocument.FilePath)) { return(null); } return(viewHost); }
static IWpfTextViewHost GetCurrentVBViewHost(IServiceProvider serviceProvider) { IWpfTextViewHost viewHost = VisualStudioInteraction.GetCurrentViewHost(serviceProvider); if (viewHost == null) { return(null); } ITextDocument textDocument = viewHost.GetTextDocument(); if ((textDocument == null) || !IsVBFileName(textDocument.FilePath)) { return(null); } return(viewHost); }
public CoverageMargin(IWpfTextViewHost textViewHost, SVsServiceProvider serviceProvider, ICoverageProviderBroker coverageProviderBroker) { ITextDocument document; _textViewHost = textViewHost; _dte = (DTE)serviceProvider.GetService(typeof(DTE)); _documentName = CoverageProvider.GetFileName(_textViewHost.TextView.TextBuffer); _codeMarkManager = new CodeMarkManager(); _coverageProvider = coverageProviderBroker.GetCoverageProvider(_textViewHost.TextView, _dte, serviceProvider); _codeMarks = GetAllCodeMarksForMargin(); _textViewHost.TextView.LayoutChanged += TextViewLayoutChanged; _textViewHost.TextView.GotAggregateFocus += TextViewGotAggregateFocus; _textViewHost.TextView.ViewportHeightChanged += TextViewViewportHeightChanged; _textViewHost.TextView.TextBuffer.Changed += TextBufferChanged; _textViewHost.TextView.Closed += TextViewClosed; //create a canvas to hold the margin UI and set its properties _marginCanvas = new Canvas(); _marginCanvas.Background = Brushes.Transparent; ClipToBounds = true; Background = Brushes.Transparent; BorderBrush = Brushes.Transparent; Width = (_textViewHost.TextView.ZoomLevel / 100) * _marginWidth; BorderThickness = new Thickness(0.5); // add margin canvas to the children list Child = _marginCanvas; UpdateCodeMarks(_coverageProvider.GetCoveredLines(_textViewHost.TextView)); }
internal CodeEditor CreateCodeEditor(Microsoft.VisualStudio.Text.ITextBuffer textBuffer) { EditingService.DefaultEnvironment defaultEnvironment = new EditingService.DefaultEnvironment(); IWpfTextViewHost textViewHost = this.textEditorFactoryProvider.CreateTextViewHost(textBuffer, (IEnvironment)defaultEnvironment, false); defaultEnvironment.SetTextViewHost(textViewHost); IWpfTextView textView = textViewHost.TextView; IEditorOperations editorOperations = this.editorCommandsProvider.GetEditorOperations((ITextView)textView); ITextBufferUndoManager bufferUndoManager = this.undoManagerProvider.GetTextBufferUndoManager(textBuffer); IFindLogic service1 = this.loader.GetService <IFindLogic>(); IClassificationTypeRegistry service2 = this.loader.GetService <IClassificationTypeRegistry>(); IClassificationFormatMap service3 = this.loader.GetService <IClassificationFormatMap>(); ISquiggleProvider squiggleProvider = this.squiggleProviderFactory.GetSquiggleProvider((ITextView)textView); ICompletionBroker brokerForTextView = this.completionBrokerMap.GetBrokerForTextView((ITextView)textView); IMessageDisplayService messageDisplayService = (IMessageDisplayService)this.serviceProvider.GetService(typeof(IMessageDisplayService)); ICodeAidProvider codeAidProvider = this.GetCodeAidProvider(); return(new CodeEditor(textView, textViewHost, editorOperations, bufferUndoManager, service1, service2, service3, squiggleProvider, brokerForTextView, this.codeOptionsModel, messageDisplayService, codeAidProvider, (IEnvironment)defaultEnvironment)); }
protected override void CreateControls(IWpfTextViewHost host, string source) { int width = WESettings.GetInt(_settingsKey); width = width == -1 ? 400 : width; _browser = new WebBrowser(); _browser.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Pixel) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(width) }); grid.RowDefinitions.Add(new RowDefinition()); grid.Children.Add(_browser); this.Children.Add(grid); Grid.SetColumn(_browser, 2); Grid.SetRow(_browser, 0); GridSplitter splitter = new GridSplitter(); splitter.Width = 5; splitter.ResizeDirection = GridResizeDirection.Columns; splitter.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; splitter.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; splitter.DragCompleted += splitter_DragCompleted; grid.Children.Add(splitter); Grid.SetColumn(splitter, 1); Grid.SetRow(splitter, 0); }
public GlyphTextMarkerServiceMouseProcessor(IGlyphTextMarkerServiceImpl glyphTextMarkerServiceImpl, IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin) { if (glyphTextMarkerServiceImpl == null) { throw new ArgumentNullException(nameof(glyphTextMarkerServiceImpl)); } if (wpfTextViewHost == null) { throw new ArgumentNullException(nameof(wpfTextViewHost)); } if (margin == null) { throw new ArgumentNullException(nameof(margin)); } this.glyphTextViewMarkerService = GlyphTextViewMarkerService.GetOrCreate(glyphTextMarkerServiceImpl, wpfTextViewHost.TextView); this.wpfTextViewHost = wpfTextViewHost; this.margin = margin; this.toolTipDispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal, margin.VisualElement.Dispatcher); this.popup = new Popup { AllowsTransparency = true }; var list = new List <IGlyphTextMarkerMouseProcessor>(); foreach (var lazy in glyphTextMarkerServiceImpl.GlyphTextMarkerMouseProcessorProviders) { if (lazy.Metadata.TextViewRoles != null && !wpfTextViewHost.TextView.Roles.ContainsAny(lazy.Metadata.TextViewRoles)) { continue; } var mouseProcessor = lazy.Value.GetAssociatedMouseProcessor(wpfTextViewHost, margin); if (mouseProcessor != null) { list.Add(mouseProcessor); } } this.glyphTextMarkerMouseProcessors = list.ToArray(); wpfTextViewHost.TextView.Closed += TextView_Closed; wpfTextViewHost.TextView.LayoutChanged += TextView_LayoutChanged; toolTipDispatcherTimer.Tick += ToolTipDispatcherTimer_Tick; popup.Closed += Popup_Closed; glyphTextViewMarkerService.AddGlyphTextMarkerListener(this); }
public DevViewMargin(IWpfTextViewHost wpfTextViewHost, IFileExtensionRegistryService fers, IVsfSettings settings) { this.model = new DevMarginViewModel(); this.wpfTextViewHost = wpfTextViewHost; this.extensionRegistry = fers; this.settings = settings; this.settings.SettingsChanged += OnSettingsChanged; this.wpfTextViewHost.Closed += OnTextViewHostClosed; this.visual = new DevMarginVisual(this.model, settings); this.visual.ViewBuffer += OnViewBuffer; UpdateVisibility(); InitializeTextView(); RefreshBufferGraphList(); this.model.RefreshView(wpfTextViewHost.TextView); }
protected IMarginCore TryGetMarginCore(IWpfTextViewHost textViewHost) { MarginCore marginCore; if (textViewHost.TextView.Properties.TryGetProperty(typeof(MarginCore), out marginCore)) { return(marginCore); } // play nice with other source control providers ITextView textView = textViewHost.TextView; ITextDataModel textDataModel = textView != null ? textView.TextDataModel : null; ITextBuffer documentBuffer = textDataModel != null ? textDataModel.DocumentBuffer : null; if (documentBuffer == null) { return(null); } ITextDocument textDocument; if (!TextDocumentFactoryService.TryGetTextDocument(documentBuffer, out textDocument)) { return(null); } var fullPath = GetFullPath(textDocument.FilePath); if (fullPath == null) { return(null); } var repositoryPath = GitCommands.GetGitRepository(fullPath); if (repositoryPath == null) { return(null); } return(textViewHost.TextView.Properties.GetOrCreateSingletonProperty( () => new MarginCore(textViewHost.TextView, TextDocumentFactoryService, ClassificationFormatMapService, EditorFormatMapService, GitCommands))); }
protected LineNumberMarginBase(string marginName, IWpfTextViewHost wpfTextViewHost, IClassificationFormatMapService classificationFormatMapService, ITextFormatterProvider textFormatterProvider) { if (classificationFormatMapService is null) { throw new ArgumentNullException(nameof(classificationFormatMapService)); } identityTagToLine = new Dictionary <object, Line>(); this.marginName = marginName ?? throw new ArgumentNullException(nameof(marginName)); this.wpfTextViewHost = wpfTextViewHost ?? throw new ArgumentNullException(nameof(wpfTextViewHost)); classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(wpfTextViewHost.TextView); textLayer = new Layer(); this.textFormatterProvider = textFormatterProvider ?? throw new ArgumentNullException(nameof(textFormatterProvider)); Children.Add(textLayer); wpfTextViewHost.TextView.Options.OptionChanged += Options_OptionChanged; IsVisibleChanged += LineNumberMargin_IsVisibleChanged; ClipToBounds = true; IsHitTestVisible = false; UpdateVisibility(); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { IWpfTextView view = textViewHost.TextView; // Files larger than 1 MB should be skipped to avoid hangs. if (view.TextSnapshot.Length > (1024 * 1024)) { return(null); } ITextDocument document; if (!_TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document)) { return(null); } IVsExtensionManager manager = _serviceProvider.GetService(typeof(SVsExtensionManager)) as IVsExtensionManager; if (manager == null) { return(null); } IInstalledExtension extension; manager.TryGetInstalledExtension("FixMixedTabs", out extension); if (extension != null) { return(null); } ITextUndoHistory history; if (!_UndoHistoryRegistry.TryGetHistory(view.TextBuffer, out history)) { Debug.Fail("Unexpected: couldn't get an undo history for the given text buffer"); return(null); } return(new InformationBarMargin(view, document, _OperationsFactory.GetEditorOperations(view), history)); }
public IGuidObjectsProvider Create(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin, string marginName) { if (wpfTextViewHost == null) { throw new ArgumentNullException(nameof(wpfTextViewHost)); } if (margin == null) { throw new ArgumentNullException(nameof(margin)); } if (marginName == null) { throw new ArgumentNullException(nameof(marginName)); } if (margin.GetTextViewMargin(marginName) != margin) { throw new ArgumentException(); } return(new GuidObjectsProvider(wpfTextViewHost, margin, marginName, marginContextMenuHandlerProviders)); }
public void Dispose() { if (!disposed) { this.disposed = true; this.editorCommandTarget = null; ((IVsPersistDocData)this.textBuffer).Close(); this.textBuffer = null; this.textViewHost.Close(); this.textViewHost = null; this.codeWindow.Close(); this.codeWindow = null; this.textView.CloseView(); this.textView = null; } }
public void Dispose() { FrameworkElement element = this.Element; element.PreviewLostKeyboardFocus -= new KeyboardFocusChangedEventHandler(this.Editor_LostFocus); element.LostFocus -= new RoutedEventHandler(this.Editor_LostFocus); element.GotFocus -= new RoutedEventHandler(this.Editor_GotFocus); this.textView.Caret.PositionChanged -= new EventHandler <CaretPositionChangedEventArgs>(this.Caret_PositionChanged); this.codeOptionsModel.PropertyChanged -= new PropertyChangedEventHandler(this.CodeOptionsModel_PropertyChanged); this.editorSpecificOptionsModel.PropertyChanged -= new PropertyChangedEventHandler(this.CodeOptionsModel_PropertyChanged); this.textViewHost.Close(); this.textViewHost = (IWpfTextViewHost)null; this.textView = (IWpfTextView)null; if (this.codeEditorOperations == null) { return; } this.codeEditorOperations.Dispose(); this.codeEditorOperations = (CodeEditorOperations)null; }
// ReSharper disable once UnusedParameter.Local public BottomMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer, IServiceProvider serviceProvider) { _textView = wpfTextViewHost.TextView; var properties = _textView.TextBuffer.Properties; properties.TryGetProperty(typeof(ITextDocument), out _document); _compilationIndicator = new CompilationIndicator(Children); _informationTextBlock = new TextBlock { Text = "", Foreground = Brushes.Green, Margin = new Thickness(15, 4, 15, 4) }; Children.Add(_informationTextBlock); _textView.VisualElement.KeyDown += OnKeyDown; _textView.VisualElement.PreviewMouseDown += OnMouseDown; }
public VerticalScrollBarMargin(IScrollMapFactoryService scrollMapFactoryService, IWpfTextViewHost wpfTextViewHost) { if (scrollMapFactoryService == null) { throw new ArgumentNullException(nameof(scrollMapFactoryService)); } if (wpfTextViewHost == null) { throw new ArgumentNullException(nameof(wpfTextViewHost)); } this.wpfTextViewHost = wpfTextViewHost; this.scrollMap = scrollMapFactoryService.Create(wpfTextViewHost.TextView, true); IsVisibleChanged += VerticalScrollBarMargin_IsVisibleChanged; wpfTextViewHost.TextView.Options.OptionChanged += Options_OptionChanged; SetResourceReference(StyleProperty, typeof(ScrollBar)); HorizontalAlignment = HorizontalAlignment.Center; Orientation = System.Windows.Controls.Orientation.Vertical; SmallChange = 1; UpdateVisibility(); }
protected override Control CreateControl() { wpfTextViewHost = Imports.TextEditorFactoryService.CreateTextViewHost(TextView, setFocus: true); var wpfControl = wpfTextViewHost.HostControl; Gtk.Widget widget = new RootWpfWidget(wpfControl) { HeightRequest = 50, WidthRequest = 100 }; TextView.VisualElement.Tag = widget; var xwtWidget = Xwt.Toolkit.CurrentEngine.WrapWidget(widget, Xwt.NativeWidgetSizing.External); xwtWidget.Show(); XwtControl = new XwtControl(xwtWidget); return(XwtControl); }
/// <summary> /// /// </summary> public RegexEditorDialog(IWpfTextViewHost regexEditor) { InitializeComponent(); this.regexEditor = regexEditor; TextViewEventManager textViewEventManager = this.regexEditor.TextView.Properties.GetProperty <TextViewEventManager>(TextViewEventManager.Key); textViewEventManager.IntellisenseSessionStart += new EventHandler(OnIntellisenseSessionStart); textViewEventManager.IntellisenseSessionEnd += new EventHandler(OnIntellisenseSessionEnd); context = new RegexDataContext(); context.RegexRepositoryService = new RegexRepositoryService(); context.SelectedItem = context.RegexRepositoryService.CreateItem("[new]", string.Empty); this.expressionContainer.Children.Add(regexEditor.HostControl); this.DataContext = context; this.regexEditor.TextView.Caret.MoveTo(new SnapshotPoint(this.regexEditor.TextView.TextBuffer.CurrentSnapshot, this.regexEditor.TextView.TextBuffer.CurrentSnapshot.Length)); this.regexEditor.HostControl.Focus(); }
internal static bool?ShowDialog(string regex, IWpfTextViewHost regexEditor, out string result) { RegexEditorDialog editorDialog = new RegexEditorDialog(regexEditor); RegexRepositoryItem selectedRepositoryItem = editorDialog.context.RegexRepositoryService.Items.FirstOrDefault(item => string.Compare(item.Regex, regex, true) == 0); if (selectedRepositoryItem != null) { editorDialog.context.SelectedItem = selectedRepositoryItem; editorDialog.regexRepositoryItemsDataGrid.SelectedItem = selectedRepositoryItem; } else { editorDialog.context.SelectedItem.Regex = regex; } bool?dialogResult = editorDialog.ShowDialog(); result = editorDialog.GetExpressionText(); return(dialogResult); }
private bool TryGetMarginViewModel(out EditorDiffMarginViewModel viewModel) { viewModel = null; IWpfTextViewHost textViewHost = _editorAdaptersFactoryService.GetWpfTextViewHost(TextViewAdapter); if (textViewHost == null) { return(false); } EditorDiffMargin margin = textViewHost.GetTextViewMargin(EditorDiffMargin.MarginNameConst) as EditorDiffMargin; if (margin == null) { return(false); } viewModel = margin.VisualElement.DataContext as EditorDiffMarginViewModel; return(viewModel != null); }
private static IWpfTextViewHost CreateTextViewHost(string contentType) { if (contentType == null) { return(null); } var componentModel = ProjectHelpers.GetComponentModel(); var service = componentModel.GetService <IContentTypeRegistryService>(); var type = service.GetContentType(contentType); var textBufferFactory = componentModel.GetService <ITextBufferFactoryService>(); var textViewFactory = componentModel.GetService <ITextEditorFactoryService>(); var textRoles = contentType == "JavaScript" ? new[] { PredefinedTextViewRoles.Document } : new[] { PredefinedTextViewRoles.Interactive }; ITextBuffer textBuffer = textBufferFactory.CreateTextBuffer(string.Empty, type); ITextViewRoleSet roles = textViewFactory.CreateTextViewRoleSet(textRoles); IWpfTextView textView = textViewFactory.CreateTextView(textBuffer, roles); IWpfTextViewHost host = textViewFactory.CreateTextViewHost(textView, false); return(host); }
public IMouseProcessor GetAssociatedMouseProcessor(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin) { var aggregator = AggregatorFactory.CreateTagAggregator <$safeitemname$Tag>(wpfTextViewHost.TextView); var operations = OperationsFactory.GetEditorOperations(wpfTextViewHost.TextView); string commentString; if (wpfTextViewHost.TextView.TextDataModel.ContentType.IsOfType("basic")) { commentString = "' TODO: "; } else if (wpfTextViewHost.TextView.TextDataModel.ContentType.IsOfType("html")) { commentString = "<!-- TODO: -->"; } else { commentString = "// TODO: "; } return(new GlyphMouseProcessor(commentString, wpfTextViewHost.TextView, margin, operations, aggregator)); }
protected ContainerMargin(string name, Orientation orientation, IWpfTextViewHost textViewHost, IList <Lazy <IWpfTextViewMarginProvider, IWpfTextViewMarginMetadata> > marginProviders) { _marginName = name; _orientation = orientation; this.TextViewHost = textViewHost; _marginProviders = new List <Lazy <IWpfTextViewMarginProvider, IWpfTextViewMarginMetadata> >(); var viewRoles = this.TextViewHost.TextView.Roles; foreach (var marginProvider in marginProviders) { if (String.Compare(marginProvider.Metadata.MarginContainer, _marginName, StringComparison.OrdinalIgnoreCase) == 0) { if (viewRoles.ContainsAny(marginProvider.Metadata.TextViewRoles)) { _marginProviders.Add(marginProvider); } } } }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { IWpfTextView view = textViewHost.TextView; ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document)) { return(null); } ITextUndoHistory history; if (!UndoHistoryRegistry.TryGetHistory(view.TextBuffer, out history)) { Debug.Fail("Unexpected: couldn't get an undo history for the given text buffer"); return(null); } return(new InformationBarMargin(view, document, OperationsFactory.GetEditorOperations(view), history)); }