… | |
… | |
54 | typedef char * octet_string; |
54 | typedef char * octet_string; |
55 | typedef char * utf8_string; |
55 | typedef char * utf8_string; |
56 | |
56 | |
57 | typedef int render_repeat_mode; |
57 | typedef int render_repeat_mode; |
58 | |
58 | |
|
|
59 | #if HAVE_PIXBUF |
59 | typedef GdkPixbuf * urxvt__pixbuf; |
60 | typedef GdkPixbuf * urxvt__pixbuf; |
|
|
61 | #endif |
60 | typedef rxvt_img * urxvt__img; |
62 | typedef rxvt_img * urxvt__img; |
61 | |
63 | |
62 | ///////////////////////////////////////////////////////////////////////////// |
64 | ///////////////////////////////////////////////////////////////////////////// |
63 | |
65 | |
64 | static void |
66 | static rgba |
65 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
67 | parse_rgba (SV *sv, rxvt_screen *s = 0) |
66 | { |
68 | { |
67 | //TODO: support component stuff |
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; |
68 | 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; |
69 | } |
104 | } |
70 | |
105 | |
71 | ///////////////////////////////////////////////////////////////////////////// |
106 | ///////////////////////////////////////////////////////////////////////////// |
72 | |
107 | |
73 | static wchar_t * |
108 | static wchar_t * |
… | |
… | |
341 | PERL_SYS_TERM (); |
376 | PERL_SYS_TERM (); |
342 | } |
377 | } |
343 | } |
378 | } |
344 | |
379 | |
345 | void |
380 | void |
346 | rxvt_perl_interp::init (rxvt_term *term) |
381 | rxvt_perl_interp::init () |
347 | { |
382 | { |
348 | if (!perl) |
383 | if (!perl) |
349 | { |
384 | { |
350 | rxvt_push_locale (""); // perl init destroys current locale |
385 | rxvt_push_locale (""); // perl init destroys current locale |
351 | |
386 | |
… | |
… | |
381 | } |
416 | } |
382 | } |
417 | } |
383 | |
418 | |
384 | rxvt_pop_locale (); |
419 | rxvt_pop_locale (); |
385 | } |
420 | } |
|
|
421 | } |
386 | |
422 | |
387 | if (perl) |
423 | void |
|
|
424 | rxvt_perl_interp::init (rxvt_term *term) |
|
|
425 | { |
|
|
426 | init (); |
|
|
427 | |
|
|
428 | if (perl && !term->perl.self) |
388 | { |
429 | { |
389 | // runs outside of perls ENV |
430 | // runs outside of perls ENV |
390 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
431 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
391 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
432 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
392 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
433 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
393 | } |
434 | } |
394 | } |
435 | } |
395 | |
436 | |
396 | void |
437 | void |
|
|
438 | rxvt_perl_interp::eval (const char *str) |
|
|
439 | { |
|
|
440 | eval_pv (str, 1); |
|
|
441 | } |
|
|
442 | |
|
|
443 | void |
397 | rxvt_perl_interp::usage (rxvt_term *term, int type) |
444 | rxvt_perl_interp::usage (rxvt_term *term, int type) |
398 | { |
445 | { |
399 | localise_env set_environ (perl_environ); |
446 | localise_env set_environ (perl_environ); |
400 | |
447 | |
401 | ENTER; |
448 | ENTER; |
402 | SAVETMPS; |
449 | SAVETMPS; |
403 | |
450 | |
404 | dSP; |
451 | dSP; |
|
|
452 | PUSHMARK (SP); |
405 | EXTEND (SP, 2); |
453 | EXTEND (SP, 2); |
406 | PUSHs (sv_2mortal (newSVterm (term))); |
454 | PUSHs (sv_2mortal (newSVterm (term))); |
407 | PUSHs (sv_2mortal (newSViv (type))); |
455 | PUSHs (sv_2mortal (newSViv (type))); |
408 | PUTBACK; |
456 | PUTBACK; |
409 | call_pv ("urxvt::usage", G_VOID | G_DISCARD | G_EVAL); |
457 | call_pv ("urxvt::usage", G_VOID | G_DISCARD); |
410 | |
458 | |
411 | FREETMPS; |
459 | FREETMPS; |
412 | LEAVE; |
460 | LEAVE; |
413 | } |
461 | } |
414 | |
462 | |
415 | uint8_t |
463 | uint8_t |
416 | rxvt_perl_interp::resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
464 | rxvt_perl_interp::parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
417 | { |
465 | { |
418 | localise_env set_environ (perl_environ); |
466 | localise_env set_environ (perl_environ); |
419 | |
467 | |
420 | ENTER; |
468 | ENTER; |
421 | SAVETMPS; |
469 | SAVETMPS; |
422 | |
470 | |
423 | dSP; |
471 | dSP; |
|
|
472 | PUSHMARK (SP); |
424 | EXTEND (SP, 6); |
473 | EXTEND (SP, 6); |
425 | PUSHs (sv_2mortal (newSVterm (term))); |
474 | PUSHs (sv_2mortal (newSVterm (term))); |
426 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
475 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
427 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
476 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
428 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
477 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
429 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
478 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
430 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
479 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
431 | PUTBACK; |
480 | PUTBACK; |
432 | call_pv ("urxvt::resource", G_SCALAR | G_EVAL); |
481 | call_pv ("urxvt::parse_resource", G_SCALAR); |
|
|
482 | SPAGAIN; |
433 | |
483 | |
434 | uint8_t ret = POPi; |
484 | uint8_t ret = POPi; |
435 | |
485 | |
436 | FREETMPS; |
486 | FREETMPS; |
437 | LEAVE; |
487 | LEAVE; |
… | |
… | |
1061 | if (count) |
1111 | if (count) |
1062 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
1112 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
1063 | } |
1113 | } |
1064 | } |
1114 | } |
1065 | |
1115 | |
|
|
1116 | void |
|
|
1117 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
|
|
1118 | CODE: |
|
|
1119 | XrmPutStringResource (&THIS->option_db, specifier, value); |
|
|
1120 | |
1066 | int |
1121 | int |
1067 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1122 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1068 | CODE: |
1123 | CODE: |
1069 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1124 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1070 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1125 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
… | |
… | |
2022 | } |
2077 | } |
2023 | |
2078 | |
2024 | ############################################################################# |
2079 | ############################################################################# |
2025 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
2080 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
2026 | |
2081 | |
2027 | # TODO: ugly |
2082 | bool |
|
|
2083 | rxvt_term::has_render () |
|
|
2084 | CODE: |
|
|
2085 | RETVAL = THIS->display->flags & DISPLAY_HAS_RENDER; |
|
|
2086 | OUTPUT: |
|
|
2087 | RETVAL |
|
|
2088 | |
2028 | void |
2089 | void |
2029 | rxvt_term::get_geometry () |
2090 | rxvt_term::background_geometry (bool border = false) |
2030 | PPCODE: |
2091 | PPCODE: |
2031 | EXTEND (SP, 4); |
2092 | EXTEND (SP, 4); |
2032 | PUSHs (sv_2mortal (newSViv (THIS->parent_x))); |
2093 | PUSHs (sv_2mortal (newSViv (THIS->parent_x + (border ? THIS->window_vt_x : 0)))); |
2033 | PUSHs (sv_2mortal (newSViv (THIS->parent_y))); |
2094 | PUSHs (sv_2mortal (newSViv (THIS->parent_y + (border ? THIS->window_vt_y : 0)))); |
2034 | PUSHs (sv_2mortal (newSViv (THIS->szHint.width))); |
2095 | PUSHs (sv_2mortal (newSViv (border ? THIS->vt_width : THIS->szHint.width ))); |
2035 | PUSHs (sv_2mortal (newSViv (THIS->szHint.height))); |
2096 | PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height))); |
2036 | |
2097 | |
2037 | #if HAVE_IMG |
2098 | #if HAVE_IMG |
2038 | |
2099 | |
2039 | rxvt_img * |
2100 | rxvt_img * |
2040 | rxvt_term::new_img (SV *format, int width, int height) |
2101 | rxvt_term::new_img (SV *format, int width = 1, int height = 1) |
2041 | CODE: |
2102 | CODE: |
2042 | XRenderPictFormat *f = SvOK (format) |
2103 | XRenderPictFormat *f = SvOK (format) |
2043 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
2104 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
2044 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
2105 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
2045 | RETVAL = new rxvt_img (THIS, f, width, height); |
2106 | RETVAL = new rxvt_img (THIS, f, 0, 0, width, height); |
|
|
2107 | RETVAL->alloc (); |
2046 | OUTPUT: |
2108 | OUTPUT: |
2047 | RETVAL |
2109 | RETVAL |
2048 | |
2110 | |
2049 | #if ENABLE_TRANSPARENCY |
2111 | #if ENABLE_TRANSPARENCY |
2050 | |
2112 | |
… | |
… | |
2076 | #endif |
2138 | #endif |
2077 | |
2139 | |
2078 | #if HAVE_BG_PIXMAP |
2140 | #if HAVE_BG_PIXMAP |
2079 | |
2141 | |
2080 | void |
2142 | void |
2081 | rxvt_term::set_background (rxvt_img *img) |
2143 | rxvt_term::set_background (rxvt_img *img, bool border = false) |
2082 | CODE: |
2144 | CODE: |
2083 | THIS->bg_destroy (); |
2145 | THIS->bg_destroy (); |
2084 | THIS->bg_pixmap = None; |
2146 | THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT); |
2085 | THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH; |
|
|
2086 | |
2147 | |
2087 | if (img) // TODO: cannot be false |
2148 | if (img) // TODO: cannot be false |
2088 | { |
2149 | { |
|
|
2150 | img = img->clone (); // own the img |
|
|
2151 | |
|
|
2152 | if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap |
|
|
2153 | img->sub_rect (0, 0, |
|
|
2154 | border ? THIS->vt_width : THIS->szHint.width, |
|
|
2155 | border ? THIS->vt_height : THIS->szHint.height) |
|
|
2156 | ->replace (img); |
|
|
2157 | |
|
|
2158 | // just in case, should usually be a nop |
2089 | img->unshare (); |
2159 | img->reify () |
2090 | //TODO: convetr to visual, possibly precompose with colour |
2160 | ->replace (img); |
2091 | THIS->bg_pixmap = img->steal (); |
2161 | |
|
|
2162 | img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]) |
|
|
2163 | ->replace (img); |
|
|
2164 | |
|
|
2165 | THIS->bg_img = img; |
|
|
2166 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; |
|
|
2167 | |
|
|
2168 | if (!border) |
2092 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; |
2169 | THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; |
2093 | THIS->bg_valid_since = ev::now (); // TODO: extra bloat |
|
|
2094 | } |
2170 | } |
2095 | |
2171 | |
2096 | #endif |
2172 | #endif |
2097 | |
2173 | |
2098 | #endif |
2174 | #endif |
… | |
… | |
2150 | CODE: |
2226 | CODE: |
2151 | RETVAL = THIS->h; |
2227 | RETVAL = THIS->h; |
2152 | OUTPUT: |
2228 | OUTPUT: |
2153 | RETVAL |
2229 | RETVAL |
2154 | |
2230 | |
2155 | bool |
|
|
2156 | rxvt_img::shared () |
|
|
2157 | CODE: |
|
|
2158 | RETVAL = THIS->shared; |
|
|
2159 | OUTPUT: |
|
|
2160 | RETVAL |
|
|
2161 | |
|
|
2162 | Pixmap |
2231 | Pixmap |
2163 | rxvt_img::pm () |
2232 | rxvt_img::pm () |
2164 | CODE: |
2233 | CODE: |
2165 | RETVAL = THIS->pm; |
2234 | RETVAL = THIS->pm; |
2166 | OUTPUT: |
2235 | OUTPUT: |
2167 | RETVAL |
2236 | RETVAL |
2168 | |
2237 | |
2169 | void |
2238 | void |
2170 | rxvt_img::fill (SV *c) |
2239 | rxvt_img::fill (SV *c) |
2171 | INIT: |
2240 | INIT: |
2172 | rxvt_color rc; |
2241 | rgba cc = parse_rgba (c, THIS->s); |
2173 | parse_color (THIS->s, rc, c); |
|
|
2174 | C_ARGS: rc |
2242 | C_ARGS: cc |
2175 | |
2243 | |
2176 | void |
2244 | void |
2177 | rxvt_img::DESTROY () |
2245 | rxvt_img::DESTROY () |
2178 | CODE: |
2246 | CODE: |
2179 | delete THIS; |
2247 | delete THIS; |
|
|
2248 | |
|
|
2249 | void |
|
|
2250 | rxvt_img::unshare () |
|
|
2251 | |
|
|
2252 | int |
|
|
2253 | rxvt_img::repeat_mode (render_repeat_mode repeat = 0) |
|
|
2254 | CODE: |
|
|
2255 | if (items >= 2) |
|
|
2256 | THIS->repeat_mode (repeat); |
|
|
2257 | if (GIMME_V != G_VOID) |
|
|
2258 | XPUSHs (sv_2mortal (newSViv (THIS->repeat))); |
|
|
2259 | |
|
|
2260 | void |
|
|
2261 | rxvt_img::move (int dx, int dy) |
|
|
2262 | |
|
|
2263 | void |
|
|
2264 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2265 | |
|
|
2266 | void |
|
|
2267 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2268 | |
|
|
2269 | rxvt_img * |
|
|
2270 | rxvt_img::clone () |
|
|
2271 | |
|
|
2272 | rxvt_img * |
|
|
2273 | rxvt_img::reify () |
|
|
2274 | |
|
|
2275 | rxvt_img * |
|
|
2276 | rxvt_img::sub_rect (int x, int y, int width, int height) |
2180 | |
2277 | |
2181 | rxvt_img * |
2278 | rxvt_img * |
2182 | rxvt_img::blur (int rh, int rv) |
2279 | rxvt_img::blur (int rh, int rv) |
2183 | |
2280 | |
2184 | void |
|
|
2185 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2186 | |
|
|
2187 | void |
|
|
2188 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2189 | |
|
|
2190 | void |
|
|
2191 | rxvt_img::unshare () |
|
|
2192 | |
|
|
2193 | rxvt_img * |
2281 | rxvt_img * |
2194 | rxvt_img::clone () |
2282 | rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) |
2195 | |
|
|
2196 | rxvt_img * |
|
|
2197 | rxvt_img::sub_rect (int x, int y, int width, int height, render_repeat_mode repeat = RepeatNormal) |
|
|
2198 | |
|
|
2199 | rxvt_img * |
|
|
2200 | 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, render_repeat_mode repeat = RepeatNormal) |
|
|
2201 | INIT: |
2283 | INIT: |
2202 | double matrix[9] = { |
2284 | double matrix[3][3] = { |
2203 | p11, p12, p13, |
2285 | { p11, p12, p13 }, |
2204 | p21, p22, p23, |
2286 | { p21, p22, p23 }, |
2205 | p31, p32, p33 |
2287 | { p31, p32, p33 } |
2206 | }; |
2288 | }; |
2207 | C_ARGS: new_width, new_height, matrix, repeat |
2289 | C_ARGS: matrix |
2208 | |
2290 | |
2209 | rxvt_img * |
2291 | rxvt_img * |
2210 | rxvt_img::scale (int new_width, int new_height) |
2292 | rxvt_img::scale (int new_width, int new_height) |
2211 | |
2293 | |
2212 | rxvt_img * |
2294 | rxvt_img * |
2213 | rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi, render_repeat_mode repeat = RepeatNormal) |
2295 | rxvt_img::rotate (int x, int y, NV phi) |
2214 | |
2296 | |
2215 | #endif |
2297 | #endif |
2216 | |
2298 | |