comparison src/nsterm.m @ 104069:13c45bf5b233

* nsfont.m (nsfont_draw): Revert 2009-07-15 change. * nsterm.m (ns_maybe_dumpglyphs_background): Revert 2009-07-15 change. (ns_get_color): Revert 2009-07-16 change.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 26 Jul 2009 12:58:56 +0000
parents f3ac65e9abd6
children 76f05970298e
comparison
equal deleted inserted replaced
104068:a86fc864e9fc 104069:13c45bf5b233
1346 /* -------------------------------------------------------------------------- 1346 /* --------------------------------------------------------------------------
1347 Parse a color name 1347 Parse a color name
1348 /* -------------------------------------------------------------------------- 1348 /* --------------------------------------------------------------------------
1349 /* On *Step, we recognize several color formats, in addition to a catalog 1349 /* On *Step, we recognize several color formats, in addition to a catalog
1350 of colors found in the file Emacs.clr. Color formats include: 1350 of colors found in the file Emacs.clr. Color formats include:
1351 - #rrggbb where rr, gg, bb specify red, green and blue in hex. */ 1351 - #rrggbb or RGBrrggbb where rr, gg, bb specify red, green and blue in hex
1352 - ARGBaarrggbb is similar, with aa being the alpha channel (FF = opaque)
1353 - HSVhhssvv and AHSVaahhssvv (or HSB/AHSB) are similar for hue, saturation,
1354 value;
1355 - CMYKccmmyykk is similar for cyan, magenta, yellow, black. */
1352 { 1356 {
1353 NSColor * new = nil; 1357 NSColor * new = nil;
1354 const char *hex = NULL; 1358 const char *hex = NULL;
1355 enum { rgb } color_space; 1359 enum { rgb, argb, hsv, ahsv, cmyk, gray } color_space;
1356 NSString *nsname = [NSString stringWithUTF8String: name]; 1360 NSString *nsname = [NSString stringWithUTF8String: name];
1357 1361
1358 /*fprintf (stderr, "ns_get_color: '%s'\n", name); */ 1362 /*fprintf (stderr, "ns_get_color: '%s'\n", name); */
1359 BLOCK_INPUT; 1363 BLOCK_INPUT;
1360 1364
1375 *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0]; 1379 *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0];
1376 UNBLOCK_INPUT; 1380 UNBLOCK_INPUT;
1377 return 0; 1381 return 0;
1378 } 1382 }
1379 1383
1384 /* FIXME: emacs seems to downcase everything before passing it here,
1385 which we can work around, except for GRAY, since gray##, where ## is
1386 decimal between 0 and 99, is also an X11 colorname. */
1380 if (name[0] == '#') /* X11 format */ 1387 if (name[0] == '#') /* X11 format */
1381 { 1388 {
1382 hex = name + 1; 1389 hex = name + 1;
1383 color_space = rgb; 1390 color_space = rgb;
1391 }
1392 else if (!memcmp (name, "RGB", 3) || !memcmp (name, "rgb", 3))
1393 {
1394 hex = name + 3;
1395 color_space = rgb;
1396 }
1397 else if (!memcmp (name, "ARGB", 4) || !memcmp (name, "argb", 4))
1398 {
1399 hex = name + 4;
1400 color_space = argb;
1401 }
1402 else if (!memcmp (name, "HSV", 3) || !memcmp (name, "hsv", 3) ||
1403 !memcmp (name, "HSB", 3) || !memcmp (name, "hsb", 3))
1404 {
1405 hex = name + 3;
1406 color_space = hsv;
1407 }
1408 else if (!memcmp (name, "AHSV", 4) || !memcmp (name, "ahsv", 4) ||
1409 !memcmp (name, "AHSB", 4) || !memcmp (name, "ahsb", 4))
1410 {
1411 hex = name + 4;
1412 color_space = ahsv;
1413 }
1414 else if (!memcmp (name, "CMYK", 4) || !memcmp (name, "cmyk", 4))
1415 {
1416 hex = name + 4;
1417 color_space = cmyk;
1418 }
1419 else if (!memcmp (name, "GRAY", 4) /*|| !memcmp (name, "gray", 4)*/)
1420 {
1421 hex = name + 4;
1422 color_space = gray;
1384 } 1423 }
1385 1424
1386 /* Direct colors (hex values) */ 1425 /* Direct colors (hex values) */
1387 if (hex) 1426 if (hex)
1388 { 1427 {
1408 case rgb: 1447 case rgb:
1409 *col = [NSColor colorWithCalibratedRed: f2 1448 *col = [NSColor colorWithCalibratedRed: f2
1410 green: f3 1449 green: f3
1411 blue: f4 1450 blue: f4
1412 alpha: 1.0]; 1451 alpha: 1.0];
1452 break;
1453 case argb:
1454 *col = [NSColor colorWithCalibratedRed: f2
1455 green: f3
1456 blue: f4
1457 alpha: f1];
1458 break;
1459 case hsv:
1460 *col = [NSColor colorWithCalibratedHue: f2
1461 saturation: f3
1462 brightness: f4
1463 alpha: 1.0];
1464 break;
1465 case ahsv:
1466 *col = [NSColor colorWithCalibratedHue: f2
1467 saturation: f3
1468 brightness: f4
1469 alpha: f1];
1470 break;
1471 case gray:
1472 *col = [NSColor colorWithCalibratedWhite: f3 alpha: f4];
1473 break;
1474 case cmyk:
1475 *col = [NSColor colorWithDeviceCyan: f1
1476 magenta: f2
1477 yellow: f3
1478 black: f4
1479 alpha: 1.0];
1413 break; 1480 break;
1414 } 1481 }
1415 *col = [*col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; 1482 *col = [*col colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
1416 UNBLOCK_INPUT; 1483 UNBLOCK_INPUT;
1417 return 0; 1484 return 0;
2651 /* expand full-width row over internal borders */ 2718 /* expand full-width row over internal borders */
2652 if (s->row->full_width_p) 2719 if (s->row->full_width_p)
2653 r = ns_fix_rect_ibw (r, FRAME_INTERNAL_BORDER_WIDTH (s->f), 2720 r = ns_fix_rect_ibw (r, FRAME_INTERNAL_BORDER_WIDTH (s->f),
2654 FRAME_PIXEL_WIDTH (s->f)); 2721 FRAME_PIXEL_WIDTH (s->f));
2655 2722
2656 /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */ if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color) 2723 /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */
2724 if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
2657 { 2725 {
2658 ns_draw_box (r, abs (thickness), 2726 ns_draw_box (r, abs (thickness),
2659 ns_lookup_indexed_color (face->box_color, s->f), 2727 ns_lookup_indexed_color (face->box_color, s->f),
2660 left_p, right_p); 2728 left_p, right_p);
2661 } 2729 }
2690 if (!face) 2758 if (!face)
2691 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 2759 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2692 } 2760 }
2693 else 2761 else
2694 face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 2762 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
2695 #if 0
2696 if (!face->stipple) 2763 if (!face->stipple)
2697 #endif
2698 [(NS_FACE_BACKGROUND (face) != 0 2764 [(NS_FACE_BACKGROUND (face) != 0
2699 ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) 2765 ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f)
2700 : FRAME_BACKGROUND_COLOR (s->f)) set]; 2766 : FRAME_BACKGROUND_COLOR (s->f)) set];
2701 #if 0 /* This is tiling, not stippling. */
2702 else 2767 else
2703 { 2768 {
2704 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (s->f); 2769 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (s->f);
2705 [[dpyinfo->bitmaps[face->stipple-1].img stippleMask] set]; 2770 [[dpyinfo->bitmaps[face->stipple-1].img stippleMask] set];
2706 } 2771 }
2707 #endif
2708 2772
2709 if (s->hl != DRAW_CURSOR) 2773 if (s->hl != DRAW_CURSOR)
2710 { 2774 {
2711 NSRect r = NSMakeRect (s->x, s->y + box_line_width, 2775 NSRect r = NSMakeRect (s->x, s->y + box_line_width,
2712 s->background_width, 2776 s->background_width,