refactor colours to constants
This commit is contained in:
@@ -71,10 +71,10 @@ public partial class CustomHighlighter : SyntaxHighlighter
|
|||||||
return kind switch
|
return kind switch
|
||||||
{
|
{
|
||||||
SharpIdeRazorSpanKind.Code => GetColorForClassification(codeClassificationType!),
|
SharpIdeRazorSpanKind.Code => GetColorForClassification(codeClassificationType!),
|
||||||
SharpIdeRazorSpanKind.Comment => CachedColors.Green, // green
|
SharpIdeRazorSpanKind.Comment => CachedColors.CommentGreen, // green
|
||||||
SharpIdeRazorSpanKind.MetaCode => new Color("a699e6"), // purple
|
SharpIdeRazorSpanKind.MetaCode => CachedColors.RazorMetaCodePurple, // purple
|
||||||
SharpIdeRazorSpanKind.Markup => GetColorForMarkupSpanKind(vsSemanticRangeType),
|
SharpIdeRazorSpanKind.Markup => GetColorForMarkupSpanKind(vsSemanticRangeType),
|
||||||
SharpIdeRazorSpanKind.Transition => new Color("a699e6"), // purple
|
SharpIdeRazorSpanKind.Transition => CachedColors.RazorMetaCodePurple, // purple
|
||||||
SharpIdeRazorSpanKind.None => CachedColors.White,
|
SharpIdeRazorSpanKind.None => CachedColors.White,
|
||||||
_ => CachedColors.White
|
_ => CachedColors.White
|
||||||
};
|
};
|
||||||
@@ -84,14 +84,14 @@ public partial class CustomHighlighter : SyntaxHighlighter
|
|||||||
{
|
{
|
||||||
return vsSemanticRangeType switch
|
return vsSemanticRangeType switch
|
||||||
{
|
{
|
||||||
"razorDirective" or "razorTransition" => new Color("a699e6"), // purple
|
"razorDirective" or "razorTransition" => CachedColors.RazorMetaCodePurple, // purple
|
||||||
"markupTagDelimiter" => new Color("808080"), // gray
|
"markupTagDelimiter" => CachedColors.HtmlDelimiterGray, // gray
|
||||||
"markupTextLiteral" => CachedColors.White, // white
|
"markupTextLiteral" => CachedColors.White, // white
|
||||||
"markupElement" => new Color("569cd6"), // blue
|
"markupElement" => CachedColors.KeywordBlue, // blue
|
||||||
"razorComponentElement" => new Color("0b7f7f"), // dark green
|
"razorComponentElement" => CachedColors.RazorComponentGreen, // dark green
|
||||||
"razorComponentAttribute" => CachedColors.White, // white
|
"razorComponentAttribute" => CachedColors.White, // white
|
||||||
"razorComment" or "razorCommentStar" or "razorCommentTransition" => CachedColors.Green, // green
|
"razorComment" or "razorCommentStar" or "razorCommentTransition" => CachedColors.CommentGreen, // green
|
||||||
"markupOperator" =>CachedColors.White, // white
|
"markupOperator" => CachedColors.White, // white
|
||||||
"markupAttributeQuote" => CachedColors.White, // white
|
"markupAttributeQuote" => CachedColors.White, // white
|
||||||
_ => CachedColors.White // default to white
|
_ => CachedColors.White // default to white
|
||||||
};
|
};
|
||||||
@@ -136,34 +136,34 @@ public partial class CustomHighlighter : SyntaxHighlighter
|
|||||||
var colour = classificationType switch
|
var colour = classificationType switch
|
||||||
{
|
{
|
||||||
// Keywords
|
// Keywords
|
||||||
"keyword" => new Color("569cd6"),
|
"keyword" => CachedColors.KeywordBlue,
|
||||||
"keyword - control" => new Color("569cd6"),
|
"keyword - control" => CachedColors.KeywordBlue,
|
||||||
"preprocessor keyword" => new Color("569cd6"),
|
"preprocessor keyword" => CachedColors.KeywordBlue,
|
||||||
|
|
||||||
// Literals & comments
|
// Literals & comments
|
||||||
"string" => new Color("d69d85"),
|
"string" => CachedColors.LightOrangeBrown,
|
||||||
"comment" => CachedColors.Green,
|
"comment" => CachedColors.CommentGreen,
|
||||||
"number" => new Color("b5cea8"),
|
"number" => CachedColors.NumberGreen,
|
||||||
|
|
||||||
// Types (User Types)
|
// Types (User Types)
|
||||||
"class name" => new Color("4ec9b0"),
|
"class name" => CachedColors.ClassBlue,
|
||||||
"record class name" => new Color("4ec9b0"),
|
"record class name" => CachedColors.ClassBlue,
|
||||||
"struct name" => new Color("4ec9b0"),
|
"struct name" => CachedColors.ClassBlue,
|
||||||
"interface name" => new Color("b8d7a3"),
|
"interface name" => CachedColors.InterfaceGreen,
|
||||||
"enum name" => new Color("b8d7a3"),
|
"enum name" => CachedColors.InterfaceGreen,
|
||||||
"namespace name" => CachedColors.White,
|
"namespace name" => CachedColors.White,
|
||||||
|
|
||||||
// Identifiers & members
|
// Identifiers & members
|
||||||
"identifier" => CachedColors.White,
|
"identifier" => CachedColors.White,
|
||||||
"constant name" => CachedColors.White,
|
"constant name" => CachedColors.White,
|
||||||
"enum member name" => CachedColors.White,
|
"enum member name" => CachedColors.White,
|
||||||
"method name" => new Color("dcdcaa"),
|
"method name" => CachedColors.Yellow,
|
||||||
"extension method name" => new Color("dcdcaa"),
|
"extension method name" => CachedColors.Yellow,
|
||||||
"property name" => CachedColors.White,
|
"property name" => CachedColors.White,
|
||||||
"field name" => CachedColors.White,
|
"field name" => CachedColors.White,
|
||||||
"static symbol" => new Color("dcdcaa"),
|
"static symbol" => CachedColors.Yellow, // ??
|
||||||
"parameter name" => new Color("9cdcfe"),
|
"parameter name" => CachedColors.VariableBlue,
|
||||||
"local name" => new Color("9cdcfe"),
|
"local name" => CachedColors.VariableBlue,
|
||||||
|
|
||||||
// Punctuation & operators
|
// Punctuation & operators
|
||||||
"operator" => CachedColors.White,
|
"operator" => CachedColors.White,
|
||||||
@@ -171,18 +171,18 @@ public partial class CustomHighlighter : SyntaxHighlighter
|
|||||||
"punctuation" => CachedColors.White,
|
"punctuation" => CachedColors.White,
|
||||||
|
|
||||||
// Xml comments
|
// Xml comments
|
||||||
"xml doc comment - delimiter" => CachedColors.Green,
|
"xml doc comment - delimiter" => CachedColors.CommentGreen,
|
||||||
"xml doc comment - name" => CachedColors.White,
|
"xml doc comment - name" => CachedColors.White,
|
||||||
"xml doc comment - text" => CachedColors.Green,
|
"xml doc comment - text" => CachedColors.CommentGreen,
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
"excluded code" => new Color("a9a9a9"),
|
"excluded code" => CachedColors.Gray,
|
||||||
|
|
||||||
_ => CachedColors.Orange // orange, warning color for unhandled classifications
|
_ => CachedColors.Orange // orange, warning color for unhandled classifications
|
||||||
};
|
};
|
||||||
if (colour == CachedColors.Orange)
|
if (colour == CachedColors.Orange)
|
||||||
{
|
{
|
||||||
GD.PrintErr($"Unhandled classification type: {classificationType}");
|
GD.PrintErr($"Unhandled classification type: '{classificationType}'");
|
||||||
}
|
}
|
||||||
return colour;
|
return colour;
|
||||||
}
|
}
|
||||||
@@ -193,5 +193,16 @@ file static class CachedColors
|
|||||||
public static readonly Color Orange = new("f27718");
|
public static readonly Color Orange = new("f27718");
|
||||||
public static readonly Color White = new("dcdcdc");
|
public static readonly Color White = new("dcdcdc");
|
||||||
public static readonly Color Yellow = new("dcdcaa");
|
public static readonly Color Yellow = new("dcdcaa");
|
||||||
public static readonly Color Green = new("57a64a");
|
public static readonly Color CommentGreen = new("57a64a");
|
||||||
|
public static readonly Color KeywordBlue = new("569cd6");
|
||||||
|
public static readonly Color LightOrangeBrown = new("d69d85");
|
||||||
|
public static readonly Color NumberGreen = new("b5cea8");
|
||||||
|
public static readonly Color InterfaceGreen = new("b8d7a3");
|
||||||
|
public static readonly Color ClassBlue = new("4ec9b0");
|
||||||
|
public static readonly Color VariableBlue = new("9cdcfe");
|
||||||
|
public static readonly Color Gray = new("a9a9a9");
|
||||||
|
|
||||||
|
public static readonly Color RazorComponentGreen = new("0b7f7f");
|
||||||
|
public static readonly Color RazorMetaCodePurple = new("a699e6");
|
||||||
|
public static readonly Color HtmlDelimiterGray = new("808080");
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user