Improve dark mode syntax highlighting

This commit is contained in:
Neil Brommer 2023-07-24 15:56:32 -07:00
parent c14ef4ed80
commit 8471a8e263
3 changed files with 33 additions and 45 deletions

View file

@ -32,7 +32,8 @@ public class LanguageDescriptor : NSObject
/// the keywords for this language. /// the keywords for this language.
/// </summary> /// </summary>
/// <value>The keywords.</value> /// <value>The keywords.</value>
public Dictionary<string, KeywordDescriptor> Keywords { get; set; } = new Dictionary<string, KeywordDescriptor>(); public Dictionary<string, KeywordDescriptor> Keywords { get; set; }
= new Dictionary<string, KeywordDescriptor>();
/// <summary> /// <summary>
/// Gets or sets the collection of <see cref="FormatDescriptor"/> formats used to syntax /// Gets or sets the collection of <see cref="FormatDescriptor"/> formats used to syntax
@ -61,7 +62,7 @@ public class LanguageDescriptor : NSObject
[Export("KeywordColor")] [Export("KeywordColor")]
public NSColor KeywordColor public NSColor KeywordColor
{ {
get => LoadColor("KeywordColor", NSColor.FromRgba(0.06f, 0.52f, 0.50f, 1.0f)); get => LoadColor("KeywordColor", NSColor.SystemTeal);
set set
{ {
WillChangeValue("KeywordColor"); WillChangeValue("KeywordColor");
@ -75,7 +76,7 @@ public class LanguageDescriptor : NSObject
[Export("TypeColor")] [Export("TypeColor")]
public NSColor TypeColor public NSColor TypeColor
{ {
get => LoadColor("TypeColor", NSColor.FromRgba(0.06f, 0.52f, 0.50f, 1.0f)); get => LoadColor("TypeColor", NSColor.SystemTeal);
set set
{ {
WillChangeValue("TypeColor"); WillChangeValue("TypeColor");
@ -89,7 +90,7 @@ public class LanguageDescriptor : NSObject
[Export("ValueTypeColor")] [Export("ValueTypeColor")]
public NSColor ValueTypeColor public NSColor ValueTypeColor
{ {
get => LoadColor("ValueTypeColor", NSColor.Blue); get => LoadColor("ValueTypeColor", NSColor.SystemBlue);
set set
{ {
WillChangeValue("ValueTypeColor"); WillChangeValue("ValueTypeColor");
@ -103,7 +104,7 @@ public class LanguageDescriptor : NSObject
[Export("ReferenceTypeColor")] [Export("ReferenceTypeColor")]
public NSColor ReferenceTypeColor public NSColor ReferenceTypeColor
{ {
get => LoadColor("ReferenceTypeColor", NSColor.FromRgba(0f, 0.56f, 0.80f, 1.0f)); get => LoadColor("ReferenceTypeColor", NSColor.SystemCyan);
set set
{ {
WillChangeValue("ReferenceTypeColor"); WillChangeValue("ReferenceTypeColor");
@ -117,7 +118,7 @@ public class LanguageDescriptor : NSObject
[Export("AccessModifierColor")] [Export("AccessModifierColor")]
public NSColor AccessModifierColor public NSColor AccessModifierColor
{ {
get => LoadColor("AccessModifierColor", NSColor.FromRgba(0.06f, 0.52f, 0.50f, 1.0f)); get => LoadColor("AccessModifierColor", NSColor.SystemTeal);
set set
{ {
WillChangeValue("AccessModifierColor"); WillChangeValue("AccessModifierColor");
@ -131,7 +132,7 @@ public class LanguageDescriptor : NSObject
[Export("ModifierColor")] [Export("ModifierColor")]
public NSColor ModifierColor public NSColor ModifierColor
{ {
get => LoadColor("ModifierColor", NSColor.FromRgba(0.06f, 0.52f, 0.50f, 1.0f)); get => LoadColor("ModifierColor", NSColor.SystemTeal);
set set
{ {
WillChangeValue("ModifierColor"); WillChangeValue("ModifierColor");
@ -145,7 +146,7 @@ public class LanguageDescriptor : NSObject
[Export("SelectionStatementColor")] [Export("SelectionStatementColor")]
public NSColor SelectionStatementColor public NSColor SelectionStatementColor
{ {
get => LoadColor("SelectionStatementColor", NSColor.FromRgba(0.50f, 0.25f, 0f, 1.0f)); get => LoadColor("SelectionStatementColor", NSColor.SystemBrown);
set set
{ {
WillChangeValue("SelectionStatementColor"); WillChangeValue("SelectionStatementColor");
@ -159,7 +160,7 @@ public class LanguageDescriptor : NSObject
[Export("IterationStatementColor")] [Export("IterationStatementColor")]
public NSColor IterationStatementColor public NSColor IterationStatementColor
{ {
get => LoadColor("IterationStatementColor", NSColor.FromRgba(0.50f, 0f, 0f, 1.0f)); get => LoadColor("IterationStatementColor", NSColor.SystemRed);
set set
{ {
WillChangeValue("IterationStatementColor"); WillChangeValue("IterationStatementColor");
@ -173,7 +174,7 @@ public class LanguageDescriptor : NSObject
[Export("JumpStatementColor")] [Export("JumpStatementColor")]
public NSColor JumpStatementColor public NSColor JumpStatementColor
{ {
get => LoadColor("JumpStatementColor", NSColor.FromRgba(0.50f, 0.50f, 0.0f, 1.0f)); get => LoadColor("JumpStatementColor", NSColor.SystemYellow);
set set
{ {
WillChangeValue("JumpStatementColor"); WillChangeValue("JumpStatementColor");
@ -187,7 +188,7 @@ public class LanguageDescriptor : NSObject
[Export("ExceptionHandlingColor")] [Export("ExceptionHandlingColor")]
public NSColor ExceptionHandlingColor public NSColor ExceptionHandlingColor
{ {
get => LoadColor("ExceptionHandlingColor", NSColor.FromRgba(1f, 0f, 0f, 1.0f)); get => LoadColor("ExceptionHandlingColor", NSColor.SystemRed);
set set
{ {
WillChangeValue("ExceptionHandlingColor"); WillChangeValue("ExceptionHandlingColor");
@ -201,7 +202,7 @@ public class LanguageDescriptor : NSObject
[Export("StatementColor")] [Export("StatementColor")]
public NSColor StatementColor public NSColor StatementColor
{ {
get => LoadColor("StatementColor", NSColor.FromRgba(1f, 0f, 0.50f, 1.0f)); get => LoadColor("StatementColor", NSColor.SystemPink);
set set
{ {
WillChangeValue("StatementColor"); WillChangeValue("StatementColor");
@ -215,7 +216,7 @@ public class LanguageDescriptor : NSObject
[Export("MethodParameterColor")] [Export("MethodParameterColor")]
public NSColor MethodParameterColor public NSColor MethodParameterColor
{ {
get => LoadColor("MethodParameterColor", NSColor.FromRgba(0.06f, 0.52f, 0.50f, 1.0f)); get => LoadColor("MethodParameterColor", NSColor.SystemTeal);
set set
{ {
WillChangeValue("MethodParameterColor"); WillChangeValue("MethodParameterColor");
@ -229,7 +230,7 @@ public class LanguageDescriptor : NSObject
[Export("NamespaceColor")] [Export("NamespaceColor")]
public NSColor NamespaceColor public NSColor NamespaceColor
{ {
get => LoadColor("NamespaceColor", NSColor.FromRgba(0.06f, 0.52f, 0.50f, 1.0f)); get => LoadColor("NamespaceColor", NSColor.SystemTeal);
set set
{ {
WillChangeValue("NamespaceColor"); WillChangeValue("NamespaceColor");
@ -243,7 +244,7 @@ public class LanguageDescriptor : NSObject
[Export("OperatorKeywordColor")] [Export("OperatorKeywordColor")]
public NSColor OperatorKeywordColor public NSColor OperatorKeywordColor
{ {
get => LoadColor("OperatorKeywordColor", NSColor.FromRgba(0.80f, 0.40f, 1f, 1.0f)); get => LoadColor("OperatorKeywordColor", NSColor.SystemPurple);
set set
{ {
WillChangeValue("OperatorKeywordColor"); WillChangeValue("OperatorKeywordColor");
@ -257,7 +258,7 @@ public class LanguageDescriptor : NSObject
[Export("ConversionKeywordColor")] [Export("ConversionKeywordColor")]
public NSColor ConversionKeywordColor public NSColor ConversionKeywordColor
{ {
get => LoadColor("ConversionKeywordColor", NSColor.Purple); get => LoadColor("ConversionKeywordColor", NSColor.SystemPurple);
set set
{ {
WillChangeValue("ConversionKeywordColor"); WillChangeValue("ConversionKeywordColor");
@ -271,7 +272,7 @@ public class LanguageDescriptor : NSObject
[Export("AccessKeywordColor")] [Export("AccessKeywordColor")]
public NSColor AccessKeywordColor public NSColor AccessKeywordColor
{ {
get => LoadColor("AccessKeywordColor", NSColor.Purple); get => LoadColor("AccessKeywordColor", NSColor.SystemPurple);
set set
{ {
WillChangeValue("AccessKeywordColor"); WillChangeValue("AccessKeywordColor");
@ -285,7 +286,7 @@ public class LanguageDescriptor : NSObject
[Export("LiteralKeywordColor")] [Export("LiteralKeywordColor")]
public NSColor LiteralKeywordColor public NSColor LiteralKeywordColor
{ {
get => LoadColor("LiteralKeywordColor", NSColor.Purple); get => LoadColor("LiteralKeywordColor", NSColor.SystemPurple);
set set
{ {
WillChangeValue("LiteralKeywordColor"); WillChangeValue("LiteralKeywordColor");
@ -299,7 +300,7 @@ public class LanguageDescriptor : NSObject
[Export("ContextualKeywordColor")] [Export("ContextualKeywordColor")]
public NSColor ContextualKeywordColor public NSColor ContextualKeywordColor
{ {
get => LoadColor("ContextualKeywordColor", NSColor.FromRgba(0f, 0.50f, 0.25f, 1.0f)); get => LoadColor("ContextualKeywordColor", NSColor.SystemGreen);
set set
{ {
WillChangeValue("ContextualKeywordColor"); WillChangeValue("ContextualKeywordColor");
@ -313,7 +314,7 @@ public class LanguageDescriptor : NSObject
[Export("QueryKeywordColor")] [Export("QueryKeywordColor")]
public NSColor QueryKeywordColor public NSColor QueryKeywordColor
{ {
get => LoadColor("QueryKeywordColor", NSColor.Orange); get => LoadColor("QueryKeywordColor", NSColor.SystemOrange);
set set
{ {
WillChangeValue("QueryKeywordColor"); WillChangeValue("QueryKeywordColor");
@ -327,7 +328,7 @@ public class LanguageDescriptor : NSObject
[Export("PreprocessorDirectiveColor")] [Export("PreprocessorDirectiveColor")]
public NSColor PreprocessorDirectiveColor public NSColor PreprocessorDirectiveColor
{ {
get => LoadColor("PreprocessorDirectiveColor", NSColor.FromRgba(0.69f, 0.03f, 0.61f, 1.0f)); get => LoadColor("PreprocessorDirectiveColor", NSColor.SystemPurple);
set set
{ {
WillChangeValue("PreprocessorDirectiveColor"); WillChangeValue("PreprocessorDirectiveColor");
@ -341,7 +342,7 @@ public class LanguageDescriptor : NSObject
[Export("CommentColor")] [Export("CommentColor")]
public NSColor CommentColor public NSColor CommentColor
{ {
get => LoadColor("CommentColor", NSColor.Gray); get => LoadColor("CommentColor", NSColor.SystemGray);
set set
{ {
WillChangeValue("CommentColor"); WillChangeValue("CommentColor");
@ -355,7 +356,7 @@ public class LanguageDescriptor : NSObject
[Export("StringLiteralColor")] [Export("StringLiteralColor")]
public NSColor StringLiteralColor public NSColor StringLiteralColor
{ {
get => LoadColor("StringLiteralColor", NSColor.Orange); get => LoadColor("StringLiteralColor", NSColor.SystemOrange);
set set
{ {
WillChangeValue("StringLiteralColor"); WillChangeValue("StringLiteralColor");

View file

@ -309,6 +309,8 @@ public class LanguageFormatter : NSObject
{ {
TextEditor.LayoutManager.RemoveTemporaryAttribute( TextEditor.LayoutManager.RemoveTemporaryAttribute(
NSStringAttributeKey.ForegroundColor, range); NSStringAttributeKey.ForegroundColor, range);
TextEditor.LayoutManager.SetTemporaryAttributes(
new NSDictionary(NSStringAttributeKey.ForegroundColor, NSColor.ControlText), range);
} }
} }
catch catch

View file

@ -193,18 +193,14 @@ public class SourceTextView : NSTextView
#region Constructors #region Constructors
/// <summary> /// <summary>Initializes a new instance of the <see cref="SourceTextView"/> class.</summary>
/// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.SourceTextView"/> class.
/// </summary>
public SourceTextView() public SourceTextView()
{ {
// Init // Init
Initialize(); Initialize();
} }
/// <summary> /// <summary>Initializes a new instance of the <see cref="SourceTextView"/> class.</summary>
/// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.SourceTextView"/> class.
/// </summary>
/// <param name="frameRect">Frame rect.</param> /// <param name="frameRect">Frame rect.</param>
public SourceTextView(CGRect frameRect) : base(frameRect) public SourceTextView(CGRect frameRect) : base(frameRect)
{ {
@ -212,9 +208,7 @@ public class SourceTextView : NSTextView
Initialize(); Initialize();
} }
/// <summary> /// <summary>Initializes a new instance of the <see cref="SourceTextView"/> class.</summary>
/// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.SourceTextView"/> class.
/// </summary>
/// <param name="frameRect">Frame rect.</param> /// <param name="frameRect">Frame rect.</param>
/// <param name="container">Container.</param> /// <param name="container">Container.</param>
public SourceTextView(CGRect frameRect, NSTextContainer container) : base(frameRect, container) public SourceTextView(CGRect frameRect, NSTextContainer container) : base(frameRect, container)
@ -223,9 +217,7 @@ public class SourceTextView : NSTextView
Initialize(); Initialize();
} }
/// <summary> /// <summary>Initializes a new instance of the <see cref="SourceTextView"/> class.</summary>
/// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.SourceTextView"/> class.
/// </summary>
/// <param name="coder">Coder.</param> /// <param name="coder">Coder.</param>
public SourceTextView(NSCoder coder) : base(coder) public SourceTextView(NSCoder coder) : base(coder)
{ {
@ -233,25 +225,18 @@ public class SourceTextView : NSTextView
Initialize(); Initialize();
} }
/// <summary> /// <summary>Initializes a new instance of the <see cref="SourceTextView"/> class.</summary>
/// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.SourceTextView"/> class.
/// </summary>
/// <param name="handle">Handle.</param> /// <param name="handle">Handle.</param>
public SourceTextView(IntPtr handle) : base(handle) public SourceTextView(IntPtr handle) : base(handle)
{ {
// Init
Initialize(); Initialize();
} }
/// <summary> /// <summary>Initialize this instance.</summary>
/// Initialize this instance.
/// </summary>
private void Initialize() private void Initialize()
{ {
// Init
this.Delegate = new SourceTextViewDelegate(this); this.Delegate = new SourceTextViewDelegate(this);
this.UsesAdaptiveColorMappingForDarkAppearance = true;
} }
#endregion #endregion