adium 5474:15de7b973d1e: [NSColor colorWithHTMLString:@"purple"]...

commits at adium.im commits at adium.im
Tue May 7 16:55:52 UTC 2013


details:	http://hg.adium.im/adium/rev/15de7b973d1e
revision:	5474:15de7b973d1e
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Tue May 07 18:55:25 2013 +0200

[NSColor colorWithHTMLString:@"purple"] returned something that is not equal to the CSS color 'purple' (#a020f0), because emacs uses rgb(160, 32, 240). Changed the order of built-in colornames and parsing the emacs rgb file so that the built-in colors override the emacs colors.

diffs (65 lines):

diff -r 264a98a8aed2 -r 15de7b973d1e Frameworks/AIUtilities Framework/Source/AIColorAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m	Tue May 07 16:38:56 2013 +0200
+++ b/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m	Tue May 07 18:55:25 2013 +0200
@@ -151,27 +151,9 @@
 
 + (NSDictionary *)colorNamesDictionary
 {
-	if (!RGBColorValues) {
-		RGBColorValues = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
-						  [NSColor colorWithHTMLString:@"#000"],    @"black",
-						  [NSColor colorWithHTMLString:@"#c0c0c0"], @"silver",
-						  [NSColor colorWithHTMLString:@"#808080"], @"gray",
-						  [NSColor colorWithHTMLString:@"#808080"], @"grey",
-						  [NSColor colorWithHTMLString:@"#fff"],    @"white",
-						  [NSColor colorWithHTMLString:@"#800000"], @"maroon",
-						  [NSColor colorWithHTMLString:@"#f00"],    @"red",
-						  [NSColor colorWithHTMLString:@"#800080"], @"purple",
-						  [NSColor colorWithHTMLString:@"#f0f"],    @"fuchsia",
-						  [NSColor colorWithHTMLString:@"#008000"], @"green",
-						  [NSColor colorWithHTMLString:@"#0f0"],    @"lime",
-						  [NSColor colorWithHTMLString:@"#808000"], @"olive",
-						  [NSColor colorWithHTMLString:@"#ff0"],    @"yellow",
-						  [NSColor colorWithHTMLString:@"#000080"], @"navy",
-						  [NSColor colorWithHTMLString:@"#00f"],    @"blue",
-						  [NSColor colorWithHTMLString:@"#008080"], @"teal",
-						  [NSColor colorWithHTMLString:@"#0ff"],    @"aqua",
-						  [NSColor colorWithHTMLString:@"#4b0082"], @"indigo",
-						  nil];
+	static dispatch_once_t onceToken;
+	dispatch_once(&onceToken, ^{
+		RGBColorValues = [[NSMutableDictionary alloc] init];
 		NSArray *paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:defaultRGBTxtLocation1 error:NULL];
 		for (NSString *middlePath in paths) {
 			NSString *path = [defaultRGBTxtLocation1 stringByAppendingPathComponent:[middlePath stringByAppendingPathComponent:defaultRGBTxtLocation2]];
@@ -184,7 +166,29 @@
 				break;
 			}
 		}
-	}
+		[RGBColorValues addEntriesFromDictionary:@{
+		 @"black": [NSColor colorWithHTMLString:@"#000"],
+		 @"silver": [NSColor colorWithHTMLString:@"#c0c0c0"],
+		 @"gray": [NSColor colorWithHTMLString:@"#808080"],
+		 @"grey": [NSColor colorWithHTMLString:@"#808080"],
+		 @"white": [NSColor colorWithHTMLString:@"#fff"],
+		 @"maroon": [NSColor colorWithHTMLString:@"#800000"],
+		 @"red": [NSColor colorWithHTMLString:@"#f00"],
+		 @"purple": [NSColor colorWithHTMLString:@"#800080"],
+		 @"fuchsia": [NSColor colorWithHTMLString:@"#f0f"],
+		 @"green": [NSColor colorWithHTMLString:@"#008000"],
+		 @"lime": [NSColor colorWithHTMLString:@"#0f0"],
+		 @"olive": [NSColor colorWithHTMLString:@"#808000"],
+		 @"yellow": [NSColor colorWithHTMLString:@"#ff0"],
+		 @"navy": [NSColor colorWithHTMLString:@"#000080"],
+		 @"blue": [NSColor colorWithHTMLString:@"#00f"],
+		 @"teal": [NSColor colorWithHTMLString:@"#008080"],
+		 @"aqua": [NSColor colorWithHTMLString:@"#0ff"],
+		 @"indigo": [NSColor colorWithHTMLString:@"#4b0082"],
+		 @"crimson": [NSColor colorWithHTMLString:@"#dc143c"]
+		 }];
+	});
+	
 	return RGBColorValues;
 }
 




More information about the commits mailing list