diff options
| author | YAMAMOTO Mitsuharu | 2009-07-16 08:24:33 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2009-07-16 08:24:33 +0000 |
| commit | 042f7b692fcc3fe35af0b1afc0a85543440984f1 (patch) | |
| tree | 620e23671216153a5b228d4d22552540e9c2413b /src | |
| parent | 68d0f8a54cbb4bdb070fae27db440f25fe58724d (diff) | |
| download | emacs-042f7b692fcc3fe35af0b1afc0a85543440984f1.tar.gz emacs-042f7b692fcc3fe35af0b1afc0a85543440984f1.zip | |
(ns_get_color): Remove incompatible color formats.
(ns_color_to_lisp): Generate #rrggbb color format string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/nsterm.m | 78 |
2 files changed, 13 insertions, 73 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 698ab0d58dd..ba05615a0c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2009-07-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * nsfns.m (Fns_set_alpha): Remove function. | ||
| 4 | (syms_of_nsfns): Don't defsubr it. | ||
| 5 | |||
| 6 | * nsterm.m (ns_get_color): Remove incompatible color formats. | ||
| 7 | (ns_color_to_lisp): Generate #rrggbb color format string. | ||
| 8 | |||
| 1 | 2009-07-16 Richard Stallman <rms@gnu.org> | 9 | 2009-07-16 Richard Stallman <rms@gnu.org> |
| 2 | 10 | ||
| 3 | * fileio.c (Fwrite_region, Fdo_auto_save): Handle save_length = -2. | 11 | * fileio.c (Fwrite_region, Fdo_auto_save): Handle save_length = -2. |
diff --git a/src/nsterm.m b/src/nsterm.m index 6457b88eef7..32075cf20e1 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1345,15 +1345,11 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1345 | /* -------------------------------------------------------------------------- | 1345 | /* -------------------------------------------------------------------------- |
| 1346 | /* On *Step, we recognize several color formats, in addition to a catalog | 1346 | /* On *Step, we recognize several color formats, in addition to a catalog |
| 1347 | of colors found in the file Emacs.clr. Color formats include: | 1347 | of colors found in the file Emacs.clr. Color formats include: |
| 1348 | - #rrggbb or RGBrrggbb where rr, gg, bb specify red, green and blue in hex | 1348 | - #rrggbb where rr, gg, bb specify red, green and blue in hex. */ |
| 1349 | - ARGBaarrggbb is similar, with aa being the alpha channel (FF = opaque) | ||
| 1350 | - HSVhhssvv and AHSVaahhssvv (or HSB/AHSB) are similar for hue, saturation, | ||
| 1351 | value; | ||
| 1352 | - CMYKccmmyykk is similar for cyan, magenta, yellow, black. */ | ||
| 1353 | { | 1349 | { |
| 1354 | NSColor * new = nil; | 1350 | NSColor * new = nil; |
| 1355 | const char *hex = NULL; | 1351 | const char *hex = NULL; |
| 1356 | enum { rgb, argb, hsv, ahsv, cmyk, gray } color_space; | 1352 | enum { rgb } color_space; |
| 1357 | NSString *nsname = [NSString stringWithUTF8String: name]; | 1353 | NSString *nsname = [NSString stringWithUTF8String: name]; |
| 1358 | 1354 | ||
| 1359 | /*fprintf (stderr, "ns_get_color: '%s'\n", name); */ | 1355 | /*fprintf (stderr, "ns_get_color: '%s'\n", name); */ |
| @@ -1378,46 +1374,11 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1378 | return 0; | 1374 | return 0; |
| 1379 | } | 1375 | } |
| 1380 | 1376 | ||
| 1381 | /* FIXME: emacs seems to downcase everything before passing it here, | ||
| 1382 | which we can work around, except for GRAY, since gray##, where ## is | ||
| 1383 | decimal between 0 and 99, is also an X11 colorname. */ | ||
| 1384 | if (name[0] == '#') /* X11 format */ | 1377 | if (name[0] == '#') /* X11 format */ |
| 1385 | { | 1378 | { |
| 1386 | hex = name + 1; | 1379 | hex = name + 1; |
| 1387 | color_space = rgb; | 1380 | color_space = rgb; |
| 1388 | } | 1381 | } |
| 1389 | else if (!memcmp (name, "RGB", 3) || !memcmp (name, "rgb", 3)) | ||
| 1390 | { | ||
| 1391 | hex = name + 3; | ||
| 1392 | color_space = rgb; | ||
| 1393 | } | ||
| 1394 | else if (!memcmp (name, "ARGB", 4) || !memcmp (name, "argb", 4)) | ||
| 1395 | { | ||
| 1396 | hex = name + 4; | ||
| 1397 | color_space = argb; | ||
| 1398 | } | ||
| 1399 | else if (!memcmp (name, "HSV", 3) || !memcmp (name, "hsv", 3) || | ||
| 1400 | !memcmp (name, "HSB", 3) || !memcmp (name, "hsb", 3)) | ||
| 1401 | { | ||
| 1402 | hex = name + 3; | ||
| 1403 | color_space = hsv; | ||
| 1404 | } | ||
| 1405 | else if (!memcmp (name, "AHSV", 4) || !memcmp (name, "ahsv", 4) || | ||
| 1406 | !memcmp (name, "AHSB", 4) || !memcmp (name, "ahsb", 4)) | ||
| 1407 | { | ||
| 1408 | hex = name + 4; | ||
| 1409 | color_space = ahsv; | ||
| 1410 | } | ||
| 1411 | else if (!memcmp (name, "CMYK", 4) || !memcmp (name, "cmyk", 4)) | ||
| 1412 | { | ||
| 1413 | hex = name + 4; | ||
| 1414 | color_space = cmyk; | ||
| 1415 | } | ||
| 1416 | else if (!memcmp (name, "GRAY", 4) /*|| !memcmp (name, "gray", 4)*/) | ||
| 1417 | { | ||
| 1418 | hex = name + 4; | ||
| 1419 | color_space = gray; | ||
| 1420 | } | ||
| 1421 | 1382 | ||
| 1422 | /* Direct colors (hex values) */ | 1383 | /* Direct colors (hex values) */ |
| 1423 | if (hex) | 1384 | if (hex) |
| @@ -1447,34 +1408,6 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1447 | blue: f4 | 1408 | blue: f4 |
| 1448 | alpha: 1.0]; | 1409 | alpha: 1.0]; |
| 1449 | break; | 1410 | break; |
| 1450 | case argb: | ||
| 1451 | *col = [NSColor colorWithCalibratedRed: f2 | ||
| 1452 | green: f3 | ||
| 1453 | blue: f4 | ||
| 1454 | alpha: f1]; | ||
| 1455 | break; | ||
| 1456 | case hsv: | ||
| 1457 | *col = [NSColor colorWithCalibratedHue: f2 | ||
| 1458 | saturation: f3 | ||
| 1459 | brightness: f4 | ||
| 1460 | alpha: 1.0]; | ||
| 1461 | break; | ||
| 1462 | case ahsv: | ||
| 1463 | *col = [NSColor colorWithCalibratedHue: f2 | ||
| 1464 | saturation: f3 | ||
| 1465 | brightness: f4 | ||
| 1466 | alpha: f1]; | ||
| 1467 | break; | ||
| 1468 | case gray: | ||
| 1469 | *col = [NSColor colorWithCalibratedWhite: f3 alpha: f4]; | ||
| 1470 | break; | ||
| 1471 | case cmyk: | ||
| 1472 | *col = [NSColor colorWithDeviceCyan: f1 | ||
| 1473 | magenta: f2 | ||
| 1474 | yellow: f3 | ||
| 1475 | black: f4 | ||
| 1476 | alpha: 1.0]; | ||
| 1477 | break; | ||
| 1478 | } | 1411 | } |
| 1479 | *col = [*col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; | 1412 | *col = [*col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; |
| 1480 | UNBLOCK_INPUT; | 1413 | UNBLOCK_INPUT; |
| @@ -1573,14 +1506,13 @@ ns_color_to_lisp (NSColor *col) | |||
| 1573 | { | 1506 | { |
| 1574 | [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace] | 1507 | [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace] |
| 1575 | getWhite: &gray alpha: &alpha]; | 1508 | getWhite: &gray alpha: &alpha]; |
| 1576 | snprintf (buf, sizeof (buf), "GRAY%02.2lx%02.2lx", | 1509 | snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx", |
| 1577 | lrint (gray * 0xff), lrint (alpha * 0xff)); | 1510 | lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff)); |
| 1578 | UNBLOCK_INPUT; | 1511 | UNBLOCK_INPUT; |
| 1579 | return build_string (buf); | 1512 | return build_string (buf); |
| 1580 | } | 1513 | } |
| 1581 | 1514 | ||
| 1582 | snprintf (buf, sizeof (buf), "ARGB%02.2lx%02.2lx%02.2lx%02.2lx", | 1515 | snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx", |
| 1583 | lrint (alpha*0xff), | ||
| 1584 | lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff)); | 1516 | lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff)); |
| 1585 | 1517 | ||
| 1586 | UNBLOCK_INPUT; | 1518 | UNBLOCK_INPUT; |