Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/AmbientColor.cs188
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ChunkStyle.cs186
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorDescriptionAttribute.cs47
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs1030
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColoredSegment.cs59
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/IStreamProvider.cs97
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SemanticHighlighting.cs76
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs216
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs64
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateExtensionNodeLoader.cs55
10 files changed, 2018 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/AmbientColor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/AmbientColor.cs
new file mode 100644
index 0000000000..b65a66a3de
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/AmbientColor.cs
@@ -0,0 +1,188 @@
+//
+// AmbientColor.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml.Linq;
+using System.Xml.XPath;
+using System.Reflection;
+using MonoDevelop.Components;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public sealed class AmbientColor
+ {
+ public string Name { get; private set; }
+ public readonly List<Tuple<string, HslColor>> Colors = new List<Tuple<string, HslColor>> ();
+
+ public HslColor Color {
+ get {
+ return GetColor ("color");
+ }
+ set {
+ for (int i = 0; i < Colors.Count; i++) {
+ var t = Colors [i];
+ if (t.Item1 == "color") {
+ Colors [i] = Tuple.Create ("color", value);
+ return;
+ }
+ }
+ Colors.Add (Tuple.Create ("color", value));
+ }
+ }
+
+ public HslColor SecondColor {
+ get {
+ return GetColor ("secondcolor");
+ }
+ set {
+ for (int i = 0; i < Colors.Count; i++) {
+ var t = Colors [i];
+ if (t.Item1 == "secondcolor") {
+ Colors [i] = Tuple.Create ("secondcolor", value);
+ return;
+ }
+ }
+ Colors.Add (Tuple.Create ("secondcolor", value));
+ }
+ }
+
+ public bool HasSecondColor {
+ get {
+ return Colors.Any (c => c.Item1 == "secondcolor");
+ }
+ }
+
+ public HslColor BorderColor {
+ get {
+ return GetColor ("bordercolor");
+ }
+ set {
+ for (int i = 0; i < Colors.Count; i++) {
+ var t = Colors [i];
+ if (t.Item1 == "bordercolor") {
+ Colors [i] = Tuple.Create ("bordercolor", value);
+ return;
+ }
+ }
+ Colors.Add (Tuple.Create ("bordercolor", value));
+ }
+ }
+
+ public bool HasBorderColor {
+ get {
+ return Colors.Any (c => c.Item1 == "bordercolor");
+ }
+ }
+
+ public HslColor GetColor (string name)
+ {
+ foreach (var color in Colors) {
+ if (color.Item1 == name)
+ return color.Item2;
+ }
+
+ return new HslColor (0, 0, 0);
+ }
+
+ public static AmbientColor Create (XElement element, Dictionary<string, HslColor> palette)
+ {
+ var result = new AmbientColor ();
+ foreach (var node in element.DescendantNodes ()) {
+ if (node.NodeType == System.Xml.XmlNodeType.Element) {
+ var el = (XElement)node;
+ switch (el.Name.LocalName) {
+ case "name":
+ result.Name = el.Value;
+ break;
+ default:
+ result.Colors.Add (Tuple.Create (el.Name.LocalName, ColorScheme.ParsePaletteColor (palette, el.Value)));
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj == null)
+ return false;
+ if (ReferenceEquals (this, obj))
+ return true;
+ if (obj.GetType () != typeof(AmbientColor))
+ return false;
+ AmbientColor other = (AmbientColor)obj;
+ return Colors.Equals (other.Colors) && Name == other.Name;
+ }
+
+ public override int GetHashCode ()
+ {
+ unchecked {
+ return (Colors != null ? Colors.GetHashCode () : 0) ^ (Name != null ? Name.GetHashCode () : 0);
+ }
+ }
+
+
+ public static AmbientColor Import (Dictionary<string, ColorScheme.VSSettingColor> colors, string vsSetting)
+ {
+ var result = new AmbientColor ();
+ var attrs = vsSetting.Split (',');
+ foreach (var attr in attrs) {
+ var info = attr.Split ('=');
+ if (info.Length != 2)
+ continue;
+ var idx = info [1].LastIndexOf ('/');
+ var source = info [1].Substring (0, idx);
+ var dest = info [1].Substring (idx + 1);
+
+ ColorScheme.VSSettingColor color;
+ if (!colors.TryGetValue (source, out color))
+ continue;
+ result.Name = color.Name;
+ string colorString;
+ switch (dest) {
+ case "Foreground":
+ colorString = color.Foreground;
+ break;
+ case "Background":
+ colorString = color.Background;
+ break;
+ default:
+ throw new InvalidDataException ("Invalid attribute source: " + dest);
+ }
+ result.Colors.Add (Tuple.Create (info [0], ColorScheme.ImportVsColor (colorString)));
+ }
+ if (result.Colors.Count == 0)
+ return null;
+ return result;
+ }
+ }
+
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ChunkStyle.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ChunkStyle.cs
new file mode 100644
index 0000000000..bed02ad91d
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ChunkStyle.cs
@@ -0,0 +1,186 @@
+//
+// ChunkStyle.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Xml.Linq;
+using MonoDevelop.Components;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public sealed class ChunkStyle
+ {
+ public string Name { get; set; }
+ public HslColor Foreground { get; set; }
+ public HslColor Background { get; set; }
+
+ public bool TransparentForeground {
+ get {
+ return Foreground.Alpha == 0.0;
+
+ }
+ }
+ public bool TransparentBackground {
+ get {
+ return Background.Alpha == 0.0;
+ }
+ }
+
+ public Xwt.Drawing.FontWeight FontWeight { get; set; }
+
+ public Xwt.Drawing.FontStyle FontStyle { get; set; }
+
+ [Obsolete("Will be removed - use FontWeight")]
+ public bool Bold {
+ get {
+ return FontWeight == Xwt.Drawing.FontWeight.Bold;
+ }
+ }
+
+ [Obsolete("Will be removed - use FontStyle")]
+ public bool Italic {
+ get {
+ return FontStyle == Xwt.Drawing.FontStyle.Italic;
+ }
+ }
+
+ public bool Underline {
+ get; set;
+ }
+
+ public ChunkStyle ()
+ {
+ Foreground = Background = new HslColor (0, 0, 0, 0);
+ FontWeight = Xwt.Drawing.FontWeight.Normal;
+ FontStyle = Xwt.Drawing.FontStyle.Normal;
+ }
+
+ public ChunkStyle (ChunkStyle baseStyle)
+ {
+ this.Name = baseStyle.Name;
+ this.Foreground = baseStyle.Foreground;
+ this.Background = baseStyle.Background;
+ this.FontWeight = baseStyle.FontWeight;
+ this.FontStyle = baseStyle.FontStyle;
+ this.Underline = baseStyle.Underline;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj == null)
+ return false;
+ if (ReferenceEquals (this, obj))
+ return true;
+ if (obj.GetType () != typeof(ChunkStyle))
+ return false;
+ ChunkStyle other = (ChunkStyle)obj;
+ return Name == other.Name && Foreground.Equals (other.Foreground) && Background.Equals (other.Background) && FontWeight == other.FontWeight && FontStyle == other.FontStyle;
+ }
+
+ public override int GetHashCode ()
+ {
+ unchecked {
+ return (Name != null ? Name.GetHashCode () : 0) ^ Foreground.GetHashCode () ^ Background.GetHashCode () ^ FontWeight.GetHashCode () ^ FontStyle.GetHashCode ();
+ }
+ }
+
+ public static ChunkStyle Create (XElement element, Dictionary<string, HslColor> palette)
+ {
+ var result = new ChunkStyle ();
+
+ foreach (var node in element.DescendantNodes ()) {
+ if (node.NodeType == System.Xml.XmlNodeType.Element) {
+ var el = (XElement)node;
+ switch (el.Name.LocalName) {
+ case "name":
+ result.Name = el.Value;
+ break;
+ case "fore":
+ result.Foreground = ColorScheme.ParsePaletteColor (palette, el.Value);
+ break;
+ case "back":
+ result.Background = ColorScheme.ParsePaletteColor (palette, el.Value);
+ break;
+ case "weight":
+ Xwt.Drawing.FontWeight weight;
+ if (!Enum.TryParse<Xwt.Drawing.FontWeight> (el.Value, true, out weight))
+ throw new InvalidDataException (el.Value + " is no valid text weight values are: " + string.Join (",", Enum.GetNames (typeof(Xwt.Drawing.FontWeight))) );
+ result.FontWeight = weight;
+ break;
+ case "style":
+ Xwt.Drawing.FontStyle style;
+ if (!Enum.TryParse<Xwt.Drawing.FontStyle> (el.Value, true, out style))
+ throw new InvalidDataException (el.Value + " is no valid text weight values are: " + string.Join (",", Enum.GetNames (typeof(Xwt.Drawing.FontStyle))) );
+ result.FontStyle = style;
+ break;
+ default:
+ throw new InvalidDataException ("Invalid element in text color:" + el.Name);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public Gdk.GC CreateBgGC (Gdk.Drawable drawable)
+ {
+ return new Gdk.GC (drawable) { RgbBgColor = (HslColor)Foreground, RgbFgColor = (HslColor)Background };
+ }
+
+ public Gdk.GC CreateFgGC (Gdk.Drawable drawable)
+ {
+ return new Gdk.GC (drawable) { RgbBgColor = (HslColor)Background, RgbFgColor = (HslColor)Foreground };
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("[ChunkStyle: Name={0}, CairoColor={1}, CairoBackgroundColor={2}, FontWeight={3}, FontStyle={4}]", Name, Foreground, Background, FontWeight, FontStyle);
+ }
+
+ public static ChunkStyle Import (string name, ColorScheme.VSSettingColor vsc)
+ {
+ var textColor = new ChunkStyle ();
+ textColor.Name = name;
+ if (!string.IsNullOrEmpty (vsc.Foreground) && vsc.Foreground != "0x02000000") {
+ textColor.Foreground = ColorScheme.ImportVsColor (vsc.Foreground);
+ if (textColor.TransparentForeground && name != "Selected Text" && name != "Selected Text(Inactive)")
+ textColor.Foreground = new HslColor (0, 0, 0);
+ }
+ if (!string.IsNullOrEmpty (vsc.Background) && vsc.Background != "0x02000000")
+ textColor.Background = ColorScheme.ImportVsColor (vsc.Background);
+ if (vsc.BoldFont)
+ textColor.FontWeight = Xwt.Drawing.FontWeight.Bold;
+ return textColor;
+ }
+
+ public ChunkStyle Clone ()
+ {
+ return (ChunkStyle)this.MemberwiseClone ();
+ }
+ }
+
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorDescriptionAttribute.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorDescriptionAttribute.cs
new file mode 100644
index 0000000000..d69e2013c9
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorDescriptionAttribute.cs
@@ -0,0 +1,47 @@
+//
+// ColorDescriptionAttribute.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public sealed class ColorDescriptionAttribute : Attribute
+ {
+ public string Name { get; private set; }
+ public string Description { get; set; }
+ public string VSSetting { get; set; }
+
+ public ColorDescriptionAttribute (string name)
+ {
+ Name = name;
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("[ColorDescriptionAttribute: Name={0}, Description={1}, VSSetting={2}]", Name, Description, VSSetting);
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs
new file mode 100644
index 0000000000..6714d9abe9
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs
@@ -0,0 +1,1030 @@
+//
+// ColorScheme.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml.Linq;
+using System.Xml.XPath;
+using System.Reflection;
+using System.Text;
+using System.Xml;
+using MonoDevelop.Components;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public sealed class ColorScheme
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public string Originator { get; set; }
+ public string BaseScheme { get; set; }
+ public string FileName { get; set; }
+
+ #region Ambient Colors
+
+ [ColorDescription("Background(Read Only)",VSSetting="color=Plain Text/Background")]
+ public AmbientColor BackgroundReadOnly { get; private set; }
+
+ [ColorDescription("Search result background")]
+ public AmbientColor SearchResult { get; private set; }
+
+ [ColorDescription("Search result background (highlighted)")]
+ public AmbientColor SearchResultMain { get; private set; }
+
+ [ColorDescription("Fold Square", VSSetting="color=outlining.verticalrule/Foreground")]
+ public AmbientColor FoldLineColor { get; private set; }
+
+ [ColorDescription("Fold Cross", VSSetting="color=outlining.square/Foreground,secondcolor=outlining.square/Background")]
+ public AmbientColor FoldCross { get; private set; }
+
+ [ColorDescription("Indentation Guide")] // not defined
+ public AmbientColor IndentationGuide { get; private set; }
+
+ [ColorDescription("Indicator Margin", VSSetting="color=Indicator Margin/Background")]
+ public AmbientColor IndicatorMargin { get; private set; }
+
+ [ColorDescription("Indicator Margin(Separator)", VSSetting="color=Indicator Margin/Background")]
+ public AmbientColor IndicatorMarginSeparator { get; private set; }
+
+ [ColorDescription("Tooltip Border")]
+ public AmbientColor TooltipBorder { get; private set; }
+
+ [ColorDescription("Tooltip Pager Top")]
+ public AmbientColor TooltipPagerTop { get; private set; }
+
+ [ColorDescription("Tooltip Pager Bottom")]
+ public AmbientColor TooltipPagerBottom { get; private set; }
+
+ [ColorDescription("Tooltip Pager Triangle")]
+ public AmbientColor TooltipPagerTriangle { get; private set; }
+
+ [ColorDescription("Tooltip Pager Text")]
+ public AmbientColor TooltipPagerText { get; private set; }
+
+ [ColorDescription("Notification Border")]
+ public AmbientColor NotificationBorder { get; private set; }
+
+ [ColorDescription("Bookmarks")]
+ public AmbientColor Bookmarks { get; private set; }
+
+ [ColorDescription("Underline(Error)", VSSetting="color=Syntax Error/Foreground")]
+ public AmbientColor UnderlineError { get; private set; }
+
+ [ColorDescription("Underline(Warning)", VSSetting="color=Warning/Foreground")]
+ public AmbientColor UnderlineWarning { get; private set; }
+
+ [ColorDescription("Underline(Suggestion)", VSSetting="color=Other Error/Foreground")]
+ public AmbientColor UnderlineSuggestion { get; private set; }
+
+ [ColorDescription("Underline(Hint)", VSSetting="color=Other Error/Foreground")]
+ public AmbientColor UnderlineHint { get; private set; }
+
+ [ColorDescription("Quick Diff(Dirty)")]
+ public AmbientColor QuickDiffDirty { get; private set; }
+
+ [ColorDescription("Quick Diff(Changed)")]
+ public AmbientColor QuickDiffChanged { get; private set; }
+
+ [ColorDescription("Brace Matching(Rectangle)", VSSetting="color=Brace Matching (Rectangle)/Background,secondcolor=Brace Matching (Rectangle)/Foreground")]
+ public AmbientColor BraceMatchingRectangle { get; private set; }
+
+ [ColorDescription("Usages(Rectangle)", VSSetting="color=MarkerFormatDefinition/HighlightedReference/Background,secondcolor=MarkerFormatDefinition/HighlightedReference/Background,bordercolor=MarkerFormatDefinition/HighlightedReference/Background")]
+ public AmbientColor UsagesRectangle { get; private set; }
+
+ [ColorDescription("Changing usages(Rectangle)", VSSetting="color=MarkerFormatDefinition/HighlightedReference/Background,secondcolor=MarkerFormatDefinition/HighlightedReference/Background,bordercolor=MarkerFormatDefinition/HighlightedReference/Background")]
+ public AmbientColor ChangingUsagesRectangle { get; private set; }
+
+ [ColorDescription("Breakpoint Marker", VSSetting = "color=Breakpoint (Enabled)/Background")]
+ public AmbientColor BreakpointMarker { get; private set; }
+
+ [ColorDescription("Breakpoint Marker(Invalid)", VSSetting = "color=Breakpoint (Disabled)/Background")]
+ public AmbientColor BreakpointMarkerInvalid { get; private set; }
+
+ [ColorDescription("Breakpoint Marker(Disabled)")]
+ public AmbientColor BreakpointMarkerDisabled { get; private set; }
+
+ [ColorDescription("Debugger Current Line Marker", VSSetting = "color=Current Statement/Background")]
+ public AmbientColor DebuggerCurrentLineMarker { get; private set; }
+
+ [ColorDescription("Debugger Stack Line Marker")]
+ public AmbientColor DebuggerStackLineMarker { get; private set; }
+
+ [ColorDescription("Primary Link", VSSetting = "color=Refactoring Dependent Field/Background" )]
+ public AmbientColor PrimaryTemplate { get; private set; }
+
+ [ColorDescription("Primary Link(Highlighted)", VSSetting = "color=Refactoring Current Field/Background")]
+ public AmbientColor PrimaryTemplateHighlighted { get; private set; }
+
+ [ColorDescription("Secondary Link")] // not defined
+ public AmbientColor SecondaryTemplate { get; private set; }
+
+ [ColorDescription("Secondary Link(Highlighted)")] // not defined
+ public AmbientColor SecondaryTemplateHighlighted { get; private set; }
+
+ [ColorDescription("Current Line Marker", VSSetting = "color=CurrentLineActiveFormat/Background,secondcolor=CurrentLineActiveFormat/Foreground")]
+ public AmbientColor LineMarker { get; private set; }
+
+ [ColorDescription("Current Line Marker(Inactive)", VSSetting = "color=CurrentLineInactiveFormat/Background,secondcolor=CurrentLineInactiveFormat/Foreground")]
+ public AmbientColor LineMarkerInactive { get; private set; }
+
+ [ColorDescription("Column Ruler")] // not defined
+ public AmbientColor Ruler { get; private set; }
+
+ [ColorDescription("Completion Matching Substring")]
+ public AmbientColor CompletionHighlight { get; private set; }
+
+ [ColorDescription("Completion Border")]
+ public AmbientColor CompletionBorder { get; private set; }
+
+ [ColorDescription("Completion Border(Inactive)")]
+ public AmbientColor CompletionInactiveBorder { get; private set; }
+
+ [ColorDescription("Message Bubble Error Marker")]
+ public AmbientColor MessageBubbleErrorMarker { get; private set; }
+
+ [ColorDescription("Message Bubble Error Tag")]
+ public AmbientColor MessageBubbleErrorTag { get; private set; }
+
+ [ColorDescription("Message Bubble Error Tooltip")]
+ public AmbientColor MessageBubbleErrorTooltip { get; private set; }
+
+ [ColorDescription("Message Bubble Error Line")]
+ public AmbientColor MessageBubbleErrorLine { get; private set; }
+
+ [ColorDescription("Message Bubble Error Counter")]
+ public AmbientColor MessageBubbleErrorCounter { get; private set; }
+
+ [ColorDescription("Message Bubble Error IconMargin")]
+ public AmbientColor MessageBubbleErrorIconMargin { get; private set; }
+
+ [ColorDescription("Message Bubble Warning Marker")]
+ public AmbientColor MessageBubbleWarningMarker { get; private set; }
+
+ [ColorDescription("Message Bubble Warning Tag")]
+ public AmbientColor MessageBubbleWarningTag { get; private set; }
+
+ [ColorDescription("Message Bubble Warning Tooltip")]
+ public AmbientColor MessageBubbleWarningTooltip { get; private set; }
+
+ [ColorDescription("Message Bubble Warning Line")]
+ public AmbientColor MessageBubbleWarningLine { get; private set; }
+
+ [ColorDescription("Message Bubble Warning Counter")]
+ public AmbientColor MessageBubbleWarningCounter { get; private set; }
+
+ [ColorDescription("Message Bubble Warning IconMargin")]
+ public AmbientColor MessageBubbleWarningIconMargin { get; private set; }
+
+ #endregion
+
+ #region Text Colors
+
+ public const string PlainTextKey = "Plain Text";
+
+ [ColorDescription(PlainTextKey, VSSetting = "Plain Text")]
+ public ChunkStyle PlainText { get; private set; }
+
+ public const string SelectedTextKey = "Selected Text";
+ [ColorDescription(SelectedTextKey, VSSetting = "Selected Text")]
+ public ChunkStyle SelectedText { get; private set; }
+
+ public const string SelectedInactiveTextKey = "Selected Text(Inactive)";
+ [ColorDescription(SelectedInactiveTextKey, VSSetting = "Inactive Selected Text")]
+ public ChunkStyle SelectedInactiveText { get; private set; }
+
+ public const string CollapsedTextKey = "Collapsed Text";
+ [ColorDescription(CollapsedTextKey, VSSetting = "Collapsible Text")]
+ public ChunkStyle CollapsedText { get; private set; }
+
+ public const string LineNumbersKey = "Line Numbers";
+ [ColorDescription(LineNumbersKey, VSSetting = "Line Numbers")]
+ public ChunkStyle LineNumbers { get; private set; }
+
+ public const string PunctuationKey = "Punctuation";
+ [ColorDescription(PunctuationKey, VSSetting = "Operator")]
+ public ChunkStyle Punctuation { get; private set; }
+
+ public const string PunctuationForBracketsKey = "Punctuation(Brackets)";
+ [ColorDescription(PunctuationForBracketsKey, VSSetting = "Plain Text")]
+ public ChunkStyle PunctuationForBrackets { get; private set; }
+
+ public const string CommentsSingleLineKey = "Comment(Line)";
+ [ColorDescription(CommentsSingleLineKey, VSSetting = "Comment")]
+ public ChunkStyle CommentsSingleLine { get; private set; }
+
+ public const string CommentsBlockKey = "Comment(Block)";
+ [ColorDescription(CommentsBlockKey, VSSetting = "Comment")]
+ public ChunkStyle CommentsBlock { get; private set; }
+
+ public const string CommentsForDocumentationKey = "Comment(Doc)";
+ [ColorDescription(CommentsForDocumentationKey, VSSetting = "XML Doc Comment")]
+ public ChunkStyle CommentsForDocumentation { get; private set; }
+
+ public const string CommentsForDocumentationTagsKey = "Comment(DocTag)";
+ [ColorDescription(CommentsForDocumentationTagsKey, VSSetting = "XML Doc Tag")]
+ public ChunkStyle CommentsForDocumentationTags { get; private set; }
+
+ public const string CommentTagsKey = "Comment Tag";
+ [ColorDescription(CommentTagsKey, VSSetting = "Comment")]
+ public ChunkStyle CommentTags { get; private set; }
+
+ public const string ExcludedCodeKey = "Excluded Code";
+ [ColorDescription(ExcludedCodeKey, VSSetting = "Excluded Code")]
+ public ChunkStyle ExcludedCode { get; private set; }
+
+ public const string StringKey = "String";
+ [ColorDescription(StringKey, VSSetting = "String")]
+ public ChunkStyle String { get; private set; }
+
+ public const string StringEscapeSequenceKey = "String(Escape)";
+ [ColorDescription(StringEscapeSequenceKey, VSSetting = "String")]
+ public ChunkStyle StringEscapeSequence { get; private set; }
+
+ public const string StringVerbatimKey = "String(C# @ Verbatim)";
+ [ColorDescription(StringVerbatimKey, VSSetting = "String(C# @ Verbatim)")]
+ public ChunkStyle StringVerbatim { get; private set; }
+
+ public const string NumberKey = "Number";
+ [ColorDescription(NumberKey, VSSetting = "Number")]
+ public ChunkStyle Number { get; private set; }
+
+ public const string PreprocessorKey = "Preprocessor";
+ [ColorDescription(PreprocessorKey, VSSetting = "Preprocessor Keyword")]
+ public ChunkStyle Preprocessor { get; private set; }
+
+ public const string PreprocessorRegionNameKey = "Preprocessor(Region Name)";
+ [ColorDescription(PreprocessorRegionNameKey, VSSetting = "Plain Text")]
+ public ChunkStyle PreprocessorRegionName { get; private set; }
+
+ public const string XmlTextKey = "Xml Text";
+ [ColorDescription(XmlTextKey, VSSetting = "XML Text")]
+ public ChunkStyle XmlText { get; private set; }
+
+ public const string XmlDelimiterKey = "Xml Delimiter";
+ [ColorDescription(XmlDelimiterKey, VSSetting = "XML Delimiter")]
+ public ChunkStyle XmlDelimiter { get; private set; }
+
+ public const string XmlNameKey = "Xml Name";
+ [ColorDescription(XmlNameKey, VSSetting ="XML Name")]
+ public ChunkStyle XmlName { get; private set; }
+
+ public const string XmlAttributeKey = "Xml Attribute";
+ [ColorDescription(XmlAttributeKey, VSSetting = "XML Attribute")]
+ public ChunkStyle XmlAttribute { get; private set; }
+
+ public const string XmlAttributeQuotesKey = "Xml Attribute Quotes";
+ [ColorDescription(XmlAttributeQuotesKey, VSSetting = "XML Attribute Quotes")]
+ public ChunkStyle XmlAttributeQuotes { get; private set; }
+
+ public const string XmlAttributeValueKey = "Xml Attribute Value";
+ [ColorDescription(XmlAttributeValueKey, VSSetting = "XML Attribute Value")]
+ public ChunkStyle XmlAttributeValue { get; private set; }
+
+ public const string XmlCommentKey = "Xml Comment";
+ [ColorDescription(XmlCommentKey, VSSetting = "XML Comment")]
+ public ChunkStyle XmlComment { get; private set; }
+
+ public const string XmlCDataSectionKey = "Xml CData Section";
+ [ColorDescription(XmlCDataSectionKey, VSSetting = "XML CData Section")]
+ public ChunkStyle XmlCDataSection { get; private set; }
+
+ public const string TooltipTextKey = "Tooltip Text";
+ [ColorDescription(TooltipTextKey)] // not defined in vs.net
+ public ChunkStyle TooltipText { get; private set; }
+
+ public const string NotificationTextKey = "Notification Text";
+ [ColorDescription(NotificationTextKey)] // not defined in vs.net
+ public ChunkStyle NotificationText { get; private set; }
+
+ public const string CompletionTextKey = "Completion Text";
+ [ColorDescription(CompletionTextKey)] //not defined in vs.net
+ public ChunkStyle CompletionText { get; private set; }
+
+ public const string CompletionSelectedTextKey = "Completion Selected Text";
+ [ColorDescription(CompletionSelectedTextKey)] //not defined in vs.net
+ public ChunkStyle CompletionSelectedText { get; private set; }
+
+ public const string CompletionSelectedInactiveTextKey = "Completion Selected Text(Inactive)";
+ [ColorDescription(CompletionSelectedInactiveTextKey)] //not defined in vs.net
+ public ChunkStyle CompletionSelectedInactiveText { get; private set; }
+
+ public const string KeywordAccessorsKey = "Keyword(Access)";
+ [ColorDescription(KeywordAccessorsKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordAccessors { get; private set; }
+
+ public const string KeywordTypesKey = "Keyword(Type)";
+ [ColorDescription(KeywordTypesKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordTypes { get; private set; }
+
+ public const string KeywordOperatorsKey = "Keyword(Operator)";
+ [ColorDescription(KeywordOperatorsKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordOperators { get; private set; }
+
+ public const string KeywordSelectionKey = "Keyword(Selection)";
+ [ColorDescription(KeywordSelectionKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordSelection { get; private set; }
+
+ public const string KeywordIterationKey = "Keyword(Iteration)";
+ [ColorDescription(KeywordIterationKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordIteration { get; private set; }
+
+ public const string KeywordJumpKey = "Keyword(Jump)";
+ [ColorDescription(KeywordJumpKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordJump { get; private set; }
+
+ public const string KeywordContextKey = "Keyword(Context)";
+ [ColorDescription(KeywordContextKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordContext { get; private set; }
+
+ public const string KeywordExceptionKey = "Keyword(Exception)";
+ [ColorDescription(KeywordExceptionKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordException { get; private set; }
+
+ public const string KeywordModifiersKey = "Keyword(Modifiers)";
+ [ColorDescription(KeywordModifiersKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordModifiers { get; private set; }
+
+ public const string KeywordConstantsKey = "Keyword(Constants)";
+ [ColorDescription(KeywordConstantsKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordConstants { get; private set; }
+
+ public const string KeywordVoidKey = "Keyword(Void)";
+ [ColorDescription(KeywordVoidKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordVoid { get; private set; }
+
+ public const string KeywordNamespaceKey = "Keyword(Namespace)";
+ [ColorDescription(KeywordNamespaceKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordNamespace { get; private set; }
+
+ public const string KeywordPropertyKey = "Keyword(Property)";
+ [ColorDescription(KeywordPropertyKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordProperty { get; private set; }
+
+ public const string KeywordDeclarationKey = "Keyword(Declaration)";
+ [ColorDescription(KeywordDeclarationKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordDeclaration { get; private set; }
+
+ public const string KeywordParameterKey = "Keyword(Parameter)";
+ [ColorDescription(KeywordParameterKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordParameter { get; private set; }
+
+ public const string KeywordOperatorDeclarationKey = "Keyword(Operator Declaration)";
+ [ColorDescription(KeywordOperatorDeclarationKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordOperatorDeclaration { get; private set; }
+
+ public const string KeywordOtherKey = "Keyword(Other)";
+ [ColorDescription(KeywordOtherKey, VSSetting = "Keyword")]
+ public ChunkStyle KeywordOther { get; private set; }
+
+ public const string UserTypesKey = "User Types";
+ [ColorDescription(UserTypesKey, VSSetting = "User Types")]
+ public ChunkStyle UserTypes { get; private set; }
+
+ public const string UserTypesEnumsKey = "User Types(Enums)";
+ [ColorDescription(UserTypesEnumsKey, VSSetting = "User Types(Enums)")]
+ public ChunkStyle UserTypesEnums { get; private set; }
+
+ public const string UserTypesInterfacesKey = "User Types(Interfaces)";
+ [ColorDescription(UserTypesInterfacesKey, VSSetting = "User Types(Interfaces)")]
+ public ChunkStyle UserTypesInterfaces { get; private set; }
+
+ public const string UserTypesDelegatesKey = "User Types(Delegates)";
+ [ColorDescription(UserTypesDelegatesKey, VSSetting = "User Types(Delegates)")]
+ public ChunkStyle UserTypesDelegates { get; private set; }
+
+ public const string UserTypesValueTypesKey = "User Types(Value types)";
+ [ColorDescription(UserTypesValueTypesKey, VSSetting = "User Types(Value types)")]
+ public ChunkStyle UserTypesValueTypes { get; private set; }
+
+ public const string UserTypesTypeParametersKey = "User Types(Type parameters)";
+ [ColorDescription(UserTypesTypeParametersKey, VSSetting = "User Types(Type parameters)")]
+ public ChunkStyle UserTypesTypeParameters { get; private set; }
+
+ public const string UserFieldUsageKey = "User Field Usage";
+ [ColorDescription(UserFieldUsageKey, VSSetting = "Identifier")]
+ public ChunkStyle UserFieldUsage { get; private set; }
+
+ public const string UserFieldDeclarationKey = "User Field Declaration";
+ [ColorDescription(UserFieldDeclarationKey, VSSetting = "Identifier")]
+ public ChunkStyle UserFieldDeclaration { get; private set; }
+
+ public const string UserPropertyUsageKey = "User Property Usage";
+ [ColorDescription(UserPropertyUsageKey, VSSetting = "Identifier")]
+ public ChunkStyle UserPropertyUsage { get; private set; }
+
+ public const string UserPropertyDeclarationKey = "User Property Declaration";
+ [ColorDescription(UserPropertyDeclarationKey, VSSetting = "Identifier")]
+ public ChunkStyle UserPropertyDeclaration { get; private set; }
+
+ public const string UserEventUsageKey = "User Event Usage";
+ [ColorDescription(UserEventUsageKey, VSSetting = "Identifier")]
+ public ChunkStyle UserEventUsage { get; private set; }
+
+ public const string UserEventDeclarationKey = "User Event Declaration";
+ [ColorDescription(UserEventDeclarationKey, VSSetting = "Identifier")]
+ public ChunkStyle UserEventDeclaration { get; private set; }
+
+ public const string UserMethodUsageKey = "User Method Usage";
+ [ColorDescription(UserMethodUsageKey, VSSetting = "Identifier")]
+ public ChunkStyle UserMethodUsage { get; private set; }
+
+ public const string UserMethodDeclarationKey = "User Method Declaration";
+ [ColorDescription(UserMethodDeclarationKey, VSSetting = "Identifier")]
+ public ChunkStyle UserMethodDeclaration { get; private set; }
+
+ public const string UserParameterUsageKey = "User Parameter Usage";
+ [ColorDescription(UserParameterUsageKey, VSSetting = "Identifier")]
+ public ChunkStyle UserParameterUsage { get; private set; }
+
+ public const string UserParameterDeclarationKey = "User Parameter Declaration";
+ [ColorDescription(UserParameterDeclarationKey, VSSetting = "Identifier")]
+ public ChunkStyle UserParameterDeclaration { get; private set; }
+
+ public const string UserVariableUsageKey = "User Variable Usage";
+ [ColorDescription(UserVariableUsageKey, VSSetting = "Identifier")]
+ public ChunkStyle UserVariableUsage { get; private set; }
+
+ public const string UserVariableDeclarationKey = "User Variable Declaration";
+ [ColorDescription(UserVariableDeclarationKey, VSSetting = "Identifier")]
+ public ChunkStyle UserVariableDeclaration { get; private set; }
+
+ public const string SyntaxErrorKey = "Syntax Error";
+ [ColorDescription(SyntaxErrorKey, VSSetting = "Syntax Error")]
+ public ChunkStyle SyntaxError { get; private set; }
+
+ public const string StringFormatItemsKey = "String Format Items";
+ [ColorDescription(StringFormatItemsKey, VSSetting = "String")]
+ public ChunkStyle StringFormatItems { get; private set; }
+
+ public const string BreakpointTextKey = "Breakpoint Text";
+ [ColorDescription(BreakpointTextKey, VSSetting = "Breakpoint (Enabled)")]
+ public ChunkStyle BreakpointText { get; private set; }
+
+ public const string DebuggerCurrentLineKey = "Debugger Current Statement";
+ [ColorDescription(DebuggerCurrentLineKey, VSSetting = "Current Statement")]
+ public ChunkStyle DebuggerCurrentLine { get; private set; }
+
+ public const string DebuggerStackLineKey = "Debugger Stack Line";
+ [ColorDescription(DebuggerStackLineKey)] // not defined
+ public ChunkStyle DebuggerStackLine { get; private set; }
+
+ public const string DiffLineAddedKey = "Diff Line(Added)";
+ [ColorDescription(DiffLineAddedKey)] //not defined
+ public ChunkStyle DiffLineAdded { get; private set; }
+
+ public const string DiffLineRemovedKey = "Diff Line(Removed)";
+ [ColorDescription(DiffLineRemovedKey)] //not defined
+ public ChunkStyle DiffLineRemoved { get; private set; }
+
+ public const string DiffLineChangedKey = "Diff Line(Changed)";
+ [ColorDescription(DiffLineChangedKey)] //not defined
+ public ChunkStyle DiffLineChanged { get; private set; }
+
+ public const string DiffHeaderKey = "Diff Header";
+ [ColorDescription(DiffHeaderKey)] //not defined
+ public ChunkStyle DiffHeader { get; private set; }
+
+ public const string DiffHeaderSeparatorKey = "Diff Header(Separator)";
+ [ColorDescription(DiffHeaderSeparatorKey)] //not defined
+ public ChunkStyle DiffHeaderSeparator { get; private set; }
+
+ public const string DiffHeaderOldKey = "Diff Header(Old)";
+ [ColorDescription(DiffHeaderOldKey)] //not defined
+ public ChunkStyle DiffHeaderOld { get; private set; }
+
+ public const string DiffHeaderNewKey = "Diff Header(New)";
+ [ColorDescription(DiffHeaderNewKey)] //not defined
+ public ChunkStyle DiffHeaderNew { get; private set; }
+
+ public const string DiffLocationKey = "Diff Location";
+ [ColorDescription(DiffLocationKey)] //not defined
+ public ChunkStyle DiffLocation { get; private set; }
+
+ public const string HtmlAttributeNameKey = "Html Attribute Name";
+ [ColorDescription(HtmlAttributeNameKey, VSSetting="HTML Attribute")]
+ public ChunkStyle HtmlAttributeName { get; private set; }
+
+ public const string HtmlAttributeValueKey = "Html Attribute Value";
+ [ColorDescription(HtmlAttributeValueKey, VSSetting="HTML Attribute Value")]
+ public ChunkStyle HtmlAttributeValue { get; private set; }
+
+ public const string HtmlCommentKey = "Html Comment";
+ [ColorDescription(HtmlCommentKey, VSSetting="HTML Comment")]
+ public ChunkStyle HtmlComment { get; private set; }
+
+ public const string HtmlElementNameKey = "Html Element Name";
+ [ColorDescription(HtmlElementNameKey, VSSetting="HTML Element Name")]
+ public ChunkStyle HtmlElementName { get; private set; }
+
+ public const string HtmlEntityKey = "Html Entity";
+ [ColorDescription(HtmlEntityKey, VSSetting="HTML Entity")]
+ public ChunkStyle HtmlEntity { get; private set; }
+
+ public const string HtmlOperatorKey = "Html Operator";
+ [ColorDescription(HtmlOperatorKey, VSSetting="HTML Operator")]
+ public ChunkStyle HtmlOperator { get; private set; }
+
+ public const string HtmlServerSideScriptKey = "Html Server-Side Script";
+ [ColorDescription(HtmlServerSideScriptKey, VSSetting="HTML Server-Side Script")]
+ public ChunkStyle HtmlServerSideScript { get; private set; }
+
+ public const string HtmlTagDelimiterKey = "Html Tag Delimiter";
+ [ColorDescription(HtmlTagDelimiterKey, VSSetting="HTML Tag Delimiter")]
+ public ChunkStyle HtmlTagDelimiter { get; private set; }
+
+ public const string RazorCodeKey = "Razor Code";
+ [ColorDescription(RazorCodeKey, VSSetting="Razor Code")]
+ public ChunkStyle RazorCode { get; private set; }
+
+ public const string CssCommentKey = "Css Comment";
+ [ColorDescription(CssCommentKey, VSSetting="CSS Comment")]
+ public ChunkStyle CssComment { get; private set; }
+
+ public const string CssPropertyNameKey = "Css Property Name";
+ [ColorDescription(CssPropertyNameKey, VSSetting="CSS Property Name")]
+ public ChunkStyle CssPropertyName { get; private set; }
+
+ public const string CssPropertyValueKey = "Css Property Value";
+ [ColorDescription(CssPropertyValueKey, VSSetting="CSS Property Value")]
+ public ChunkStyle CssPropertyValue { get; private set; }
+
+ public const string CssSelectorKey = "Css Selector";
+ [ColorDescription(CssSelectorKey, VSSetting="CSS Selector")]
+ public ChunkStyle CssSelector { get; private set; }
+
+ public const string CssStringValueKey = "Css String Value";
+ [ColorDescription(CssStringValueKey, VSSetting="CSS String Value")]
+ public ChunkStyle CssStringValue { get; private set; }
+
+ public const string CssKeywordKey = "Css Keyword";
+ [ColorDescription(CssKeywordKey, VSSetting="CSS Keyword")]
+ public ChunkStyle CssKeyword { get; private set; }
+
+ public const string ScriptCommentKey = "Script Comment";
+ [ColorDescription(ScriptCommentKey, VSSetting="Script Comment")]
+ public ChunkStyle ScriptComment { get; private set; }
+
+ public const string ScriptIdentifierKey = "Script Identifier";
+ [ColorDescription(ScriptIdentifierKey, VSSetting="Script Identifier")]
+ public ChunkStyle ScriptIdentifier { get; private set; }
+
+ public const string ScriptKeywordKey = "Script Keyword";
+ [ColorDescription(ScriptKeywordKey, VSSetting="Script Keyword")]
+ public ChunkStyle ScriptKeyword { get; private set; }
+
+ public const string ScriptNumberKey = "Script Number";
+ [ColorDescription(ScriptNumberKey, VSSetting="Script Number")]
+ public ChunkStyle ScriptNumber { get; private set; }
+
+ public const string ScriptOperatorKey = "Script Operator";
+ [ColorDescription(ScriptOperatorKey, VSSetting="Script Operator")]
+ public ChunkStyle ScriptOperator { get; private set; }
+
+ public const string ScriptStringKey = "Script String";
+ [ColorDescription(ScriptStringKey, VSSetting="Script String")]
+ public ChunkStyle ScriptString { get; private set; }
+
+ #endregion
+
+ public class PropertyDecsription
+ {
+ public readonly PropertyInfo Info;
+ public readonly ColorDescriptionAttribute Attribute;
+
+ public PropertyDecsription (PropertyInfo info, ColorDescriptionAttribute attribute)
+ {
+ this.Info = info;
+ this.Attribute = attribute;
+ }
+ }
+
+ static Dictionary<string, PropertyDecsription> textColors = new Dictionary<string, PropertyDecsription> ();
+
+ public static IEnumerable<PropertyDecsription> TextColors {
+ get {
+ return textColors.Values;
+ }
+ }
+
+ static Dictionary<string, PropertyDecsription> ambientColors = new Dictionary<string, PropertyDecsription> ();
+
+ public static IEnumerable<PropertyDecsription> AmbientColors {
+ get {
+ return ambientColors.Values;
+ }
+ }
+
+ static ColorScheme ()
+ {
+ foreach (var property in typeof(ColorScheme).GetProperties ()) {
+ var description = property.GetCustomAttributes (false).FirstOrDefault (p => p is ColorDescriptionAttribute) as ColorDescriptionAttribute;
+ if (description == null)
+ continue;
+ if (property.PropertyType == typeof (ChunkStyle)) {
+ textColors.Add (description.Name, new PropertyDecsription (property, description));
+ } else {
+ ambientColors.Add (description.Name, new PropertyDecsription (property, description));
+ }
+ }
+ }
+
+ public ColorScheme Clone ()
+ {
+ var result = new ColorScheme () {
+ Name = this.Name,
+ BaseScheme = this.BaseScheme,
+ Originator = this.Originator,
+ Description = this.Description
+ };
+ result.CopyValues (this);
+ return result;
+ }
+
+ static HslColor ParseColor (string value)
+ {
+ if (value.Length == 9 && value.StartsWith ("#", StringComparison.Ordinal)) {
+ double r = ((double) int.Parse (value.Substring (1,2), System.Globalization.NumberStyles.HexNumber)) / 255;
+ double g = ((double) int.Parse (value.Substring (3,2), System.Globalization.NumberStyles.HexNumber)) / 255;
+ double b = ((double) int.Parse (value.Substring (5,2), System.Globalization.NumberStyles.HexNumber)) / 255;
+ double a = ((double) int.Parse (value.Substring (7,2), System.Globalization.NumberStyles.HexNumber)) / 255;
+ return new HslColor (r, g, b, a);
+ }
+ return HslColor.Parse (value);
+ }
+
+ public static HslColor ParsePaletteColor (Dictionary<string, HslColor> palette, string value)
+ {
+ HslColor result;
+ if (palette.TryGetValue (value, out result))
+ return result;
+ return ParseColor (value);
+ }
+
+ public ChunkStyle GetChunkStyle (string color)
+ {
+ if (color == null)
+ return GetChunkStyle ("Plain Text");
+ PropertyDecsription val;
+ if (!textColors.TryGetValue (color, out val)) {
+ Console.WriteLine ("Chunk style : " + color + " is undefined.");
+ return GetChunkStyle ("Plain Text");
+ }
+ return val.Info.GetValue (this, null) as ChunkStyle;
+ }
+
+ void CopyValues (ColorScheme baseScheme)
+ {
+ foreach (var color in textColors.Values)
+ color.Info.SetValue (this, color.Info.GetValue (baseScheme, null), null);
+ foreach (var color in ambientColors.Values)
+ color.Info.SetValue (this, color.Info.GetValue (baseScheme, null), null);
+ }
+
+ public static ColorScheme LoadFrom (Stream stream)
+ {
+ var result = new ColorScheme ();
+ var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (stream, new System.Xml.XmlDictionaryReaderQuotas ());
+
+ var root = XElement.Load(reader);
+
+ // The fields we'd like to extract
+ result.Name = root.XPathSelectElement("name").Value;
+
+ if (result.Name != "Default")
+ result.CopyValues (SyntaxModeService.DefaultColorStyle);
+
+ var version = Version.Parse (root.XPathSelectElement("version").Value);
+ if (version.Major != 1)
+ return null;
+ var el = root.XPathSelectElement ("description");
+ if (el != null)
+ result.Description = el.Value;
+ el = root.XPathSelectElement ("originator");
+ if (el != null)
+ result.Originator = el.Value;
+ el = root.XPathSelectElement ("baseScheme");
+ if (el != null)
+ result.BaseScheme = el.Value;
+
+ if (result.BaseScheme != null) {
+ var baseScheme = SyntaxModeService.GetColorStyle (result.BaseScheme);
+ if (baseScheme != null)
+ result.CopyValues (baseScheme);
+ }
+
+ var palette = new Dictionary<string, HslColor> ();
+ foreach (var color in root.XPathSelectElements("palette/*")) {
+ var name = color.XPathSelectElement ("name").Value;
+ if (palette.ContainsKey (name))
+ throw new InvalidDataException ("Duplicate palette color definition for: " + name);
+ palette.Add (
+ name,
+ ParseColor (color.XPathSelectElement ("value").Value)
+ );
+ }
+
+ foreach (var colorElement in root.XPathSelectElements("//colors/*")) {
+ var color = AmbientColor.Create (colorElement, palette);
+ PropertyDecsription info;
+ if (!ambientColors.TryGetValue (color.Name, out info)) {
+ Console.WriteLine ("Ambient color:" + color.Name + " not found.");
+ continue;
+ }
+ info.Info.SetValue (result, color, null);
+ }
+
+ foreach (var textColorElement in root.XPathSelectElements("//text/*")) {
+ var color = ChunkStyle.Create (textColorElement, palette);
+ PropertyDecsription info;
+ if (!textColors.TryGetValue (color.Name, out info)) {
+ Console.WriteLine ("Text color:" + color.Name + " not found.");
+ continue;
+ }
+ info.Info.SetValue (result, color, null);
+ }
+
+ // Check scheme
+ bool valid = true;
+ foreach (var color in textColors.Values) {
+ if (color.Info.GetValue (result, null) == null) {
+ Console.WriteLine (color.Attribute.Name + " == null");
+ valid = false;
+ }
+ }
+ foreach (var color in ambientColors.Values) {
+ if (color.Info.GetValue (result, null) == null) {
+ Console.WriteLine (color.Attribute.Name + " == null");
+ valid = false;
+ }
+ }
+ if (!valid)
+ throw new InvalidDataException ("Scheme " + result.Name + " is not valid.");
+ return result;
+ }
+
+ public static string ColorToMarkup (HslColor color)
+ {
+ return color.ToMarkup ();
+ }
+
+
+ public void Save (string fileName)
+ {
+ using (var writer = new StreamWriter (fileName)) {
+ writer.WriteLine ("{");
+ writer.WriteLine ("\t\"name\":\"{0}\",", Name);
+ writer.WriteLine ("\t\"version\":\"1.0\",");
+ if (!string.IsNullOrEmpty (Description))
+ writer.WriteLine ("\t\"description\":\"{0}\",", Description);
+ if (!string.IsNullOrEmpty (Originator))
+ writer.WriteLine ("\t\"originator\":\"{0}\",", Originator);
+ if (!string.IsNullOrEmpty (BaseScheme))
+ writer.WriteLine ("\t\"baseScheme\":\"{0}\",", BaseScheme);
+
+ var baseStyle = SyntaxModeService.GetColorStyle (BaseScheme ?? "Default");
+
+ writer.WriteLine ("\t\"colors\":[");
+ bool first = true;
+ foreach (var ambient in ambientColors) {
+ var thisValue = ambient.Value.Info.GetValue (this, null) as AmbientColor;
+ if (thisValue == null)
+ continue;
+ var baseValue = ambient.Value.Info.GetValue (baseStyle, null) as AmbientColor;
+ if (thisValue.Equals (baseValue)) {
+ continue;
+ }
+
+ var colorString = new StringBuilder ();
+ foreach (var color in thisValue.Colors) {
+ if (colorString.Length > 0)
+ colorString.Append (", ");
+ colorString.Append (string.Format ("\"{0}\":\"{1}\"", color.Item1, ColorToMarkup (color.Item2)));
+ }
+ if (colorString.Length == 0) {
+ Console.WriteLine ("Invalid ambient color :" + thisValue);
+ continue;
+ }
+ if (!first) {
+ writer.WriteLine (",");
+ } else {
+ first = false;
+ }
+ writer.Write ("\t\t{");
+ writer.Write ("\"name\": \"{0}\", {1}", ambient.Value.Attribute.Name, colorString);
+ writer.Write (" }");
+ }
+
+ writer.WriteLine ("\t],");
+ first = true;
+ writer.WriteLine ("\t\"text\":[");
+ foreach (var textColor in textColors) {
+ var thisValue = textColor.Value.Info.GetValue (this, null) as ChunkStyle;
+ if (thisValue == null)
+ continue;
+ var baseValue = textColor.Value.Info.GetValue (baseStyle, null) as ChunkStyle;
+ if (thisValue.Equals (baseValue)) {
+ continue;
+ }
+ var colorString = new StringBuilder ();
+ if (!thisValue.TransparentForeground)
+ colorString.Append (string.Format ("\"fore\":\"{0}\"", ColorToMarkup (thisValue.Foreground)));
+ if (!thisValue.TransparentBackground) {
+ if (colorString.Length > 0)
+ colorString.Append (", ");
+ colorString.Append (string.Format ("\"back\":\"{0}\"", ColorToMarkup (thisValue.Background)));
+ }
+ if (thisValue.FontWeight != Xwt.Drawing.FontWeight.Normal) {
+ if (colorString.Length > 0)
+ colorString.Append (", ");
+ colorString.Append (string.Format ("\"weight\":\"{0}\"", thisValue.FontWeight));
+ }
+ if (thisValue.FontStyle != Xwt.Drawing.FontStyle.Normal) {
+ if (colorString.Length > 0)
+ colorString.Append (", ");
+ colorString.Append (string.Format ("\"style\":\"{0}\"", thisValue.FontStyle));
+ }
+ if (!first) {
+ writer.WriteLine (",");
+ } else {
+ first = false;
+ }
+ writer.Write ("\t\t{");
+ if (colorString.Length == 0) {
+ writer.Write ("\"name\": \"{0}\"", textColor.Value.Attribute.Name);
+ } else {
+ writer.Write ("\"name\": \"{0}\", {1}", textColor.Value.Attribute.Name, colorString);
+ }
+ writer.Write (" }");
+ }
+ writer.WriteLine ();
+ writer.WriteLine ("\t]");
+
+ writer.WriteLine ("}");
+ }
+ }
+
+ internal static HslColor ImportVsColor (string colorString)
+ {
+ if (colorString == "0x02000000")
+ return new HslColor (0, 0, 0, 0);
+ string color = "#" + colorString.Substring (8, 2) + colorString.Substring (6, 2) + colorString.Substring (4, 2);
+ return HslColor.Parse (color);
+ }
+
+ public class VSSettingColor
+ {
+ public string Name { get; private set; }
+ public string Foreground { get; private set; }
+ public string Background { get; private set; }
+ public bool BoldFont { get; private set; }
+
+ public static VSSettingColor Create (XmlReader reader)
+ {
+ return new VSSettingColor {
+ Name = reader.GetAttribute ("Name"),
+ Foreground = reader.GetAttribute ("Foreground"),
+ Background = reader.GetAttribute ("Background"),
+ BoldFont = reader.GetAttribute ("BoldFont") == "Yes"
+ };
+ }
+ }
+
+ public static HslColor AlphaBlend (HslColor fore, HslColor back, double alpha)
+ {
+ var fc = (Cairo.Color)fore;
+ var bc = (Cairo.Color)back;
+ return new HslColor (
+ (1.0 - alpha) * bc.R + alpha * fc.R,
+ (1.0 - alpha) * bc.G + alpha * fc.G,
+ (1.0 - alpha) * bc.B + alpha * fc.B);
+ }
+
+ public static ColorScheme Import (string fileName, Stream stream)
+ {
+ var result = new ColorScheme ();
+ result.Name = Path.GetFileNameWithoutExtension (fileName);
+ result.Description = "Imported color scheme";
+ result.Originator = "Imported from " + fileName;
+
+ var colors = new Dictionary<string, VSSettingColor> ();
+ using (var reader = XmlReader.Create (stream)) {
+ while (reader.Read ()) {
+ if (reader.LocalName == "Item") {
+ var color = VSSettingColor.Create (reader);
+ if (colors.ContainsKey (color.Name)) {
+ Console.WriteLine ("Warning: {0} is defined twice in vssettings.", color.Name);
+ continue;
+ }
+ colors[color.Name] = color;
+ }
+ }
+ }
+
+
+ HashSet<string> importedAmbientColors = new HashSet<string> ();
+ // convert ambient colors
+ foreach (var ambient in ambientColors.Values) {
+ if (!string.IsNullOrEmpty (ambient.Attribute.VSSetting)) {
+ var import = AmbientColor.Import (colors, ambient.Attribute.VSSetting);
+ if (import != null) {
+ importedAmbientColors.Add (import.Name);
+ ambient.Info.SetValue (result, import, null);
+ continue;
+ }
+ }
+ }
+
+ // convert text colors
+ foreach (var vsc in colors.Values) {
+ bool found = false;
+ foreach (var color in textColors) {
+ if (color.Value.Attribute.VSSetting == null)
+ continue;
+ var split = color.Value.Attribute.VSSetting.Split ('?');
+ foreach (var s in split) {
+ if (s == vsc.Name) {
+ /* if (vsc.Foreground == "0x02000000" && vsc.Background == "0x02000000") {
+ color.Value.Info.SetValue (result, result.PlainText, null);
+ found = true;
+ continue;
+ }*/
+ var textColor = ChunkStyle.Import (color.Value.Attribute.Name, vsc);
+ if (textColor != null) {
+ color.Value.Info.SetValue (result, textColor, null);
+ found = true;
+ }
+ }
+ }
+ }
+ if (!found && !importedAmbientColors.Contains (vsc.Name))
+ Console.WriteLine (vsc.Name + " not imported!");
+ }
+
+ result.IndentationGuide = new AmbientColor ();
+ result.IndentationGuide.Colors.Add (Tuple.Create ("color", AlphaBlend (result.PlainText.Foreground, result.PlainText.Background, 0.3)));
+
+ result.TooltipText = result.PlainText.Clone ();
+ var h = (HslColor)result.TooltipText.Background;
+ h.L += 0.01;
+ result.TooltipText.Background = h;
+
+ result.TooltipPagerTop = new AmbientColor ();
+ result.TooltipPagerTop.Colors.Add (Tuple.Create ("color", result.TooltipText.Background));
+
+ result.TooltipPagerBottom = new AmbientColor ();
+ result.TooltipPagerBottom.Colors.Add (Tuple.Create ("color", result.TooltipText.Background));
+
+ result.TooltipPagerTriangle = new AmbientColor ();
+ result.TooltipPagerTriangle.Colors.Add (Tuple.Create ("color", AlphaBlend (result.PlainText.Foreground, result.PlainText.Background, 0.8)));
+
+ result.TooltipBorder = new AmbientColor ();
+ result.TooltipBorder.Colors.Add (Tuple.Create ("color", AlphaBlend (result.PlainText.Foreground, result.PlainText.Background, 0.5)));
+
+ var defaultStyle = SyntaxModeService.GetColorStyle (HslColor.Brightness (result.PlainText.Background) < 0.5 ? "Monokai" : "Default");
+
+ foreach (var color in textColors.Values) {
+ if (color.Info.GetValue (result, null) == null)
+ color.Info.SetValue (result, color.Info.GetValue (defaultStyle, null), null);
+ }
+ foreach (var color in ambientColors.Values) {
+ if (color.Info.GetValue (result, null) == null)
+ color.Info.SetValue (result, color.Info.GetValue (defaultStyle, null), null);
+ }
+ if (result.PlainText.TransparentForeground)
+ result.PlainText.Foreground = new HslColor (0, 0, 0);
+ return result;
+ }
+
+ public HslColor GetForeground (ChunkStyle chunkStyle)
+ {
+ if (chunkStyle.TransparentForeground)
+ return PlainText.Foreground;
+ return chunkStyle.Foreground;
+ }
+
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColoredSegment.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColoredSegment.cs
new file mode 100644
index 0000000000..9f67c54602
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColoredSegment.cs
@@ -0,0 +1,59 @@
+//
+// ColoredSegment.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using MonoDevelop.Core.Text;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ /// <summary>
+ /// A colored segment is used in the highlighter to specify a color scheme style to a specfic part of text.
+ /// </summary>
+ public sealed class ColoredSegment : AbstractSegment
+ {
+ readonly string colorStyleKey;
+
+ //// <summary>
+ /// Gets the color style. The style is looked up in the current color scheme.
+ /// </summary>
+ public string ColorStyleKey {
+ get {
+ return colorStyleKey;
+ }
+ }
+
+ public ColoredSegment (int offset, int length, string colorStyleKey) : base (offset, length)
+ {
+ this.colorStyleKey = colorStyleKey;
+ }
+
+ public ColoredSegment (ISegment segment, string colorStyleKey) : base (segment)
+ {
+ this.colorStyleKey = colorStyleKey;
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/IStreamProvider.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/IStreamProvider.cs
new file mode 100644
index 0000000000..97126a1219
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/IStreamProvider.cs
@@ -0,0 +1,97 @@
+// IXmlProvider.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public interface IStreamProvider
+ {
+ Stream Open ();
+ }
+
+ [Obsolete("Do not use this anymore. Use ResourceStreamProvider.")]
+ public class ResourceXmlProvider : ResourceStreamProvider
+ {
+ public ResourceXmlProvider (Assembly assembly, string manifestResourceName) : base(assembly, manifestResourceName)
+ {
+
+ }
+ }
+ public class ResourceStreamProvider : IStreamProvider
+ {
+ Assembly assembly;
+ string manifestResourceName;
+
+ public string ManifestResourceName {
+ get {
+ return manifestResourceName;
+ }
+ }
+
+ public Assembly Assembly {
+ get {
+ return assembly;
+ }
+ }
+
+ public ResourceStreamProvider (Assembly assembly, string manifestResourceName)
+ {
+ this.assembly = assembly;
+ this.manifestResourceName = manifestResourceName;
+ }
+
+ public Stream Open ()
+ {
+ return assembly.GetManifestResourceStream (this.ManifestResourceName);
+ }
+ }
+
+ public class UrlStreamProvider : IStreamProvider
+ {
+ string url;
+
+ public string Url {
+ get {
+ return url;
+ }
+ }
+
+ public UrlStreamProvider (string url)
+ {
+ this.url = url;
+ }
+
+ public Stream Open ()
+ {
+ return File.OpenRead (url);
+ }
+ }
+
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SemanticHighlighting.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SemanticHighlighting.cs
new file mode 100644
index 0000000000..f0f27f39f6
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SemanticHighlighting.cs
@@ -0,0 +1,76 @@
+//
+// SemanticHighlighting.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Core.Text;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ /// <summary>
+ /// Semantic highlighting adds the ability to add highlighting for things that require
+ /// a background parser to be colored. For example type names.
+ /// </summary>
+ public abstract class SemanticHighlighting : IDisposable
+ {
+ protected readonly internal TextEditor editor;
+ protected readonly internal DocumentContext documentContext;
+
+ protected SemanticHighlighting (TextEditor editor, DocumentContext documentContext)
+ {
+ this.editor = editor;
+ this.documentContext = documentContext;
+ this.documentContext.DocumentParsed += HandleDocumentParsed;
+ }
+
+ protected abstract void DocumentParsed ();
+
+ public void NotifySemanticHighlightingUpdate ()
+ {
+ var handler = SemanticHighlightingUpdated;
+ if (handler != null)
+ handler (this, EventArgs.Empty);
+ }
+
+ /// <summary>
+ /// Colorize the specified offset, count and colorizeCallback.
+ /// </summary>
+ /// <param name="segment">The area to run the colorizer in.</param>
+ public abstract IEnumerable<ColoredSegment> GetColoredSegments (ISegment segment);
+
+ void HandleDocumentParsed (object sender, EventArgs e)
+ {
+ if (DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting)
+ DocumentParsed ();
+ }
+
+ public void Dispose ()
+ {
+ documentContext.DocumentParsed -= HandleDocumentParsed;
+ }
+
+ internal event EventHandler SemanticHighlightingUpdated;
+ }
+} \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs
new file mode 100644
index 0000000000..539bcc5c6a
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs
@@ -0,0 +1,216 @@
+// SyntaxModeService.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+using System.Xml;
+using System.Xml.Schema;
+using System.Linq;
+using Mono.Addins;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public static class SyntaxModeService
+ {
+ static Dictionary<string, ColorScheme> styles = new Dictionary<string, ColorScheme> ();
+ static Dictionary<string, IStreamProvider> styleLookup = new Dictionary<string, IStreamProvider> ();
+
+ public static string[] Styles {
+ get {
+ List<string> result = new List<string> ();
+ foreach (string style in styles.Keys) {
+ if (!result.Contains (style))
+ result.Add (style);
+ }
+ foreach (string style in styleLookup.Keys) {
+ if (!result.Contains (style))
+ result.Add (style);
+ }
+ return result.ToArray ();
+ }
+ }
+
+ public static ColorScheme GetColorStyle (string name)
+ {
+ if (styles.ContainsKey (name))
+ return styles [name];
+ if (styleLookup.ContainsKey (name)) {
+ LoadStyle (name);
+ return GetColorStyle (name);
+ }
+ return GetColorStyle ("Default");
+ }
+
+ public static IStreamProvider GetProvider (ColorScheme style)
+ {
+ if (styleLookup.ContainsKey (style.Name))
+ return styleLookup[style.Name];
+ return null;
+ }
+
+ static void LoadStyle (string name)
+ {
+ if (!styleLookup.ContainsKey (name))
+ throw new System.ArgumentException ("Style " + name + " not found", "name");
+ var provider = styleLookup [name];
+ styleLookup.Remove (name);
+ var stream = provider.Open ();
+ try {
+ if (provider is UrlStreamProvider) {
+ var usp = provider as UrlStreamProvider;
+ if (usp.Url.EndsWith (".vssettings", StringComparison.Ordinal)) {
+ styles [name] = ColorScheme.Import (usp.Url, stream);
+ } else {
+ styles [name] = ColorScheme.LoadFrom (stream);
+ }
+ styles [name].FileName = usp.Url;
+ } else {
+ styles [name] = ColorScheme.LoadFrom (stream);
+ }
+ } catch (Exception e) {
+ throw new IOException ("Error while loading style :" + name, e);
+ } finally {
+ stream.Close ();
+ }
+ }
+
+
+ public static void Remove (ColorScheme style)
+ {
+ if (styleLookup.ContainsKey (style.Name))
+ styleLookup.Remove (style.Name);
+
+ foreach (var kv in styles) {
+ if (kv.Value == style) {
+ styles.Remove (kv.Key);
+ return;
+ }
+ }
+ }
+
+
+ public static List<ValidationEventArgs> ValidateStyleFile (string fileName)
+ {
+ List<ValidationEventArgs> result = new List<ValidationEventArgs> ();
+ return result;
+ }
+
+
+ public static void LoadStylesAndModes (string path)
+ {
+ foreach (string file in Directory.GetFiles (path)) {
+ if (file.EndsWith (".json", StringComparison.Ordinal)) {
+ using (var stream = File.OpenRead (file)) {
+ string styleName = ScanStyle (stream);
+ if (!string.IsNullOrEmpty (styleName)) {
+ styleLookup [styleName] = new UrlStreamProvider (file);
+ } else {
+ Console.WriteLine ("Invalid .json syntax sheme file : " + file);
+ }
+ }
+ } else if (file.EndsWith (".vssettings", StringComparison.Ordinal)) {
+ using (var stream = File.OpenRead (file)) {
+ string styleName = Path.GetFileNameWithoutExtension (file);
+ styleLookup [styleName] = new UrlStreamProvider (file);
+ }
+ }
+ }
+ }
+
+ public static void LoadStylesAndModes (Assembly assembly)
+ {
+ foreach (string resource in assembly.GetManifestResourceNames ()) {
+ if (resource.EndsWith ("Style.json", StringComparison.Ordinal)) {
+ using (Stream stream = assembly.GetManifestResourceStream (resource)) {
+ string styleName = ScanStyle (stream);
+ styleLookup [styleName] = new ResourceStreamProvider (assembly, resource);
+ }
+ }
+ }
+ }
+ static System.Text.RegularExpressions.Regex nameRegex = new System.Text.RegularExpressions.Regex ("\\s*\"name\"\\s*:\\s*\"(.*)\"\\s*,");
+
+ static string ScanStyle (Stream stream)
+ {
+ try {
+ var file = new StreamReader (stream);
+ file.ReadLine ();
+ var nameLine = file.ReadLine ();
+ var match = nameRegex.Match (nameLine);
+ if (!match.Success)
+ return null;
+ return match.Groups[1].Value;
+ } catch (Exception e) {
+ Console.WriteLine ("Error while scanning json:");
+ Console.WriteLine (e);
+ return null;
+ }
+ }
+
+ public static void AddStyle (ColorScheme style)
+ {
+ styles [style.Name] = style;
+ }
+
+ public static void AddStyle (IStreamProvider provider)
+ {
+ using (var stream = provider.Open ()) {
+ string styleName = ScanStyle (stream);
+ styleLookup [styleName] = provider;
+ }
+ }
+
+ public static void RemoveStyle (IStreamProvider provider)
+ {
+ using (var stream = provider.Open ()) {
+ string styleName = ScanStyle (stream);
+ styleLookup.Remove (styleName);
+ }
+ }
+
+ public static ColorScheme DefaultColorStyle {
+ get {
+ return GetColorStyle ("Default");
+ }
+ }
+
+ static SyntaxModeService ()
+ {
+ var textEditorAssembly = Assembly.Load ("Mono.TextEditor");
+ if (textEditorAssembly != null) {
+ LoadStylesAndModes (textEditorAssembly);
+ } else {
+ LoggingService.LogError ("Can't lookup Mono.TextEditor assembly. Default styles won't be loaded.");
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs
new file mode 100644
index 0000000000..bd57ac22d0
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs
@@ -0,0 +1,64 @@
+// TemplateCodon.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+using System.IO;
+using System;
+using System.Xml;
+
+using Mono.Addins;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ [ExtensionNode (Description="A template for color and syntax shemes.")]
+ class TemplateCodon : ExtensionNode, IStreamProvider
+ {
+ [NodeAttribute("resource", "Name of the resource where the template is stored.")]
+ string resource;
+
+ [NodeAttribute("file", "Name of the file where the template is stored.")]
+ string file;
+
+ public TemplateCodon ()
+ {
+ resource = file = null;
+ }
+
+ public Stream Open ()
+ {
+ Stream stream;
+ if (!string.IsNullOrEmpty (file)) {
+ stream = File.OpenRead (Addin.GetFilePath (file));
+ } else if (!string.IsNullOrEmpty (resource)) {
+ stream = Addin.GetResource (resource);
+ if (stream == null)
+ throw new ApplicationException ("Template " + resource + " not found");
+ } else {
+ throw new InvalidOperationException ("Template file or resource not provided");
+ }
+
+ return stream;
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateExtensionNodeLoader.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateExtensionNodeLoader.cs
new file mode 100644
index 0000000000..ddf704e991
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateExtensionNodeLoader.cs
@@ -0,0 +1,55 @@
+// TemplateExtensionNodeLoader.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using Mono.Addins;
+using MonoDevelop.Ide.Editor.Highlighting;
+
+namespace MonoDevelop.Ide.Editor.Highlighting
+{
+ public static class TemplateExtensionNodeLoader
+ {
+ static bool initialized = false;
+
+ public static void Init ()
+ {
+ if (initialized)
+ return;
+ initialized = true;
+ AddinManager.AddExtensionNodeHandler ("/MonoDevelop/SourceEditor2/Styles", OnStylesExtensionChanged);
+ }
+
+ static void OnStylesExtensionChanged (object s, ExtensionNodeEventArgs args)
+ {
+ TemplateCodon codon = (TemplateCodon)args.ExtensionNode;
+ if (args.Change == ExtensionChange.Add) {
+ SyntaxModeService.AddStyle (codon);
+ } else {
+ SyntaxModeService.RemoveStyle (codon);
+ }
+ }
+ }
+} \ No newline at end of file