--- rxvt-unicode/src/rxvtperl.xs 2012/06/10 15:01:14 1.191 +++ rxvt-unicode/src/rxvtperl.xs 2012/06/14 17:16:05 1.195 @@ -63,11 +63,44 @@ ///////////////////////////////////////////////////////////////////////////// -static void -parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) +static rgba +parse_rgba (SV *sv, rxvt_screen *s = 0) { - //TODO: support component stuff, 0..1 - c.set (s, SvPVbyte_nolen (sv)); + rgba c; + + if (AV *av = (AV *)SvRV (sv)) + { + if (SvTYPE ((SV *)av) != SVt_PVAV) + croak ("colour must be either a colour string, or an array,"); + + int len = av_len (av) + 1; + + if (len != 1 && len != 3 && len != 4) + croak ("component colour array must have 1, 3 or 4 components,"); + + c.a = rgba::MAX_CC; + + c.r = c.g = c.b = float_to_component (SvIV (*av_fetch (av, 0, 0))); + + if (len >= 3) + { + c.g = float_to_component (SvIV (*av_fetch (av, 1, 0))); + c.b = float_to_component (SvIV (*av_fetch (av, 2, 0))); + + if (len >= 4) + c.a = float_to_component (SvIV (*av_fetch (av, 3, 0))); + } + } + else if (s) + { + rxvt_color rc; + rc.set (s, SvPVbyte_nolen (sv)); + rc.get (c); + } + else + croak ("unable to parse colour,"); + + return c; } ///////////////////////////////////////////////////////////////////////////// @@ -345,7 +378,7 @@ } void -rxvt_perl_interp::init (rxvt_term *term) +rxvt_perl_interp::init () { if (!perl) { @@ -385,6 +418,12 @@ rxvt_pop_locale (); } +} + +void +rxvt_perl_interp::init (rxvt_term *term) +{ + init (); if (perl && !term->perl.self) { @@ -396,6 +435,12 @@ } void +rxvt_perl_interp::eval (const char *str) +{ + eval_pv (str, 1); +} + +void rxvt_perl_interp::usage (rxvt_term *term, int type) { localise_env set_environ (perl_environ); @@ -2041,7 +2086,6 @@ OUTPUT: RETVAL -# TODO: ugly void rxvt_term::background_geometry (bool border = false) PPCODE: @@ -2194,9 +2238,8 @@ void rxvt_img::fill (SV *c) INIT: - rxvt_color rc; - parse_color (THIS->s, rc, c); - C_ARGS: rc + rgba cc = parse_rgba (c, THIS->s); + C_ARGS: cc void rxvt_img::DESTROY () @@ -2236,20 +2279,20 @@ rxvt_img::blur (int rh, int rv) rxvt_img * -rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) +rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) INIT: - double matrix[9] = { - p11, p12, p13, - p21, p22, p23, - p31, p32, p33 + double matrix[3][3] = { + { p11, p12, p13 }, + { p21, p22, p23 }, + { p31, p32, p33 } }; - C_ARGS: new_width, new_height, matrix + C_ARGS: matrix rxvt_img * rxvt_img::scale (int new_width, int new_height) rxvt_img * -rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi) +rxvt_img::rotate (int x, int y, NV phi) #endif