From 25ebc1b7e12b0631862c92597cd797c469e1b4f6 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 12:34:53 +0200 Subject: [PATCH 01/13] Diff language file --- ColorCode.Core/Compilation/Languages/Diff.cs | 97 ++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 ColorCode.Core/Compilation/Languages/Diff.cs diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs new file mode 100644 index 0000000..65cde43 --- /dev/null +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -0,0 +1,97 @@ +using System.Collections.Generic; +using ColorSyntax.Common; + +namespace ColorSyntax.Compilation.Languages +{ + public class Diff : ILanguage + { + public string Id + { + get { return LanguageId.Fortran; } + } + + public string Name + { + get { return "Fortran"; } + } + + public string CssClassName + { + get { return "fortran"; } + } + + public string FirstLinePattern + { + get + { + return null; + } + } + + public IList Rules + { + get + { + return new List + { + // Comments + new LanguageRule( + @"(?m)(^\+.*$)|(^!.*$)", + new Dictionary + { + { 0, ScopeName.Addition }, + }), + new LanguageRule( + @"(?m)^\-.*$", + new Dictionary + { + { 0, ScopeName.Deletion }, + }), + new LanguageRule( + @"(?m)^@@.*@@$", + new Dictionary + { + { 0, ScopeName.Type }, + }), + new LanguageRule( + @"(?m)^((---)|(\+\+\+)|(\*\*\*)) +\d+,\d+ +((----)|(\+\+\+\+)|(\*\*\*\*))", + new Dictionary + { + { 0, ScopeName.Type }, + }), + new LanguageRule( + @"(?m)^((Index:)|(={3,})|(\+{3})|(\*{3})|(\-{3})).*$", + new Dictionary + { + { 0, ScopeName.Brackets }, + }), + new LanguageRule( + @"(?m)^(\*{5}).*(\*{5})$", + new Dictionary + { + { 0, ScopeName.Brackets }, + }), + + }; + } + } + + public bool HasAlias(string lang) + { + switch (lang.ToLower()) + { + case "diff": + return true; + case "patch": + return true; + default: + return false; + } + } + + public override string ToString() + { + return Name; + } + } +} From c26d8b9efc2297feb3ebdcdfb37eef04f4da020a Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 12:35:40 +0200 Subject: [PATCH 02/13] Load Diff within Languages.cs --- ColorCode.Core/Languages.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 +} From a1d96f1c2ad222a3d45eacdde256630b719cbc2d Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 12:39:54 +0200 Subject: [PATCH 03/13] Add "Adition" and "Deletion" to dark style --- .../Styling/StyleDictionary.DefaultDark.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs index 560e1b3..eb5dd34 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs @@ -298,8 +298,18 @@ public static StyleDictionary DefaultDark { ReferenceName = "specialChar" }, + new Style(ScopeName.Addition) + { + Foreground = Green, + ReferenceName = "addition" + }, + new Style(ScopeName.Deletion) + { + Foreground = Red, + ReferenceName = "addition" + } }; } } } -} \ No newline at end of file +} From 94f2d6ef590c54163cab9c301035bdbd853a53e6 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 14:17:27 +0200 Subject: [PATCH 04/13] Update Diff.cs --- ColorCode.Core/Compilation/Languages/Diff.cs | 45 +++++++++----------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs index 65cde43..d8a2bca 100644 --- a/ColorCode.Core/Compilation/Languages/Diff.cs +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -1,3 +1,7 @@ +// Copyright (c) 2015 Christopher Pardi. + +// Copyright (c) Microsoft Corporation. All rights reserved. + using System.Collections.Generic; using ColorSyntax.Common; @@ -7,17 +11,17 @@ public class Diff : ILanguage { public string Id { - get { return LanguageId.Fortran; } + get { return LanguageId.Diff; } } public string Name { - get { return "Fortran"; } + get { return "Diff"; } } public string CssClassName { - get { return "fortran"; } + get { return "diff"; } } public string FirstLinePattern @@ -34,44 +38,36 @@ public IList Rules { return new List { - // Comments - new LanguageRule( - @"(?m)(^\+.*$)|(^!.*$)", - new Dictionary - { - { 0, ScopeName.Addition }, - }), - new LanguageRule( - @"(?m)^\-.*$", + new LanguageRule( + @"(?m)^(((---)|(\*\*\*)) +\d+,\d+ +((----)|(\*\*\*\*))|@@ +\-\d+,\d+ \+\d+,\d+ +@@)", new Dictionary { - { 0, ScopeName.Deletion }, + { 0, ScopeName.DiffMeta }, }), - new LanguageRule( - @"(?m)^@@.*@@$", + new LanguageRule( + @"(?m)^(\*{5}).*(\*{5})$", new Dictionary { - { 0, ScopeName.Type }, + { 0, ScopeName.Brackets }, }), - new LanguageRule( - @"(?m)^((---)|(\+\+\+)|(\*\*\*)) +\d+,\d+ +((----)|(\+\+\+\+)|(\*\*\*\*))", + new LanguageRule( + @"(?m)^((-{3,})|(\*{3,})|(\+{3,})|(Index:)|(={3,})).*$", new Dictionary { - { 0, ScopeName.Type }, + { 0, ScopeName.Brackets }, }), new LanguageRule( - @"(?m)^((Index:)|(={3,})|(\+{3})|(\*{3})|(\-{3})).*$", + @"(?m)(^(\+|!).*$)", new Dictionary { - { 0, ScopeName.Brackets }, + { 0, ScopeName.DiffAddition }, }), new LanguageRule( - @"(?m)^(\*{5}).*(\*{5})$", + @"(?m)^\-.*$", new Dictionary { - { 0, ScopeName.Brackets }, + { 0, ScopeName.DiffDeletion }, }), - }; } } @@ -81,7 +77,6 @@ public bool HasAlias(string lang) switch (lang.ToLower()) { case "diff": - return true; case "patch": return true; default: From 2a696527c287a79cbebe1a2d6b8bd1b7053f859c Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:06:04 +0200 Subject: [PATCH 05/13] Update Diff.cs --- ColorCode.Core/Compilation/Languages/Diff.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs index d8a2bca..e493472 100644 --- a/ColorCode.Core/Compilation/Languages/Diff.cs +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -39,31 +39,31 @@ public IList Rules return new List { new LanguageRule( - @"(?m)^(((---)|(\*\*\*)) +\d+,\d+ +((----)|(\*\*\*\*))|@@ +\-\d+,\d+ \+\d+,\d+ +@@)", + @"^(((---)|(\*\*\*)) +\d+,\d+ +((----)|(\*\*\*\*))|@@ +\-\d+,\d+ \+\d+,\d+ +@@)(\r?\n?)", new Dictionary { { 0, ScopeName.DiffMeta }, }), new LanguageRule( - @"(?m)^(\*{5}).*(\*{5})$", + @"^(\*{5}).*(\*{5})(\r?\n?)", new Dictionary { { 0, ScopeName.Brackets }, }), new LanguageRule( - @"(?m)^((-{3,})|(\*{3,})|(\+{3,})|(Index:)|(={3,})).*$", + @"^((-{3,})|(\*{3,})|(\+{3,})|(Index:)|(={3,})).*(\r?\n?)", new Dictionary { { 0, ScopeName.Brackets }, }), new LanguageRule( - @"(?m)(^(\+|!).*$)", + @"(^(\+|!).*(\r?\n?))", new Dictionary { { 0, ScopeName.DiffAddition }, }), new LanguageRule( - @"(?m)^\-.*$", + @"^\-.*(\r?\n?)", new Dictionary { { 0, ScopeName.DiffDeletion }, From cc00c4f6cd27f34474c7aecf836fb51c1a549b49 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:08:25 +0200 Subject: [PATCH 06/13] Update Diff colors --- .../Styling/StyleDictionary.DefaultDark.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs index eb5dd34..a93df8b 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs @@ -298,16 +298,21 @@ public static StyleDictionary DefaultDark { ReferenceName = "specialChar" }, - new Style(ScopeName.Addition) + new Style(ScopeName.DiffAddition) { Foreground = Green, - ReferenceName = "addition" + ReferenceName = "diffAddition" }, - new Style(ScopeName.Deletion) + new Style(ScopeName.DiffDeletion) { Foreground = Red, - ReferenceName = "addition" - } + ReferenceName = "diffDeletion" + }, + new Style(ScopeName.DiffMeta) + { + Foreground = OrangeRed, + ReferenceName = "diffMeta" + }, }; } } From fd87dff13a77056a16cde3adb112466ebb5c227d Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:12:58 +0200 Subject: [PATCH 07/13] Update StyleDictionary.DefaultDark.cs --- ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs index a93df8b..a7f1a58 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs @@ -313,6 +313,11 @@ public static StyleDictionary DefaultDark Foreground = OrangeRed, ReferenceName = "diffMeta" }, + new Style(ScopeName.DiffComment) + { + Foreground = VSDarkGray, + ReferenceName = "diffComment" + } }; } } From b0378a4e1a4a11e11bb5ef77dc354546074dfd39 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:14:39 +0200 Subject: [PATCH 08/13] Update StyleDictionary.DefaultLight.cs --- .../Styling/StyleDictionary.DefaultLight.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs index 16403b1..573d765 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 = VSDarkGray, + ReferenceName = "diffComment" + } }; } } } -} \ No newline at end of file +} From a5c59689393a22f5d3d850055147495ecbf28aac Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:14:53 +0200 Subject: [PATCH 09/13] Update StyleDictionary.DefaultLight.cs --- ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs index 573d765..2f32d31 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs @@ -298,7 +298,7 @@ public static StyleDictionary DefaultLight }, new Style(ScopeName.DiffComment) { - Foreground = VSDarkGray, + Foreground = Gray, ReferenceName = "diffComment" } }; From 652c0ae4e07307dd4ac65b775973e00ada55dcf7 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:15:41 +0200 Subject: [PATCH 10/13] Update Diff.cs --- ColorCode.Core/Compilation/Languages/Diff.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs index e493472..714f706 100644 --- a/ColorCode.Core/Compilation/Languages/Diff.cs +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -48,13 +48,13 @@ public IList Rules @"^(\*{5}).*(\*{5})(\r?\n?)", new Dictionary { - { 0, ScopeName.Brackets }, + { 0, ScopeName.DiffComment }, }), new LanguageRule( @"^((-{3,})|(\*{3,})|(\+{3,})|(Index:)|(={3,})).*(\r?\n?)", new Dictionary { - { 0, ScopeName.Brackets }, + { 0, ScopeName.DiffComment }, }), new LanguageRule( @"(^(\+|!).*(\r?\n?))", From 5d8e7673c7e27bc5b26d4be67ec4d86a1cd968ef Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:16:58 +0200 Subject: [PATCH 11/13] Added Diff-specific scopes --- ColorCode.Core/Common/ScopeName.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 +} From ae2d78a8e03ce07bd19c875d8dacb86e0045cfa7 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 16:55:52 +0200 Subject: [PATCH 12/13] Fixed typo --- ColorCode.Core/Compilation/Languages/Diff.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs index 714f706..5d3bd47 100644 --- a/ColorCode.Core/Compilation/Languages/Diff.cs +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using ColorSyntax.Common; -namespace ColorSyntax.Compilation.Languages +namespace ColorCode.Compilation.Languages { public class Diff : ILanguage { From 8006024cc580d6b81436ee4e3cf120ac221b2091 Mon Sep 17 00:00:00 2001 From: karmaecrivain94 Date: Wed, 13 Jun 2018 17:40:58 +0200 Subject: [PATCH 13/13] Fixed typo --- ColorCode.Core/Compilation/Languages/Diff.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ColorCode.Core/Compilation/Languages/Diff.cs b/ColorCode.Core/Compilation/Languages/Diff.cs index 5d3bd47..2b6e713 100644 --- a/ColorCode.Core/Compilation/Languages/Diff.cs +++ b/ColorCode.Core/Compilation/Languages/Diff.cs @@ -3,7 +3,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. using System.Collections.Generic; -using ColorSyntax.Common; +using ColorCode.Common; namespace ColorCode.Compilation.Languages {