public override void Close() {
            ServiceManager.RemoveService<VsMdEditorDocument>(TextBuffer);
            base.Close();

            _editorInstance?.Dispose();
            _editorInstance = null;
        }
Exemple #2
0
 public VsMdEditorDocument(IEditorInstance editorInstance,
                           IProjectionBufferFactoryService projectionBufferFactoryService,
                           IContentTypeRegistryService contentTypeRegistryService)
     : base(editorInstance.ViewBuffer, projectionBufferFactoryService, contentTypeRegistryService)
 {
     _editorInstance = editorInstance;
     ServiceManager.AddService <VsMdEditorDocument>(this, TextBuffer);
 }
Exemple #3
0
        public override void Close()
        {
            ServiceManager.RemoveService <VsMdEditorDocument>(TextBuffer);
            base.Close();

            _editorInstance?.Dispose();
            _editorInstance = null;
        }
Exemple #4
0
        public override void Close() {
            ServiceManager.RemoveService<VsREditorDocument>(TextBuffer);
            base.Close();

            // Prevent stack overflow
            var instance = _editorInstance;
            _editorInstance = null;
            instance?.Dispose();
        }
Exemple #5
0
 private void InitEditorInstance(ITextBuffer textBuffer)
 {
     if (ServiceManager.GetService <IEditorInstance>(textBuffer) == null)
     {
         ContentTypeImportComposer <IEditorFactory> importComposer = new ContentTypeImportComposer <IEditorFactory>(_shell.CompositionService);
         IEditorFactory  factory        = importComposer.GetImport(textBuffer.ContentType.TypeName);
         IEditorInstance editorInstance = factory.CreateEditorInstance(textBuffer, new RDocumentFactory(_shell));
     }
 }
Exemple #6
0
 public void Start(string map)
 {
     if (editor != null)
     {
         Log.Warning("Editor is already started");
         return;
     }
     editor = Game.GameFactory.CreateEditor(Game, map);
     editor?.Initialize();
 }
Exemple #7
0
        protected override void OnTextBufferDisposing(ITextBuffer textBuffer)
        {
            IEditorInstance editorInstance = ServiceManager.GetService <IEditorInstance>(textBuffer);

            if (editorInstance != null)
            {
                editorInstance.Dispose();
            }
            base.OnTextBufferDisposing(textBuffer);
        }
Exemple #8
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);
        }
Exemple #9
0
        public override void Close()
        {
            ServiceManager.RemoveService <VsREditorDocument>(TextBuffer);
            base.Close();

            // Prevent stack overflow
            var instance = _editorInstance;

            _editorInstance = null;
            instance?.Dispose();
        }
Exemple #10
0
        public void Close()
        {
            if (_wpftextViewHost != null)
            {
                _wpftextViewHost.Close();
                _wpftextViewHost = null;
            }

            if (_editorIntance != null)
            {
                _editorIntance.Dispose();
                _editorIntance = null;
            }
        }
Exemple #11
0
        private void InitEditorInstance(ITextBuffer textBuffer)
        {
            if (ServiceManager.GetService <IEditorInstance>(textBuffer) == null)
            {
                ITextDocument textDocument;

                textBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDocument);
                Debug.Assert(textDocument != null);

                ContentTypeImportComposer <IEditorFactory> importComposer = new ContentTypeImportComposer <IEditorFactory>(VsAppShell.Current.CompositionService);
                IEditorFactory factory = importComposer.GetImport(textBuffer.ContentType.TypeName);

                IEditorInstance editorInstance = factory.CreateEditorInstance(textBuffer, new VsREditorDocumentFactory());
            }
        }
        protected override void OnTextBufferDisposing(ITextBuffer textBuffer)
        {
            IEditorInstance editorInstance = ServiceManager.GetService <IEditorInstance>(textBuffer);

            if (editorInstance != null)
            {
                editorInstance.Dispose();
            }
            else
            {
                IREditorDocument doc = REditorDocument.TryFromTextBuffer(textBuffer);
                if (doc != null)
                {
                    doc.Dispose();
                }
            }

            base.OnTextBufferDisposing(textBuffer);
        }
