emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114473: Pick up default selection color on OSX when


From: Jan D.
Subject: [Emacs-diffs] trunk r114473: Pick up default selection color on OSX when user defaults are not set.
Date: Sat, 28 Sep 2013 10:01:55 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114473
revision-id: address@hidden
parent: address@hidden
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Sat 2013-09-28 12:01:50 +0200
message:
  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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/faces.el                  faces.el-20091113204419-o5vbwnq5f7feedwu-562
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/nsterm.h                   nsterm.h-20091113204419-o5vbwnq5f7feedwu-8746
  src/nsterm.m                   nsterm.m-20091113204419-o5vbwnq5f7feedwu-8747
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-09-28 03:15:56 +0000
+++ b/lisp/ChangeLog    2013-09-28 10:01:50 +0000
@@ -1,3 +1,8 @@
+2013-09-28  Jan Djärv  <address@hidden>
+
+       * faces.el (region): Change ns_selection_color to
+       ns_selection_fg_color, add ns_selection_bg_color.
+
 2013-09-28  Leo Liu  <address@hidden>
 
        * progmodes/octave.el (inferior-octave-completion-table)

=== modified file 'lisp/faces.el'
--- a/lisp/faces.el     2013-09-18 03:53:10 +0000
+++ b/lisp/faces.el     2013-09-28 10:01:50 +0000
@@ -2259,7 +2259,8 @@
      :foreground "gtk_selection_fg_color"
      :background "gtk_selection_bg_color")
     (((class color) (min-colors 88) (background light) (type ns))
-     :background "ns_selection_color")
+     :foreground "ns_selection_fg_color"
+     :background "ns_selection_bg_color")
     (((class color) (min-colors 88) (background light))
      :background "lightgoldenrod2")
     (((class color) (min-colors 16) (background dark))

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-09-28 08:19:33 +0000
+++ b/src/ChangeLog     2013-09-28 10:01:50 +0000
@@ -1,3 +1,15 @@
+2013-09-28  Jan Djärv  <address@hidden>
+
+       * 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.
+
+       * nsterm.h (NS_SELECTION_BG_COLOR_DEFAULT): Renamed from
+       NS_SELECTION_COLOR_DEFAULT.
+       (NS_SELECTION_FG_COLOR_DEFAULT): New.
+
 2013-09-28  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (Fdump_tool_bar_row): Ifdef away the body if 'struct

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2013-09-19 07:48:53 +0000
+++ b/src/nsterm.h      2013-09-28 10:01:50 +0000
@@ -911,7 +911,8 @@
 
 #define NS_SCROLL_BAR_WIDTH_DEFAULT     [EmacsScroller scrollerWidth]
 /* This is to match emacs on other platforms, ugly though it is. */
-#define NS_SELECTION_COLOR_DEFAULT     @"LightGoldenrod2";
+#define NS_SELECTION_BG_COLOR_DEFAULT  @"LightGoldenrod2";
+#define NS_SELECTION_FG_COLOR_DEFAULT  @"Black";
 #define RESIZE_HANDLE_SIZE 12
 
 /* Little utility macros */

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2013-09-22 14:26:10 +0000
+++ b/src/nsterm.m      2013-09-28 10:01:50 +0000
@@ -179,9 +179,6 @@
    no way to control this behavior. */
 float ns_antialias_threshold;
 
-/* Used to pick up AppleHighlightColor on OS X */
-NSString *ns_selection_color;
-
 NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0;
 NSString *ns_app_name = @"Emacs";  /* default changed later */
 
@@ -1454,11 +1451,41 @@
 /*fprintf (stderr, "ns_get_color: '%s'\n", name); */
   block_input ();
 
-  if ([nsname isEqualToString: @"ns_selection_color"])
-    {
-      nsname = ns_selection_color;
-      name = [ns_selection_color UTF8String];
-    }
+#ifdef NS_IMPL_COCOA
+  if ([nsname isEqualToString: @"ns_selection_bg_color"])
+    {
+      NSString *defname = [[NSUserDefaults standardUserDefaults]
+                            stringForKey: @"AppleHighlightColor"];
+
+      if (defname != nil)
+        nsname = defname;
+      else if ((new = [NSColor selectedTextBackgroundColor]) != nil)
+        {
+          *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+          unblock_input ();
+          return 0;
+        }
+      else
+        nsname = NS_SELECTION_BG_COLOR_DEFAULT;
+
+      name = [nsname UTF8String];
+    }
+  else if ([nsname isEqualToString: @"ns_selection_fg_color"])
+    {
+      /* NOTE: OSX applications normally don't set foreground selection, but
+         text may be unreadable if we don't.
+      */
+      if ((new = [NSColor selectedTextColor]) != nil)
+        {
+          *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+          unblock_input ();
+          return 0;
+        }
+
+      nsname = NS_SELECTION_FG_COLOR_DEFAULT;
+      name = [nsname UTF8String];
+    }
+#endif // NS_IMPL_COCOA
 
   /* First, check for some sort of numeric specification. */
   hex[0] = '\0';
@@ -4168,11 +4195,6 @@
       ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp);
     }
 
-  ns_selection_color = [[NSUserDefaults standardUserDefaults]
-                        stringForKey: @"AppleHighlightColor"];
-  if (ns_selection_color == nil)
-    ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
-
   {
     NSColorList *cl = [NSColorList colorListNamed: @"Emacs"];
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]