--- rxvt-unicode/src/rxvtperl.xs 2006/01/08 08:43:11 1.42 +++ rxvt-unicode/src/rxvtperl.xs 2006/01/10 04:49:54 1.53 @@ -31,8 +31,9 @@ #include #include -#include "rxvt.h" #include "iom.h" +#include "rxvt.h" +#include "keyboard.h" #include "rxvtutil.h" #include "rxvtperl.h" @@ -408,20 +409,20 @@ } void -rxvt_perl_interp::init (bool tainted) +rxvt_perl_interp::init () { if (!perl) { char *argv[] = { "", - "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", "-T", + "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", }; perl = perl_alloc (); perl_construct (perl); - if (perl_parse (perl, xs_init, 2 + !!tainted, argv, (char **)NULL) + if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) || perl_run (perl)) { rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); @@ -433,6 +434,17 @@ } } +static void +ungrab (rxvt_term *THIS) +{ + if (THIS->perl.grabtime) + { + XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); + XUngrabPointer (THIS->display->display, THIS->perl.grabtime); + THIS->perl.grabtime = 0; + } +} + bool rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) { @@ -450,20 +462,25 @@ { // handled later } - else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) + else { - HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); - - if (HvKEYS (hv)) + if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) { - hv_iterinit (hv); + HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); + + if (HvKEYS (hv)) + { + hv_iterinit (hv); + + while (HE *he = hv_iternext (hv)) + ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); + } - while (HE *he = hv_iternext (hv)) - ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); } + + if (!should_invoke [htype]) + return false; } - else if (!should_invoke [htype]) - return false; dSP; va_list ap; @@ -584,7 +601,10 @@ LEAVE; if (SvTRUE (ERRSV)) - rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); + { + rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); + ungrab (term); // better lose the grab than the session + } if (htype == HOOK_DESTROY) { @@ -609,7 +629,10 @@ BOOT: { - sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); + sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); + sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1)); + sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1)); + sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1)); AV *hookname = get_av ("urxvt::HOOKNAME", 1); # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); @@ -648,6 +671,10 @@ export_const_iv (Button4Mask); export_const_iv (Button5Mask); export_const_iv (AnyModifier); + + export_const_iv (EVENT_NONE); + export_const_iv (EVENT_READ); + export_const_iv (EVENT_WRITE); } SV * @@ -695,6 +722,21 @@ CODE: rxvt_fatal ("%s", msg); +SV * +untaint (SV *sv) + CODE: + RETVAL = newSVsv (sv); + SvTAINTED_off (RETVAL); + OUTPUT: + RETVAL + +bool +safe () + CODE: + RETVAL = !rxvt_tainted (); + OUTPUT: + RETVAL + NV NOW () CODE: @@ -784,27 +826,25 @@ RETVAL void -rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) +rxvt_term::allow_events_async () CODE: - XAllowEvents (THIS->display->display, AsyncBoth, eventtime); + XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); void -rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) +rxvt_term::allow_events_sync () CODE: - XAllowEvents (THIS->display->display, SyncBoth, eventtime); + XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); void -rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) +rxvt_term::allow_events_replay () CODE: - XAllowEvents (THIS->display->display, ReplayPointer, eventtime); - XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); + XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); + XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); void -rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) +rxvt_term::ungrab () CODE: - THIS->perl.grabtime = 0; - XUngrabKeyboard (THIS->display->display, eventtime); - XUngrabPointer (THIS->display->display, eventtime); + ungrab (THIS); int rxvt_term::strwidth (SV *str) @@ -907,6 +947,29 @@ OUTPUT: RETVAL +char * +rxvt_term::display_id () + ALIAS: + display_id = 0 + locale = 1 + CODE: + switch (ix) + { + case 0: RETVAL = THIS->display->id; break; + case 1: RETVAL = THIS->locale; break; + } + OUTPUT: + RETVAL + +int +rxvt_term::pty_ev_events (int events = EVENT_UNDEF) + CODE: + RETVAL = THIS->pty_ev.events; + if (events != EVENT_UNDEF) + THIS->pty_ev.set (events); + OUTPUT: + RETVAL + U32 rxvt_term::parent () CODE: @@ -1217,8 +1280,16 @@ OUTPUT: RETVAL +bool +rxvt_term::parse_keysym (char *keysym, char *str) + CODE: + RETVAL = 0 < THIS->parse_keysym (keysym, str); + THIS->keyboard->register_done (); + OUTPUT: + RETVAL + void -rxvt_term::cur (...) +rxvt_term::screen_cur (...) PROTOTYPE: $;$$ ALIAS: screen_cur = 0 @@ -1249,6 +1320,13 @@ } } +char +rxvt_term::cur_charset () + CODE: + RETVAL = THIS->charsets [THIS->screen.charset]; + OUTPUT: + RETVAL + int rxvt_term::selection_grab (U32 eventtime) @@ -1257,7 +1335,9 @@ PPCODE: { if (GIMME_V != G_VOID) - XPUSHs (taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))); + XPUSHs (THIS->selection.text + ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) + : &PL_sv_undef); if (newtext) { @@ -1269,6 +1349,15 @@ } void +rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline) + +void +rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) + +void +rxvt_term::scr_bell () + +void rxvt_term::scr_add_lines (SV *string) CODE: {