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.136 by root, Fri Jan 7 21:17:08 2011 UTC vs.
Revision 1.148 by root, Sat Dec 17 23:17:33 2011 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtperl.xs 2 * File: rxvtperl.xs
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008,2011 Marc Lehmann <schmorp@schmorp.de>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
341 " unshift @INC, '" LIBDIR "';" 341 " unshift @INC, '" LIBDIR "';"
342 "}" 342 "}"
343 "" 343 ""
344 "use urxvt;" 344 "use urxvt;"
345 }; 345 };
346 int argc = ARRAY_LENGTH(args); 346 int argc = ecb_array_length (args);
347 char **argv = args; 347 char **argv = args;
348 348
349 PERL_SYS_INIT3 (&argc, &argv, &environ); 349 PERL_SYS_INIT3 (&argc, &argv, &environ);
350 perl = perl_alloc (); 350 perl = perl_alloc ();
351 perl_construct (perl); 351 perl_construct (perl);
367 if (perl) 367 if (perl)
368 { 368 {
369 // runs outside of perls ENV 369 // runs outside of perls ENV
370 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 370 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
371 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); 371 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
372 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
372 } 373 }
373} 374}
374 375
375static void 376static void
376ungrab (rxvt_term *THIS) 377ungrab (rxvt_term *THIS)
397 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 398 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
398 399
399 for (int i = 0; i <= AvFILL (av); i++) 400 for (int i = 0; i <= AvFILL (av); i++)
400 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 401 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
401 } 402 }
403 else if (htype == HOOK_DESTROY)
404 {
405 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
406
407 for (int i = AvFILL (av); i >= 0; i--)
408 {
409 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
410 delete req;
411 }
412 }
402 413
403 bool event_consumed; 414 bool event_consumed;
404 415
405 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 416 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
406 || term->perl.should_invoke [htype]) 417 || term->perl.should_invoke [htype])
413 ENTER; 424 ENTER;
414 SAVETMPS; 425 SAVETMPS;
415 426
416 PUSHMARK (SP); 427 PUSHMARK (SP);
417 428
429 EXTEND (SP, 2);
418 XPUSHs (sv_2mortal (newSVterm (term))); 430 PUSHs (sv_2mortal (newSVterm (term)));
419 XPUSHs (sv_2mortal (newSViv (htype))); 431 PUSHs (sv_2mortal (newSViv (htype)));
420 432
421 for (;;) { 433 for (;;) {
422 data_type dt = (data_type)va_arg (ap, int); 434 data_type dt = (data_type)va_arg (ap, int);
423 435
424 switch (dt) 436 switch (dt)
581 FREETMPS; 593 FREETMPS;
582 LEAVE; 594 LEAVE;
583 595
584 if (SvTRUE (ERRSV)) 596 if (SvTRUE (ERRSV))
585 { 597 {
586 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 598 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
587 ungrab (term); // better lose the grab than the session 599 ungrab (term); // better lose the grab than the session
588 } 600 }
589 601
590 event_consumed = !!count; 602 event_consumed = !!count;
591 } 603 }
608 // don't allow further calls 620 // don't allow further calls
609 term->perl.self = 0; 621 term->perl.self = 0;
610 } 622 }
611 623
612 return event_consumed; 624 return event_consumed;
625}
626
627void
628rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
629{
630 localise_env set_environ (perl_environ);
631
632 ENTER;
633 SAVETMPS;
634
635 dSP;
636 XPUSHs (sv_2mortal (newSVpvn (data, len)));
637 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
638
639 if (SvTRUE (ERRSV))
640 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
641
642 FREETMPS;
643 LEAVE;
613} 644}
614 645
615///////////////////////////////////////////////////////////////////////////// 646/////////////////////////////////////////////////////////////////////////////
616 647
617MODULE = urxvt PACKAGE = urxvt 648MODULE = urxvt PACKAGE = urxvt
768 const_iv (XIMDontChange), 799 const_iv (XIMDontChange),
769# endif 800# endif
770# endif 801# endif
771 }; 802 };
772 803
773 for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) 804 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
774 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 805 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
775} 806}
776 807
777void 808void
778warn (const char *msg) 809warn (const char *msg)
779 CODE: 810 CODE:
851 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 882 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
852 if ((*t)->perl.self) 883 if ((*t)->perl.self)
853 PUSHs (sv_2mortal (newSVterm (*t))); 884 PUSHs (sv_2mortal (newSVterm (*t)));
854} 885}
855 886
887IV
888_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
889 CODE:
890 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
891 req->cb_sv = newSVsv (cb);
892 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
893 av_push (av, newSViv ((IV)req));
894 RETVAL = (IV)req;
895 OUTPUT:
896 RETVAL
897
898void
899_delete_selection_request (IV req_)
900 CODE:
901 rxvt_selection *req = (rxvt_selection *)req_;
902 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
903 int i;
904
905 for (i = AvFILL (av); i >= 0; i--)
906 if (SvIV (*av_fetch (av, i, 1)) == req_)
907 break;
908
909 for (; i < AvFILL (av); i++)
910 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
911
912 av_pop (av);
913
914 delete req;
915
856MODULE = urxvt PACKAGE = urxvt::term 916MODULE = urxvt PACKAGE = urxvt::term
857 917
858SV * 918SV *
859_new (AV *env, AV *arg) 919_new (AV *env, AV *arg)
860 CODE: 920 CODE:
861{ 921{
862 rxvt_term *term = new rxvt_term; 922 rxvt_term *term = new rxvt_term;
863 923
864 stringvec *argv = new stringvec; 924 stringvec *argv = new stringvec;
865 stringvec *envv = new stringvec;
866
867 for (int i = 0; i <= AvFILL (arg); i++) 925 for (int i = 0; i <= AvFILL (arg); i++)
868 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 926 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
869 927
928 stringvec *envv = new stringvec;
870 for (int i = AvFILL (env) + 1; i--; ) 929 for (int i = AvFILL (env) + 1; i--; )
871 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 930 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
872
873 envv->push_back (0);
874 931
875 try 932 try
876 { 933 {
877 term->init (argv, envv); 934 term->init (argv, envv);
878 } 935 }
918 975
919void 976void
920rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 977rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
921 CODE: 978 CODE:
922 XUngrabKey (THIS->dpy, keycode, modifiers, window); 979 XUngrabKey (THIS->dpy, keycode, modifiers, window);
923
924void
925rxvt_term::XUngrabKeyboard (Time eventtime)
926 CODE:
927 XUngrabKeyboard (THIS->dpy, eventtime);
928 980
929bool 981bool
930rxvt_term::grab (Time eventtime, int sync = 0) 982rxvt_term::grab (Time eventtime, int sync = 0)
931 CODE: 983 CODE:
932{ 984{
1167 RETVAL 1219 RETVAL
1168 1220
1169Window 1221Window
1170rxvt_term::parent () 1222rxvt_term::parent ()
1171 CODE: 1223 CODE:
1172 RETVAL = THIS->parent [0]; 1224 RETVAL = THIS->parent;
1173 OUTPUT: 1225 OUTPUT:
1174 RETVAL 1226 RETVAL
1175 1227
1176Window 1228Window
1177rxvt_term::vt () 1229rxvt_term::vt ()
1204 if (newval <= 0) 1256 if (newval <= 0)
1205 THIS->scr_changeview (max (newval, THIS->top_row)); 1257 THIS->scr_changeview (max (newval, THIS->top_row));
1206} 1258}
1207 OUTPUT: 1259 OUTPUT:
1208 RETVAL 1260 RETVAL
1261
1262void
1263rxvt_term::set_urgency (bool enable)
1209 1264
1210void 1265void
1211rxvt_term::focus_in () 1266rxvt_term::focus_in ()
1212 1267
1213void 1268void
1446# include "rsinc.h" 1501# include "rsinc.h"
1447# undef def 1502# undef def
1448# undef reserve 1503# undef reserve
1449 }; 1504 };
1450 1505
1451 rs = rslist + ARRAY_LENGTH(rslist); 1506 rs = rslist + ecb_array_length (rslist);
1452 1507
1453 if (*name) 1508 if (*name)
1454 { 1509 {
1455 do { 1510 do {
1456 if (rs-- == rslist) 1511 if (rs-- == rslist)
1528 CODE: 1583 CODE:
1529 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1584 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1530 THIS->keyboard->register_done (); 1585 THIS->keyboard->register_done ();
1531 OUTPUT: 1586 OUTPUT:
1532 RETVAL 1587 RETVAL
1588
1589void
1590rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1591 CODE:
1592 wchar_t *wstr = sv2wcs (str);
1593 THIS->keyboard->register_user_translation (keysym, state, wstr);
1594 free (wstr);
1533 1595
1534void 1596void
1535rxvt_term::screen_cur (...) 1597rxvt_term::screen_cur (...)
1536 PROTOTYPE: $;$$ 1598 PROTOTYPE: $;$$
1537 ALIAS: 1599 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines