-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.
This commit is contained in:
Родитель
e070cee927
Коммит
ec0f848237
|
@ -17,7 +17,7 @@ namespace ColorCode
|
|||
this.languageParser = languageParser
|
||||
?? new LanguageParser(new LanguageCompiler(Languages.CompiledLanguages), Languages.LanguageRepository);
|
||||
|
||||
this.Styles = Styles ?? StyleDictionary.Default;
|
||||
this.Styles = Styles ?? StyleDictionary.DefaultLight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -35,6 +35,6 @@ namespace ColorCode
|
|||
/// <summary>
|
||||
/// The styles to Apply to the formatted Code.
|
||||
/// </summary>
|
||||
protected readonly StyleDictionary Styles;
|
||||
public readonly StyleDictionary Styles;
|
||||
}
|
||||
}
|
|
@ -93,6 +93,19 @@ namespace ColorCode.Compilation.Languages
|
|||
{
|
||||
{ 1, ScopeName.Keyword }
|
||||
}),
|
||||
new LanguageRule(
|
||||
@"\b[0-9]{1,}\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Number }
|
||||
}),
|
||||
/* WIP
|
||||
new LanguageRule(
|
||||
@"\b((?=<modifiers>public|protected|internal|private|abstract)?(?(?=<modifiers>) |[^]))[a-zA-Z][a-zA-Z0-9.]{1,})){1,}",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.ClassName }
|
||||
}), */
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace ColorCode.Compilation.Languages
|
|||
{ 1, ScopeName.Keyword }
|
||||
}),
|
||||
new LanguageRule(
|
||||
@"\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",
|
||||
@"\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",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 1, ScopeName.Keyword }
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace ColorCode.Compilation.Languages
|
|||
{ 1, ScopeName.PreprocessorKeyword },
|
||||
}),
|
||||
new LanguageRule(
|
||||
@"(?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",
|
||||
@"(?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",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 1, ScopeName.Keyword },
|
||||
|
|
|
@ -0,0 +1,289 @@
|
|||
using ColorCode.Common;
|
||||
|
||||
namespace ColorCode.Styling
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the Default Dark Theme.
|
||||
/// </summary>
|
||||
public partial class StyleDictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// A theme with Dark Colors.
|
||||
/// </summary>
|
||||
public static StyleDictionary DefaultDark
|
||||
{
|
||||
get
|
||||
{
|
||||
return new StyleDictionary
|
||||
{
|
||||
new Style(ScopeName.PlainText)
|
||||
{
|
||||
Foreground = White,
|
||||
Background = VSDarkBackground,
|
||||
ReferenceName = "plainText"
|
||||
},
|
||||
new Style(ScopeName.HtmlServerSideScript)
|
||||
{
|
||||
Background = Yellow,
|
||||
ReferenceName = "htmlServerSideScript"
|
||||
},
|
||||
new Style(ScopeName.HtmlComment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "htmlComment"
|
||||
},
|
||||
new Style(ScopeName.HtmlTagDelimiter)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "htmlTagDelimiter"
|
||||
},
|
||||
new Style(ScopeName.HtmlElementName)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "htmlElementName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeName)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "htmlAttributeName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeValue)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "htmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.HtmlOperator)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "htmlOperator"
|
||||
},
|
||||
new Style(ScopeName.Comment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "comment"
|
||||
},
|
||||
new Style(ScopeName.XmlDocTag)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "xmlDocTag"
|
||||
},
|
||||
new Style(ScopeName.XmlDocComment)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "xmlDocComment"
|
||||
},
|
||||
new Style(ScopeName.String)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "string"
|
||||
},
|
||||
new Style(ScopeName.StringCSharpVerbatim)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "stringCSharpVerbatim"
|
||||
},
|
||||
new Style(ScopeName.Keyword)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "keyword"
|
||||
},
|
||||
new Style(ScopeName.PreprocessorKeyword)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "preprocessorKeyword"
|
||||
},
|
||||
new Style(ScopeName.HtmlEntity)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "htmlEntity"
|
||||
},
|
||||
new Style(ScopeName.XmlAttribute)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "xmlAttribute"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeQuotes)
|
||||
{
|
||||
Foreground = Black,
|
||||
ReferenceName = "xmlAttributeQuotes"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeValue)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "xmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.XmlCDataSection)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "xmlCDataSection"
|
||||
},
|
||||
new Style(ScopeName.XmlComment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "xmlComment"
|
||||
},
|
||||
new Style(ScopeName.XmlDelimiter)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "xmlDelimiter"
|
||||
},
|
||||
new Style(ScopeName.XmlName)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "xmlName"
|
||||
},
|
||||
new Style(ScopeName.ClassName)
|
||||
{
|
||||
Foreground = MediumTurqoise,
|
||||
ReferenceName = "className"
|
||||
},
|
||||
new Style(ScopeName.CssSelector)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "cssSelector"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyName)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "cssPropertyName"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyValue)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "cssPropertyValue"
|
||||
},
|
||||
new Style(ScopeName.SqlSystemFunction)
|
||||
{
|
||||
Foreground = Magenta,
|
||||
ReferenceName = "sqlSystemFunction"
|
||||
},
|
||||
new Style(ScopeName.PowerShellAttribute)
|
||||
{
|
||||
Foreground = PowderBlue,
|
||||
ReferenceName = "powershellAttribute"
|
||||
},
|
||||
new Style(ScopeName.PowerShellOperator)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "powershellOperator"
|
||||
},
|
||||
new Style(ScopeName.PowerShellType)
|
||||
{
|
||||
Foreground = Teal,
|
||||
ReferenceName = "powershellType"
|
||||
},
|
||||
new Style(ScopeName.PowerShellVariable)
|
||||
{
|
||||
Foreground = OrangeRed,
|
||||
ReferenceName = "powershellVariable"
|
||||
},
|
||||
|
||||
new Style(ScopeName.Type)
|
||||
{
|
||||
Foreground = Teal,
|
||||
ReferenceName = "type"
|
||||
},
|
||||
new Style(ScopeName.TypeVariable)
|
||||
{
|
||||
Foreground = Teal,
|
||||
Italic = true,
|
||||
ReferenceName = "typeVariable"
|
||||
},
|
||||
new Style(ScopeName.NameSpace)
|
||||
{
|
||||
Foreground = Navy,
|
||||
ReferenceName = "namespace"
|
||||
},
|
||||
new Style(ScopeName.Constructor)
|
||||
{
|
||||
Foreground = Purple,
|
||||
ReferenceName = "constructor"
|
||||
},
|
||||
new Style(ScopeName.Predefined)
|
||||
{
|
||||
Foreground = Navy,
|
||||
ReferenceName = "predefined"
|
||||
},
|
||||
new Style(ScopeName.PseudoKeyword)
|
||||
{
|
||||
Foreground = Navy,
|
||||
ReferenceName = "pseudoKeyword"
|
||||
},
|
||||
new Style(ScopeName.StringEscape)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "stringEscape"
|
||||
},
|
||||
new Style(ScopeName.ControlKeyword)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "controlKeyword"
|
||||
},
|
||||
new Style(ScopeName.Number)
|
||||
{
|
||||
ReferenceName = "number",
|
||||
Foreground = NumberGreen
|
||||
},
|
||||
new Style(ScopeName.Operator)
|
||||
{
|
||||
ReferenceName = "operator"
|
||||
},
|
||||
new Style(ScopeName.Delimiter)
|
||||
{
|
||||
ReferenceName = "delimiter"
|
||||
},
|
||||
|
||||
new Style(ScopeName.MarkdownHeader)
|
||||
{
|
||||
Foreground = Blue,
|
||||
Bold = true,
|
||||
ReferenceName = "markdownHeader"
|
||||
},
|
||||
new Style(ScopeName.MarkdownCode)
|
||||
{
|
||||
Foreground = Teal,
|
||||
ReferenceName = "markdownCode"
|
||||
},
|
||||
new Style(ScopeName.MarkdownListItem)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "markdownListItem"
|
||||
},
|
||||
new Style(ScopeName.MarkdownEmph)
|
||||
{
|
||||
Italic = true,
|
||||
ReferenceName = "italic"
|
||||
},
|
||||
new Style(ScopeName.MarkdownBold)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "bold"
|
||||
},
|
||||
|
||||
new Style(ScopeName.BuiltinFunction)
|
||||
{
|
||||
Foreground = OliveDrab,
|
||||
Bold = true,
|
||||
ReferenceName = "builtinFunction"
|
||||
},
|
||||
new Style(ScopeName.BuiltinValue)
|
||||
{
|
||||
Foreground = DarkOliveGreen,
|
||||
Bold = true,
|
||||
ReferenceName = "builtinValue"
|
||||
},
|
||||
new Style(ScopeName.Attribute)
|
||||
{
|
||||
Foreground = DarkCyan,
|
||||
Italic = true,
|
||||
ReferenceName = "attribute"
|
||||
},
|
||||
new Style(ScopeName.SpecialCharacter)
|
||||
{
|
||||
ReferenceName = "specialChar"
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
using ColorCode.Common;
|
||||
|
||||
namespace ColorCode.Styling
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the Default Light Theme.
|
||||
/// </summary>
|
||||
public partial class StyleDictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// A theme with Light Colors.
|
||||
/// </summary>
|
||||
public static StyleDictionary DefaultLight
|
||||
{
|
||||
get
|
||||
{
|
||||
return new StyleDictionary
|
||||
{
|
||||
new Style(ScopeName.PlainText)
|
||||
{
|
||||
Foreground = Black,
|
||||
Background = White,
|
||||
ReferenceName = "plainText"
|
||||
},
|
||||
new Style(ScopeName.HtmlServerSideScript)
|
||||
{
|
||||
Background = Yellow,
|
||||
ReferenceName = "htmlServerSideScript"
|
||||
},
|
||||
new Style(ScopeName.HtmlComment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "htmlComment"
|
||||
},
|
||||
new Style(ScopeName.HtmlTagDelimiter)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "htmlTagDelimiter"
|
||||
},
|
||||
new Style(ScopeName.HtmlElementName)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "htmlElementName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeName)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "htmlAttributeName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeValue)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "htmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.HtmlOperator)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "htmlOperator"
|
||||
},
|
||||
new Style(ScopeName.Comment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "comment"
|
||||
},
|
||||
new Style(ScopeName.XmlDocTag)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "xmlDocTag"
|
||||
},
|
||||
new Style(ScopeName.XmlDocComment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "xmlDocComment"
|
||||
},
|
||||
new Style(ScopeName.String)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "string"
|
||||
},
|
||||
new Style(ScopeName.StringCSharpVerbatim)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "stringCSharpVerbatim"
|
||||
},
|
||||
new Style(ScopeName.Keyword)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "keyword"
|
||||
},
|
||||
new Style(ScopeName.PreprocessorKeyword)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "preprocessorKeyword"
|
||||
},
|
||||
new Style(ScopeName.HtmlEntity)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "htmlEntity"
|
||||
},
|
||||
new Style(ScopeName.XmlAttribute)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "xmlAttribute"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeQuotes)
|
||||
{
|
||||
Foreground = Black,
|
||||
ReferenceName = "xmlAttributeQuotes"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeValue)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "xmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.XmlCDataSection)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "xmlCDataSection"
|
||||
},
|
||||
new Style(ScopeName.XmlComment)
|
||||
{
|
||||
Foreground = Green,
|
||||
ReferenceName = "xmlComment"
|
||||
},
|
||||
new Style(ScopeName.XmlDelimiter)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "xmlDelimiter"
|
||||
},
|
||||
new Style(ScopeName.XmlName)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "xmlName"
|
||||
},
|
||||
new Style(ScopeName.ClassName)
|
||||
{
|
||||
Foreground = MediumTurqoise,
|
||||
ReferenceName = "className"
|
||||
},
|
||||
new Style(ScopeName.CssSelector)
|
||||
{
|
||||
Foreground = DullRed,
|
||||
ReferenceName = "cssSelector"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyName)
|
||||
{
|
||||
Foreground = Red,
|
||||
ReferenceName = "cssPropertyName"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyValue)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "cssPropertyValue"
|
||||
},
|
||||
new Style(ScopeName.SqlSystemFunction)
|
||||
{
|
||||
Foreground = Magenta,
|
||||
ReferenceName = "sqlSystemFunction"
|
||||
},
|
||||
new Style(ScopeName.PowerShellAttribute)
|
||||
{
|
||||
Foreground = PowderBlue,
|
||||
ReferenceName = "powershellAttribute"
|
||||
},
|
||||
new Style(ScopeName.PowerShellOperator)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "powershellOperator"
|
||||
},
|
||||
new Style(ScopeName.PowerShellType)
|
||||
{
|
||||
Foreground = Teal,
|
||||
ReferenceName = "powershellType"
|
||||
},
|
||||
new Style(ScopeName.PowerShellVariable)
|
||||
{
|
||||
Foreground = OrangeRed,
|
||||
ReferenceName = "powershellVariable"
|
||||
},
|
||||
|
||||
new Style(ScopeName.Type)
|
||||
{
|
||||
Foreground = Teal,
|
||||
ReferenceName = "type"
|
||||
},
|
||||
new Style(ScopeName.TypeVariable)
|
||||
{
|
||||
Foreground = Teal,
|
||||
Italic = true,
|
||||
ReferenceName = "typeVariable"
|
||||
},
|
||||
new Style(ScopeName.NameSpace)
|
||||
{
|
||||
Foreground = Navy,
|
||||
ReferenceName = "namespace"
|
||||
},
|
||||
new Style(ScopeName.Constructor)
|
||||
{
|
||||
Foreground = Purple,
|
||||
ReferenceName = "constructor"
|
||||
},
|
||||
new Style(ScopeName.Predefined)
|
||||
{
|
||||
Foreground = Navy,
|
||||
ReferenceName = "predefined"
|
||||
},
|
||||
new Style(ScopeName.PseudoKeyword)
|
||||
{
|
||||
Foreground = Navy,
|
||||
ReferenceName = "pseudoKeyword"
|
||||
},
|
||||
new Style(ScopeName.StringEscape)
|
||||
{
|
||||
Foreground = Gray,
|
||||
ReferenceName = "stringEscape"
|
||||
},
|
||||
new Style(ScopeName.ControlKeyword)
|
||||
{
|
||||
Foreground = Blue,
|
||||
ReferenceName = "controlKeyword"
|
||||
},
|
||||
new Style(ScopeName.Number)
|
||||
{
|
||||
ReferenceName = "number"
|
||||
},
|
||||
new Style(ScopeName.Operator)
|
||||
{
|
||||
ReferenceName = "operator"
|
||||
},
|
||||
new Style(ScopeName.Delimiter)
|
||||
{
|
||||
ReferenceName = "delimiter"
|
||||
},
|
||||
|
||||
new Style(ScopeName.MarkdownHeader)
|
||||
{
|
||||
Foreground = Blue,
|
||||
Bold = true,
|
||||
ReferenceName = "markdownHeader"
|
||||
},
|
||||
new Style(ScopeName.MarkdownCode)
|
||||
{
|
||||
Foreground = Teal,
|
||||
ReferenceName = "markdownCode"
|
||||
},
|
||||
new Style(ScopeName.MarkdownListItem)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "markdownListItem"
|
||||
},
|
||||
new Style(ScopeName.MarkdownEmph)
|
||||
{
|
||||
Italic = true,
|
||||
ReferenceName = "italic"
|
||||
},
|
||||
new Style(ScopeName.MarkdownBold)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "bold"
|
||||
},
|
||||
|
||||
new Style(ScopeName.BuiltinFunction)
|
||||
{
|
||||
Foreground = OliveDrab,
|
||||
Bold = true,
|
||||
ReferenceName = "builtinFunction"
|
||||
},
|
||||
new Style(ScopeName.BuiltinValue)
|
||||
{
|
||||
Foreground = DarkOliveGreen,
|
||||
Bold = true,
|
||||
ReferenceName = "builtinValue"
|
||||
},
|
||||
new Style(ScopeName.Attribute)
|
||||
{
|
||||
Foreground = DarkCyan,
|
||||
Italic = true,
|
||||
ReferenceName = "attribute"
|
||||
},
|
||||
new Style(ScopeName.SpecialCharacter)
|
||||
{
|
||||
ReferenceName = "specialChar"
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
using ColorCode.Common;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace ColorCode.Styling
|
||||
|
@ -8,7 +7,7 @@ namespace ColorCode.Styling
|
|||
/// <summary>
|
||||
/// A dictionary of <see cref="Style" /> instances, keyed by the styles' scope name.
|
||||
/// </summary>
|
||||
public class StyleDictionary : KeyedCollection<string, Style>
|
||||
public partial class StyleDictionary : KeyedCollection<string, Style>
|
||||
{
|
||||
/// <summary>
|
||||
/// When implemented in a derived class, extracts the key from the specified element.
|
||||
|
@ -20,298 +19,25 @@ namespace ColorCode.Styling
|
|||
return item.ScopeName;
|
||||
}
|
||||
|
||||
public static StyleDictionary Default
|
||||
{
|
||||
get
|
||||
{
|
||||
var blue = "#FF0000FF";
|
||||
var white = "#FFFFFFFF";
|
||||
var black = "#FF000000";
|
||||
var dullRed = "#FFA31515";
|
||||
var yellow = "#FFFFFF00";
|
||||
var green = "#FF008000";
|
||||
var powderBlue = "#FFB0E0E6";
|
||||
var teal = "#FF008080";
|
||||
var gray = "#FF808080";
|
||||
var navy = "#FF000080";
|
||||
var orangeRed = "#FFFF4500";
|
||||
var purple = "#FF800080";
|
||||
var red = "#FFFF0000";
|
||||
var mediumTurqoise = "FF48D1CC";
|
||||
var magenta = "FFFF00FF";
|
||||
var oliveDrab = "#FF6B8E23";
|
||||
var darkOliveGreen = "#FF556B2F";
|
||||
var darkCyan = "#FF008B8B";
|
||||
|
||||
return new StyleDictionary
|
||||
{
|
||||
new Style(ScopeName.PlainText)
|
||||
{
|
||||
Foreground = black,
|
||||
Background = white,
|
||||
ReferenceName = "plainText"
|
||||
},
|
||||
new Style(ScopeName.HtmlServerSideScript)
|
||||
{
|
||||
Background = yellow,
|
||||
ReferenceName = "htmlServerSideScript"
|
||||
},
|
||||
new Style(ScopeName.HtmlComment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "htmlComment"
|
||||
},
|
||||
new Style(ScopeName.HtmlTagDelimiter)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlTagDelimiter"
|
||||
},
|
||||
new Style(ScopeName.HtmlElementName)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "htmlElementName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeName)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "htmlAttributeName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeValue)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.HtmlOperator)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlOperator"
|
||||
},
|
||||
new Style(ScopeName.Comment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "comment"
|
||||
},
|
||||
new Style(ScopeName.XmlDocTag)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "xmlDocTag"
|
||||
},
|
||||
new Style(ScopeName.XmlDocComment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "xmlDocComment"
|
||||
},
|
||||
new Style(ScopeName.String)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "string"
|
||||
},
|
||||
new Style(ScopeName.StringCSharpVerbatim)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "stringCSharpVerbatim"
|
||||
},
|
||||
new Style(ScopeName.Keyword)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "keyword"
|
||||
},
|
||||
new Style(ScopeName.PreprocessorKeyword)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "preprocessorKeyword"
|
||||
},
|
||||
new Style(ScopeName.HtmlEntity)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "htmlEntity"
|
||||
},
|
||||
new Style(ScopeName.XmlAttribute)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "xmlAttribute"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeQuotes)
|
||||
{
|
||||
Foreground = black,
|
||||
ReferenceName = "xmlAttributeQuotes"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeValue)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "xmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.XmlCDataSection)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "xmlCDataSection"
|
||||
},
|
||||
new Style(ScopeName.XmlComment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "xmlComment"
|
||||
},
|
||||
new Style(ScopeName.XmlDelimiter)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "xmlDelimiter"
|
||||
},
|
||||
new Style(ScopeName.XmlName)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "xmlName"
|
||||
},
|
||||
new Style(ScopeName.ClassName)
|
||||
{
|
||||
Foreground = mediumTurqoise,
|
||||
ReferenceName = "className"
|
||||
},
|
||||
new Style(ScopeName.CssSelector)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "cssSelector"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyName)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "cssPropertyName"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyValue)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "cssPropertyValue"
|
||||
},
|
||||
new Style(ScopeName.SqlSystemFunction)
|
||||
{
|
||||
Foreground = magenta,
|
||||
ReferenceName = "sqlSystemFunction"
|
||||
},
|
||||
new Style(ScopeName.PowerShellAttribute)
|
||||
{
|
||||
Foreground = powderBlue,
|
||||
ReferenceName = "powershellAttribute"
|
||||
},
|
||||
new Style(ScopeName.PowerShellOperator)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "powershellOperator"
|
||||
},
|
||||
new Style(ScopeName.PowerShellType)
|
||||
{
|
||||
Foreground = teal,
|
||||
ReferenceName = "powershellType"
|
||||
},
|
||||
new Style(ScopeName.PowerShellVariable)
|
||||
{
|
||||
Foreground = orangeRed,
|
||||
ReferenceName = "powershellVariable"
|
||||
},
|
||||
|
||||
new Style(ScopeName.Type)
|
||||
{
|
||||
Foreground = teal,
|
||||
ReferenceName = "type"
|
||||
},
|
||||
new Style(ScopeName.TypeVariable)
|
||||
{
|
||||
Foreground = teal,
|
||||
Italic = true,
|
||||
ReferenceName = "typeVariable"
|
||||
},
|
||||
new Style(ScopeName.NameSpace)
|
||||
{
|
||||
Foreground = navy,
|
||||
ReferenceName = "namespace"
|
||||
},
|
||||
new Style(ScopeName.Constructor)
|
||||
{
|
||||
Foreground = purple,
|
||||
ReferenceName = "constructor"
|
||||
},
|
||||
new Style(ScopeName.Predefined)
|
||||
{
|
||||
Foreground = navy,
|
||||
ReferenceName = "predefined"
|
||||
},
|
||||
new Style(ScopeName.PseudoKeyword)
|
||||
{
|
||||
Foreground = navy,
|
||||
ReferenceName = "pseudoKeyword"
|
||||
},
|
||||
new Style(ScopeName.StringEscape)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "stringEscape"
|
||||
},
|
||||
new Style(ScopeName.ControlKeyword)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "controlKeyword"
|
||||
},
|
||||
new Style(ScopeName.Number)
|
||||
{
|
||||
ReferenceName = "number"
|
||||
},
|
||||
new Style(ScopeName.Operator)
|
||||
{
|
||||
ReferenceName = "operator"
|
||||
},
|
||||
new Style(ScopeName.Delimiter)
|
||||
{
|
||||
ReferenceName = "delimiter"
|
||||
},
|
||||
|
||||
new Style(ScopeName.MarkdownHeader)
|
||||
{
|
||||
Foreground = blue,
|
||||
Bold = true,
|
||||
ReferenceName = "markdownHeader"
|
||||
},
|
||||
new Style(ScopeName.MarkdownCode)
|
||||
{
|
||||
Foreground = teal,
|
||||
ReferenceName = "markdownCode"
|
||||
},
|
||||
new Style(ScopeName.MarkdownListItem)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "markdownListItem"
|
||||
},
|
||||
new Style(ScopeName.MarkdownEmph)
|
||||
{
|
||||
Italic = true,
|
||||
ReferenceName = "italic"
|
||||
},
|
||||
new Style(ScopeName.MarkdownBold)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "bold"
|
||||
},
|
||||
|
||||
new Style(ScopeName.BuiltinFunction)
|
||||
{
|
||||
Foreground = oliveDrab,
|
||||
Bold = true,
|
||||
ReferenceName = "builtinFunction"
|
||||
},
|
||||
new Style(ScopeName.BuiltinValue)
|
||||
{
|
||||
Foreground = darkOliveGreen,
|
||||
Bold = true,
|
||||
ReferenceName = "builtinValue"
|
||||
},
|
||||
new Style(ScopeName.Attribute)
|
||||
{
|
||||
Foreground = darkCyan,
|
||||
Italic = true,
|
||||
ReferenceName = "attribute"
|
||||
},
|
||||
new Style(ScopeName.SpecialCharacter)
|
||||
{
|
||||
ReferenceName = "specialChar"
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
public const string VSDarkBackground = "#FF1E1E1E";
|
||||
public const string Blue = "#FF0000FF";
|
||||
public const string White = "#FFFFFFFF";
|
||||
public const string Black = "#FF000000";
|
||||
public const string DullRed = "#FFA31515";
|
||||
public const string Yellow = "#FFFFFF00";
|
||||
public const string Green = "#FF008000";
|
||||
public const string PowderBlue = "#FFB0E0E6";
|
||||
public const string Teal = "#FF008080";
|
||||
public const string Gray = "#FF808080";
|
||||
public const string Navy = "#FF000080";
|
||||
public const string OrangeRed = "#FFFF4500";
|
||||
public const string Purple = "#FF800080";
|
||||
public const string Red = "#FFFF0000";
|
||||
public const string MediumTurqoise = "FF48D1CC";
|
||||
public const string Magenta = "FFFF00FF";
|
||||
public const string OliveDrab = "#FF6B8E23";
|
||||
public const string DarkOliveGreen = "#FF556B2F";
|
||||
public const string DarkCyan = "#FF008B8B";
|
||||
public const string NumberGreen = "#FFB5CEA8";
|
||||
}
|
||||
}
|
|
@ -60,6 +60,9 @@ namespace ColorCode
|
|||
{
|
||||
var str = new StringBuilder();
|
||||
|
||||
var plainText = Styles[ScopeName.PlainText];
|
||||
if (!string.IsNullOrWhiteSpace(plainText?.Background)) str.Append($"body{{background-color:{plainText.Background};}}");
|
||||
|
||||
foreach (var style in Styles)
|
||||
{
|
||||
str.Append($" .{style.ReferenceName}{{");
|
||||
|
|
|
@ -6,6 +6,7 @@ using ColorCode.Styling;
|
|||
using Windows.UI.Text;
|
||||
using ColorCode.UWP.Common;
|
||||
using ColorCode.Common;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace ColorCode
|
||||
{
|
||||
|
@ -19,7 +20,7 @@ namespace ColorCode
|
|||
/// </summary>
|
||||
/// <param name="Style">The Custom styles to Apply to the formatted Code.</param>
|
||||
/// <param name="languageParser">The language parser that the <see cref="RichTextBlockFormatter"/> instance will use for its lifetime.</param>
|
||||
public RichTextBlockFormatter(StyleDictionary Style = null, ILanguageParser languageParser = null) : base(Style, languageParser)
|
||||
public RichTextBlockFormatter(ElementTheme Theme = ElementTheme.Default, StyleDictionary Style = null, ILanguageParser languageParser = null) : base(Theme == ElementTheme.Dark ? Style ?? StyleDictionary.DefaultDark : Style, languageParser)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,7 @@ namespace ColorCode
|
|||
|
||||
if (Styles.Contains(Scope.Name))
|
||||
{
|
||||
Style style = Styles[Scope.Name];
|
||||
Styling.Style style = Styles[Scope.Name];
|
||||
|
||||
foreground = style.Foreground;
|
||||
background = style.Background;
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NerdbankGitVersioningVersion>2.0.41</NerdbankGitVersioningVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition="'$(IsUwpProject)' == 'true' or '$(IsAndroidProject)' == 'true'">
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -7,16 +7,21 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid x:Name="MainGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<Button Content="Render to Rich Text Block" Click="Load_Click" />
|
||||
<Button Content="Create HTML" Click="MakeHTML" />
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<ScrollViewer VerticalScrollMode="Disabled" HorizontalScrollBarVisibility="Auto" HorizontalScrollMode="Auto">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Render to Rich Text Block Light Theme" Click="RenderLight" Margin="5" />
|
||||
<Button Content="Render to Rich Text Block Dark Theme" Click="RenderDark" Margin="5" />
|
||||
<Button Content="Create HTML Light Theme" Click="HTMLLight" Margin="5" />
|
||||
<Button Content="Create HTML Dark Theme" Click="HTMLDark" Margin="5" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<ScrollViewer Grid.Row="1" IsHorizontalRailEnabled="True" HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
<RichTextBlock x:Name="PresentationBlock" FontFamily="Consolas" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
using System;
|
||||
using ColorCode.Common;
|
||||
using ColorCode.Styling;
|
||||
using ColorCode.UWP.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
|
@ -21,17 +24,6 @@ namespace ColorCode.UWPTests
|
|||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private async void Load_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PresentationBlock.Blocks.Clear();
|
||||
|
||||
var result = await GetCodeFileText();
|
||||
if (result == null) return;
|
||||
|
||||
var formatter = new RichTextBlockFormatter();
|
||||
formatter.FormatRichTextBlock(result.Item1, result.Item2, PresentationBlock);
|
||||
}
|
||||
|
||||
private async Task<Tuple<string, ILanguage>> GetCodeFileText()
|
||||
{
|
||||
var picker = new FileOpenPicker();
|
||||
|
@ -50,12 +42,47 @@ namespace ColorCode.UWPTests
|
|||
return new Tuple<string, ILanguage>(text, Language);
|
||||
}
|
||||
|
||||
private async void MakeHTML(object sender, RoutedEventArgs e)
|
||||
private void RenderLight(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainGrid.RequestedTheme = ElementTheme.Light;
|
||||
Render();
|
||||
}
|
||||
|
||||
private void RenderDark(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainGrid.RequestedTheme = ElementTheme.Dark;
|
||||
Render();
|
||||
}
|
||||
|
||||
private async void Render()
|
||||
{
|
||||
PresentationBlock.Blocks.Clear();
|
||||
|
||||
var result = await GetCodeFileText();
|
||||
if (result == null) return;
|
||||
|
||||
var formatter = new RichTextBlockFormatter(MainGrid.RequestedTheme);
|
||||
var plainText = formatter.Styles[ScopeName.PlainText];
|
||||
MainGrid.Background = (plainText?.Background ?? StyleDictionary.White).GetSolidColorBrush();
|
||||
formatter.FormatRichTextBlock(result.Item1, result.Item2, PresentationBlock);
|
||||
}
|
||||
|
||||
private void HTMLLight(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MakeHTML(StyleDictionary.DefaultLight);
|
||||
}
|
||||
|
||||
private void HTMLDark(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MakeHTML(StyleDictionary.DefaultDark);
|
||||
}
|
||||
|
||||
private async void MakeHTML(StyleDictionary Styles)
|
||||
{
|
||||
var result = await GetCodeFileText();
|
||||
if (result == null) return;
|
||||
|
||||
var formatter = new HtmlFormatter();
|
||||
var formatter = new HtmlFormatter(Styles);
|
||||
var html = formatter.GetHtmlString(result.Item1, result.Item2);
|
||||
|
||||
var tempfile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("HTMLResult.html", CreationCollisionOption.ReplaceExisting);
|
||||
|
|
|
@ -174,9 +174,7 @@ if (!(Test-Path $CAKE_EXE)) {
|
|||
|
||||
# Start Cake
|
||||
Write-Host "Running build script..."
|
||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
|
||||
|
||||
Write-Host "Press any key to continue ..."
|
||||
$fin = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
|
||||
$path = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$Script = "$path/build.cake"
|
||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
|
||||
exit $LASTEXITCODE
|
11
version.json
11
version.json
|
@ -1,3 +1,12 @@
|
|||
{
|
||||
"version": "2.0.1"
|
||||
"version": "2.0.2",
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/master$", // we release out of master
|
||||
"^refs/heads/rel/\\d+\\.\\d+\\.\\d+" // we also release branches starting with rel/N.N.N
|
||||
],
|
||||
"cloudBuild": {
|
||||
"buildNumber": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче