Skip to content

Commit ec0f848

Browse files
-Added CSharp Number Scope.
-Added Async Keywords to FSharp and VbDotNet. -Created an Alternate DefaultDark Theme, needs work to make it dark friendly. -Moved DefaultLight and DefaultDark to their own Partial file definitions for StyleDictionary. -Added Dark Theme tests to the Test App. Added Horizontal Scroll to RichTextBlock tests. -You can now Specify ElementTheme to RichTextBlockFormatter, it will determine the default Style Dictionary to use. -Added Background theming to HtmlClassFormatter. -Made Styles property public on CodeColorzerBase.
1 parent e070cee commit ec0f848

14 files changed

Lines changed: 686 additions & 331 deletions

File tree

ColorCode.Core/CodeColorizerBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public CodeColorizerBase(StyleDictionary Styles, ILanguageParser languageParser)
1717
this.languageParser = languageParser
1818
?? new LanguageParser(new LanguageCompiler(Languages.CompiledLanguages), Languages.LanguageRepository);
1919

20-
this.Styles = Styles ?? StyleDictionary.Default;
20+
this.Styles = Styles ?? StyleDictionary.DefaultLight;
2121
}
2222

2323
/// <summary>
@@ -35,6 +35,6 @@ public CodeColorizerBase(StyleDictionary Styles, ILanguageParser languageParser)
3535
/// <summary>
3636
/// The styles to Apply to the formatted Code.
3737
/// </summary>
38-
protected readonly StyleDictionary Styles;
38+
public readonly StyleDictionary Styles;
3939
}
4040
}

ColorCode.Core/Compilation/Languages/CSharp.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ public IList<LanguageRule> Rules
9393
{
9494
{ 1, ScopeName.Keyword }
9595
}),
96+
new LanguageRule(
97+
@"\b[0-9]{1,}\b",
98+
new Dictionary<int, string>
99+
{
100+
{ 0, ScopeName.Number }
101+
}),
102+
/* WIP
103+
new LanguageRule(
104+
@"\b((?=<modifiers>public|protected|internal|private|abstract)?(?(?=<modifiers>) |[^]))[a-zA-Z][a-zA-Z0-9.]{1,})){1,}",
105+
new Dictionary<int, string>
106+
{
107+
{ 0, ScopeName.ClassName }
108+
}), */
96109
};
97110
}
98111
}

