diff --git a/ColorCode.Core/Common/ScopeName.cs b/ColorCode.Core/Common/ScopeName.cs index 7635baf..2784c69 100644 --- a/ColorCode.Core/Common/ScopeName.cs +++ b/ColorCode.Core/Common/ScopeName.cs @@ -60,5 +60,9 @@ public class ScopeName public const string Intrinsic = "Intrinsic"; public const string Brackets = "Brackets"; public const string Continuation = "Continuation"; + public const string DiffAddition = "DiffAddition"; + public const string DiffDeletion = "DiffDeletion"; + public const string DiffMeta = "DiffMeta"; + public const string DiffComment = "DiffComment"; } -} \ No newline at end of file +} diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs new file mode 100644 index 0000000..2b6e713 --- /dev/null +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -0,0 +1,92 @@ +// Copyright (c) 2015 Christopher Pardi. + +// Copyright (c) Microsoft Corporation. All rights reserved. + +using System.Collections.Generic; +using ColorCode.Common; + +namespace ColorCode.Compilation.Languages +{ + public class Diff : ILanguage + { + public string Id + { + get { return LanguageId.Diff; } + } + + public string Name + { + get { return "Diff"; } + } + + public string CssClassName + { + get { return "diff"; } + } + + public string FirstLinePattern + { + get + { + return null; + } + } + + public IList Rules + { + get + { + return new List + { + new LanguageRule( + @"^(((---)|(\*\*\*)) +\d+,\d+ +((----)|(\*\*\*\*))|@@ +\-\d+,\d+ \+\d+,\d+ +@@)(\r?\n?)", + new Dictionary + { + { 0, ScopeName.DiffMeta }, + }), + new LanguageRule( + @"^(\*{5}).*(\*{5})(\r?\n?)", + new Dictionary + { + { 0, ScopeName.DiffComment }, + }), + new LanguageRule( + @"^((-{3,})|(\*{3,})|(\+{3,})|(Index:)|(={3,})).*(\r?\n?)", + new Dictionary + { + { 0, ScopeName.DiffComment }, + }), + new LanguageRule( + @"(^(\+|!).*(\r?\n?))", + new Dictionary + { + { 0, ScopeName.DiffAddition }, + }), + new LanguageRule( + @"^\-.*(\r?\n?)", + new Dictionary + { + { 0, ScopeName.DiffDeletion }, + }), + }; + } + } + + public bool HasAlias(string lang) + { + switch (lang.ToLower()) + { + case "diff": + case "patch": + return true; + default: + return false; + } + } + + public override string ToString() + { + return Name; + } + } +} diff --git a/ColorCode.Core/Languages.cs b/ColorCode.Core/Languages.cs index 7924e92..226abd0 100644 --- a/ColorCode.Core/Languages.cs +++ b/ColorCode.Core/Languages.cs @@ -44,6 +44,7 @@ static Languages() Load(); Load(); Load(); + Load(); } /// @@ -280,4 +281,4 @@ public static void Load(ILanguage language) LanguageRepository.Load(language); } } -} \ No newline at end of file +} diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs index 560e1b3..a7f1a58 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs @@ -298,8 +298,28 @@ public static StyleDictionary DefaultDark { ReferenceName = "specialChar" }, + new Style(ScopeName.DiffAddition) + { + Foreground = Green, + ReferenceName = "diffAddition" + }, + new Style(ScopeName.DiffDeletion) + { + Foreground = Red, + ReferenceName = "diffDeletion" + }, + new Style(ScopeName.DiffMeta) + { + Foreground = OrangeRed, + ReferenceName = "diffMeta" + }, + new Style(ScopeName.DiffComment) + { + Foreground = VSDarkGray, + ReferenceName = "diffComment" + } }; } } } -} \ No newline at end of file +} diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs index 16403b1..2f32d31 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs @@ -281,8 +281,28 @@ public static StyleDictionary DefaultLight { ReferenceName = "specialChar" }, + new Style(ScopeName.DiffAddition) + { + Foreground = Green, + ReferenceName = "diffAddition" + }, + new Style(ScopeName.DiffDeletion) + { + Foreground = Red, + ReferenceName = "diffDeletion" + }, + new Style(ScopeName.DiffMeta) + { + Foreground = OrangeRed, + ReferenceName = "diffMeta" + }, + new Style(ScopeName.DiffComment) + { + Foreground = Gray, + ReferenceName = "diffComment" + } }; } } } -} \ No newline at end of file +}