diff options
| author | Jan Djärv | 2013-09-28 12:01:50 +0200 |
|---|---|---|
| committer | Jan Djärv | 2013-09-28 12:01:50 +0200 |
| commit | 1610938f74bd8cee71c0190deb470b5bd102d51f (patch) | |
| tree | 7114f6a13439b06d3b4affb2a77abaf606653727 /src | |
| parent | 0d2647e645d9965e0707d25e39e4152abfda99bf (diff) | |
| download | emacs-1610938f74bd8cee71c0190deb470b5bd102d51f.tar.gz emacs-1610938f74bd8cee71c0190deb470b5bd102d51f.zip | |
Pick up default selection color on OSX when user defaults are not set.
* lisp/faces.el (region): Change ns_selection_color to
ns_selection_fg_color, add ns_selection_bg_color.
* src/nsterm.h (NS_SELECTION_BG_COLOR_DEFAULT): Renamed from
NS_SELECTION_COLOR_DEFAULT.
(NS_SELECTION_FG_COLOR_DEFAULT): New.
* src/nsterm.m (ns_selection_color): Remove.
(ns_get_color): Check for ns_selection_(fg|bg)_color using
NSColor selectedText(Background)Color. Only for COCOA.
(ns_term_init): Remove assignment of ns_selection_color, logic
moved to ns_get_color.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/nsterm.h | 3 | ||||
| -rw-r--r-- | src/nsterm.m | 44 |
3 files changed, 47 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ec36db90dfa..4c298873dcc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2013-09-28 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsterm.m (ns_selection_color): Remove. | ||
| 4 | (ns_get_color): Check for ns_selection_(fg|bg)_color using | ||
| 5 | NSColor selectedText(Background)Color. Only for COCOA. | ||
| 6 | (ns_term_init): Remove assignment of ns_selection_color, logic | ||
| 7 | moved to ns_get_color. | ||
| 8 | |||
| 9 | * nsterm.h (NS_SELECTION_BG_COLOR_DEFAULT): Renamed from | ||
| 10 | NS_SELECTION_COLOR_DEFAULT. | ||
| 11 | (NS_SELECTION_FG_COLOR_DEFAULT): New. | ||
| 12 | |||
| 1 | 2013-09-28 Eli Zaretskii <eliz@gnu.org> | 13 | 2013-09-28 Eli Zaretskii <eliz@gnu.org> |
| 2 | 14 | ||
| 3 | * xdisp.c (Fdump_tool_bar_row): Ifdef away the body if 'struct | 15 | * xdisp.c (Fdump_tool_bar_row): Ifdef away the body if 'struct |
diff --git a/src/nsterm.h b/src/nsterm.h index 9f7767b312e..e99ed3d289a 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -911,7 +911,8 @@ extern char gnustep_base_version[]; /* version tracking */ | |||
| 911 | 911 | ||
| 912 | #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth] | 912 | #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth] |
| 913 | /* This is to match emacs on other platforms, ugly though it is. */ | 913 | /* This is to match emacs on other platforms, ugly though it is. */ |
| 914 | #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2"; | 914 | #define NS_SELECTION_BG_COLOR_DEFAULT @"LightGoldenrod2"; |
| 915 | #define NS_SELECTION_FG_COLOR_DEFAULT @"Black"; | ||
| 915 | #define RESIZE_HANDLE_SIZE 12 | 916 | #define RESIZE_HANDLE_SIZE 12 |
| 916 | 917 | ||
| 917 | /* Little utility macros */ | 918 | /* Little utility macros */ |
diff --git a/src/nsterm.m b/src/nsterm.m index 65c67eb9b56..47000da94da 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -179,9 +179,6 @@ static Lisp_Object QUTF8_STRING; | |||
| 179 | no way to control this behavior. */ | 179 | no way to control this behavior. */ |
| 180 | float ns_antialias_threshold; | 180 | float ns_antialias_threshold; |
| 181 | 181 | ||
| 182 | /* Used to pick up AppleHighlightColor on OS X */ | ||
| 183 | NSString *ns_selection_color; | ||
| 184 | |||
| 185 | NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0; | 182 | NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0; |
| 186 | NSString *ns_app_name = @"Emacs"; /* default changed later */ | 183 | NSString *ns_app_name = @"Emacs"; /* default changed later */ |
| 187 | 184 | ||
| @@ -1454,11 +1451,41 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1454 | /*fprintf (stderr, "ns_get_color: '%s'\n", name); */ | 1451 | /*fprintf (stderr, "ns_get_color: '%s'\n", name); */ |
| 1455 | block_input (); | 1452 | block_input (); |
| 1456 | 1453 | ||
| 1457 | if ([nsname isEqualToString: @"ns_selection_color"]) | 1454 | #ifdef NS_IMPL_COCOA |
| 1455 | if ([nsname isEqualToString: @"ns_selection_bg_color"]) | ||
| 1456 | { | ||
| 1457 | NSString *defname = [[NSUserDefaults standardUserDefaults] | ||
| 1458 | stringForKey: @"AppleHighlightColor"]; | ||
| 1459 | |||
| 1460 | if (defname != nil) | ||
| 1461 | nsname = defname; | ||
| 1462 | else if ((new = [NSColor selectedTextBackgroundColor]) != nil) | ||
| 1463 | { | ||
| 1464 | *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; | ||
| 1465 | unblock_input (); | ||
| 1466 | return 0; | ||
| 1467 | } | ||
| 1468 | else | ||
| 1469 | nsname = NS_SELECTION_BG_COLOR_DEFAULT; | ||
| 1470 | |||
| 1471 | name = [nsname UTF8String]; | ||
| 1472 | } | ||
| 1473 | else if ([nsname isEqualToString: @"ns_selection_fg_color"]) | ||
| 1458 | { | 1474 | { |
| 1459 | nsname = ns_selection_color; | 1475 | /* NOTE: OSX applications normally don't set foreground selection, but |
| 1460 | name = [ns_selection_color UTF8String]; | 1476 | text may be unreadable if we don't. |
| 1477 | */ | ||
| 1478 | if ((new = [NSColor selectedTextColor]) != nil) | ||
| 1479 | { | ||
| 1480 | *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; | ||
| 1481 | unblock_input (); | ||
| 1482 | return 0; | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | nsname = NS_SELECTION_FG_COLOR_DEFAULT; | ||
| 1486 | name = [nsname UTF8String]; | ||
| 1461 | } | 1487 | } |
| 1488 | #endif // NS_IMPL_COCOA | ||
| 1462 | 1489 | ||
| 1463 | /* First, check for some sort of numeric specification. */ | 1490 | /* First, check for some sort of numeric specification. */ |
| 1464 | hex[0] = '\0'; | 1491 | hex[0] = '\0'; |
| @@ -4168,11 +4195,6 @@ ns_term_init (Lisp_Object display_name) | |||
| 4168 | ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp); | 4195 | ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp); |
| 4169 | } | 4196 | } |
| 4170 | 4197 | ||
| 4171 | ns_selection_color = [[NSUserDefaults standardUserDefaults] | ||
| 4172 | stringForKey: @"AppleHighlightColor"]; | ||
| 4173 | if (ns_selection_color == nil) | ||
| 4174 | ns_selection_color = NS_SELECTION_COLOR_DEFAULT; | ||
| 4175 | |||
| 4176 | { | 4198 | { |
| 4177 | NSColorList *cl = [NSColorList colorListNamed: @"Emacs"]; | 4199 | NSColorList *cl = [NSColorList colorListNamed: @"Emacs"]; |
| 4178 | 4200 | ||