… | |
… | |
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 | |
|
|
101 | return c; |
69 | } |
102 | } |
70 | |
103 | |
71 | ///////////////////////////////////////////////////////////////////////////// |
104 | ///////////////////////////////////////////////////////////////////////////// |
72 | |
105 | |
73 | static wchar_t * |
106 | static wchar_t * |
… | |
… | |
341 | PERL_SYS_TERM (); |
374 | PERL_SYS_TERM (); |
342 | } |
375 | } |
343 | } |
376 | } |
344 | |
377 | |
345 | void |
378 | void |
346 | rxvt_perl_interp::init (rxvt_term *term) |
379 | rxvt_perl_interp::init () |
347 | { |
380 | { |
348 | if (!perl) |
381 | if (!perl) |
349 | { |
382 | { |
350 | rxvt_push_locale (""); // perl init destroys current locale |
383 | rxvt_push_locale (""); // perl init destroys current locale |
351 | |
384 | |
… | |
… | |
381 | } |
414 | } |
382 | } |
415 | } |
383 | |
416 | |
384 | rxvt_pop_locale (); |
417 | rxvt_pop_locale (); |
385 | } |
418 | } |
|
|
419 | } |
386 | |
420 | |
387 | if (perl) |
421 | void |
|
|
422 | rxvt_perl_interp::init (rxvt_term *term) |
|
|
423 | { |
|
|
424 | init (); |
|
|
425 | |
|
|
426 | if (perl && !term->perl.self) |
388 | { |
427 | { |
389 | // runs outside of perls ENV |
428 | // runs outside of perls ENV |
390 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
429 | 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); |
430 | 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); |
431 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
393 | } |
432 | } |
394 | } |
433 | } |
395 | |
434 | |
396 | void |
435 | void |
|
|
436 | rxvt_perl_interp::eval (const char *str) |
|
|
437 | { |
|
|
438 | eval_pv (str, 1); |
|
|
439 | } |
|
|
440 | |
|
|
441 | void |
397 | rxvt_perl_interp::usage (int type) |
442 | rxvt_perl_interp::usage (rxvt_term *term, int type) |
398 | { |
443 | { |
399 | localise_env set_environ (perl_environ); |
444 | localise_env set_environ (perl_environ); |
400 | |
445 | |
401 | ENTER; |
446 | ENTER; |
402 | SAVETMPS; |
447 | SAVETMPS; |
403 | |
448 | |
404 | dSP; |
449 | dSP; |
|
|
450 | PUSHMARK (SP); |
|
|
451 | EXTEND (SP, 2); |
|
|
452 | PUSHs (sv_2mortal (newSVterm (term))); |
405 | XPUSHs (sv_2mortal (newSViv (type))); |
453 | PUSHs (sv_2mortal (newSViv (type))); |
406 | PUTBACK; |
454 | PUTBACK; |
407 | call_pv ("urxvt::usage", G_VOID | G_DISCARD | G_EVAL); |
455 | call_pv ("urxvt::usage", G_VOID | G_DISCARD); |
408 | |
456 | |
409 | FREETMPS; |
457 | FREETMPS; |
410 | LEAVE; |
458 | LEAVE; |
411 | } |
459 | } |
412 | |
460 | |
413 | uint8_t |
461 | uint8_t |
414 | rxvt_perl_interp::resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
462 | rxvt_perl_interp::parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
415 | { |
463 | { |
416 | localise_env set_environ (perl_environ); |
464 | localise_env set_environ (perl_environ); |
417 | |
465 | |
418 | ENTER; |
466 | ENTER; |
419 | SAVETMPS; |
467 | SAVETMPS; |
420 | |
468 | |
421 | dSP; |
469 | dSP; |
|
|
470 | PUSHMARK (SP); |
422 | EXTEND (SP, 6); |
471 | EXTEND (SP, 6); |
423 | PUSHs (sv_2mortal (newSVterm (term))); |
472 | PUSHs (sv_2mortal (newSVterm (term))); |
424 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
473 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
425 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
474 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
426 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
475 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
427 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
476 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
428 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
477 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
429 | PUTBACK; |
478 | PUTBACK; |
430 | call_pv ("urxvt::resource", G_SCALAR | G_EVAL); |
479 | call_pv ("urxvt::parse_resource", G_SCALAR); |
|
|
480 | SPAGAIN; |
431 | |
481 | |
432 | uint8_t ret = POPi; |
482 | uint8_t ret = POPi; |
433 | |
483 | |
434 | FREETMPS; |
484 | FREETMPS; |
435 | LEAVE; |
485 | LEAVE; |
… | |
… | |
879 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
929 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
880 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
930 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
881 | } |
931 | } |
882 | |
932 | |
883 | void |
933 | void |
|
|
934 | log (const char *msg) |
|
|
935 | CODE: |
|
|
936 | rxvt_log ("%s", msg); |
|
|
937 | |
|
|
938 | void |
884 | warn (const char *msg) |
939 | warn (const char *msg) |
885 | CODE: |
940 | CODE: |
886 | rxvt_warn ("%s", msg); |
941 | rxvt_warn ("%s", msg); |
887 | |
942 | |
888 | void |
943 | void |
… | |
… | |
1053 | case HOOK_POSITION_CHANGE: |
1108 | case HOOK_POSITION_CHANGE: |
1054 | if (count) |
1109 | if (count) |
1055 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
1110 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
1056 | } |
1111 | } |
1057 | } |
1112 | } |
|
|
1113 | |
|
|
1114 | void |
|
|
1115 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
|
|
1116 | CODE: |
|
|
1117 | XrmPutStringResource (&THIS->option_db, specifier, value); |
1058 | |
1118 | |
1059 | int |
1119 | int |
1060 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1120 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1061 | CODE: |
1121 | CODE: |
1062 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1122 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
… | |
… | |
2015 | } |
2075 | } |
2016 | |
2076 | |
2017 | ############################################################################# |
2077 | ############################################################################# |
2018 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
2078 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
2019 | |
2079 | |
2020 | # TODO: ugly |
2080 | bool |
|
|
2081 | rxvt_term::has_render () |
|
|
2082 | CODE: |
|
|
2083 | RETVAL = THIS->display->flags & DISPLAY_HAS_RENDER; |
|
|
2084 | OUTPUT: |
|
|
2085 | RETVAL |
|
|
2086 | |
2021 | void |
2087 | void |
2022 | rxvt_term::get_geometry () |
2088 | rxvt_term::background_geometry (bool border = false) |
2023 | PPCODE: |
2089 | PPCODE: |
2024 | EXTEND (SP, 4); |
2090 | EXTEND (SP, 4); |
2025 | PUSHs (sv_2mortal (newSViv (THIS->parent_x))); |
2091 | PUSHs (sv_2mortal (newSViv (THIS->parent_x + (border ? THIS->window_vt_x : 0)))); |
2026 | PUSHs (sv_2mortal (newSViv (THIS->parent_y))); |
2092 | PUSHs (sv_2mortal (newSViv (THIS->parent_y + (border ? THIS->window_vt_y : 0)))); |
2027 | PUSHs (sv_2mortal (newSViv (THIS->szHint.width))); |
2093 | PUSHs (sv_2mortal (newSViv (border ? THIS->vt_width : THIS->szHint.width ))); |
2028 | PUSHs (sv_2mortal (newSViv (THIS->szHint.height))); |
2094 | PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height))); |
2029 | |
2095 | |
2030 | #if HAVE_IMG |
2096 | #if HAVE_IMG |
2031 | |
2097 | |
2032 | rxvt_img * |
2098 | rxvt_img * |
2033 | rxvt_term::new_img (SV *format, int width, int height) |
2099 | rxvt_term::new_img (SV *format, int width = 1, int height = 1) |
2034 | CODE: |
2100 | CODE: |
2035 | XRenderPictFormat *f = SvOK (format) |
2101 | XRenderPictFormat *f = SvOK (format) |
2036 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
2102 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
2037 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
2103 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
2038 | RETVAL = new rxvt_img (THIS, f, width, height); |
2104 | RETVAL = new rxvt_img (THIS, f, 0, 0, width, height); |
|
|
2105 | RETVAL->alloc (); |
2039 | OUTPUT: |
2106 | OUTPUT: |
2040 | RETVAL |
2107 | RETVAL |
2041 | |
2108 | |
2042 | #if ENABLE_TRANSPARENCY |
2109 | #if ENABLE_TRANSPARENCY |
2043 | |
|
|
2044 | #if 0 |
|
|
2045 | |
2110 | |
2046 | rxvt_img * |
2111 | rxvt_img * |
2047 | rxvt_term::new_img_from_root () |
2112 | rxvt_term::new_img_from_root () |
2048 | CODE: |
2113 | CODE: |
2049 | RETVAL = rxvt_img::new_from_root (THIS); |
2114 | RETVAL = rxvt_img::new_from_root (THIS); |
2050 | OUTPUT: |
2115 | OUTPUT: |
2051 | RETVAL |
2116 | RETVAL |
2052 | |
2117 | |
2053 | #endif |
2118 | #endif |
2054 | |
2119 | |
2055 | #endif |
|
|
2056 | |
|
|
2057 | #if HAVE_PIXBUF |
2120 | #if HAVE_PIXBUF |
2058 | |
2121 | |
2059 | rxvt_img * |
2122 | rxvt_img * |
2060 | rxvt_term::new_img_from_file (octet_string filename) |
2123 | rxvt_term::new_img_from_file (octet_string filename) |
2061 | CODE: |
2124 | CODE: |
… | |
… | |
2073 | #endif |
2136 | #endif |
2074 | |
2137 | |
2075 | #if HAVE_BG_PIXMAP |
2138 | #if HAVE_BG_PIXMAP |
2076 | |
2139 | |
2077 | void |
2140 | void |
2078 | rxvt_term::set_background (rxvt_img *img) |
2141 | rxvt_term::set_background (rxvt_img *img, bool border = false) |
2079 | CODE: |
2142 | CODE: |
2080 | THIS->bg_destroy (); |
2143 | THIS->bg_destroy (); |
2081 | THIS->bg_pixmap = None; |
2144 | THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT); |
2082 | THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH; |
|
|
2083 | |
2145 | |
2084 | if (img) // TODO: cannot be false |
2146 | if (img) // TODO: cannot be false |
2085 | { |
2147 | { |
|
|
2148 | img = img->clone (); // own the img |
|
|
2149 | |
|
|
2150 | if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap |
|
|
2151 | img->sub_rect (0, 0, |
|
|
2152 | border ? THIS->vt_width : THIS->szHint.width, |
|
|
2153 | border ? THIS->vt_height : THIS->szHint.height) |
|
|
2154 | ->replace (img); |
|
|
2155 | |
|
|
2156 | // just in case, should usually be a nop |
2086 | img->unshare (); |
2157 | img->reify () |
2087 | THIS->bg_pixmap = img->steal (); |
2158 | ->replace (img); |
|
|
2159 | |
|
|
2160 | img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]) |
|
|
2161 | ->replace (img); |
|
|
2162 | |
|
|
2163 | THIS->bg_img = img; |
|
|
2164 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; |
|
|
2165 | |
|
|
2166 | if (!border) |
2088 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; |
2167 | THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; |
2089 | THIS->bg_valid_since = ev::now (); // TODO: extra bloat |
|
|
2090 | } |
2168 | } |
2091 | |
2169 | |
2092 | #endif |
2170 | #endif |
2093 | |
2171 | |
2094 | #endif |
2172 | #endif |
… | |
… | |
2146 | CODE: |
2224 | CODE: |
2147 | RETVAL = THIS->h; |
2225 | RETVAL = THIS->h; |
2148 | OUTPUT: |
2226 | OUTPUT: |
2149 | RETVAL |
2227 | RETVAL |
2150 | |
2228 | |
2151 | bool |
|
|
2152 | rxvt_img::shared () |
|
|
2153 | CODE: |
|
|
2154 | RETVAL = THIS->shared; |
|
|
2155 | OUTPUT: |
|
|
2156 | RETVAL |
|
|
2157 | |
|
|
2158 | Pixmap |
2229 | Pixmap |
2159 | rxvt_img::pm () |
2230 | rxvt_img::pm () |
2160 | CODE: |
2231 | CODE: |
2161 | RETVAL = THIS->pm; |
2232 | RETVAL = THIS->pm; |
2162 | OUTPUT: |
2233 | OUTPUT: |
2163 | RETVAL |
2234 | RETVAL |
2164 | |
2235 | |
2165 | void |
2236 | void |
2166 | rxvt_img::fill (SV *c) |
2237 | rxvt_img::fill (SV *c) |
2167 | INIT: |
2238 | INIT: |
2168 | rxvt_color rc; |
2239 | rgba cc = parse_rgba (c, THIS->s); |
2169 | parse_color (THIS->s, rc, c); |
|
|
2170 | C_ARGS: rc |
2240 | C_ARGS: cc |
2171 | |
2241 | |
2172 | void |
2242 | void |
2173 | rxvt_img::DESTROY () |
2243 | rxvt_img::DESTROY () |
2174 | CODE: |
2244 | CODE: |
2175 | delete THIS; |
2245 | delete THIS; |
|
|
2246 | |
|
|
2247 | void |
|
|
2248 | rxvt_img::unshare () |
|
|
2249 | |
|
|
2250 | int |
|
|
2251 | rxvt_img::repeat_mode (render_repeat_mode repeat = 0) |
|
|
2252 | CODE: |
|
|
2253 | if (items >= 2) |
|
|
2254 | THIS->repeat_mode (repeat); |
|
|
2255 | if (GIMME_V != G_VOID) |
|
|
2256 | XPUSHs (sv_2mortal (newSViv (THIS->repeat))); |
|
|
2257 | |
|
|
2258 | void |
|
|
2259 | rxvt_img::move (int dx, int dy) |
|
|
2260 | |
|
|
2261 | void |
|
|
2262 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2263 | |
|
|
2264 | void |
|
|
2265 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2266 | |
|
|
2267 | rxvt_img * |
|
|
2268 | rxvt_img::clone () |
|
|
2269 | |
|
|
2270 | rxvt_img * |
|
|
2271 | rxvt_img::reify () |
|
|
2272 | |
|
|
2273 | rxvt_img * |
|
|
2274 | rxvt_img::sub_rect (int x, int y, int width, int height) |
2176 | |
2275 | |
2177 | rxvt_img * |
2276 | rxvt_img * |
2178 | rxvt_img::blur (int rh, int rv) |
2277 | rxvt_img::blur (int rh, int rv) |
2179 | |
2278 | |
2180 | void |
|
|
2181 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2182 | |
|
|
2183 | void |
|
|
2184 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2185 | |
|
|
2186 | void |
|
|
2187 | rxvt_img::unshare () |
|
|
2188 | |
|
|
2189 | rxvt_img * |
2279 | rxvt_img * |
2190 | rxvt_img::clone () |
2280 | rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) |
2191 | |
|
|
2192 | rxvt_img * |
|
|
2193 | rxvt_img::sub_rect (int x, int y, int width, int height, render_repeat_mode repeat = RepeatNormal) |
|
|
2194 | |
|
|
2195 | rxvt_img * |
|
|
2196 | 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) |
|
|
2197 | INIT: |
2281 | INIT: |
2198 | double matrix[9] = { |
2282 | double matrix[3][3] = { |
2199 | p11, p12, p13, |
2283 | { p11, p12, p13 }, |
2200 | p21, p22, p23, |
2284 | { p21, p22, p23 }, |
2201 | p31, p32, p33 |
2285 | { p31, p32, p33 } |
2202 | }; |
2286 | }; |
2203 | C_ARGS: new_width, new_height, matrix, repeat |
2287 | C_ARGS: matrix |
2204 | |
2288 | |
2205 | rxvt_img * |
2289 | rxvt_img * |
2206 | rxvt_img::scale (int new_width, int new_height) |
2290 | rxvt_img::scale (int new_width, int new_height) |
2207 | |
2291 | |
2208 | rxvt_img * |
2292 | rxvt_img * |
2209 | rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi, render_repeat_mode repeat = RepeatNormal) |
2293 | rxvt_img::rotate (int x, int y, NV phi) |
2210 | |
2294 | |
2211 | #endif |
2295 | #endif |
2212 | |
2296 | |