ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.C
(Generate patch)

Comparing rxvt-unicode/src/rxvttoolkit.C (file contents):
Revision 1.38 by root, Mon Jan 30 19:46:13 2006 UTC vs.
Revision 1.39 by root, Tue Jan 31 00:25:16 2006 UTC

633} 633}
634 634
635bool 635bool
636rxvt_color::set (rxvt_screen *screen, const char *name) 636rxvt_color::set (rxvt_screen *screen, const char *name)
637{ 637{
638 int l = strlen (name);
639 rxvt_rgba r; 638 rxvt_rgba c;
640 char eos; 639 char eos;
641 int mult; 640 int skip;
642 XColor xc, xc_exact;
643 641
644 // parse a number of non-standard ARGB colour specifications 642 if (1 <= sscanf (name, "[%hx]%n", &c.a, &skip))
645 if ( l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos))
646 mult = rxvt_rgba::MAX_CC / 0x0010;
647 else if (l == 1+4*2 && 4 == sscanf (name, "#%2hx%2hx%2hx%2hx%c", &r.a, &r.r, &r.g, &r.b, &eos))
648 mult = rxvt_rgba::MAX_CC / 0x0100;
649 else if (l == 1+4*4 && 4 == sscanf (name, "#%4hx%4hx%4hx%4hx%c", &r.a, &r.r, &r.g, &r.b, &eos))
650 mult = rxvt_rgba::MAX_CC / 0x0100;
651 else if (l == 4+5*4 && 4 == sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos))
652 mult = rxvt_rgba::MAX_CC / 0xffff;
653 else if (XParseColor (screen->xdisp, screen->cmap, name, &xc))
654 { 643 {
655 r.r = xc.red; 644 switch (skip)
656 r.g = xc.green; 645 {
657 r.b = xc.blue; 646 case 2 + 1: c.a *= rxvt_rgba::MAX_CC / 0x000f; break;
658 mult = rxvt_rgba::MAX_CC / 0xffff; 647 case 2 + 2: c.a *= rxvt_rgba::MAX_CC / 0x00ff; break;
648 case 2 + 3: c.a *= rxvt_rgba::MAX_CC / 0x0fff; break;
649 case 2 + 4: c.a *= rxvt_rgba::MAX_CC / 0xffff; break;
650 }
651
652 name += skip;
659 } 653 }
660 else 654 else
655 c.a = rxvt_rgba::MAX_CC;
656
657 // parse the non-standard rgba format
658 if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &c.r, &c.g, &c.b, &c.a, &eos))
661 { 659 {
660 XColor xc, xc_exact;
661
662 if (XParseColor (screen->xdisp, screen->cmap, name, &xc))
663 {
664 c.r = xc.red;
665 c.g = xc.green;
666 c.b = xc.blue;
667 }
668 else
669 {
670 c.r = 0xffff;
671 c.g = 0x6969;
672 c.b = 0xb4b4;
673
662 rxvt_warn ("failed to allocate color '%s', using pink instead.\n", name); 674 rxvt_warn ("unable to parse color '%s', using pink instead.\n", name);
663 r.r = 255; 675 }
664 r.g = 105;
665 r.b = 180;
666 mult = rxvt_rgba::MAX_CC / 0x00ff;
667 } 676 }
668 677
669 r.r *= mult; r.g *= mult; r.b *= mult; r.a *= mult;
670
671 return set (screen, r); 678 return set (screen, c);
672} 679}
673 680
674bool 681bool
675rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) 682rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba)
676{ 683{
716#endif 723#endif
717 724
718 return got; 725 return got;
719} 726}
720 727
721void 728void
722rxvt_color::get (rxvt_screen *screen, rxvt_rgba &rgba) 729rxvt_color::get (rxvt_screen *screen, rxvt_rgba &rgba)
723{ 730{
724#if XFT 731#if XFT
725 rgba.r = c.color.red; 732 rgba.r = c.color.red;
726 rgba.g = c.color.green; 733 rgba.g = c.color.green;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines