]> git.eshelyaron.com Git - emacs.git/commitdiff
(ns_get_color): Remove incompatible color formats.
authorYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Thu, 16 Jul 2009 08:27:07 +0000 (08:27 +0000)
committerYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Thu, 16 Jul 2009 08:27:07 +0000 (08:27 +0000)
(ns_color_to_lisp): Generate #rrggbb color format string.

src/ChangeLog
src/nsterm.m

index 1c0f67aaa21f5610a49d1bdbd99023f7c0257b8e..b517ef0c006e1c582b0af07ce64cc48975ba552b 100644 (file)
@@ -1,3 +1,11 @@
+2009-07-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+       * nsfns.m (Fns_set_alpha): Remove function.
+       (syms_of_nsfns): Don't defsubr it.
+
+       * nsterm.m (ns_get_color): Remove incompatible color formats.
+       (ns_color_to_lisp): Generate #rrggbb color format string.
+
 2009-07-15  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * nsfont.m (nsfont_draw): Remove code for stippling, which actually
index 6457b88eef7176233d096ea58e7c58f6d3eb4640..32075cf20e1aff1425888eb7aef1b88cba60e899 100644 (file)
@@ -1345,15 +1345,11 @@ ns_get_color (const char *name, NSColor **col)
 /* --------------------------------------------------------------------------
 /* On *Step, we recognize several color formats, in addition to a catalog
    of colors found in the file Emacs.clr. Color formats include:
-   - #rrggbb or RGBrrggbb where rr, gg, bb specify red, green and blue in hex
-   - ARGBaarrggbb is similar, with aa being the alpha channel (FF = opaque)
-   - HSVhhssvv and AHSVaahhssvv (or HSB/AHSB) are similar for hue, saturation,
-     value;
-   - CMYKccmmyykk is similar for cyan, magenta, yellow, black. */
+   - #rrggbb where rr, gg, bb specify red, green and blue in hex. */
 {
   NSColor * new = nil;
   const char *hex = NULL;
-  enum { rgb, argb, hsv, ahsv, cmyk, gray } color_space;
+  enum { rgb } color_space;
   NSString *nsname = [NSString stringWithUTF8String: name];
 
 /*fprintf (stderr, "ns_get_color: '%s'\n", name); */
@@ -1378,46 +1374,11 @@ ns_get_color (const char *name, NSColor **col)
       return 0;
     }
 
-  /*  FIXME: emacs seems to downcase everything before passing it here,
-        which we can work around, except for GRAY, since gray##, where ## is
-        decimal between 0 and 99, is also an X11 colorname. */
   if (name[0] == '#')             /* X11 format */
     {
       hex = name + 1;
       color_space = rgb;
     }
-  else if (!memcmp (name, "RGB", 3) || !memcmp (name, "rgb", 3))
-    {
-      hex = name + 3;
-      color_space = rgb;
-    }
-  else if (!memcmp (name, "ARGB", 4) || !memcmp (name, "argb", 4))
-    {
-      hex = name + 4;
-      color_space = argb;
-    }
-  else if (!memcmp (name, "HSV", 3) || !memcmp (name, "hsv", 3) || 
-           !memcmp (name, "HSB", 3) || !memcmp (name, "hsb", 3))
-    {
-      hex = name + 3;
-      color_space = hsv;
-    }
-  else if (!memcmp (name, "AHSV", 4) || !memcmp (name, "ahsv", 4) ||
-           !memcmp (name, "AHSB", 4) || !memcmp (name, "ahsb", 4))
-    {
-      hex = name + 4;
-      color_space = ahsv;
-    }
-  else if (!memcmp (name, "CMYK", 4) || !memcmp (name, "cmyk", 4))
-    {
-      hex = name + 4;
-      color_space = cmyk;
-    }
-  else if (!memcmp (name, "GRAY", 4) /*|| !memcmp (name, "gray", 4)*/)
-    {
-      hex = name + 4;
-      color_space = gray;
-    }
 
   /* Direct colors (hex values) */
   if (hex)
@@ -1447,34 +1408,6 @@ ns_get_color (const char *name, NSColor **col)
                                                 blue: f4
                                                alpha: 1.0];
               break;
-            case argb:
-              *col = [NSColor colorWithCalibratedRed: f2
-                                               green: f3
-                                                blue: f4
-                                               alpha: f1];
-              break;
-            case hsv:
-              *col = [NSColor colorWithCalibratedHue: f2
-                                          saturation: f3
-                                          brightness: f4
-                                               alpha: 1.0];
-              break;
-            case ahsv:
-              *col = [NSColor colorWithCalibratedHue: f2
-                                          saturation: f3
-                                          brightness: f4
-                                               alpha: f1];
-              break;
-            case gray:
-              *col = [NSColor colorWithCalibratedWhite: f3 alpha: f4];
-              break;
-            case cmyk:
-              *col = [NSColor colorWithDeviceCyan: f1
-                                          magenta: f2
-                                           yellow: f3
-                                            black: f4
-                                            alpha: 1.0];
-              break;
             }
           *col = [*col colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
           UNBLOCK_INPUT;
@@ -1573,14 +1506,13 @@ ns_color_to_lisp (NSColor *col)
     {
       [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
             getWhite: &gray alpha: &alpha];
-      snprintf (buf, sizeof (buf), "GRAY%02.2lx%02.2lx",
-               lrint (gray * 0xff), lrint (alpha * 0xff));
+      snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+               lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
       UNBLOCK_INPUT;
       return build_string (buf);
     }
 
-  snprintf (buf, sizeof (buf), "ARGB%02.2lx%02.2lx%02.2lx%02.2lx",
-            lrint (alpha*0xff),
+  snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
             lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
 
   UNBLOCK_INPUT;