Exemple #13
0
        public int OnLoadCompleted(int fReload)
        {
            var adapterService = VsAppShell.Current.ExportProvider.GetExport <IVsEditorAdaptersFactoryService>().Value;

            // Set language service ID as early as possible, since it may change content type of the buffer,
            // e.g. in a weird scenario when someone does "Open With X Editor" on an Y file. Calling this
            // will change content type to the one language service specifies instead of the default one for
            // the file extension, and will ensure that correct editor factory is used.
            _textLines.SetLanguageServiceID(ref _languageServiceGuid);
            ITextBuffer diskBuffer = adapterService.GetDocumentBuffer(_textLines);

            Debug.Assert(diskBuffer != null);

            try {
                var importComposer = new ContentTypeImportComposer <IEditorFactory>(VsAppShell.Current.CompositionService);
                var factory        = importComposer.GetImport(diskBuffer.ContentType.TypeName);

                var documentFactoryImportComposer = new ContentTypeImportComposer <IVsEditorDocumentFactory>(VsAppShell.Current.CompositionService);
                var documentFactory = documentFactoryImportComposer.GetImport(diskBuffer.ContentType.TypeName);

                IEditorInstance editorInstance = ServiceManager.GetService <IEditorInstance>(diskBuffer);

                if (factory != null && editorInstance == null)
                {
                    editorInstance = factory.CreateEditorInstance(diskBuffer, documentFactory);
                    adapterService.SetDataBuffer(_textLines, editorInstance.ViewBuffer);
                }
            } finally {
                cp.Unadvise(cookie);
                cookie = 0;

                _textLines = null;
                _hierarchy = null;

                _trackers.Remove(this);
                _trackers = null;
            }

            return(VSConstants.S_OK);
        }
Exemple #14
0
 public IEditorDocument CreateDocument(IEditorInstance editorInstance)
 {
     return(new MdEditorDocument(editorInstance.DiskBuffer, _projectionBufferFactoryService, _contentTypeRegistryService, _shell));
 }
Exemple #15
0
        public void Close() {
            if (_wpftextViewHost != null) {
                _wpftextViewHost.Close();
                _wpftextViewHost = null;
            }

            if (_editorIntance != null) {
                _editorIntance.Dispose();
                _editorIntance = null;
            }
        }
Exemple #16
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);
        }
 public IEditorDocument CreateDocument(IEditorInstance editorInstance)
 {
     return(new VsREditorDocument(editorInstance, _shell));
 }
 public IEditorDocument CreateDocument(IEditorInstance editorInstance) {
     return new VsREditorDocument(editorInstance, _shell);
 }
Exemple #19
0
 public IEditorDocument CreateDocument(IEditorInstance editorInstance)
 {
     return(new REditorDocument(editorInstance.DiskBuffer));
 }
Exemple #20
0
        public VsREditorDocument(IEditorInstance editorInstance, ICoreShell shell)
            : base(editorInstance.ViewBuffer, shell) {

            _editorInstance = editorInstance;
            ServiceManager.AddService<VsREditorDocument>(this, TextBuffer, shell);
        }
 public IEditorDocument CreateDocument(IEditorInstance editorInstance) {
     return new MdEditorDocument(editorInstance.ViewBuffer);
 }
        public VsMdEditorDocument(IEditorInstance editorInstance)
            : base(editorInstance.ViewBuffer) {

            _editorInstance = editorInstance;
            ServiceManager.AddService<VsMdEditorDocument>(this, TextBuffer);
        }
Exemple #23
0
 public IEditorDocument CreateDocument(IEditorInstance editorInstance) {
     return new REditorDocument(editorInstance.DiskBuffer, _shell);
 }
 public IEditorDocument CreateDocument(IEditorInstance editorInstance) {
     return new MdEditorDocument(editorInstance.DiskBuffer, _projectionBufferFactoryService, _contentTypeRegistryService, _shell);
 }
 public IEditorDocument CreateDocument(IEditorInstance editorInstance)
 {
     return(new VsMdEditorDocument(editorInstance));
 }
Exemple #26
0
 public VsREditorDocument(IEditorInstance editorInstance)
     : base(editorInstance.ViewBuffer)
 {
     _editorInstance = editorInstance;
     ServiceManager.AddService <VsREditorDocument>(this, TextBuffer);
 }
Exemple #27
0
 public VsREditorDocument(IEditorInstance editorInstance, ICoreShell shell)
     : base(editorInstance.ViewBuffer, shell)
 {
     _editorInstance = editorInstance;
     ServiceManager.AddService <VsREditorDocument>(this, TextBuffer, shell);
 }
Exemple #28
0
        public VsMdEditorDocument(IEditorInstance editorInstance, IProjectionBufferFactoryService projectionBufferFactoryService, IContentTypeRegistryService contentTypeRegistryService, ICoreShell shell)
            : base(editorInstance.ViewBuffer, projectionBufferFactoryService, contentTypeRegistryService, shell) {

            _editorInstance = editorInstance;
            ServiceManager.AddService<VsMdEditorDocument>(this, TextBuffer, shell);
        }
Exemple #29
0
 public IEditorDocument CreateDocument(IEditorInstance editorInstance)
 {
     return(new MdEditorDocument(editorInstance.ViewBuffer));
 }