… | |
… | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
31 | #include <cstddef> |
31 | #include <cstddef> |
32 | #include <cstdarg> |
32 | #include <cstdarg> |
33 | |
33 | |
|
|
34 | #include "iom.h" |
34 | #include "rxvt.h" |
35 | #include "rxvt.h" |
35 | #include "iom.h" |
36 | #include "keyboard.h" |
36 | #include "rxvtutil.h" |
37 | #include "rxvtutil.h" |
37 | #include "rxvtperl.h" |
38 | #include "rxvtperl.h" |
38 | |
39 | |
39 | #include "perlxsi.c" |
40 | #include "perlxsi.c" |
40 | |
41 | |
… | |
… | |
48 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
49 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
49 | #undef ROW |
50 | #undef ROW |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
51 | #define ROW(n) THIS->row_buf [LINENO (n)] |
51 | |
52 | |
52 | ///////////////////////////////////////////////////////////////////////////// |
53 | ///////////////////////////////////////////////////////////////////////////// |
|
|
54 | |
|
|
55 | static SV * |
|
|
56 | taint (SV *sv) |
|
|
57 | { |
|
|
58 | SvTAINT (sv); |
|
|
59 | return sv; |
|
|
60 | } |
|
|
61 | |
|
|
62 | static SV * |
|
|
63 | taint_if (SV *sv, SV *src) |
|
|
64 | { |
|
|
65 | if (SvTAINTED (src)) |
|
|
66 | SvTAINT (sv); |
|
|
67 | |
|
|
68 | return sv; |
|
|
69 | } |
53 | |
70 | |
54 | static wchar_t * |
71 | static wchar_t * |
55 | sv2wcs (SV *sv) |
72 | sv2wcs (SV *sv) |
56 | { |
73 | { |
57 | STRLEN len; |
74 | STRLEN len; |
… | |
… | |
376 | |
393 | |
377 | struct rxvt_perl_interp rxvt_perl; |
394 | struct rxvt_perl_interp rxvt_perl; |
378 | |
395 | |
379 | static PerlInterpreter *perl; |
396 | static PerlInterpreter *perl; |
380 | |
397 | |
381 | rxvt_perl_interp::rxvt_perl_interp () |
|
|
382 | { |
|
|
383 | } |
|
|
384 | |
|
|
385 | rxvt_perl_interp::~rxvt_perl_interp () |
398 | rxvt_perl_interp::~rxvt_perl_interp () |
386 | { |
399 | { |
387 | if (perl) |
400 | if (perl) |
388 | { |
401 | { |
389 | perl_destruct (perl); |
402 | perl_destruct (perl); |
… | |
… | |
394 | void |
407 | void |
395 | rxvt_perl_interp::init () |
408 | rxvt_perl_interp::init () |
396 | { |
409 | { |
397 | if (!perl) |
410 | if (!perl) |
398 | { |
411 | { |
|
|
412 | perl_environ = rxvt_environ; |
|
|
413 | swap (perl_environ, environ); |
|
|
414 | |
399 | char *argv[] = { |
415 | char *argv[] = { |
400 | "", |
416 | "", |
|
|
417 | "-T", |
401 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
418 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
402 | }; |
419 | }; |
403 | |
420 | |
404 | perl = perl_alloc (); |
421 | perl = perl_alloc (); |
405 | perl_construct (perl); |
422 | perl_construct (perl); |
406 | |
423 | |
407 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
424 | if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) |
408 | || perl_run (perl)) |
425 | || perl_run (perl)) |
409 | { |
426 | { |
410 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
427 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
411 | |
428 | |
412 | perl_destruct (perl); |
429 | perl_destruct (perl); |
413 | perl_free (perl); |
430 | perl_free (perl); |
414 | perl = 0; |
431 | perl = 0; |
415 | } |
432 | } |
|
|
433 | |
|
|
434 | swap (perl_environ, environ); |
|
|
435 | } |
|
|
436 | } |
|
|
437 | |
|
|
438 | static void |
|
|
439 | ungrab (rxvt_term *THIS) |
|
|
440 | { |
|
|
441 | if (THIS->perl.grabtime) |
|
|
442 | { |
|
|
443 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
|
|
444 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
|
|
445 | THIS->perl.grabtime = 0; |
416 | } |
446 | } |
417 | } |
447 | } |
418 | |
448 | |
419 | bool |
449 | bool |
420 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
450 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
… | |
… | |
431 | return false; // perl not initialized for this instance |
461 | return false; // perl not initialized for this instance |
432 | else if (htype == HOOK_DESTROY) |
462 | else if (htype == HOOK_DESTROY) |
433 | { |
463 | { |
434 | // handled later |
464 | // handled later |
435 | } |
465 | } |
436 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
466 | else |
437 | { |
467 | { |
438 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
468 | if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
439 | |
|
|
440 | if (HvKEYS (hv)) |
|
|
441 | { |
469 | { |
|
|
470 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
471 | |
|
|
472 | if (HvKEYS (hv)) |
|
|
473 | { |
442 | hv_iterinit (hv); |
474 | hv_iterinit (hv); |
443 | |
475 | |
444 | while (HE *he = hv_iternext (hv)) |
476 | while (HE *he = hv_iternext (hv)) |
445 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
477 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
478 | } |
|
|
479 | |
446 | } |
480 | } |
|
|
481 | |
|
|
482 | if (!should_invoke [htype]) |
|
|
483 | return false; |
447 | } |
484 | } |
448 | else if (!should_invoke [htype]) |
|
|
449 | return false; |
|
|
450 | |
485 | |
|
|
486 | swap (perl_environ, environ); |
|
|
487 | |
|
|
488 | try |
|
|
489 | { |
451 | dSP; |
490 | dSP; |
452 | va_list ap; |
491 | va_list ap; |
453 | |
492 | |
454 | va_start (ap, htype); |
493 | va_start (ap, htype); |
455 | |
494 | |
456 | ENTER; |
495 | ENTER; |
457 | SAVETMPS; |
496 | SAVETMPS; |
458 | |
497 | |
459 | PUSHMARK (SP); |
498 | PUSHMARK (SP); |
460 | |
499 | |
461 | XPUSHs (sv_2mortal (newSVterm (term))); |
500 | XPUSHs (sv_2mortal (newSVterm (term))); |
462 | XPUSHs (sv_2mortal (newSViv (htype))); |
501 | XPUSHs (sv_2mortal (newSViv (htype))); |
463 | |
502 | |
464 | for (;;) { |
503 | for (;;) { |
465 | data_type dt = (data_type)va_arg (ap, int); |
504 | data_type dt = (data_type)va_arg (ap, int); |
466 | |
505 | |
467 | switch (dt) |
506 | switch (dt) |
468 | { |
507 | { |
469 | case DT_INT: |
508 | case DT_INT: |
470 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
509 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
471 | break; |
510 | break; |
472 | |
511 | |
473 | case DT_LONG: |
512 | case DT_LONG: |
474 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
513 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
475 | break; |
514 | break; |
476 | |
515 | |
477 | case DT_STR: |
516 | case DT_STR: |
478 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
517 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
479 | break; |
518 | break; |
480 | |
519 | |
481 | case DT_STR_LEN: |
520 | case DT_STR_LEN: |
482 | { |
521 | { |
483 | char *str = va_arg (ap, char *); |
522 | char *str = va_arg (ap, char *); |
484 | int len = va_arg (ap, int); |
523 | int len = va_arg (ap, int); |
485 | |
524 | |
486 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
525 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
487 | } |
526 | } |
488 | break; |
527 | break; |
489 | |
528 | |
490 | case DT_WCS_LEN: |
529 | case DT_WCS_LEN: |
491 | { |
530 | { |
492 | wchar_t *wstr = va_arg (ap, wchar_t *); |
531 | wchar_t *wstr = va_arg (ap, wchar_t *); |
493 | int wlen = va_arg (ap, int); |
532 | int wlen = va_arg (ap, int); |
494 | |
533 | |
495 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
534 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
496 | } |
535 | } |
497 | break; |
536 | break; |
498 | |
537 | |
499 | case DT_XEVENT: |
538 | case DT_XEVENT: |
500 | { |
539 | { |
501 | XEvent *xe = va_arg (ap, XEvent *); |
540 | XEvent *xe = va_arg (ap, XEvent *); |
502 | HV *hv = newHV (); |
541 | HV *hv = newHV (); |
503 | |
542 | |
504 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
543 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
505 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
544 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
506 | # undef set |
545 | # undef set |
507 | |
546 | |
508 | setiv (type, xe->type); |
547 | setiv (type, xe->type); |
509 | setiv (send_event, xe->xany.send_event); |
548 | setiv (send_event, xe->xany.send_event); |
510 | setiv (serial, xe->xany.serial); |
549 | setiv (serial, xe->xany.serial); |
511 | |
550 | |
512 | switch (xe->type) |
551 | switch (xe->type) |
|
|
552 | { |
|
|
553 | case KeyPress: |
|
|
554 | case KeyRelease: |
|
|
555 | case ButtonPress: |
|
|
556 | case ButtonRelease: |
|
|
557 | case MotionNotify: |
|
|
558 | setiv (time, xe->xmotion.time); |
|
|
559 | setiv (x, xe->xmotion.x); |
|
|
560 | setiv (y, xe->xmotion.y); |
|
|
561 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
562 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
563 | setiv (x_root, xe->xmotion.x_root); |
|
|
564 | setiv (y_root, xe->xmotion.y_root); |
|
|
565 | setiv (state, xe->xmotion.state); |
|
|
566 | break; |
|
|
567 | } |
|
|
568 | |
|
|
569 | switch (xe->type) |
|
|
570 | { |
|
|
571 | case KeyPress: |
|
|
572 | case KeyRelease: |
|
|
573 | setiv (keycode, xe->xkey.keycode); |
|
|
574 | break; |
|
|
575 | |
|
|
576 | case ButtonPress: |
|
|
577 | case ButtonRelease: |
|
|
578 | setiv (button, xe->xbutton.button); |
|
|
579 | break; |
|
|
580 | |
|
|
581 | case MotionNotify: |
|
|
582 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
583 | break; |
|
|
584 | } |
|
|
585 | |
|
|
586 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
587 | } |
|
|
588 | break; |
|
|
589 | |
|
|
590 | case DT_END: |
513 | { |
591 | { |
514 | case KeyPress: |
592 | va_end (ap); |
515 | case KeyRelease: |
593 | |
516 | case ButtonPress: |
594 | PUTBACK; |
517 | case ButtonRelease: |
595 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
518 | case MotionNotify: |
596 | SPAGAIN; |
519 | setiv (time, xe->xmotion.time); |
597 | |
520 | setiv (x, xe->xmotion.x); |
598 | if (count) |
521 | setiv (y, xe->xmotion.y); |
|
|
522 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
523 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
524 | setiv (x_root, xe->xmotion.x_root); |
|
|
525 | setiv (y_root, xe->xmotion.y_root); |
|
|
526 | setiv (state, xe->xmotion.state); |
|
|
527 | break; |
599 | { |
|
|
600 | SV *status = POPs; |
|
|
601 | count = SvTRUE (status); |
|
|
602 | } |
|
|
603 | |
|
|
604 | PUTBACK; |
|
|
605 | FREETMPS; |
|
|
606 | LEAVE; |
|
|
607 | |
|
|
608 | if (SvTRUE (ERRSV)) |
|
|
609 | { |
|
|
610 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
611 | ungrab (term); // better lose the grab than the session |
|
|
612 | } |
|
|
613 | |
|
|
614 | if (htype == HOOK_DESTROY) |
|
|
615 | { |
|
|
616 | clearSVptr ((SV *)term->perl.self); |
|
|
617 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
618 | } |
|
|
619 | |
|
|
620 | swap (perl_environ, environ); |
|
|
621 | return count; |
528 | } |
622 | } |
529 | |
623 | |
530 | switch (xe->type) |
|
|
531 | { |
|
|
532 | case KeyPress: |
|
|
533 | case KeyRelease: |
|
|
534 | setiv (keycode, xe->xkey.keycode); |
|
|
535 | break; |
|
|
536 | |
|
|
537 | case ButtonPress: |
|
|
538 | case ButtonRelease: |
|
|
539 | setiv (button, xe->xbutton.button); |
|
|
540 | break; |
|
|
541 | |
|
|
542 | case MotionNotify: |
|
|
543 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
544 | break; |
|
|
545 | } |
|
|
546 | |
|
|
547 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
548 | } |
|
|
549 | break; |
|
|
550 | |
|
|
551 | case DT_END: |
|
|
552 | { |
|
|
553 | va_end (ap); |
|
|
554 | |
|
|
555 | PUTBACK; |
|
|
556 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
557 | SPAGAIN; |
|
|
558 | |
|
|
559 | if (count) |
|
|
560 | { |
|
|
561 | SV *status = POPs; |
|
|
562 | count = SvTRUE (status); |
|
|
563 | } |
|
|
564 | |
|
|
565 | PUTBACK; |
|
|
566 | FREETMPS; |
|
|
567 | LEAVE; |
|
|
568 | |
|
|
569 | if (SvTRUE (ERRSV)) |
|
|
570 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
571 | |
|
|
572 | if (htype == HOOK_DESTROY) |
|
|
573 | { |
|
|
574 | clearSVptr ((SV *)term->perl.self); |
|
|
575 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
576 | } |
|
|
577 | |
|
|
578 | return count; |
|
|
579 | } |
|
|
580 | |
|
|
581 | default: |
624 | default: |
582 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
625 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
626 | } |
583 | } |
627 | } |
584 | } |
628 | } |
|
|
629 | catch (...) |
|
|
630 | { |
|
|
631 | swap (perl_environ, environ); |
|
|
632 | throw; |
|
|
633 | } |
585 | } |
634 | } |
586 | |
635 | |
587 | ///////////////////////////////////////////////////////////////////////////// |
636 | ///////////////////////////////////////////////////////////////////////////// |
588 | |
637 | |
589 | MODULE = urxvt PACKAGE = urxvt |
638 | MODULE = urxvt PACKAGE = urxvt |
590 | |
639 | |
591 | PROTOTYPES: ENABLE |
640 | PROTOTYPES: ENABLE |
592 | |
641 | |
593 | BOOT: |
642 | BOOT: |
594 | { |
643 | { |
595 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
644 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
645 | sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1)); |
|
|
646 | sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1)); |
|
|
647 | sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1)); |
596 | |
648 | |
597 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
649 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
598 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
650 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
599 | # include "hookinc.h" |
651 | # include "hookinc.h" |
600 | # undef def |
652 | # undef def |
… | |
… | |
629 | export_const_iv (Button2Mask); |
681 | export_const_iv (Button2Mask); |
630 | export_const_iv (Button3Mask); |
682 | export_const_iv (Button3Mask); |
631 | export_const_iv (Button4Mask); |
683 | export_const_iv (Button4Mask); |
632 | export_const_iv (Button5Mask); |
684 | export_const_iv (Button5Mask); |
633 | export_const_iv (AnyModifier); |
685 | export_const_iv (AnyModifier); |
|
|
686 | |
|
|
687 | export_const_iv (EVENT_NONE); |
|
|
688 | export_const_iv (EVENT_READ); |
|
|
689 | export_const_iv (EVENT_WRITE); |
634 | } |
690 | } |
|
|
691 | |
|
|
692 | void |
|
|
693 | set_should_invoke (int htype, int value) |
|
|
694 | CODE: |
|
|
695 | rxvt_perl.should_invoke [htype] = value; |
|
|
696 | |
|
|
697 | void |
|
|
698 | warn (const char *msg) |
|
|
699 | CODE: |
|
|
700 | rxvt_warn ("%s", msg); |
|
|
701 | |
|
|
702 | void |
|
|
703 | fatal (const char *msg) |
|
|
704 | CODE: |
|
|
705 | rxvt_fatal ("%s", msg); |
635 | |
706 | |
636 | SV * |
707 | SV * |
637 | new (...) |
708 | untaint (SV *sv) |
638 | CODE: |
709 | CODE: |
639 | { |
710 | RETVAL = newSVsv (sv); |
640 | stringvec *argv = new stringvec; |
711 | SvTAINTED_off (RETVAL); |
641 | bool success; |
712 | OUTPUT: |
642 | |
|
|
643 | for (int i = 0; i < items ;i++) |
|
|
644 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
645 | |
|
|
646 | rxvt_term *term = new rxvt_term; |
|
|
647 | |
|
|
648 | term->argv = argv; |
|
|
649 | |
|
|
650 | try |
|
|
651 | { |
|
|
652 | if (!term->init (argv->size (), argv->begin ())) |
|
|
653 | term = 0; |
|
|
654 | } |
|
|
655 | catch (const class rxvt_failure_exception &e) |
|
|
656 | { |
|
|
657 | term->destroy (); |
|
|
658 | croak ("exception caught while initializing new terminal instance"); |
|
|
659 | } |
|
|
660 | |
|
|
661 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
|
|
662 | } |
|
|
663 | OUTPUT: |
|
|
664 | RETVAL |
713 | RETVAL |
665 | |
714 | |
666 | void |
715 | bool |
667 | set_should_invoke (int htype, int value) |
716 | safe () |
668 | CODE: |
717 | CODE: |
669 | rxvt_perl.should_invoke [htype] = value; |
718 | RETVAL = !rxvt_tainted (); |
670 | |
719 | OUTPUT: |
671 | void |
720 | RETVAL |
672 | warn (const char *msg) |
|
|
673 | CODE: |
|
|
674 | rxvt_warn ("%s", msg); |
|
|
675 | |
|
|
676 | void |
|
|
677 | fatal (const char *msg) |
|
|
678 | CODE: |
|
|
679 | rxvt_fatal ("%s", msg); |
|
|
680 | |
721 | |
681 | NV |
722 | NV |
682 | NOW () |
723 | NOW () |
683 | CODE: |
724 | CODE: |
684 | RETVAL = NOW; |
725 | RETVAL = NOW; |
… | |
… | |
732 | } |
773 | } |
733 | OUTPUT: |
774 | OUTPUT: |
734 | RETVAL |
775 | RETVAL |
735 | |
776 | |
736 | MODULE = urxvt PACKAGE = urxvt::term |
777 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
778 | |
|
|
779 | SV * |
|
|
780 | _new (...) |
|
|
781 | CODE: |
|
|
782 | { |
|
|
783 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
784 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
785 | |
|
|
786 | rxvt_term *term = new rxvt_term; |
|
|
787 | |
|
|
788 | term->argv = new stringvec; |
|
|
789 | term->envv = new stringvec; |
|
|
790 | |
|
|
791 | for (int i = 1; i < items; i++) |
|
|
792 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
793 | |
|
|
794 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
795 | for (int i = av_len (envv) + 1; i--; ) |
|
|
796 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
|
|
797 | |
|
|
798 | term->envv->push_back (0); |
|
|
799 | |
|
|
800 | bool success; |
|
|
801 | |
|
|
802 | try |
|
|
803 | { |
|
|
804 | success = term->init (term->argv->size (), term->argv->begin ()); |
|
|
805 | } |
|
|
806 | catch (const class rxvt_failure_exception &e) |
|
|
807 | { |
|
|
808 | success = false; |
|
|
809 | } |
|
|
810 | |
|
|
811 | if (!success) |
|
|
812 | { |
|
|
813 | term->destroy (); |
|
|
814 | croak ("error while initializing new terminal instance"); |
|
|
815 | } |
|
|
816 | |
|
|
817 | RETVAL = term && term->perl.self |
|
|
818 | ? newSVterm (term) : &PL_sv_undef; |
|
|
819 | } |
|
|
820 | OUTPUT: |
|
|
821 | RETVAL |
737 | |
822 | |
738 | void |
823 | void |
739 | rxvt_term::destroy () |
824 | rxvt_term::destroy () |
740 | |
825 | |
741 | void |
826 | void |
… | |
… | |
765 | } |
850 | } |
766 | OUTPUT: |
851 | OUTPUT: |
767 | RETVAL |
852 | RETVAL |
768 | |
853 | |
769 | void |
854 | void |
770 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
855 | rxvt_term::allow_events_async () |
771 | CODE: |
856 | CODE: |
772 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
857 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
773 | |
858 | |
774 | void |
859 | void |
775 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
860 | rxvt_term::allow_events_sync () |
776 | CODE: |
861 | CODE: |
777 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
862 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
778 | |
863 | |
779 | void |
864 | void |
780 | rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) |
865 | rxvt_term::allow_events_replay () |
781 | CODE: |
866 | CODE: |
782 | XAllowEvents (THIS->display->display, ReplayPointer, eventtime); |
867 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
783 | XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); |
868 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
784 | |
869 | |
785 | void |
870 | void |
786 | rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) |
871 | rxvt_term::ungrab () |
787 | CODE: |
872 | CODE: |
788 | THIS->perl.grabtime = 0; |
873 | ungrab (THIS); |
789 | XUngrabKeyboard (THIS->display->display, eventtime); |
|
|
790 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
791 | |
874 | |
792 | int |
875 | int |
793 | rxvt_term::strwidth (SV *str) |
876 | rxvt_term::strwidth (SV *str) |
794 | CODE: |
877 | CODE: |
795 | { |
878 | { |
… | |
… | |
814 | char *mbstr = rxvt_wcstombs (wstr); |
897 | char *mbstr = rxvt_wcstombs (wstr); |
815 | rxvt_pop_locale (); |
898 | rxvt_pop_locale (); |
816 | |
899 | |
817 | free (wstr); |
900 | free (wstr); |
818 | |
901 | |
819 | RETVAL = newSVpv (mbstr, 0); |
902 | RETVAL = taint_if (newSVpv (mbstr, 0), str); |
820 | free (mbstr); |
903 | free (mbstr); |
821 | } |
904 | } |
822 | OUTPUT: |
905 | OUTPUT: |
823 | RETVAL |
906 | RETVAL |
824 | |
907 | |
… | |
… | |
831 | |
914 | |
832 | rxvt_push_locale (THIS->locale); |
915 | rxvt_push_locale (THIS->locale); |
833 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
916 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
834 | rxvt_pop_locale (); |
917 | rxvt_pop_locale (); |
835 | |
918 | |
836 | RETVAL = wcs2sv (wstr); |
919 | RETVAL = taint_if (wcs2sv (wstr), octets); |
837 | free (wstr); |
920 | free (wstr); |
838 | } |
921 | } |
839 | OUTPUT: |
922 | OUTPUT: |
840 | RETVAL |
923 | RETVAL |
841 | |
924 | |
… | |
… | |
888 | case 2: RETVAL = THIS->ModNumLockMask; break; |
971 | case 2: RETVAL = THIS->ModNumLockMask; break; |
889 | } |
972 | } |
890 | OUTPUT: |
973 | OUTPUT: |
891 | RETVAL |
974 | RETVAL |
892 | |
975 | |
|
|
976 | char * |
|
|
977 | rxvt_term::display_id () |
|
|
978 | ALIAS: |
|
|
979 | display_id = 0 |
|
|
980 | locale = 1 |
|
|
981 | CODE: |
|
|
982 | switch (ix) |
|
|
983 | { |
|
|
984 | case 0: RETVAL = THIS->display->id; break; |
|
|
985 | case 1: RETVAL = THIS->locale; break; |
|
|
986 | } |
|
|
987 | OUTPUT: |
|
|
988 | RETVAL |
|
|
989 | |
|
|
990 | SV * |
|
|
991 | rxvt_term::_env () |
|
|
992 | CODE: |
|
|
993 | { |
|
|
994 | if (THIS->envv) |
|
|
995 | { |
|
|
996 | AV *av = newAV (); |
|
|
997 | |
|
|
998 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
|
|
999 | if (*i) |
|
|
1000 | av_push (av, newSVpv (*i, 0)); |
|
|
1001 | |
|
|
1002 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1003 | } |
|
|
1004 | else |
|
|
1005 | RETVAL = &PL_sv_undef; |
|
|
1006 | } |
|
|
1007 | OUTPUT: |
|
|
1008 | RETVAL |
|
|
1009 | |
|
|
1010 | int |
|
|
1011 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
|
|
1012 | CODE: |
|
|
1013 | RETVAL = THIS->pty_ev.events; |
|
|
1014 | if (events != EVENT_UNDEF) |
|
|
1015 | THIS->pty_ev.set (events); |
|
|
1016 | OUTPUT: |
|
|
1017 | RETVAL |
|
|
1018 | |
893 | U32 |
1019 | U32 |
894 | rxvt_term::parent () |
1020 | rxvt_term::parent () |
895 | CODE: |
1021 | CODE: |
896 | RETVAL = (U32)THIS->parent [0]; |
1022 | RETVAL = (U32)THIS->parent [0]; |
897 | OUTPUT: |
1023 | OUTPUT: |
… | |
… | |
948 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
1074 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
949 | |
1075 | |
950 | for (int col = 0; col < THIS->ncol; col++) |
1076 | for (int col = 0; col < THIS->ncol; col++) |
951 | wstr [col] = l.t [col]; |
1077 | wstr [col] = l.t [col]; |
952 | |
1078 | |
953 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1079 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); |
954 | |
1080 | |
955 | delete [] wstr; |
1081 | delete [] wstr; |
956 | } |
1082 | } |
957 | |
1083 | |
958 | if (new_text) |
1084 | if (new_text) |
… | |
… | |
1079 | else |
1205 | else |
1080 | *r++ = *s; |
1206 | *r++ = *s; |
1081 | |
1207 | |
1082 | rxvt_pop_locale (); |
1208 | rxvt_pop_locale (); |
1083 | |
1209 | |
1084 | RETVAL = wcs2sv (rstr, r - rstr); |
1210 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); |
1085 | |
1211 | |
1086 | delete [] rstr; |
1212 | delete [] rstr; |
1087 | } |
1213 | } |
1088 | OUTPUT: |
1214 | OUTPUT: |
1089 | RETVAL |
1215 | RETVAL |
… | |
… | |
1115 | else if (IS_COMPOSE (*s)) |
1241 | else if (IS_COMPOSE (*s)) |
1116 | r += rxvt_composite.expand (*s, r); |
1242 | r += rxvt_composite.expand (*s, r); |
1117 | else |
1243 | else |
1118 | *r++ = *s; |
1244 | *r++ = *s; |
1119 | |
1245 | |
1120 | RETVAL = wcs2sv (rstr, r - rstr); |
1246 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); |
1121 | |
1247 | |
1122 | delete [] rstr; |
1248 | delete [] rstr; |
1123 | } |
1249 | } |
1124 | OUTPUT: |
1250 | OUTPUT: |
1125 | RETVAL |
1251 | RETVAL |
… | |
… | |
1147 | |
1273 | |
1148 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1274 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1149 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1275 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1150 | |
1276 | |
1151 | if (GIMME_V != G_VOID) |
1277 | if (GIMME_V != G_VOID) |
1152 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
1278 | XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); |
1153 | |
1279 | |
1154 | if (newval) |
1280 | if (newval) |
1155 | { |
1281 | { |
1156 | if (SvOK (newval)) |
1282 | if (SvOK (newval)) |
1157 | { |
1283 | { |
… | |
… | |
1162 | else |
1288 | else |
1163 | THIS->rs [index] = 0; |
1289 | THIS->rs [index] = 0; |
1164 | } |
1290 | } |
1165 | } |
1291 | } |
1166 | |
1292 | |
|
|
1293 | const char * |
|
|
1294 | rxvt_term::x_resource (const char *name) |
|
|
1295 | CLEANUP: |
|
|
1296 | SvTAINTED_on (ST (0)); |
|
|
1297 | |
1167 | bool |
1298 | bool |
1168 | rxvt_term::option (U32 optval, int set = -1) |
1299 | rxvt_term::option (U32 optval, int set = -1) |
1169 | CODE: |
1300 | CODE: |
1170 | { |
1301 | { |
1171 | RETVAL = THIS->options & optval; |
1302 | RETVAL = THIS->options & optval; |
… | |
… | |
1198 | } |
1329 | } |
1199 | } |
1330 | } |
1200 | OUTPUT: |
1331 | OUTPUT: |
1201 | RETVAL |
1332 | RETVAL |
1202 | |
1333 | |
|
|
1334 | bool |
|
|
1335 | rxvt_term::parse_keysym (char *keysym, char *str) |
|
|
1336 | CODE: |
|
|
1337 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
|
|
1338 | THIS->keyboard->register_done (); |
|
|
1339 | OUTPUT: |
|
|
1340 | RETVAL |
|
|
1341 | |
1203 | void |
1342 | void |
1204 | rxvt_term::cur (...) |
1343 | rxvt_term::screen_cur (...) |
1205 | PROTOTYPE: $;$$ |
1344 | PROTOTYPE: $;$$ |
1206 | ALIAS: |
1345 | ALIAS: |
1207 | screen_cur = 0 |
1346 | screen_cur = 0 |
1208 | selection_beg = 1 |
1347 | selection_beg = 1 |
1209 | selection_end = 2 |
1348 | selection_end = 2 |
… | |
… | |
1230 | if (ix) |
1369 | if (ix) |
1231 | THIS->want_refresh = 1; |
1370 | THIS->want_refresh = 1; |
1232 | } |
1371 | } |
1233 | } |
1372 | } |
1234 | |
1373 | |
|
|
1374 | char |
|
|
1375 | rxvt_term::cur_charset () |
|
|
1376 | CODE: |
|
|
1377 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1378 | OUTPUT: |
|
|
1379 | RETVAL |
|
|
1380 | |
1235 | int |
1381 | int |
1236 | rxvt_term::selection_grab (U32 eventtime) |
1382 | rxvt_term::selection_grab (U32 eventtime) |
1237 | |
1383 | |
1238 | void |
1384 | void |
1239 | rxvt_term::selection (SV *newtext = 0) |
1385 | rxvt_term::selection (SV *newtext = 0) |
1240 | PPCODE: |
1386 | PPCODE: |
1241 | { |
1387 | { |
1242 | if (GIMME_V != G_VOID) |
1388 | if (GIMME_V != G_VOID) |
|
|
1389 | XPUSHs (THIS->selection.text |
1243 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
1390 | ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) |
|
|
1391 | : &PL_sv_undef); |
1244 | |
1392 | |
1245 | if (newtext) |
1393 | if (newtext) |
1246 | { |
1394 | { |
1247 | free (THIS->selection.text); |
1395 | free (THIS->selection.text); |
1248 | |
1396 | |
1249 | THIS->selection.text = sv2wcs (newtext); |
1397 | THIS->selection.text = sv2wcs (newtext); |
1250 | THIS->selection.len = wcslen (THIS->selection.text); |
1398 | THIS->selection.len = wcslen (THIS->selection.text); |
1251 | } |
1399 | } |
1252 | } |
1400 | } |
|
|
1401 | |
|
|
1402 | void |
|
|
1403 | 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) |
|
|
1404 | |
|
|
1405 | void |
|
|
1406 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
|
|
1407 | |
|
|
1408 | void |
|
|
1409 | rxvt_term::scr_bell () |
1253 | |
1410 | |
1254 | void |
1411 | void |
1255 | rxvt_term::scr_add_lines (SV *string) |
1412 | rxvt_term::scr_add_lines (SV *string) |
1256 | CODE: |
1413 | CODE: |
1257 | { |
1414 | { |