Ejemplo n.º 1
0
        private IWpfTextViewHost CreateTextViewHost()
        {
            // Create buffer

            var contentType = ContentTypeRegistryService.GetContentType("NQuery");
            var textBuffer  = TextBufferFactoryService.CreateTextBuffer(contentType);

            var textView     = TextEditorFactoryService.CreateTextView(textBuffer);
            var textViewHost = TextEditorFactoryService.CreateTextViewHost(textView, false);

            // Set the appearance of collapsed text
            textViewHost.TextView.VisualElement.Resources["CollapsedTextForeground"] = new SolidColorBrush(Color.FromRgb(0xA5, 0xA5, 0xA5));
            textViewHost.HostControl.Resources["outlining.verticalrule.foreground"]  = new SolidColorBrush(Color.FromRgb(0xA5, 0xA5, 0xA5));

            // Set the background color of glyph margin
            const string indicatorMargin    = "Indicator Margin";
            var          backgroundColor    = Color.FromRgb(0xF0, 0xF0, 0xF0);
            var          editorFormatMap    = EditorFormatMapService.GetEditorFormatMap(textViewHost.TextView);
            var          resourceDictionary = editorFormatMap.GetProperties(indicatorMargin);

            resourceDictionary["BackgroundColor"] = backgroundColor;
            resourceDictionary["Background"]      = new SolidColorBrush(backgroundColor);
            editorFormatMap.SetProperties(indicatorMargin, resourceDictionary);

            return(textViewHost);
        }
Ejemplo n.º 2
0
        public void HostWontCreateVimBuffer()
        {
            var textView        = CreateTextView();
            var wpfTextViewHost = TextEditorFactoryService.CreateTextViewHost(textView, setFocus: false);

            IVimBuffer vimBuffer = null;

            _vim.Setup(x => x.TryGetOrCreateVimBufferForHost(textView, out vimBuffer)).Returns(false);
            Assert.Null(_commandMarginProvider.CreateMargin(wpfTextViewHost, _factory.Create <IWpfTextViewMargin>().Object));
        }
Ejemplo n.º 3
0
        private void CreateTextViewHost(string text, string filePath)
        {
            if (text == null)
            {
                text = string.Empty;
            }

            var diskBuffer = TextBufferFactoryService.CreateTextBuffer(text, ContentType);

            _editorIntance = EditorInstanceFactory.CreateEditorInstance(diskBuffer, _compositionService);

            ITextDataModel textDataModel;

            if (_editorIntance != null)
            {
                textDataModel = new TextDataModel(diskBuffer, _editorIntance.ViewBuffer);
            }
            else
            {
                textDataModel = new TextDataModel(diskBuffer, diskBuffer);
            }

            var textBuffer = textDataModel.DocumentBuffer;

            TextDocument = TextDocumentFactoryService.CreateTextDocument(textBuffer, filePath);

            SetGlobalEditorOptions();

            var textView = TextEditorFactoryService.CreateTextView(textDataModel,
                                                                   new DefaultTextViewRoleSet(),
                                                                   GlobalOptions);

            _wpftextViewHost = TextEditorFactoryService.CreateTextViewHost(textView, true);

            ApplyDefaultSettings();

            _contentControl.Content = _wpftextViewHost.HostControl;

            var baseController = new BaseController();

            BaseController = baseController;

            if (_editorIntance != null)
            {
                CommandTarget = _editorIntance.GetCommandTarget(textView);
                var controller = CommandTarget as Microsoft.Languages.Editor.Controller.Controller;
                controller.ChainedController = baseController;
            }
            else
            {
                CommandTarget = baseController;
            }

            baseController.Initialize(textView, EditorOperations, UndoManager, _coreShell);
        }
Ejemplo n.º 4
0
        protected void UpdateLayout(ITextView textView, int? tabStop = null)
        {
            if (tabStop.HasValue)
            {
                textView.Options.SetOptionValue(DefaultOptions.TabSizeOptionId, tabStop.Value);
            }

            // Need to force a layout here to get it to respect the tab settings
            var host = TextEditorFactoryService.CreateTextViewHost((IWpfTextView)textView, setFocus: false);
            host.HostControl.UpdateLayout();
        }
Ejemplo n.º 5
0
        protected WpfTextViewDisplay CreateTextViewDisplay(IWpfTextView textView, bool setFocus = true, bool show = true)
        {
            var host    = TextEditorFactoryService.CreateTextViewHost(textView, setFocus);
            var display = new WpfTextViewDisplay(host);

            if (show)
            {
                display.Show();
            }

            return(display);
        }