Browse Source

Use XML highlighting for file extensions defined in XMLEditor.addin file.

pull/15/head
mrward 15 years ago
parent
commit
cbe272ce6b
  1. 49
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs
  2. 8
      src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

49
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs

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

8
src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
# SharpDevelop 4.0.0.6374 # SharpDevelop 4.1.0.7289-alpha
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}"
@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libr
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -72,5 +74,9 @@ Global
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.Build.0 = Release|Any CPU {4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.Build.0 = Release|Any CPU
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

Loading…
Cancel
Save