ColorCode.Core/Compilation/Languages/FSharp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public IList<LanguageRule> Rules
9393
{ 1, ScopeName.Keyword }
9494
}),
9595
new LanguageRule(
96-
@"\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|sig|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|atomic|break|checked|component|const|constraint|constructor|continue|eager|fixed|fori|functor|include|measure|method|mixin|object|parallel|params|process|protected|pure|recursive|sealed|tailcall|trait|virtual|volatile)\b",
96+
@"\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|sig|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|atomic|break|checked|component|const|constraint|constructor|continue|eager|fixed|fori|functor|include|measure|method|mixin|object|parallel|params|process|protected|pure|recursive|sealed|tailcall|trait|virtual|volatile|async|let!|use!|do!)\b",
9797
new Dictionary<int, string>
9898
{
9999
{ 1, ScopeName.Keyword }

ColorCode.Core/Compilation/Languages/VbDotNet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public IList<LanguageRule> Rules
6161
{ 1, ScopeName.PreprocessorKeyword },
6262
}),
6363
new LanguageRule(
64-
@"(?i)\b(AddHandler|AddressOf|Aggregate|Alias|All|And|AndAlso|Ansi|Any|As|Ascending|(?<!<)Assembly|Auto|Average|Boolean|By|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDec|CDbl|Char|CInt|Class|CLng|CObj|Const|Continue|Count|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|DefaultStyleSheet|Delegate|Descending|Dim|DirectCast|Distinct|Do|Double|Each|Else|ElseIf|End|Enum|Equals|Erase|Error|Event|Exit|Explicit|False|Finally|For|Friend|From|Function|Get|GetType|GoSub|GoTo|Group|Group|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Into|Is|IsNot|Join|Let|Lib|Like|Long|LongCount|Loop|Max|Me|Min|Mod|Module|MustInherit|MustOverride|My|MyBase|MyClass|Namespace|New|Next|Not|Nothing|NotInheritable|NotOverridable|(?<!\.)Object|Off|On|Option|Optional|Or|Order|OrElse|Overloads|Overridable|Overrides|ParamArray|Partial|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Skip|Static|Step|Stop|String|Structure|Sub|Sum|SyncLock|Take|Then|Throw|To|True|Try|TypeOf|Unicode|Until|Variant|When|Where|While|With|WithEvents|WriteOnly|Xor|SByte|UInteger|ULong|UShort|Using|CSByte|CUInt|CULng|CUShort)\b",
64+
@"(?i)\b(AddHandler|AddressOf|Aggregate|Alias|All|And|AndAlso|Ansi|Any|As|Ascending|(?<!<)Assembly|Auto|Average|Boolean|By|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDec|CDbl|Char|CInt|Class|CLng|CObj|Const|Continue|Count|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|DefaultStyleSheet|Delegate|Descending|Dim|DirectCast|Distinct|Do|Double|Each|Else|ElseIf|End|Enum|Equals|Erase|Error|Event|Exit|Explicit|False|Finally|For|Friend|From|Function|Get|GetType|GoSub|GoTo|Group|Group|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Into|Is|IsNot|Join|Let|Lib|Like|Long|LongCount|Loop|Max|Me|Min|Mod|Module|MustInherit|MustOverride|My|MyBase|MyClass|Namespace|New|Next|Not|Nothing|NotInheritable|NotOverridable|(?<!\.)Object|Off|On|Option|Optional|Or|Order|OrElse|Overloads|Overridable|Overrides|ParamArray|Partial|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Skip|Static|Step|Stop|String|Structure|Sub|Sum|SyncLock|Take|Then|Throw|To|True|Try|TypeOf|Unicode|Until|Variant|When|Where|While|With|WithEvents|WriteOnly|Xor|SByte|UInteger|ULong|UShort|Using|CSByte|CUInt|CULng|CUShort|Async|Await)\b",
6565
new Dictionary<int, string>
6666
{
6767
{ 1, ScopeName.Keyword },
Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
using ColorCode.Common;
2+
3+
namespace ColorCode.Styling
4+
{
5+
/// <summary>
6+
/// Defines the Default Dark Theme.
7+
/// </summary>
8+
public partial class StyleDictionary
9+
{
10+
/// <summary>
11+
/// A theme with Dark Colors.
12+
/// </summary>
13+
public static StyleDictionary DefaultDark
14+
{
15+
get
16+
{
17+
return new StyleDictionary
18+
{
19+
new Style(ScopeName.PlainText)
20+
{
21+
Foreground = White,
22+
Background = VSDarkBackground,
23+
ReferenceName = "plainText"
24+
},
25+
new Style(ScopeName.HtmlServerSideScript)
26+
{
27+
Background = Yellow,
28+
ReferenceName = "htmlServerSideScript"
29+
},
30+
new Style(ScopeName.HtmlComment)
31+
{
32+
Foreground = Green,
33+
ReferenceName = "htmlComment"
34+
},
35+
new Style(ScopeName.HtmlTagDelimiter)
36+
{
37+
Foreground = Blue,
38+
ReferenceName = "htmlTagDelimiter"
39+
},
40+
new Style(ScopeName.HtmlElementName)
41+
{
42+
Foreground = DullRed,
43+
ReferenceName = "htmlElementName"
44+
},
45+
new Style(ScopeName.HtmlAttributeName)
46+
{
47+
Foreground = Red,
48+
ReferenceName = "htmlAttributeName"
49+
},
50+
new Style(ScopeName.HtmlAttributeValue)
51+
{
52+
Foreground = Blue,
53+
ReferenceName = "htmlAttributeValue"
54+
},
55+
new Style(ScopeName.HtmlOperator)
56+
{
57+
Foreground = Blue,
58+
ReferenceName = "htmlOperator"
59+
},
60+
new Style(ScopeName.Comment)
61+
{
62+
Foreground = Green,
63+
ReferenceName = "comment"
64+
},
65+
new Style(ScopeName.XmlDocTag)
66+
{
67+
Foreground = Green,
68+
ReferenceName = "xmlDocTag"
69+
},
70+
new Style(ScopeName.XmlDocComment)
71+
{
72+
Foreground = Gray,
73+
ReferenceName = "xmlDocComment"
74+
},
75+
new Style(ScopeName.String)
76+
{
77+
Foreground = DullRed,
78+
ReferenceName = "string"
79+
},
80+
new Style(ScopeName.StringCSharpVerbatim)
81+
{
82+
Foreground = DullRed,
83+
ReferenceName = "stringCSharpVerbatim"
84+
},
85+
new Style(ScopeName.Keyword)
86+
{
87+
Foreground = Blue,
88+
ReferenceName = "keyword"
89+
},
90+
new Style(ScopeName.PreprocessorKeyword)
91+
{
92+
Foreground = Blue,
93+
ReferenceName = "preprocessorKeyword"
94+
},
95+
new Style(ScopeName.HtmlEntity)
96+
{
97+
Foreground = Red,
98+
ReferenceName = "htmlEntity"
99+
},
100+
new Style(ScopeName.XmlAttribute)
101+
{
102+
Foreground = Red,
103+
ReferenceName = "xmlAttribute"
104+
},
105+
new Style(ScopeName.XmlAttributeQuotes)
106+
{
107+
Foreground = Black,
108+
ReferenceName = "xmlAttributeQuotes"
109+
},
110+
new Style(ScopeName.XmlAttributeValue)
111+
{
112+
Foreground = Blue,
113+
ReferenceName = "xmlAttributeValue"
114+
},
115+
new Style(ScopeName.XmlCDataSection)
116+
{
117+
Foreground = Gray,
118+
ReferenceName = "xmlCDataSection"
119+
},
120+
new Style(ScopeName.XmlComment)
121+
{
122+
Foreground = Green,
123+
ReferenceName = "xmlComment"
124+
},
125+
new Style(ScopeName.XmlDelimiter)
126+
{
127+
Foreground = Blue,
128+
ReferenceName = "xmlDelimiter"
129+
},
130+
new Style(ScopeName.XmlName)
131+
{
132+
Foreground = DullRed,
133+
ReferenceName = "xmlName"
134+
},
135+
new Style(ScopeName.ClassName)
136+
{
137+
Foreground = MediumTurqoise,
138+
ReferenceName = "className"
139+
},
140+
new Style(ScopeName.CssSelector)
141+
{
142+
Foreground = DullRed,
143+
ReferenceName = "cssSelector"
144+
},
145+
new Style(ScopeName.CssPropertyName)
146+
{
147+
Foreground = Red,
148+
ReferenceName = "cssPropertyName"
149+
},
150+
new Style(ScopeName.CssPropertyValue)
151+
{
152+
Foreground = Blue,
153+
ReferenceName = "cssPropertyValue"
154+
},
155+
new Style(ScopeName.SqlSystemFunction)
156+
{
157+
Foreground = Magenta,
158+
ReferenceName = "sqlSystemFunction"
159+
},
160+
new Style(ScopeName.PowerShellAttribute)
161+
{
162+
Foreground = PowderBlue,
163+
ReferenceName = "powershellAttribute"
164+
},
165+
new Style(ScopeName.PowerShellOperator)
166+
{
167+
Foreground = Gray,
168+
ReferenceName = "powershellOperator"
169+
},
170+
new Style(ScopeName.PowerShellType)
171+
{
172+
Foreground = Teal,
173+
ReferenceName = "powershellType"
174+
},
175+
new Style(ScopeName.PowerShellVariable)
176+
{
177+
Foreground = OrangeRed,
178+
ReferenceName = "powershellVariable"
179+
},
180+
181+
new Style(ScopeName.Type)
182+
{
183+
Foreground = Teal,
184+
ReferenceName = "type"
185+
},
186+
new Style(ScopeName.TypeVariable)
187+
{
188+
Foreground = Teal,
189+
Italic = true,
190+
ReferenceName = "typeVariable"
191+
},
192+
new Style(ScopeName.NameSpace)
193+
{
194+
Foreground = Navy,
195+
ReferenceName = "namespace"
196+
},
197+
new Style(ScopeName.Constructor)
198+
{
199+
Foreground = Purple,
200+
ReferenceName = "constructor"
201+
},
202+
new Style(ScopeName.Predefined)
203+
{
204+
Foreground = Navy,
205+
ReferenceName = "predefined"
206+
},
207+
new Style(ScopeName.PseudoKeyword)
208+
{
209+
Foreground = Navy,
210+
ReferenceName = "pseudoKeyword"
211+
},
212+
new Style(ScopeName.StringEscape)
213+
{
214+
Foreground = Gray,
215+
ReferenceName = "stringEscape"
216+
},
217+
new Style(ScopeName.ControlKeyword)
218+
{
219+
Foreground = Blue,
220+
ReferenceName = "controlKeyword"
221+
},
222+
new Style(ScopeName.Number)
223+
{
224+
ReferenceName = "number",
225+
Foreground = NumberGreen
226+
},
227+
new Style(ScopeName.Operator)
228+
{
229+
ReferenceName = "operator"
230+
},
231+
new Style(ScopeName.Delimiter)
232+
{
233+
ReferenceName = "delimiter"
234+
},
235+
236+
new Style(ScopeName.MarkdownHeader)
237+
{
238+
Foreground = Blue,
239+
Bold = true,
240+
ReferenceName = "markdownHeader"
241+
},
242+
new Style(ScopeName.MarkdownCode)
243+
{
244+
Foreground = Teal,
245+
ReferenceName = "markdownCode"
246+
},
247+
new Style(ScopeName.MarkdownListItem)
248+
{
249+
Bold = true,
250+
ReferenceName = "markdownListItem"
251+
},
252+
new Style(ScopeName.MarkdownEmph)
253+
{
254+
Italic = true,
255+
ReferenceName = "italic"
256+
},
257+
new Style(ScopeName.MarkdownBold)
258+
{
259+
Bold = true,
260+
ReferenceName = "bold"
261+
},
262+
263+
new Style(ScopeName.BuiltinFunction)
264+
{
265+
Foreground = OliveDrab,
266+
Bold = true,
267+
ReferenceName = "builtinFunction"
268+
},
269+
new Style(ScopeName.BuiltinValue)
270+
{
271+
Foreground = DarkOliveGreen,
272+
Bold = true,
273+
ReferenceName = "builtinValue"
274+
},
275+
new Style(ScopeName.Attribute)
276+
{
277+
Foreground = DarkCyan,
278+
Italic = true,
279+
ReferenceName = "attribute"
280+
},
281+
new Style(ScopeName.SpecialCharacter)
282+
{
283+
ReferenceName = "specialChar"
284+
},
285+
};
286+
}
287+
}
288+
}
289+
}

0 commit comments

Comments
 (0)