… | |
… | |
61 | #endif |
61 | #endif |
62 | typedef rxvt_img * urxvt__img; |
62 | typedef rxvt_img * urxvt__img; |
63 | |
63 | |
64 | ///////////////////////////////////////////////////////////////////////////// |
64 | ///////////////////////////////////////////////////////////////////////////// |
65 | |
65 | |
66 | static void |
66 | static rgba |
67 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
67 | parse_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 | |
75 | static wchar_t * |
108 | static 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 | |
2067 | rxvt_img * |
2100 | rxvt_img * |
2068 | rxvt_term::new_img (SV *format, int width = 1, int height = 1) |
2101 | rxvt_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 | |
|
|
2217 | void |
|
|
2218 | rxvt_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 | |
|
|
2226 | int |
|
|
2227 | rxvt_img::x () |
|
|
2228 | CODE: |
|
|
2229 | RETVAL = THIS->x; |
|
|
2230 | OUTPUT: |
|
|
2231 | RETVAL |
|
|
2232 | |
|
|
2233 | int |
|
|
2234 | rxvt_img::y () |
|
|
2235 | CODE: |
|
|
2236 | RETVAL = THIS->y; |
|
|
2237 | OUTPUT: |
|
|
2238 | RETVAL |
|
|
2239 | |
2184 | int |
2240 | int |
2185 | rxvt_img::w () |
2241 | rxvt_img::w () |
2186 | CODE: |
2242 | CODE: |
2187 | RETVAL = THIS->w; |
2243 | RETVAL = THIS->w; |
2188 | OUTPUT: |
2244 | OUTPUT: |
… | |
… | |
2203 | RETVAL |
2259 | RETVAL |
2204 | |
2260 | |
2205 | void |
2261 | void |
2206 | rxvt_img::fill (SV *c) |
2262 | rxvt_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 | |
2212 | void |
2267 | void |
2213 | rxvt_img::DESTROY () |
2268 | rxvt_img::DESTROY () |
2214 | CODE: |
2269 | CODE: |
2215 | delete THIS; |
2270 | delete THIS; |