… | |
… | |
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 | |
… | |
… | |
428 | |
429 | |
429 | perl_destruct (perl); |
430 | perl_destruct (perl); |
430 | perl_free (perl); |
431 | perl_free (perl); |
431 | perl = 0; |
432 | perl = 0; |
432 | } |
433 | } |
|
|
434 | } |
|
|
435 | } |
|
|
436 | |
|
|
437 | static void |
|
|
438 | ungrab (rxvt_term *THIS) |
|
|
439 | { |
|
|
440 | if (THIS->perl.grabtime) |
|
|
441 | { |
|
|
442 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
|
|
443 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
|
|
444 | THIS->perl.grabtime = 0; |
433 | } |
445 | } |
434 | } |
446 | } |
435 | |
447 | |
436 | bool |
448 | bool |
437 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
449 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
… | |
… | |
448 | return false; // perl not initialized for this instance |
460 | return false; // perl not initialized for this instance |
449 | else if (htype == HOOK_DESTROY) |
461 | else if (htype == HOOK_DESTROY) |
450 | { |
462 | { |
451 | // handled later |
463 | // handled later |
452 | } |
464 | } |
453 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
465 | else |
454 | { |
466 | { |
455 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
467 | if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
456 | |
|
|
457 | if (HvKEYS (hv)) |
|
|
458 | { |
468 | { |
|
|
469 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
470 | |
|
|
471 | if (HvKEYS (hv)) |
|
|
472 | { |
459 | hv_iterinit (hv); |
473 | hv_iterinit (hv); |
460 | |
474 | |
461 | while (HE *he = hv_iternext (hv)) |
475 | while (HE *he = hv_iternext (hv)) |
462 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
476 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
477 | } |
|
|
478 | |
463 | } |
479 | } |
|
|
480 | |
|
|
481 | if (!should_invoke [htype]) |
|
|
482 | return false; |
464 | } |
483 | } |
465 | else if (!should_invoke [htype]) |
|
|
466 | return false; |
|
|
467 | |
484 | |
468 | dSP; |
485 | dSP; |
469 | va_list ap; |
486 | va_list ap; |
470 | |
487 | |
471 | va_start (ap, htype); |
488 | va_start (ap, htype); |
… | |
… | |
582 | PUTBACK; |
599 | PUTBACK; |
583 | FREETMPS; |
600 | FREETMPS; |
584 | LEAVE; |
601 | LEAVE; |
585 | |
602 | |
586 | if (SvTRUE (ERRSV)) |
603 | if (SvTRUE (ERRSV)) |
|
|
604 | { |
587 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
605 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
606 | ungrab (term); // better lose the grab than the session |
|
|
607 | } |
588 | |
608 | |
589 | if (htype == HOOK_DESTROY) |
609 | if (htype == HOOK_DESTROY) |
590 | { |
610 | { |
591 | clearSVptr ((SV *)term->perl.self); |
611 | clearSVptr ((SV *)term->perl.self); |
592 | SvREFCNT_dec ((SV *)term->perl.self); |
612 | SvREFCNT_dec ((SV *)term->perl.self); |
… | |
… | |
607 | |
627 | |
608 | PROTOTYPES: ENABLE |
628 | PROTOTYPES: ENABLE |
609 | |
629 | |
610 | BOOT: |
630 | BOOT: |
611 | { |
631 | { |
612 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
632 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
633 | sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1)); |
|
|
634 | sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1)); |
|
|
635 | sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1)); |
613 | |
636 | |
614 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
637 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
615 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
638 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
616 | # include "hookinc.h" |
639 | # include "hookinc.h" |
617 | # undef def |
640 | # undef def |
… | |
… | |
646 | export_const_iv (Button2Mask); |
669 | export_const_iv (Button2Mask); |
647 | export_const_iv (Button3Mask); |
670 | export_const_iv (Button3Mask); |
648 | export_const_iv (Button4Mask); |
671 | export_const_iv (Button4Mask); |
649 | export_const_iv (Button5Mask); |
672 | export_const_iv (Button5Mask); |
650 | export_const_iv (AnyModifier); |
673 | export_const_iv (AnyModifier); |
|
|
674 | |
|
|
675 | export_const_iv (EVENT_NONE); |
|
|
676 | export_const_iv (EVENT_READ); |
|
|
677 | export_const_iv (EVENT_WRITE); |
651 | } |
678 | } |
652 | |
679 | |
653 | SV * |
680 | SV * |
654 | new (...) |
681 | new (...) |
655 | CODE: |
682 | CODE: |
… | |
… | |
692 | |
719 | |
693 | void |
720 | void |
694 | fatal (const char *msg) |
721 | fatal (const char *msg) |
695 | CODE: |
722 | CODE: |
696 | rxvt_fatal ("%s", msg); |
723 | rxvt_fatal ("%s", msg); |
|
|
724 | |
|
|
725 | SV * |
|
|
726 | untaint (SV *sv) |
|
|
727 | CODE: |
|
|
728 | RETVAL = newSVsv (sv); |
|
|
729 | SvTAINTED_off (RETVAL); |
|
|
730 | OUTPUT: |
|
|
731 | RETVAL |
|
|
732 | |
|
|
733 | bool |
|
|
734 | safe () |
|
|
735 | CODE: |
|
|
736 | RETVAL = !rxvt_tainted (); |
|
|
737 | OUTPUT: |
|
|
738 | RETVAL |
697 | |
739 | |
698 | NV |
740 | NV |
699 | NOW () |
741 | NOW () |
700 | CODE: |
742 | CODE: |
701 | RETVAL = NOW; |
743 | RETVAL = NOW; |
… | |
… | |
782 | } |
824 | } |
783 | OUTPUT: |
825 | OUTPUT: |
784 | RETVAL |
826 | RETVAL |
785 | |
827 | |
786 | void |
828 | void |
787 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
829 | rxvt_term::allow_events_async () |
788 | CODE: |
830 | CODE: |
789 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
831 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
790 | |
832 | |
791 | void |
833 | void |
792 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
834 | rxvt_term::allow_events_sync () |
793 | CODE: |
835 | CODE: |
794 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
836 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
795 | |
837 | |
796 | void |
838 | void |
797 | rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) |
839 | rxvt_term::allow_events_replay () |
798 | CODE: |
840 | CODE: |
799 | XAllowEvents (THIS->display->display, ReplayPointer, eventtime); |
841 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
800 | XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); |
842 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
801 | |
843 | |
802 | void |
844 | void |
803 | rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) |
845 | rxvt_term::ungrab () |
804 | CODE: |
846 | CODE: |
805 | THIS->perl.grabtime = 0; |
847 | ungrab (THIS); |
806 | XUngrabKeyboard (THIS->display->display, eventtime); |
|
|
807 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
808 | |
848 | |
809 | int |
849 | int |
810 | rxvt_term::strwidth (SV *str) |
850 | rxvt_term::strwidth (SV *str) |
811 | CODE: |
851 | CODE: |
812 | { |
852 | { |
… | |
… | |
905 | case 2: RETVAL = THIS->ModNumLockMask; break; |
945 | case 2: RETVAL = THIS->ModNumLockMask; break; |
906 | } |
946 | } |
907 | OUTPUT: |
947 | OUTPUT: |
908 | RETVAL |
948 | RETVAL |
909 | |
949 | |
|
|
950 | char * |
|
|
951 | rxvt_term::display_id () |
|
|
952 | ALIAS: |
|
|
953 | display_id = 0 |
|
|
954 | locale = 1 |
|
|
955 | CODE: |
|
|
956 | switch (ix) |
|
|
957 | { |
|
|
958 | case 0: RETVAL = THIS->display->id; break; |
|
|
959 | case 1: RETVAL = THIS->locale; break; |
|
|
960 | } |
|
|
961 | OUTPUT: |
|
|
962 | RETVAL |
|
|
963 | |
|
|
964 | int |
|
|
965 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
|
|
966 | CODE: |
|
|
967 | RETVAL = THIS->pty_ev.events; |
|
|
968 | if (events != EVENT_UNDEF) |
|
|
969 | THIS->pty_ev.set (events); |
|
|
970 | OUTPUT: |
|
|
971 | RETVAL |
|
|
972 | |
910 | U32 |
973 | U32 |
911 | rxvt_term::parent () |
974 | rxvt_term::parent () |
912 | CODE: |
975 | CODE: |
913 | RETVAL = (U32)THIS->parent [0]; |
976 | RETVAL = (U32)THIS->parent [0]; |
914 | OUTPUT: |
977 | OUTPUT: |
… | |
… | |
1215 | } |
1278 | } |
1216 | } |
1279 | } |
1217 | OUTPUT: |
1280 | OUTPUT: |
1218 | RETVAL |
1281 | RETVAL |
1219 | |
1282 | |
|
|
1283 | bool |
|
|
1284 | rxvt_term::parse_keysym (char *keysym, char *str) |
|
|
1285 | CODE: |
|
|
1286 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
|
|
1287 | THIS->keyboard->register_done (); |
|
|
1288 | OUTPUT: |
|
|
1289 | RETVAL |
|
|
1290 | |
1220 | void |
1291 | void |
1221 | rxvt_term::cur (...) |
1292 | rxvt_term::screen_cur (...) |
1222 | PROTOTYPE: $;$$ |
1293 | PROTOTYPE: $;$$ |
1223 | ALIAS: |
1294 | ALIAS: |
1224 | screen_cur = 0 |
1295 | screen_cur = 0 |
1225 | selection_beg = 1 |
1296 | selection_beg = 1 |
1226 | selection_end = 2 |
1297 | selection_end = 2 |
… | |
… | |
1247 | if (ix) |
1318 | if (ix) |
1248 | THIS->want_refresh = 1; |
1319 | THIS->want_refresh = 1; |
1249 | } |
1320 | } |
1250 | } |
1321 | } |
1251 | |
1322 | |
|
|
1323 | char |
|
|
1324 | rxvt_term::cur_charset () |
|
|
1325 | CODE: |
|
|
1326 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1327 | OUTPUT: |
|
|
1328 | RETVAL |
|
|
1329 | |
1252 | int |
1330 | int |
1253 | rxvt_term::selection_grab (U32 eventtime) |
1331 | rxvt_term::selection_grab (U32 eventtime) |
1254 | |
1332 | |
1255 | void |
1333 | void |
1256 | rxvt_term::selection (SV *newtext = 0) |
1334 | rxvt_term::selection (SV *newtext = 0) |
1257 | PPCODE: |
1335 | PPCODE: |
1258 | { |
1336 | { |
1259 | if (GIMME_V != G_VOID) |
1337 | if (GIMME_V != G_VOID) |
|
|
1338 | XPUSHs (THIS->selection.text |
1260 | XPUSHs (taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))); |
1339 | ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) |
|
|
1340 | : &PL_sv_undef); |
1261 | |
1341 | |
1262 | if (newtext) |
1342 | if (newtext) |
1263 | { |
1343 | { |
1264 | free (THIS->selection.text); |
1344 | free (THIS->selection.text); |
1265 | |
1345 | |
1266 | THIS->selection.text = sv2wcs (newtext); |
1346 | THIS->selection.text = sv2wcs (newtext); |
1267 | THIS->selection.len = wcslen (THIS->selection.text); |
1347 | THIS->selection.len = wcslen (THIS->selection.text); |
1268 | } |
1348 | } |
1269 | } |
1349 | } |
|
|
1350 | |
|
|
1351 | void |
|
|
1352 | 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) |
|
|
1353 | |
|
|
1354 | void |
|
|
1355 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
|
|
1356 | |
|
|
1357 | void |
|
|
1358 | rxvt_term::scr_bell () |
1270 | |
1359 | |
1271 | void |
1360 | void |
1272 | rxvt_term::scr_add_lines (SV *string) |
1361 | rxvt_term::scr_add_lines (SV *string) |
1273 | CODE: |
1362 | CODE: |
1274 | { |
1363 | { |