示例#1
0
        public static void SetLanguage(this IInteractiveWindow window, Guid languageServiceGuid, IContentType contentType)
        {
            VsInteractiveWindowEditorFactoryService.GetDispatcher(window).CheckAccess();

            var commandFilter = VsInteractiveWindowEditorFactoryService.GetCommandFilter(window);

            window.Properties[typeof(IContentType)]         = contentType;
            commandFilter.firstLanguageServiceCommandFilter = null;
            var provider = commandFilter._oleCommandTargetProviders.OfContentType(contentType, commandFilter._contentTypeRegistry);

            if (provider != null)
            {
                var targetFilter = commandFilter.firstLanguageServiceCommandFilter ?? commandFilter.EditorServicesCommandFilter;
                var target       = provider.GetCommandTarget(window.TextView, targetFilter);
                if (target != null)
                {
                    commandFilter.firstLanguageServiceCommandFilter = target;
                }
            }

            if (window.CurrentLanguageBuffer != null)
            {
                window.CurrentLanguageBuffer.ChangeContentType(contentType, null);
            }

            VsInteractiveWindowEditorFactoryService.SetEditorOptions(window.TextView.Options, languageServiceGuid);
        }
示例#2
0
        public static IWpfTextViewHost GetTextViewHost(this IInteractiveWindow window)
        {
            var cmdFilter = VsInteractiveWindowEditorFactoryService.GetCommandFilter(window);

            if (cmdFilter != null)
            {
                return(cmdFilter.TextViewHost);
            }
            return(null);
        }