Exemple #1
0
        internal void OnDocumentAttached()
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor == null)
            {
                return;
            }
            editor.TextChanged += OnDocumentChanged;
            //this.parsedDocument = MonoDevelop.Projects.Dom.Parser.ProjectDomService.Parse (Project, FileName, DesktopService.GetMimeTypeForUri (FileName), TextEditor.Text);
            OnDocumentChanged(this, null);

            // If the new document is a text editor, attach the extensions

            ExtensionNodeList extensions = AddinManager.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName))
                {
                    continue;
                }
                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }
                    if (last != null)
                    {
                        last.Next = ext;
                    }
                    last = ext;
                    ext.Initialize(this);
                }
            }
            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
            window.Document = this;

            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).AttachToPathedDocument(GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ());
            }
        }
Exemple #2
0
        void InitializeExtensionChain()
        {
            DetachExtensionChain();
            var editor = GetContent <IExtensibleTextEditor> ();

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;
            var mimetypeChain        = DesktopService.GetMimeTypeInheritanceChainForFile(FileName).ToArray();

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName, mimetypeChain))
                {
                    continue;
                }
                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }
                    if (last != null)
                    {
                        last.Next = ext;
                    }
                    last = ext;
                    ext.Initialize(this);
                }
            }
            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
        }
Exemple #3
0
        internal void OnDocumentAttached()
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor == null)
            {
                return;
            }

            Editor.Document.TextReplaced += (o, a) => {
                if (Editor.Document.IsInAtomicUndo)
                {
                    wasEdited = true;
                }
                else
                {
                    StartReparseThread();
                }
            };

            Editor.Document.BeginUndo += delegate {
                wasEdited = false;
            };

            Editor.Document.EndUndo += delegate {
                if (wasEdited)
                {
                    StartReparseThread();
                }
            };
            Editor.Document.Undone += (o, a) => StartReparseThread();
            Editor.Document.Redone += (o, a) => StartReparseThread();

            // If the new document is a text editor, attach the extensions

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName))
                {
                    continue;
                }
                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }
                    if (last != null)
                    {
                        last.Next = ext;
                    }
                    last = ext;
                    ext.Initialize(this);
                }
            }
            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
            window.Document = this;
            RunWhenLoaded(() => UpdateParseDocument());
            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).AttachToPathedDocument(GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ());
            }
        }
Exemple #4
0
        void InitializeEditor(IExtensibleTextEditor editor)
        {
            Editor.Document.TextReplaced += (o, a) => {
                if (parsedDocument != null)
                {
                    parsedDocument.IsInvalid = true;
                }

                if (Editor.Document.IsInAtomicUndo)
                {
                    wasEdited = true;
                }
                else
                {
                    StartReparseThread();
                }
            };

            Editor.Document.BeginUndo += delegate {
                wasEdited = false;
            };

            Editor.Document.EndUndo += delegate {
                if (wasEdited)
                {
                    StartReparseThread();
                }
            };
            Editor.Document.Undone += (o, a) => StartReparseThread();
            Editor.Document.Redone += (o, a) => StartReparseThread();

            // If the new document is a text editor, attach the extensions

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName))
                {
                    continue;
                }

                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }

                    if (last != null)
                    {
                        last.Next = ext;
                    }

                    last = ext;
                    ext.Initialize(this);
                }
            }

            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
        }