|
|
|
@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
|
|
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using ICSharpCode.AvalonEdit.Highlighting; |
|
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
|
|
|
|
|
@ -20,8 +21,9 @@ namespace ICSharpCode.XmlEditor
@@ -20,8 +21,9 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
{ |
|
|
|
|
// HACK: disable SharpDevelop's built-in folding
|
|
|
|
|
codeEditorView = editor.GetService(typeof(AvalonEdit.TextEditor)) as AvalonEdit.AddIn.CodeEditorView; |
|
|
|
|
if (codeEditorView != null) |
|
|
|
|
codeEditorView.DisableParseInformationFolding = true; |
|
|
|
|
DisableParseInformationFolding(); |
|
|
|
|
|
|
|
|
|
UpdateHighlightingIfNotXml(); |
|
|
|
|
|
|
|
|
|
foldingManager = new XmlFoldingManager(editor); |
|
|
|
|
foldingManager.UpdateFolds(); |
|
|
|
@ -30,15 +32,54 @@ namespace ICSharpCode.XmlEditor
@@ -30,15 +32,54 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
base.Attach(editor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UpdateHighlightingIfNotXml() |
|
|
|
|
{ |
|
|
|
|
if (codeEditorView != null) { |
|
|
|
|
if (!IsUsingXmlHighlighting()) { |
|
|
|
|
ChangeHighlightingToXml(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool IsUsingXmlHighlighting() |
|
|
|
|
{ |
|
|
|
|
IHighlightingDefinition highlighting = codeEditorView.SyntaxHighlighting; |
|
|
|
|
if (highlighting != null) { |
|
|
|
|
return highlighting.Name == "XML"; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ChangeHighlightingToXml() |
|
|
|
|
{ |
|
|
|
|
codeEditorView.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void Detach() |
|
|
|
|
{ |
|
|
|
|
foldingManager.Stop(); |
|
|
|
|
foldingManager.Dispose(); |
|
|
|
|
|
|
|
|
|
if (codeEditorView != null) |
|
|
|
|
codeEditorView.DisableParseInformationFolding = false; |
|
|
|
|
EnableParseInformationFolding(); |
|
|
|
|
|
|
|
|
|
base.Detach(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DisableParseInformationFolding() |
|
|
|
|
{ |
|
|
|
|
DisableParseInformationFolding(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DisableParseInformationFolding(bool disable) |
|
|
|
|
{ |
|
|
|
|
if (codeEditorView != null) { |
|
|
|
|
codeEditorView.DisableParseInformationFolding = disable; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void EnableParseInformationFolding() |
|
|
|
|
{ |
|
|
|
|
DisableParseInformationFolding(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|