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.169 by sf-exg, Tue Jun 5 15:18:24 2012 UTC vs.
Revision 1.191 by root, Sun Jun 10 15:01:14 2012 UTC

54typedef char * octet_string; 54typedef char * octet_string;
55typedef char * utf8_string; 55typedef char * utf8_string;
56 56
57typedef int render_repeat_mode; 57typedef int render_repeat_mode;
58 58
59#if HAVE_PIXBUF
59typedef GdkPixbuf * urxvt__pixbuf; 60typedef GdkPixbuf * urxvt__pixbuf;
61#endif
60typedef rxvt_img * urxvt__img; 62typedef rxvt_img * urxvt__img;
61 63
62///////////////////////////////////////////////////////////////////////////// 64/////////////////////////////////////////////////////////////////////////////
63 65
64static void 66static void
65parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) 67parse_color (rxvt_screen *s, rxvt_color &c, SV *sv)
66{ 68{
67 //TODO: support component stuff 69 //TODO: support component stuff, 0..1
68 c.set (s, SvPVbyte_nolen (sv)); 70 c.set (s, SvPVbyte_nolen (sv));
69} 71}
70 72
71///////////////////////////////////////////////////////////////////////////// 73/////////////////////////////////////////////////////////////////////////////
72 74
382 } 384 }
383 385
384 rxvt_pop_locale (); 386 rxvt_pop_locale ();
385 } 387 }
386 388
387 if (perl) 389 if (perl && !term->perl.self)
388 { 390 {
389 // runs outside of perls ENV 391 // runs outside of perls ENV
390 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 392 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); 393 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); 394 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
393 } 395 }
394} 396}
395 397
398void
399rxvt_perl_interp::usage (rxvt_term *term, int type)
400{
401 localise_env set_environ (perl_environ);
402
403 ENTER;
404 SAVETMPS;
405
406 dSP;
407 PUSHMARK (SP);
408 EXTEND (SP, 2);
409 PUSHs (sv_2mortal (newSVterm (term)));
410 PUSHs (sv_2mortal (newSViv (type)));
411 PUTBACK;
412 call_pv ("urxvt::usage", G_VOID | G_DISCARD);
413
414 FREETMPS;
415 LEAVE;
416}
417
418uint8_t
419rxvt_perl_interp::parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value)
420{
421 localise_env set_environ (perl_environ);
422
423 ENTER;
424 SAVETMPS;
425
426 dSP;
427 PUSHMARK (SP);
428 EXTEND (SP, 6);
429 PUSHs (sv_2mortal (newSVterm (term)));
430 PUSHs (sv_2mortal (newSVpv (name, 0)));
431 PUSHs (arg ? &PL_sv_yes : &PL_sv_no);
432 PUSHs (longopt ? &PL_sv_yes : &PL_sv_no);
433 PUSHs (flag ? &PL_sv_yes : &PL_sv_no);
434 PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef);
435 PUTBACK;
436 call_pv ("urxvt::parse_resource", G_SCALAR);
437 SPAGAIN;
438
439 uint8_t ret = POPi;
440
441 FREETMPS;
442 LEAVE;
443
444 return ret;
445}
446
396static void 447static void
397ungrab (rxvt_term *THIS) 448ungrab (rxvt_term *THIS)
398{ 449{
399 if (THIS->perl.grabtime) 450 if (THIS->perl.grabtime)
400 { 451 {
431 } 482 }
432 } 483 }
433 484
434 bool event_consumed; 485 bool event_consumed;
435 486
436 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
437 || term->perl.should_invoke [htype]) 487 if (term->perl.should_invoke [htype])
438 { 488 {
439 dSP; 489 dSP;
440 va_list ap; 490 va_list ap;
441 491
442 va_start (ap, htype); 492 va_start (ap, htype);
652 ENTER; 702 ENTER;
653 SAVETMPS; 703 SAVETMPS;
654 704
655 dSP; 705 dSP;
656 XPUSHs (sv_2mortal (newSVpvn (data, len))); 706 XPUSHs (sv_2mortal (newSVpvn (data, len)));
707 PUTBACK;
657 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); 708 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
658 709
659 if (SvTRUE (ERRSV)) 710 if (SvTRUE (ERRSV))
660 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); 711 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
661 712
835 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) 886 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
836 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 887 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
837} 888}
838 889
839void 890void
891log (const char *msg)
892 CODE:
893 rxvt_log ("%s", msg);
894
895void
840warn (const char *msg) 896warn (const char *msg)
841 CODE: 897 CODE:
842 rxvt_warn ("%s", msg); 898 rxvt_warn ("%s", msg);
843 899
844void 900void
1009 case HOOK_POSITION_CHANGE: 1065 case HOOK_POSITION_CHANGE:
1010 if (count) 1066 if (count)
1011 THIS->get_window_origin (THIS->parent_x, THIS->parent_y); 1067 THIS->get_window_origin (THIS->parent_x, THIS->parent_y);
1012 } 1068 }
1013 } 1069 }
1070
1071void
1072rxvt_term::put_option_db (octet_string specifier, octet_string value)
1073 CODE:
1074 XrmPutStringResource (&THIS->option_db, specifier, value);
1014 1075
1015int 1076int
1016rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) 1077rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
1017 CODE: 1078 CODE:
1018 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, 1079 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1,
1971} 2032}
1972 2033
1973############################################################################# 2034#############################################################################
1974# fancy bg bloatstuff (TODO: should be moved up somewhere) 2035# fancy bg bloatstuff (TODO: should be moved up somewhere)
1975 2036
2037bool
2038rxvt_term::has_render ()
2039 CODE:
2040 RETVAL = THIS->display->flags & DISPLAY_HAS_RENDER;
2041 OUTPUT:
2042 RETVAL
2043
1976# TODO: ugly 2044# TODO: ugly
1977void 2045void
1978rxvt_term::get_geometry () 2046rxvt_term::background_geometry (bool border = false)
1979 PPCODE: 2047 PPCODE:
1980 EXTEND (SP, 4); 2048 EXTEND (SP, 4);
1981 PUSHs (sv_2mortal (newSViv (THIS->parent_x))); 2049 PUSHs (sv_2mortal (newSViv (THIS->parent_x + (border ? THIS->window_vt_x : 0))));
1982 PUSHs (sv_2mortal (newSViv (THIS->parent_y))); 2050 PUSHs (sv_2mortal (newSViv (THIS->parent_y + (border ? THIS->window_vt_y : 0))));
1983 PUSHs (sv_2mortal (newSViv (THIS->szHint.width))); 2051 PUSHs (sv_2mortal (newSViv (border ? THIS->vt_width : THIS->szHint.width )));
1984 PUSHs (sv_2mortal (newSViv (THIS->szHint.height))); 2052 PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height)));
1985 2053
1986#if HAVE_IMG 2054#if HAVE_IMG
1987 2055
1988rxvt_img * 2056rxvt_img *
1989rxvt_term::new_img (SV *format, int width, int height) 2057rxvt_term::new_img (SV *format, int width = 1, int height = 1)
1990 CODE: 2058 CODE:
1991 XRenderPictFormat *f = SvOK (format) 2059 XRenderPictFormat *f = SvOK (format)
1992 ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) 2060 ? XRenderFindStandardFormat (THIS->dpy, SvIV (format))
1993 : XRenderFindVisualFormat (THIS->dpy, THIS->visual); 2061 : XRenderFindVisualFormat (THIS->dpy, THIS->visual);
1994 RETVAL = new rxvt_img (THIS, f, width, height); 2062 RETVAL = new rxvt_img (THIS, f, 0, 0, width, height);
2063 RETVAL->alloc ();
1995 OUTPUT: 2064 OUTPUT:
1996 RETVAL 2065 RETVAL
1997 2066
1998#if ENABLE_TRANSPARENCY 2067#if ENABLE_TRANSPARENCY
1999
2000#if 0
2001 2068
2002rxvt_img * 2069rxvt_img *
2003rxvt_term::new_img_from_root () 2070rxvt_term::new_img_from_root ()
2004 CODE: 2071 CODE:
2005 RETVAL = rxvt_img::new_from_root (THIS); 2072 RETVAL = rxvt_img::new_from_root (THIS);
2006 OUTPUT: 2073 OUTPUT:
2007 RETVAL 2074 RETVAL
2008 2075
2009#endif 2076#endif
2010 2077
2011#endif
2012
2013#if HAVE_PIXBUF 2078#if HAVE_PIXBUF
2014 2079
2015rxvt_img * 2080rxvt_img *
2016rxvt_term::new_img_from_file (octet_string filename) 2081rxvt_term::new_img_from_file (octet_string filename)
2017 CODE: 2082 CODE:
2029#endif 2094#endif
2030 2095
2031#if HAVE_BG_PIXMAP 2096#if HAVE_BG_PIXMAP
2032 2097
2033void 2098void
2034rxvt_term::set_background (rxvt_img *img) 2099rxvt_term::set_background (rxvt_img *img, bool border = false)
2035 CODE: 2100 CODE:
2036 THIS->bg_destroy (); 2101 THIS->bg_destroy ();
2037 THIS->bg_pixmap = None; 2102 THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT);
2038 THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH;
2039 2103
2040 if (img) // TODO: cannot be false 2104 if (img) // TODO: cannot be false
2041 { 2105 {
2106 img = img->clone (); // own the img
2107
2108 if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap
2109 img->sub_rect (0, 0,
2110 border ? THIS->vt_width : THIS->szHint.width,
2111 border ? THIS->vt_height : THIS->szHint.height)
2112 ->replace (img);
2113
2114 // just in case, should usually be a nop
2042 img->unshare (); 2115 img->reify ()
2043 THIS->bg_pixmap = img->steal (); 2116 ->replace (img);
2117
2118 img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg])
2119 ->replace (img);
2120
2121 THIS->bg_img = img;
2122 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER;
2123
2124 if (!border)
2044 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; 2125 THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT;
2045 THIS->bg_valid_since = ev::now (); // TODO: extra bloat
2046 } 2126 }
2047 2127
2048#endif 2128#endif
2049 2129
2050#endif 2130#endif
2099 2179
2100int 2180int
2101rxvt_img::h () 2181rxvt_img::h ()
2102 CODE: 2182 CODE:
2103 RETVAL = THIS->h; 2183 RETVAL = THIS->h;
2104 OUTPUT:
2105 RETVAL
2106
2107bool
2108rxvt_img::shared ()
2109 CODE:
2110 RETVAL = THIS->shared;
2111 OUTPUT: 2184 OUTPUT:
2112 RETVAL 2185 RETVAL
2113 2186
2114Pixmap 2187Pixmap
2115rxvt_img::pm () 2188rxvt_img::pm ()
2128void 2201void
2129rxvt_img::DESTROY () 2202rxvt_img::DESTROY ()
2130 CODE: 2203 CODE:
2131 delete THIS; 2204 delete THIS;
2132 2205
2206void
2207rxvt_img::unshare ()
2208
2209int
2210rxvt_img::repeat_mode (render_repeat_mode repeat = 0)
2211 CODE:
2212 if (items >= 2)
2213 THIS->repeat_mode (repeat);
2214 if (GIMME_V != G_VOID)
2215 XPUSHs (sv_2mortal (newSViv (THIS->repeat)));
2216
2217void
2218rxvt_img::move (int dx, int dy)
2219
2220void
2221rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.)
2222
2223void
2224rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.)
2225
2226rxvt_img *
2227rxvt_img::clone ()
2228
2229rxvt_img *
2230rxvt_img::reify ()
2231
2232rxvt_img *
2233rxvt_img::sub_rect (int x, int y, int width, int height)
2234
2133rxvt_img * 2235rxvt_img *
2134rxvt_img::blur (int rh, int rv) 2236rxvt_img::blur (int rh, int rv)
2135 2237
2136void
2137rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.)
2138
2139void
2140rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.)
2141
2142void
2143rxvt_img::unshare ()
2144
2145rxvt_img * 2238rxvt_img *
2146rxvt_img::clone ()
2147
2148rxvt_img *
2149rxvt_img::sub_rect (int x, int y, int width, int height, render_repeat_mode repeat = RepeatNormal)
2150
2151rxvt_img *
2152rxvt_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) 2239rxvt_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)
2153 INIT: 2240 INIT:
2154 double matrix[9] = { 2241 double matrix[9] = {
2155 p11, p12, p13, 2242 p11, p12, p13,
2156 p21, p22, p23, 2243 p21, p22, p23,
2157 p31, p32, p33 2244 p31, p32, p33
2158 }; 2245 };
2159 C_ARGS: new_width, new_height, matrix, repeat 2246 C_ARGS: new_width, new_height, matrix
2160 2247
2161rxvt_img * 2248rxvt_img *
2162rxvt_img::scale (int new_width, int new_height) 2249rxvt_img::scale (int new_width, int new_height)
2163 2250
2164rxvt_img * 2251rxvt_img *
2165rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi, render_repeat_mode repeat = RepeatNormal) 2252rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi)
2166 2253
2167#endif 2254#endif
2168 2255

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines