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 | |
313 | struct rxvt_perl_interp rxvt_perl; |
311 | struct rxvt_perl_interp rxvt_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 | |
|
|
616 | void |
|
|
617 | rxvt_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 | |
619 | MODULE = urxvt PACKAGE = urxvt |
637 | MODULE = urxvt PACKAGE = urxvt |