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.134 by root, Thu Dec 16 23:03:50 2010 UTC vs.
Revision 1.140 by sf-exg, Thu Apr 7 12:19:41 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.
302 THIS->refresh_check (); 302 THIS->refresh_check ();
303} 303}
304 304
305///////////////////////////////////////////////////////////////////////////// 305/////////////////////////////////////////////////////////////////////////////
306 306
307#define IOM_CLASS "urxvt"
308#define IOM_WARN rxvt_warn
309#include "iom_perl.h" 307#include "iom_perl.h"
310 308
311///////////////////////////////////////////////////////////////////////////// 309/////////////////////////////////////////////////////////////////////////////
312 310
313struct rxvt_perl_interp rxvt_perl; 311struct rxvt_perl_interp rxvt_perl;
343 " unshift @INC, '" LIBDIR "';" 341 " unshift @INC, '" LIBDIR "';"
344 "}" 342 "}"
345 "" 343 ""
346 "use urxvt;" 344 "use urxvt;"
347 }; 345 };
348 int argc = sizeof (args) / sizeof (args[0]); 346 int argc = ARRAY_LENGTH(args);
349 char **argv = args; 347 char **argv = args;
350 348
351 PERL_SYS_INIT3 (&argc, &argv, &environ); 349 PERL_SYS_INIT3 (&argc, &argv, &environ);
352 perl = perl_alloc (); 350 perl = perl_alloc ();
353 perl_construct (perl); 351 perl_construct (perl);
415 ENTER; 413 ENTER;
416 SAVETMPS; 414 SAVETMPS;
417 415
418 PUSHMARK (SP); 416 PUSHMARK (SP);
419 417
418 EXTEND (SP, 2);
420 XPUSHs (sv_2mortal (newSVterm (term))); 419 PUSHs (sv_2mortal (newSVterm (term)));
421 XPUSHs (sv_2mortal (newSViv (htype))); 420 PUSHs (sv_2mortal (newSViv (htype)));
422 421
423 for (;;) { 422 for (;;) {
424 data_type dt = (data_type)va_arg (ap, int); 423 data_type dt = (data_type)va_arg (ap, int);
425 424
426 switch (dt) 425 switch (dt)
583 FREETMPS; 582 FREETMPS;
584 LEAVE; 583 LEAVE;
585 584
586 if (SvTRUE (ERRSV)) 585 if (SvTRUE (ERRSV))
587 { 586 {
588 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 587 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
589 ungrab (term); // better lose the grab than the session 588 ungrab (term); // better lose the grab than the session
590 } 589 }
591 590
592 event_consumed = !!count; 591 event_consumed = !!count;
593 } 592 }
610 // don't allow further calls 609 // don't allow further calls
611 term->perl.self = 0; 610 term->perl.self = 0;
612 } 611 }
613 612
614 return event_consumed; 613 return event_consumed;
614}
615
616void
617rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
618{
619 localise_env set_environ (perl_environ);
620
621 ENTER;
622 SAVETMPS;
623
624 dSP;
625 XPUSHs (sv_2mortal (newSVpvn (data, len)));
626 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
627
628 if (SvTRUE (ERRSV))
629 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
630
631 FREETMPS;
632 LEAVE;
615} 633}
616 634
617///////////////////////////////////////////////////////////////////////////// 635/////////////////////////////////////////////////////////////////////////////
618 636
619MODULE = urxvt PACKAGE = urxvt 637MODULE = urxvt PACKAGE = urxvt
770 const_iv (XIMDontChange), 788 const_iv (XIMDontChange),
771# endif 789# endif
772# endif 790# endif
773 }; 791 };
774 792
775 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 793 for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; )
776 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 794 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
777} 795}
778 796
779void 797void
780warn (const char *msg) 798warn (const char *msg)
852 870
853 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 871 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
854 if ((*t)->perl.self) 872 if ((*t)->perl.self)
855 PUSHs (sv_2mortal (newSVterm (*t))); 873 PUSHs (sv_2mortal (newSVterm (*t)));
856} 874}
875
876IV
877_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
878 CODE:
879 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
880 req->cb_sv = newSVsv (cb);
881 RETVAL = (IV)req;
882 OUTPUT:
883 RETVAL
884
885void
886_delete_selection_request (IV req_)
887 CODE:
888 rxvt_selection *req = (rxvt_selection *)req_;
889 delete req;
857 890
858MODULE = urxvt PACKAGE = urxvt::term 891MODULE = urxvt PACKAGE = urxvt::term
859 892
860SV * 893SV *
861_new (AV *env, AV *arg) 894_new (AV *env, AV *arg)
1169 RETVAL 1202 RETVAL
1170 1203
1171Window 1204Window
1172rxvt_term::parent () 1205rxvt_term::parent ()
1173 CODE: 1206 CODE:
1174 RETVAL = THIS->parent [0]; 1207 RETVAL = THIS->parent;
1175 OUTPUT: 1208 OUTPUT:
1176 RETVAL 1209 RETVAL
1177 1210
1178Window 1211Window
1179rxvt_term::vt () 1212rxvt_term::vt ()
1448# include "rsinc.h" 1481# include "rsinc.h"
1449# undef def 1482# undef def
1450# undef reserve 1483# undef reserve
1451 }; 1484 };
1452 1485
1453 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1486 rs = rslist + ARRAY_LENGTH(rslist);
1454 1487
1455 if (*name) 1488 if (*name)
1456 { 1489 {
1457 do { 1490 do {
1458 if (rs-- == rslist) 1491 if (rs-- == rslist)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines