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

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.193 by root, Tue Jun 12 18:25:57 2012 UTC vs.
Revision 1.196 by root, Thu Jun 14 18:13:19 2012 UTC

61#endif 61#endif
62typedef rxvt_img * urxvt__img; 62typedef rxvt_img * urxvt__img;
63 63
64///////////////////////////////////////////////////////////////////////////// 64/////////////////////////////////////////////////////////////////////////////
65 65
66static void 66static rgba
67parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) 67parse_rgba (SV *sv, rxvt_screen *s = 0)
68{ 68{
69 //TODO: support component stuff, 0..1 69 rgba c;
70
71 if (AV *av = (AV *)SvRV (sv))
72 {
73 if (SvTYPE ((SV *)av) != SVt_PVAV)
74 croak ("colour must be either a colour string, or an array,");
75
76 int len = av_len (av) + 1;
77
78 if (len != 1 && len != 3 && len != 4)
79 croak ("component colour array must have 1, 3 or 4 components,");
80
81 c.a = rgba::MAX_CC;
82
83 c.r = c.g = c.b = float_to_component (SvIV (*av_fetch (av, 0, 0)));
84
85 if (len >= 3)
86 {
87 c.g = float_to_component (SvIV (*av_fetch (av, 1, 0)));
88 c.b = float_to_component (SvIV (*av_fetch (av, 2, 0)));
89
90 if (len >= 4)
91 c.a = float_to_component (SvIV (*av_fetch (av, 3, 0)));
92 }
93 }
94 else if (s)
95 {
96 rxvt_color rc;
70 c.set (s, SvPVbyte_nolen (sv)); 97 rc.set (s, SvPVbyte_nolen (sv));
98 rc.get (c);
99 }
100 else
101 croak ("unable to parse colour,");
102
103 return c;
71} 104}
72 105
73///////////////////////////////////////////////////////////////////////////// 106/////////////////////////////////////////////////////////////////////////////
74 107
75static wchar_t * 108static wchar_t *
2063 PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height))); 2096 PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height)));
2064 2097
2065#if HAVE_IMG 2098#if HAVE_IMG
2066 2099
2067rxvt_img * 2100rxvt_img *
2068rxvt_term::new_img (SV *format, int width = 1, int height = 1) 2101rxvt_term::new_img (SV *format, int x = 0, int y = 0, int width = 1, int height = 1)
2069 CODE: 2102 CODE:
2070 XRenderPictFormat *f = SvOK (format) 2103 XRenderPictFormat *f = SvOK (format)
2071 ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) 2104 ? XRenderFindStandardFormat (THIS->dpy, SvIV (format))
2072 : XRenderFindVisualFormat (THIS->dpy, THIS->visual); 2105 : XRenderFindVisualFormat (THIS->dpy, THIS->visual);
2073 RETVAL = new rxvt_img (THIS, f, 0, 0, width, height); 2106 RETVAL = new rxvt_img (THIS, f, x, y, width, height);
2074 RETVAL->alloc (); 2107 RETVAL->alloc ();
2075 OUTPUT: 2108 OUTPUT:
2076 RETVAL 2109 RETVAL
2077 2110
2078#if ENABLE_TRANSPARENCY 2111#if ENABLE_TRANSPARENCY
2179#if HAVE_IMG 2212#if HAVE_IMG
2180 2213
2181# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) 2214# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
2182# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); 2215# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
2183 2216
2217void
2218rxvt_img::geometry ()
2219 PPCODE:
2220 EXTEND (SP, 4);
2221 PUSHs (sv_2mortal (newSViv (THIS->x)));
2222 PUSHs (sv_2mortal (newSViv (THIS->y)));
2223 PUSHs (sv_2mortal (newSViv (THIS->w)));
2224 PUSHs (sv_2mortal (newSViv (THIS->h)));
2225
2226int
2227rxvt_img::x ()
2228 CODE:
2229 RETVAL = THIS->x;
2230 OUTPUT:
2231 RETVAL
2232
2233int
2234rxvt_img::y ()
2235 CODE:
2236 RETVAL = THIS->y;
2237 OUTPUT:
2238 RETVAL
2239
2184int 2240int
2185rxvt_img::w () 2241rxvt_img::w ()
2186 CODE: 2242 CODE:
2187 RETVAL = THIS->w; 2243 RETVAL = THIS->w;
2188 OUTPUT: 2244 OUTPUT:
2203 RETVAL 2259 RETVAL
2204 2260
2205void 2261void
2206rxvt_img::fill (SV *c) 2262rxvt_img::fill (SV *c)
2207 INIT: 2263 INIT:
2208 rxvt_color rc; 2264 rgba cc = parse_rgba (c, THIS->s);
2209 parse_color (THIS->s, rc, c);
2210 C_ARGS: rc 2265 C_ARGS: cc
2211 2266
2212void 2267void
2213rxvt_img::DESTROY () 2268rxvt_img::DESTROY ()
2214 CODE: 2269 CODE:
2215 delete THIS; 2270 delete THIS;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines