… | |
… | |
26 | #include <XSUB.h> |
26 | #include <XSUB.h> |
27 | #undef line_t |
27 | #undef line_t |
28 | |
28 | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
|
|
31 | #include <cstddef> |
31 | #include <cstdarg> |
32 | #include <cstdarg> |
32 | |
33 | |
33 | #include "rxvt.h" |
34 | #include "rxvt.h" |
34 | #include "iom.h" |
35 | #include "iom.h" |
35 | #include "rxvtutil.h" |
36 | #include "rxvtutil.h" |
36 | #include "rxvtperl.h" |
37 | #include "rxvtperl.h" |
37 | |
38 | |
38 | #include "perlxsi.c" |
39 | #include "perlxsi.c" |
39 | |
40 | |
|
|
41 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
|
|
42 | # define GRAB_CURSOR THIS->leftptr_cursor |
|
|
43 | #else |
|
|
44 | # define GRAB_CURSOR None |
|
|
45 | #endif |
|
|
46 | |
40 | #undef LINENO |
47 | #undef LINENO |
41 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
48 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
42 | #undef ROW |
49 | #undef ROW |
43 | #define ROW(n) THIS->row_buf [LINENO (n)] |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
44 | |
51 | |
45 | ///////////////////////////////////////////////////////////////////////////// |
52 | ///////////////////////////////////////////////////////////////////////////// |
46 | |
53 | |
|
|
54 | static SV * |
|
|
55 | taint (SV *sv) |
|
|
56 | { |
|
|
57 | SvTAINT (sv); |
|
|
58 | return sv; |
|
|
59 | } |
|
|
60 | |
|
|
61 | static SV * |
|
|
62 | taint_if (SV *sv, SV *src) |
|
|
63 | { |
|
|
64 | if (SvTAINTED (src)) |
|
|
65 | SvTAINT (sv); |
|
|
66 | |
|
|
67 | return sv; |
|
|
68 | } |
|
|
69 | |
47 | static wchar_t * |
70 | static wchar_t * |
48 | sv2wcs (SV *sv) |
71 | sv2wcs (SV *sv) |
49 | { |
72 | { |
50 | STRLEN len; |
73 | STRLEN len; |
51 | char *str = SvPVutf8 (sv, len); |
74 | char *str = SvPVutf8 (sv, len); |
… | |
… | |
101 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
124 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
102 | |
125 | |
103 | return (long)mg->mg_ptr; |
126 | return (long)mg->mg_ptr; |
104 | } |
127 | } |
105 | |
128 | |
106 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
129 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
107 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
130 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
108 | |
131 | |
109 | ///////////////////////////////////////////////////////////////////////////// |
132 | ///////////////////////////////////////////////////////////////////////////// |
110 | |
133 | |
111 | struct perl_watcher |
134 | struct perl_watcher |
… | |
… | |
290 | void |
313 | void |
291 | overlay::show () |
314 | overlay::show () |
292 | { |
315 | { |
293 | char key[33]; sprintf (key, "%32lx", (long)this); |
316 | char key[33]; sprintf (key, "%32lx", (long)this); |
294 | |
317 | |
295 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
318 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
296 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
319 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
297 | } |
320 | } |
298 | |
321 | |
299 | void |
322 | void |
300 | overlay::hide () |
323 | overlay::hide () |
301 | { |
324 | { |
302 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); |
325 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
303 | |
326 | |
304 | if (ovs) |
327 | if (ovs) |
305 | { |
328 | { |
306 | char key[33]; sprintf (key, "%32lx", (long)this); |
329 | char key[33]; sprintf (key, "%32lx", (long)this); |
307 | |
330 | |
… | |
… | |
389 | { |
412 | { |
390 | if (!perl) |
413 | if (!perl) |
391 | { |
414 | { |
392 | char *argv[] = { |
415 | char *argv[] = { |
393 | "", |
416 | "", |
|
|
417 | "-T", |
394 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
418 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
395 | }; |
419 | }; |
396 | |
420 | |
397 | perl = perl_alloc (); |
421 | perl = perl_alloc (); |
398 | perl_construct (perl); |
422 | perl_construct (perl); |
399 | |
423 | |
400 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
424 | if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) |
401 | || perl_run (perl)) |
425 | || perl_run (perl)) |
402 | { |
426 | { |
403 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
427 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
404 | |
428 | |
405 | perl_destruct (perl); |
429 | perl_destruct (perl); |
… | |
… | |
407 | perl = 0; |
431 | perl = 0; |
408 | } |
432 | } |
409 | } |
433 | } |
410 | } |
434 | } |
411 | |
435 | |
|
|
436 | static void |
|
|
437 | ungrab (rxvt_term *THIS) |
|
|
438 | { |
|
|
439 | if (THIS->perl.grabtime) |
|
|
440 | { |
|
|
441 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
|
|
442 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
|
|
443 | THIS->perl.grabtime = 0; |
|
|
444 | } |
|
|
445 | } |
|
|
446 | |
412 | bool |
447 | bool |
413 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
448 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
414 | { |
449 | { |
415 | if (!perl) |
450 | if (!perl) |
416 | return false; |
451 | return false; |
417 | |
452 | |
418 | if (htype == HOOK_INIT) // first hook ever called |
453 | if (htype == HOOK_INIT) // first hook ever called |
419 | { |
454 | { |
420 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
455 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
421 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
456 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
422 | } |
457 | } |
423 | else if (!term->self) |
458 | else if (!term->perl.self) |
424 | return false; // perl not initialized for this instance |
459 | return false; // perl not initialized for this instance |
425 | else if (htype == HOOK_DESTROY) |
460 | else if (htype == HOOK_DESTROY) |
426 | { |
461 | { |
427 | // handled later |
462 | // handled later |
428 | } |
463 | } |
429 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
464 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
430 | { |
465 | { |
431 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
466 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
432 | |
467 | |
433 | if (HvKEYS (hv)) |
468 | if (HvKEYS (hv)) |
434 | { |
469 | { |
435 | hv_iterinit (hv); |
470 | hv_iterinit (hv); |
436 | |
471 | |
… | |
… | |
466 | case DT_LONG: |
501 | case DT_LONG: |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
502 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
468 | break; |
503 | break; |
469 | |
504 | |
470 | case DT_STR: |
505 | case DT_STR: |
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
506 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
472 | break; |
507 | break; |
473 | |
508 | |
474 | case DT_STR_LEN: |
509 | case DT_STR_LEN: |
475 | { |
510 | { |
476 | char *str = va_arg (ap, char *); |
511 | char *str = va_arg (ap, char *); |
477 | int len = va_arg (ap, int); |
512 | int len = va_arg (ap, int); |
478 | |
513 | |
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
514 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
480 | } |
515 | } |
481 | break; |
516 | break; |
482 | |
517 | |
483 | case DT_WCS_LEN: |
518 | case DT_WCS_LEN: |
484 | { |
519 | { |
485 | wchar_t *wstr = va_arg (ap, wchar_t *); |
520 | wchar_t *wstr = va_arg (ap, wchar_t *); |
486 | int wlen = va_arg (ap, int); |
521 | int wlen = va_arg (ap, int); |
487 | |
522 | |
488 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
523 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
489 | } |
524 | } |
490 | break; |
525 | break; |
491 | |
526 | |
492 | case DT_XEVENT: |
527 | case DT_XEVENT: |
493 | { |
528 | { |
… | |
… | |
558 | PUTBACK; |
593 | PUTBACK; |
559 | FREETMPS; |
594 | FREETMPS; |
560 | LEAVE; |
595 | LEAVE; |
561 | |
596 | |
562 | if (SvTRUE (ERRSV)) |
597 | if (SvTRUE (ERRSV)) |
|
|
598 | { |
563 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
599 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
600 | ungrab (term); // better lose the grab than the session |
|
|
601 | } |
564 | |
602 | |
565 | if (htype == HOOK_DESTROY) |
603 | if (htype == HOOK_DESTROY) |
566 | { |
604 | { |
567 | clearSVptr ((SV *)term->self); |
605 | clearSVptr ((SV *)term->perl.self); |
568 | SvREFCNT_dec ((SV *)term->self); |
606 | SvREFCNT_dec ((SV *)term->perl.self); |
569 | } |
607 | } |
570 | |
608 | |
571 | return count; |
609 | return count; |
572 | } |
610 | } |
573 | |
611 | |
… | |
… | |
583 | |
621 | |
584 | PROTOTYPES: ENABLE |
622 | PROTOTYPES: ENABLE |
585 | |
623 | |
586 | BOOT: |
624 | BOOT: |
587 | { |
625 | { |
588 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
626 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
627 | |
589 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
628 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
590 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
629 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
591 | # include "hookinc.h" |
630 | # include "hookinc.h" |
592 | # undef def |
631 | # undef def |
593 | |
632 | |
|
|
633 | HV *option = get_hv ("urxvt::OPTION", 1); |
|
|
634 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
|
|
635 | # define nodef(name) |
|
|
636 | # include "optinc.h" |
|
|
637 | # undef nodef |
|
|
638 | # undef def |
|
|
639 | |
|
|
640 | HV *stash = gv_stashpv ("urxvt", 1); |
|
|
641 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
594 | export_const (DEFAULT_RSTYLE); |
642 | export_const_iv (DEFAULT_RSTYLE); |
595 | export_const (OVERLAY_RSTYLE); |
643 | export_const_iv (OVERLAY_RSTYLE); |
596 | export_const (RS_Bold); |
644 | export_const_iv (RS_Bold); |
597 | export_const (RS_Italic); |
645 | export_const_iv (RS_Italic); |
598 | export_const (RS_Blink); |
646 | export_const_iv (RS_Blink); |
599 | export_const (RS_RVid); |
647 | export_const_iv (RS_RVid); |
600 | export_const (RS_Uline); |
648 | export_const_iv (RS_Uline); |
601 | |
649 | |
602 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
650 | export_const_iv (CurrentTime); |
|
|
651 | export_const_iv (ShiftMask); |
|
|
652 | export_const_iv (LockMask); |
|
|
653 | export_const_iv (ControlMask); |
|
|
654 | export_const_iv (Mod1Mask); |
|
|
655 | export_const_iv (Mod2Mask); |
|
|
656 | export_const_iv (Mod3Mask); |
|
|
657 | export_const_iv (Mod4Mask); |
|
|
658 | export_const_iv (Mod5Mask); |
|
|
659 | export_const_iv (Button1Mask); |
|
|
660 | export_const_iv (Button2Mask); |
|
|
661 | export_const_iv (Button3Mask); |
|
|
662 | export_const_iv (Button4Mask); |
|
|
663 | export_const_iv (Button5Mask); |
|
|
664 | export_const_iv (AnyModifier); |
603 | } |
665 | } |
604 | |
666 | |
605 | SV * |
667 | SV * |
606 | new (...) |
668 | new (...) |
607 | CODE: |
669 | CODE: |
… | |
… | |
625 | { |
687 | { |
626 | term->destroy (); |
688 | term->destroy (); |
627 | croak ("exception caught while initializing new terminal instance"); |
689 | croak ("exception caught while initializing new terminal instance"); |
628 | } |
690 | } |
629 | |
691 | |
630 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
692 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
631 | } |
693 | } |
632 | OUTPUT: |
694 | OUTPUT: |
633 | RETVAL |
695 | RETVAL |
634 | |
696 | |
635 | void |
697 | void |
… | |
… | |
644 | |
706 | |
645 | void |
707 | void |
646 | fatal (const char *msg) |
708 | fatal (const char *msg) |
647 | CODE: |
709 | CODE: |
648 | rxvt_fatal ("%s", msg); |
710 | rxvt_fatal ("%s", msg); |
|
|
711 | |
|
|
712 | SV * |
|
|
713 | untaint (SV *sv) |
|
|
714 | CODE: |
|
|
715 | RETVAL = newSVsv (sv); |
|
|
716 | SvTAINTED_off (RETVAL); |
|
|
717 | OUTPUT: |
|
|
718 | RETVAL |
649 | |
719 | |
650 | NV |
720 | NV |
651 | NOW () |
721 | NOW () |
652 | CODE: |
722 | CODE: |
653 | RETVAL = NOW; |
723 | RETVAL = NOW; |
… | |
… | |
706 | |
776 | |
707 | void |
777 | void |
708 | rxvt_term::destroy () |
778 | rxvt_term::destroy () |
709 | |
779 | |
710 | void |
780 | void |
711 | rxvt_term::grab (int eventtime) |
781 | rxvt_term::grab_button (int button, U32 modifiers) |
712 | CODE: |
782 | CODE: |
713 | { |
783 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
714 | return; |
|
|
715 | XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
716 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
784 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
717 | GrabModeAsync, GrabModeAsync, None, None, eventtime); |
785 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
786 | |
|
|
787 | bool |
|
|
788 | rxvt_term::grab (U32 eventtime, int sync = 0) |
|
|
789 | CODE: |
|
|
790 | { |
|
|
791 | int mode = sync ? GrabModeSync : GrabModeAsync; |
|
|
792 | |
|
|
793 | THIS->perl.grabtime = 0; |
|
|
794 | |
|
|
795 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
796 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
797 | mode, mode, None, GRAB_CURSOR, eventtime)) |
718 | XGrabKeyboard (THIS->display->display, THIS->vt, 0, GrabModeAsync, GrabModeAsync, eventtime); |
798 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
|
|
799 | THIS->perl.grabtime = eventtime; |
|
|
800 | else |
|
|
801 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
802 | |
|
|
803 | RETVAL = !!THIS->perl.grabtime; |
719 | } |
804 | } |
|
|
805 | OUTPUT: |
|
|
806 | RETVAL |
|
|
807 | |
|
|
808 | void |
|
|
809 | rxvt_term::allow_events_async () |
|
|
810 | CODE: |
|
|
811 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
|
|
812 | |
|
|
813 | void |
|
|
814 | rxvt_term::allow_events_sync () |
|
|
815 | CODE: |
|
|
816 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
|
|
817 | |
|
|
818 | void |
|
|
819 | rxvt_term::allow_events_replay () |
|
|
820 | CODE: |
|
|
821 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
|
|
822 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
|
|
823 | |
|
|
824 | void |
|
|
825 | rxvt_term::ungrab () |
|
|
826 | CODE: |
|
|
827 | ungrab (THIS); |
720 | |
828 | |
721 | int |
829 | int |
722 | rxvt_term::strwidth (SV *str) |
830 | rxvt_term::strwidth (SV *str) |
723 | CODE: |
831 | CODE: |
724 | { |
832 | { |
… | |
… | |
743 | char *mbstr = rxvt_wcstombs (wstr); |
851 | char *mbstr = rxvt_wcstombs (wstr); |
744 | rxvt_pop_locale (); |
852 | rxvt_pop_locale (); |
745 | |
853 | |
746 | free (wstr); |
854 | free (wstr); |
747 | |
855 | |
748 | RETVAL = newSVpv (mbstr, 0); |
856 | RETVAL = taint_if (newSVpv (mbstr, 0), str); |
749 | free (mbstr); |
857 | free (mbstr); |
750 | } |
858 | } |
751 | OUTPUT: |
859 | OUTPUT: |
752 | RETVAL |
860 | RETVAL |
753 | |
861 | |
… | |
… | |
760 | |
868 | |
761 | rxvt_push_locale (THIS->locale); |
869 | rxvt_push_locale (THIS->locale); |
762 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
870 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
763 | rxvt_pop_locale (); |
871 | rxvt_pop_locale (); |
764 | |
872 | |
765 | RETVAL = wcs2sv (wstr); |
873 | RETVAL = taint_if (wcs2sv (wstr), octets); |
766 | free (wstr); |
874 | free (wstr); |
767 | } |
875 | } |
768 | OUTPUT: |
876 | OUTPUT: |
769 | RETVAL |
877 | RETVAL |
770 | |
878 | |
771 | # very portable, especially on objects as opposed to pods |
879 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
772 | #define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0) |
|
|
773 | |
880 | |
774 | #define TERM_OFFSET_width TERM_OFFSET(width) |
881 | #define TERM_OFFSET_width TERM_OFFSET(width) |
775 | #define TERM_OFFSET_height TERM_OFFSET(height) |
882 | #define TERM_OFFSET_height TERM_OFFSET(height) |
776 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
883 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
777 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
884 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
… | |
… | |
802 | CODE: |
909 | CODE: |
803 | RETVAL = *(int *)((char *)THIS + ix); |
910 | RETVAL = *(int *)((char *)THIS + ix); |
804 | OUTPUT: |
911 | OUTPUT: |
805 | RETVAL |
912 | RETVAL |
806 | |
913 | |
|
|
914 | unsigned int |
|
|
915 | rxvt_term::ModLevel3Mask () |
|
|
916 | ALIAS: |
|
|
917 | ModLevel3Mask = 0 |
|
|
918 | ModMetaMask = 1 |
|
|
919 | ModNumLockMask = 2 |
|
|
920 | CODE: |
|
|
921 | switch (ix) |
|
|
922 | { |
|
|
923 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
|
|
924 | case 1: RETVAL = THIS->ModMetaMask; break; |
|
|
925 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
926 | } |
|
|
927 | OUTPUT: |
|
|
928 | RETVAL |
|
|
929 | |
807 | U32 |
930 | U32 |
808 | rxvt_term::parent () |
931 | rxvt_term::parent () |
809 | CODE: |
932 | CODE: |
810 | RETVAL = (U32)THIS->parent [0]; |
933 | RETVAL = (U32)THIS->parent [0]; |
811 | OUTPUT: |
934 | OUTPUT: |
… | |
… | |
862 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
985 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
863 | |
986 | |
864 | for (int col = 0; col < THIS->ncol; col++) |
987 | for (int col = 0; col < THIS->ncol; col++) |
865 | wstr [col] = l.t [col]; |
988 | wstr [col] = l.t [col]; |
866 | |
989 | |
867 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
990 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); |
868 | |
991 | |
869 | delete [] wstr; |
992 | delete [] wstr; |
870 | } |
993 | } |
871 | |
994 | |
872 | if (new_text) |
995 | if (new_text) |
… | |
… | |
993 | else |
1116 | else |
994 | *r++ = *s; |
1117 | *r++ = *s; |
995 | |
1118 | |
996 | rxvt_pop_locale (); |
1119 | rxvt_pop_locale (); |
997 | |
1120 | |
998 | RETVAL = wcs2sv (rstr, r - rstr); |
1121 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); |
999 | |
1122 | |
1000 | delete [] rstr; |
1123 | delete [] rstr; |
1001 | } |
1124 | } |
1002 | OUTPUT: |
1125 | OUTPUT: |
1003 | RETVAL |
1126 | RETVAL |
… | |
… | |
1029 | else if (IS_COMPOSE (*s)) |
1152 | else if (IS_COMPOSE (*s)) |
1030 | r += rxvt_composite.expand (*s, r); |
1153 | r += rxvt_composite.expand (*s, r); |
1031 | else |
1154 | else |
1032 | *r++ = *s; |
1155 | *r++ = *s; |
1033 | |
1156 | |
1034 | RETVAL = wcs2sv (rstr, r - rstr); |
1157 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); |
1035 | |
1158 | |
1036 | delete [] rstr; |
1159 | delete [] rstr; |
1037 | } |
1160 | } |
1038 | OUTPUT: |
1161 | OUTPUT: |
1039 | RETVAL |
1162 | RETVAL |
… | |
… | |
1061 | |
1184 | |
1062 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1185 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1063 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1186 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1064 | |
1187 | |
1065 | if (GIMME_V != G_VOID) |
1188 | if (GIMME_V != G_VOID) |
1066 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
1189 | XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); |
1067 | |
1190 | |
1068 | if (newval) |
1191 | if (newval) |
1069 | { |
1192 | { |
1070 | if (SvOK (newval)) |
1193 | if (SvOK (newval)) |
1071 | { |
1194 | { |
… | |
… | |
1076 | else |
1199 | else |
1077 | THIS->rs [index] = 0; |
1200 | THIS->rs [index] = 0; |
1078 | } |
1201 | } |
1079 | } |
1202 | } |
1080 | |
1203 | |
|
|
1204 | bool |
|
|
1205 | rxvt_term::option (U32 optval, int set = -1) |
|
|
1206 | CODE: |
|
|
1207 | { |
|
|
1208 | RETVAL = THIS->options & optval; |
|
|
1209 | |
|
|
1210 | if (set >= 0) |
|
|
1211 | { |
|
|
1212 | if (set) |
|
|
1213 | THIS->options |= optval; |
|
|
1214 | else |
|
|
1215 | THIS->options &= ~optval; |
|
|
1216 | |
|
|
1217 | switch (optval) |
|
|
1218 | { |
|
|
1219 | case Opt_skipBuiltinGlyphs: |
|
|
1220 | THIS->set_fonts (); |
|
|
1221 | THIS->scr_remap_chars (); |
|
|
1222 | THIS->scr_touch (true); |
|
|
1223 | THIS->want_refresh = 1; |
|
|
1224 | break; |
|
|
1225 | |
|
|
1226 | case Opt_cursorUnderline: |
|
|
1227 | THIS->want_refresh = 1; |
|
|
1228 | break; |
|
|
1229 | |
|
|
1230 | # case Opt_scrollBar_floating: |
|
|
1231 | # case Opt_scrollBar_right: |
|
|
1232 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
|
|
1233 | # break; |
|
|
1234 | } |
|
|
1235 | } |
|
|
1236 | } |
|
|
1237 | OUTPUT: |
|
|
1238 | RETVAL |
|
|
1239 | |
1081 | void |
1240 | void |
1082 | rxvt_term::cur (...) |
1241 | rxvt_term::cur (...) |
1083 | PROTOTYPE: $;$$ |
1242 | PROTOTYPE: $;$$ |
1084 | ALIAS: |
1243 | ALIAS: |
1085 | screen_cur = 0 |
1244 | screen_cur = 0 |
… | |
… | |
1109 | THIS->want_refresh = 1; |
1268 | THIS->want_refresh = 1; |
1110 | } |
1269 | } |
1111 | } |
1270 | } |
1112 | |
1271 | |
1113 | int |
1272 | int |
1114 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
1273 | rxvt_term::selection_grab (U32 eventtime) |
1115 | |
1274 | |
1116 | void |
1275 | void |
1117 | rxvt_term::selection (SV *newtext = 0) |
1276 | rxvt_term::selection (SV *newtext = 0) |
1118 | PPCODE: |
1277 | PPCODE: |
1119 | { |
1278 | { |
1120 | if (GIMME_V != G_VOID) |
1279 | if (GIMME_V != G_VOID) |
|
|
1280 | XPUSHs (THIS->selection.text |
1121 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
1281 | ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) |
|
|
1282 | : &PL_sv_undef); |
1122 | |
1283 | |
1123 | if (newtext) |
1284 | if (newtext) |
1124 | { |
1285 | { |
1125 | free (THIS->selection.text); |
1286 | free (THIS->selection.text); |
1126 | |
1287 | |