-Added Pragma Warning/Disable to C# Keywords.
-Added Fortan Language Support from: https://colorcode.codeplex.com/SourceControl/network/forks/CPardi/ColorCodeFortran. -Language ID for Sample App is now based on File Extension. -Fixed a rare crash casued by File Encoding issues. -Console is now the RichTextBlock sample font.
This commit is contained in:
Родитель
ef62975904
Коммит
fec1b52566
|
@ -25,5 +25,6 @@ namespace ColorCode.Common
|
|||
public const string Koka = "koka";
|
||||
public const string Haskell = "haskell";
|
||||
public const string Markdown = "markdown";
|
||||
public const string Fortran = "fortran";
|
||||
}
|
||||
}
|
|
@ -53,5 +53,12 @@ namespace ColorCode.Common
|
|||
public const string MarkdownListItem = "Markdown List Item";
|
||||
public const string MarkdownEmph = "Markdown Emphasized";
|
||||
public const string MarkdownBold = "Markdown Bold";
|
||||
public const string BuiltinFunction = "Built In Function";
|
||||
public const string BuiltinValue = "Built In Value";
|
||||
public const string Attribute = "Attribute";
|
||||
public const string SpecialCharacter = "Special Character";
|
||||
public const string Intrinsic = "Intrinsic";
|
||||
public const string Brackets = "Brackets";
|
||||
public const string Continuation = "Continuation";
|
||||
}
|
||||
}
|
|
@ -88,7 +88,7 @@ namespace ColorCode.Compilation.Languages
|
|||
{ 1, ScopeName.PreprocessorKeyword }
|
||||
}),
|
||||
new LanguageRule(
|
||||
@"\b(abstract|as|ascending|base|bool|break|by|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|descending|do|double|dynamic|else|enum|equals|event|explicit|extern|false|finally|fixed|float|for|foreach|from|get|goto|group|if|implicit|in|int|into|interface|internal|is|join|let|lock|long|namespace|new|null|object|on|operator|orderby|out|override|params|partial|private|protected|public|readonly|ref|return|sbyte|sealed|select|set|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|var|virtual|void|volatile|where|while|yield|async|await)\b",
|
||||
@"\b(abstract|as|ascending|base|bool|break|by|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|descending|do|double|dynamic|else|enum|equals|event|explicit|extern|false|finally|fixed|float|for|foreach|from|get|goto|group|if|implicit|in|int|into|interface|internal|is|join|let|lock|long|namespace|new|null|object|on|operator|orderby|out|override|params|partial|private|protected|public|readonly|ref|return|sbyte|sealed|select|set|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|var|virtual|void|volatile|where|while|yield|async|await|warning|disable)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 1, ScopeName.Keyword }
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
// 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 Fortran : 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<LanguageRule> Rules
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<LanguageRule>
|
||||
{
|
||||
// Comments
|
||||
new LanguageRule(
|
||||
@"!.*",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Comment },
|
||||
}),
|
||||
// String type 1
|
||||
new LanguageRule(
|
||||
@""".*?""|'.*?'",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.String },
|
||||
}),
|
||||
// Program keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:program|endprogram)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Module keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:module|endmodule|contains)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Type keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:type|endtype|abstract)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Interface definition keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:interface|endinterface|operator|assignment)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Procedure definition keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:function|endfunction|subroutine|endsubroutine|elemental|recursive|pure)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Variable keywords
|
||||
new LanguageRule(
|
||||
@"(?i)INTEGER|REAL|DOUBLE\s*PRECISION|COMPLEX|CHARACTER|LOGICAL|TYPE",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Attribute keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:parameter|allocatable|optional|pointer|save|dimension|target)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
}),
|
||||
// Intent keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(intent)\s*(\()\s*(in|out|inout)\s*(\))",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 1, ScopeName.Keyword },
|
||||
{ 2, ScopeName.Brackets },
|
||||
{ 3, ScopeName.Keyword },
|
||||
{ 4, ScopeName.Brackets },
|
||||
}),
|
||||
// Namelist
|
||||
new LanguageRule(
|
||||
@"(?i)\b(namelist)(/)\w+(/)",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 1, ScopeName.Keyword },
|
||||
{ 2, ScopeName.Brackets },
|
||||
{ 3, ScopeName.Brackets },
|
||||
}),
|
||||
// Intrinsic functions
|
||||
new LanguageRule(
|
||||
@"(?i)\b(PRESENT" +
|
||||
"|INT|REAL|DBLE|CMPLX|AIMAG|CONJG|AINT|ANINT|NINT|ABS|MOD|SIGN|DIM|DPROD|MODULO|FLOOR|CEILING|MAX|MIN" +
|
||||
"|SQRT|EXP|LOG|LOG10|SIN|COS|TAN|ASIN|ACOS|ATAN|ATAN2|SINH|COSH|TANH" +
|
||||
"|ICHAR|CHAR|LGE|LGT|LLE|LLT|IACHAR|ACHAR|INDEX|VERIFY|ADJUSTL|ADJUSTR|SCAN|LEN_TRIM|REPEAT|TRIM" +
|
||||
"|KIND|SELECTED_INT_KIND|SELECTED_REAL_KIND" +
|
||||
"|LOGICAL" +
|
||||
"|IOR|IAND|NOT|IEOR| ISHFT|ISHFTC|BTEST|IBSET|IBCLR|BITSIZE" +
|
||||
"|TRANSFER" +
|
||||
"|RADIX|DIGITS|MINEXPONENT|MAXEXPONENT|PRECISION|RANGE|HUGE|TINY|EPSILON" +
|
||||
"|EXPONENT|SCALE|NEAREST|FRACTION|SET_EXPONENT|SPACING|RRSPACING" +
|
||||
"|LBOUND|SIZE|UBOUND" +
|
||||
"|MASK" +
|
||||
"|MATMUL|DOT_PRODUCT" +
|
||||
"|SUM|PRODUCT|MAXVAL|MINVAL|COUNT|ANY|ALL" +
|
||||
"|ALLOCATED|SIZE|SHAPE|LBOUND|UBOUND" +
|
||||
"|MERGE|SPREAD|PACK|UNPACK" +
|
||||
"|RESHAPE" +
|
||||
"|TRANSPOSE|EOSHIFT|CSHIFT" +
|
||||
"|MAXLOC|MINLOC" +
|
||||
@"|ASSOCIATED)\b(\()"
|
||||
,
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{1, ScopeName.Intrinsic },
|
||||
{2, ScopeName.Brackets },
|
||||
}),
|
||||
// Intrinsic functions
|
||||
new LanguageRule(
|
||||
@"(?i)(call)\s+(" +
|
||||
"DATE_AND_TIME|SYSTEM_CLOCK" +
|
||||
"|RANDOM_NUMBER|RANDOM_SEED" +
|
||||
"|MVBITS" +
|
||||
")\b"
|
||||
,
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{1, ScopeName.Keyword },
|
||||
{2, ScopeName.Intrinsic },
|
||||
}),
|
||||
// Special Character
|
||||
new LanguageRule(
|
||||
@"\=|\*|\+|\\|\-|\.\w+\.|>|<|::|%|,|;|\?|\$",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.SpecialCharacter },
|
||||
}),
|
||||
// Line Continuation
|
||||
new LanguageRule(
|
||||
@"&",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Continuation },
|
||||
}),
|
||||
// Number
|
||||
new LanguageRule(
|
||||
@"\b[0-9.]+(_\w+)?\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Number },
|
||||
}),
|
||||
// Brackets
|
||||
new LanguageRule(
|
||||
@"[\(\)\[\]]",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Brackets },
|
||||
}),
|
||||
// Preprocessor keywords
|
||||
new LanguageRule(
|
||||
@"(?i)(?:#define|#elif|#elifdef|#elifndef|#else|#endif|#error|#if|#ifdef|#ifndef|#include|#line|#pragma|#undef)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.PreprocessorKeyword },
|
||||
}),
|
||||
// General keywords
|
||||
new LanguageRule(
|
||||
@"(?i)\b(?:end|use|do|enddo|select|endselect|case|endcase|if|then|else|endif|implicit|none"
|
||||
+ @"|do\s+while|call|public|private|protected|where|go\s*to|file|block|data|blockdata"
|
||||
+ @"|end\s*blockdata|default|procedure|include|go\s*to|allocate|deallocate|open|close|write|stop|return)\b",
|
||||
new Dictionary<int, string>
|
||||
{
|
||||
{ 0, ScopeName.Keyword },
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAlias(string lang)
|
||||
{
|
||||
switch (lang.ToLower())
|
||||
{
|
||||
case "fortran":
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,12 +43,13 @@ namespace ColorCode
|
|||
Load<Koka>();
|
||||
Load<Haskell>();
|
||||
Load<Markdown>();
|
||||
Load<Fortran>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerable list of all loaded languages.
|
||||
/// </summary>
|
||||
public static IEnumerable<ILanguage> All
|
||||
public static IEnumerable<ILanguage> All
|
||||
{
|
||||
get { return LanguageRepository.All; }
|
||||
}
|
||||
|
@ -221,7 +222,7 @@ namespace ColorCode
|
|||
/// <value>Language support for Koka.</value>
|
||||
public static ILanguage Koka
|
||||
{
|
||||
get { return LanguageRepository.FindById(LanguageId.Koka); }
|
||||
get { return LanguageRepository.FindById(LanguageId.Koka); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -242,6 +243,15 @@ namespace ColorCode
|
|||
get { return LanguageRepository.FindById(LanguageId.Markdown); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Language support for Fortran.
|
||||
/// </summary>
|
||||
/// <value>Language support for Fortran.</value>
|
||||
public static ILanguage Fortran
|
||||
{
|
||||
get { return LanguageRepository.FindById(LanguageId.Fortran); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a loaded language by the specified identifier.
|
||||
/// </summary>
|
||||
|
|
|
@ -39,251 +39,277 @@ namespace ColorCode.Styling
|
|||
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"
|
||||
Foreground = black,
|
||||
Background = white,
|
||||
ReferenceName = "plainText"
|
||||
},
|
||||
new Style(ScopeName.HtmlServerSideScript)
|
||||
{
|
||||
Background = yellow,
|
||||
ReferenceName = "htmlServerSideScript"
|
||||
Background = yellow,
|
||||
ReferenceName = "htmlServerSideScript"
|
||||
},
|
||||
new Style(ScopeName.HtmlComment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "htmlComment"
|
||||
Foreground = green,
|
||||
ReferenceName = "htmlComment"
|
||||
},
|
||||
new Style(ScopeName.HtmlTagDelimiter)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlTagDelimiter"
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlTagDelimiter"
|
||||
},
|
||||
new Style(ScopeName.HtmlElementName)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "htmlElementName"
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "htmlElementName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeName)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "htmlAttributeName"
|
||||
Foreground = red,
|
||||
ReferenceName = "htmlAttributeName"
|
||||
},
|
||||
new Style(ScopeName.HtmlAttributeValue)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlAttributeValue"
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.HtmlOperator)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlOperator"
|
||||
Foreground = blue,
|
||||
ReferenceName = "htmlOperator"
|
||||
},
|
||||
new Style(ScopeName.Comment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "comment"
|
||||
Foreground = green,
|
||||
ReferenceName = "comment"
|
||||
},
|
||||
new Style(ScopeName.XmlDocTag)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "xmlDocTag"
|
||||
Foreground = gray,
|
||||
ReferenceName = "xmlDocTag"
|
||||
},
|
||||
new Style(ScopeName.XmlDocComment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "xmlDocComment"
|
||||
Foreground = green,
|
||||
ReferenceName = "xmlDocComment"
|
||||
},
|
||||
new Style(ScopeName.String)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "string"
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "string"
|
||||
},
|
||||
new Style(ScopeName.StringCSharpVerbatim)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "stringCSharpVerbatim"
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "stringCSharpVerbatim"
|
||||
},
|
||||
new Style(ScopeName.Keyword)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "keyword"
|
||||
Foreground = blue,
|
||||
ReferenceName = "keyword"
|
||||
},
|
||||
new Style(ScopeName.PreprocessorKeyword)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "preprocessorKeyword"
|
||||
Foreground = blue,
|
||||
ReferenceName = "preprocessorKeyword"
|
||||
},
|
||||
new Style(ScopeName.HtmlEntity)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "htmlEntity"
|
||||
Foreground = red,
|
||||
ReferenceName = "htmlEntity"
|
||||
},
|
||||
new Style(ScopeName.XmlAttribute)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "xmlAttribute"
|
||||
Foreground = red,
|
||||
ReferenceName = "xmlAttribute"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeQuotes)
|
||||
{
|
||||
Foreground = black,
|
||||
ReferenceName = "xmlAttributeQuotes"
|
||||
Foreground = black,
|
||||
ReferenceName = "xmlAttributeQuotes"
|
||||
},
|
||||
new Style(ScopeName.XmlAttributeValue)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "xmlAttributeValue"
|
||||
Foreground = blue,
|
||||
ReferenceName = "xmlAttributeValue"
|
||||
},
|
||||
new Style(ScopeName.XmlCDataSection)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "xmlCDataSection"
|
||||
Foreground = gray,
|
||||
ReferenceName = "xmlCDataSection"
|
||||
},
|
||||
new Style(ScopeName.XmlComment)
|
||||
{
|
||||
Foreground = green,
|
||||
ReferenceName = "xmlComment"
|
||||
Foreground = green,
|
||||
ReferenceName = "xmlComment"
|
||||
},
|
||||
new Style(ScopeName.XmlDelimiter)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "xmlDelimiter"
|
||||
Foreground = blue,
|
||||
ReferenceName = "xmlDelimiter"
|
||||
},
|
||||
new Style(ScopeName.XmlName)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "xmlName"
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "xmlName"
|
||||
},
|
||||
new Style(ScopeName.ClassName)
|
||||
{
|
||||
Foreground = mediumTurqoise,
|
||||
ReferenceName = "className"
|
||||
Foreground = mediumTurqoise,
|
||||
ReferenceName = "className"
|
||||
},
|
||||
new Style(ScopeName.CssSelector)
|
||||
{
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "cssSelector"
|
||||
Foreground = dullRed,
|
||||
ReferenceName = "cssSelector"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyName)
|
||||
{
|
||||
Foreground = red,
|
||||
ReferenceName = "cssPropertyName"
|
||||
Foreground = red,
|
||||
ReferenceName = "cssPropertyName"
|
||||
},
|
||||
new Style(ScopeName.CssPropertyValue)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "cssPropertyValue"
|
||||
Foreground = blue,
|
||||
ReferenceName = "cssPropertyValue"
|
||||
},
|
||||
new Style(ScopeName.SqlSystemFunction)
|
||||
{
|
||||
Foreground = magenta,
|
||||
ReferenceName = "sqlSystemFunction"
|
||||
Foreground = magenta,
|
||||
ReferenceName = "sqlSystemFunction"
|
||||
},
|
||||
new Style(ScopeName.PowerShellAttribute)
|
||||
{
|
||||
Foreground = powderBlue,
|
||||
ReferenceName = "powershellAttribute"
|
||||
Foreground = powderBlue,
|
||||
ReferenceName = "powershellAttribute"
|
||||
},
|
||||
new Style(ScopeName.PowerShellOperator)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "powershellOperator"
|
||||
Foreground = gray,
|
||||
ReferenceName = "powershellOperator"
|
||||
},
|
||||
new Style(ScopeName.PowerShellType)
|
||||
{
|
||||
Foreground = teal,
|
||||
ReferenceName = "powershellType"
|
||||
Foreground = teal,
|
||||
ReferenceName = "powershellType"
|
||||
},
|
||||
new Style(ScopeName.PowerShellVariable)
|
||||
{
|
||||
Foreground = orangeRed,
|
||||
ReferenceName = "powershellVariable"
|
||||
Foreground = orangeRed,
|
||||
ReferenceName = "powershellVariable"
|
||||
},
|
||||
|
||||
new Style(ScopeName.Type)
|
||||
{
|
||||
Foreground = teal,
|
||||
ReferenceName = "type"
|
||||
Foreground = teal,
|
||||
ReferenceName = "type"
|
||||
},
|
||||
new Style(ScopeName.TypeVariable)
|
||||
{
|
||||
Foreground = teal,
|
||||
Italic = true,
|
||||
ReferenceName = "typeVariable"
|
||||
Foreground = teal,
|
||||
Italic = true,
|
||||
ReferenceName = "typeVariable"
|
||||
},
|
||||
new Style(ScopeName.NameSpace)
|
||||
{
|
||||
Foreground = navy,
|
||||
ReferenceName = "namespace"
|
||||
Foreground = navy,
|
||||
ReferenceName = "namespace"
|
||||
},
|
||||
new Style(ScopeName.Constructor)
|
||||
{
|
||||
Foreground = purple,
|
||||
ReferenceName = "constructor"
|
||||
Foreground = purple,
|
||||
ReferenceName = "constructor"
|
||||
},
|
||||
new Style(ScopeName.Predefined)
|
||||
{
|
||||
Foreground = navy,
|
||||
ReferenceName = "predefined"
|
||||
Foreground = navy,
|
||||
ReferenceName = "predefined"
|
||||
},
|
||||
new Style(ScopeName.PseudoKeyword)
|
||||
{
|
||||
Foreground = navy,
|
||||
ReferenceName = "pseudoKeyword"
|
||||
Foreground = navy,
|
||||
ReferenceName = "pseudoKeyword"
|
||||
},
|
||||
new Style(ScopeName.StringEscape)
|
||||
{
|
||||
Foreground = gray,
|
||||
ReferenceName = "stringEscape"
|
||||
Foreground = gray,
|
||||
ReferenceName = "stringEscape"
|
||||
},
|
||||
new Style(ScopeName.ControlKeyword)
|
||||
{
|
||||
Foreground = blue,
|
||||
ReferenceName = "controlKeyword"
|
||||
Foreground = blue,
|
||||
ReferenceName = "controlKeyword"
|
||||
},
|
||||
new Style(ScopeName.Number)
|
||||
{
|
||||
ReferenceName = "number"
|
||||
ReferenceName = "number"
|
||||
},
|
||||
new Style(ScopeName.Operator)
|
||||
{
|
||||
ReferenceName = "operator"
|
||||
ReferenceName = "operator"
|
||||
},
|
||||
new Style(ScopeName.Delimiter)
|
||||
{
|
||||
ReferenceName = "delimiter"
|
||||
ReferenceName = "delimiter"
|
||||
},
|
||||
|
||||
new Style(ScopeName.MarkdownHeader)
|
||||
{
|
||||
Foreground = blue,
|
||||
Bold = true,
|
||||
ReferenceName = "markdownHeader"
|
||||
Foreground = blue,
|
||||
Bold = true,
|
||||
ReferenceName = "markdownHeader"
|
||||
},
|
||||
new Style(ScopeName.MarkdownCode)
|
||||
{
|
||||
Foreground = teal,
|
||||
ReferenceName = "markdownCode"
|
||||
Foreground = teal,
|
||||
ReferenceName = "markdownCode"
|
||||
},
|
||||
new Style(ScopeName.MarkdownListItem)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "markdownListItem"
|
||||
Bold = true,
|
||||
ReferenceName = "markdownListItem"
|
||||
},
|
||||
new Style(ScopeName.MarkdownEmph)
|
||||
{
|
||||
Italic = true,
|
||||
ReferenceName = "italic"
|
||||
Italic = true,
|
||||
ReferenceName = "italic"
|
||||
},
|
||||
new Style(ScopeName.MarkdownBold)
|
||||
{
|
||||
Bold = true,
|
||||
ReferenceName = "bold"
|
||||
}
|
||||
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"
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<TextBox x:Name="LanguageBox" Header="Language" Text="C#" />
|
||||
<Button Content="Render to Rich Text Block" Click="Load_Click" />
|
||||
<Button Content="Create HTML" Click="MakeHTML" />
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<RichTextBlock x:Name="PresentationBlock" />
|
||||
<RichTextBlock x:Name="PresentationBlock" FontFamily="Consolas" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
|
@ -38,14 +39,14 @@ namespace ColorCode.UWPTests
|
|||
|
||||
var file = await picker.PickSingleFileAsync();
|
||||
if (file == null) return null;
|
||||
var text = await FileIO.ReadTextAsync(file);
|
||||
string text = "";
|
||||
|
||||
ILanguage Language = Languages.CSharp;
|
||||
|
||||
if (LanguageBox.Text != null)
|
||||
using (var reader = new StreamReader(await file.OpenStreamForReadAsync(), true))
|
||||
{
|
||||
Language = Languages.FindById(LanguageBox.Text) ?? Languages.CSharp;
|
||||
text = await reader.ReadToEndAsync();
|
||||
}
|
||||
|
||||
ILanguage Language = Languages.FindById(file.FileType.Replace(".", "")) ?? Languages.CSharp;
|
||||
return new Tuple<string, ILanguage>(text, Language);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче