… | |
… | |
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 | |
… | |
… | |
410 | void |
411 | void |
411 | rxvt_perl_interp::init () |
412 | rxvt_perl_interp::init () |
412 | { |
413 | { |
413 | if (!perl) |
414 | if (!perl) |
414 | { |
415 | { |
|
|
416 | temp_environ temp_environ(rxvt_environ); |
|
|
417 | |
415 | char *argv[] = { |
418 | char *argv[] = { |
416 | "", |
419 | "", |
417 | "-T", |
420 | "-T", |
418 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
421 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
419 | }; |
422 | }; |
… | |
… | |
459 | return false; // perl not initialized for this instance |
462 | return false; // perl not initialized for this instance |
460 | else if (htype == HOOK_DESTROY) |
463 | else if (htype == HOOK_DESTROY) |
461 | { |
464 | { |
462 | // handled later |
465 | // handled later |
463 | } |
466 | } |
464 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
467 | else |
465 | { |
468 | { |
466 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
469 | if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
467 | |
|
|
468 | if (HvKEYS (hv)) |
|
|
469 | { |
470 | { |
|
|
471 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
472 | |
|
|
473 | if (HvKEYS (hv)) |
|
|
474 | { |
470 | hv_iterinit (hv); |
475 | hv_iterinit (hv); |
471 | |
476 | |
472 | while (HE *he = hv_iternext (hv)) |
477 | while (HE *he = hv_iternext (hv)) |
473 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
478 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
479 | } |
|
|
480 | |
474 | } |
481 | } |
|
|
482 | |
|
|
483 | if (!should_invoke [htype]) |
|
|
484 | return false; |
475 | } |
485 | } |
476 | else if (!should_invoke [htype]) |
486 | |
477 | return false; |
487 | temp_environ temp_environ(rxvt_environ); |
478 | |
488 | |
479 | dSP; |
489 | dSP; |
480 | va_list ap; |
490 | va_list ap; |
481 | |
491 | |
482 | va_start (ap, htype); |
492 | va_start (ap, htype); |
… | |
… | |
621 | |
631 | |
622 | PROTOTYPES: ENABLE |
632 | PROTOTYPES: ENABLE |
623 | |
633 | |
624 | BOOT: |
634 | BOOT: |
625 | { |
635 | { |
626 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
636 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
637 | sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1)); |
|
|
638 | sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1)); |
|
|
639 | sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1)); |
627 | |
640 | |
628 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
641 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
629 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
642 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
630 | # include "hookinc.h" |
643 | # include "hookinc.h" |
631 | # undef def |
644 | # undef def |
… | |
… | |
660 | export_const_iv (Button2Mask); |
673 | export_const_iv (Button2Mask); |
661 | export_const_iv (Button3Mask); |
674 | export_const_iv (Button3Mask); |
662 | export_const_iv (Button4Mask); |
675 | export_const_iv (Button4Mask); |
663 | export_const_iv (Button5Mask); |
676 | export_const_iv (Button5Mask); |
664 | export_const_iv (AnyModifier); |
677 | export_const_iv (AnyModifier); |
665 | } |
|
|
666 | |
678 | |
667 | SV * |
679 | export_const_iv (EVENT_NONE); |
668 | new (...) |
680 | export_const_iv (EVENT_READ); |
669 | CODE: |
681 | export_const_iv (EVENT_WRITE); |
670 | { |
|
|
671 | stringvec *argv = new stringvec; |
|
|
672 | bool success; |
|
|
673 | |
|
|
674 | for (int i = 0; i < items ;i++) |
|
|
675 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
676 | |
|
|
677 | rxvt_term *term = new rxvt_term; |
|
|
678 | |
|
|
679 | term->argv = argv; |
|
|
680 | |
|
|
681 | try |
|
|
682 | { |
|
|
683 | if (!term->init (argv->size (), argv->begin ())) |
|
|
684 | term = 0; |
|
|
685 | } |
|
|
686 | catch (const class rxvt_failure_exception &e) |
|
|
687 | { |
|
|
688 | term->destroy (); |
|
|
689 | croak ("exception caught while initializing new terminal instance"); |
|
|
690 | } |
|
|
691 | |
|
|
692 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
|
|
693 | } |
682 | } |
694 | OUTPUT: |
|
|
695 | RETVAL |
|
|
696 | |
683 | |
697 | void |
684 | void |
698 | set_should_invoke (int htype, int value) |
685 | set_should_invoke (int htype, int value) |
699 | CODE: |
686 | CODE: |
700 | rxvt_perl.should_invoke [htype] = value; |
687 | rxvt_perl.should_invoke [htype] = value; |
… | |
… | |
778 | } |
765 | } |
779 | OUTPUT: |
766 | OUTPUT: |
780 | RETVAL |
767 | RETVAL |
781 | |
768 | |
782 | MODULE = urxvt PACKAGE = urxvt::term |
769 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
770 | |
|
|
771 | SV * |
|
|
772 | _new (...) |
|
|
773 | CODE: |
|
|
774 | { |
|
|
775 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
776 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
777 | |
|
|
778 | rxvt_term *term = new rxvt_term; |
|
|
779 | |
|
|
780 | term->argv = new stringvec; |
|
|
781 | term->envv = new stringvec; |
|
|
782 | |
|
|
783 | for (int i = 1; i < items; i++) |
|
|
784 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
785 | |
|
|
786 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
787 | for (int i = av_len (envv) + 1; i--; ) |
|
|
788 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
|
|
789 | |
|
|
790 | term->envv->push_back (0); |
|
|
791 | |
|
|
792 | bool success; |
|
|
793 | |
|
|
794 | try |
|
|
795 | { |
|
|
796 | success = term->init (term->argv->size (), term->argv->begin ()); |
|
|
797 | } |
|
|
798 | catch (const class rxvt_failure_exception &e) |
|
|
799 | { |
|
|
800 | success = false; |
|
|
801 | } |
|
|
802 | |
|
|
803 | if (!success) |
|
|
804 | { |
|
|
805 | term->destroy (); |
|
|
806 | croak ("error while initializing new terminal instance"); |
|
|
807 | } |
|
|
808 | |
|
|
809 | RETVAL = term && term->perl.self |
|
|
810 | ? newSVterm (term) : &PL_sv_undef; |
|
|
811 | } |
|
|
812 | OUTPUT: |
|
|
813 | RETVAL |
783 | |
814 | |
784 | void |
815 | void |
785 | rxvt_term::destroy () |
816 | rxvt_term::destroy () |
786 | |
817 | |
787 | void |
818 | void |
… | |
… | |
934 | OUTPUT: |
965 | OUTPUT: |
935 | RETVAL |
966 | RETVAL |
936 | |
967 | |
937 | char * |
968 | char * |
938 | rxvt_term::display_id () |
969 | rxvt_term::display_id () |
|
|
970 | ALIAS: |
|
|
971 | display_id = 0 |
|
|
972 | locale = 1 |
939 | CODE: |
973 | CODE: |
|
|
974 | switch (ix) |
|
|
975 | { |
940 | RETVAL = THIS->display->id; |
976 | case 0: RETVAL = THIS->display->id; break; |
|
|
977 | case 1: RETVAL = THIS->locale; break; |
|
|
978 | } |
941 | OUTPUT: |
979 | OUTPUT: |
|
|
980 | RETVAL |
|
|
981 | |
|
|
982 | SV * |
|
|
983 | rxvt_term::_env () |
|
|
984 | CODE: |
|
|
985 | { |
|
|
986 | if (THIS->envv) |
|
|
987 | { |
|
|
988 | AV *av = newAV (); |
|
|
989 | |
|
|
990 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
|
|
991 | if (*i) |
|
|
992 | av_push (av, newSVpv (*i, 0)); |
|
|
993 | |
|
|
994 | RETVAL = newRV_noinc ((SV *)av); |
|
|
995 | } |
|
|
996 | else |
|
|
997 | RETVAL = &PL_sv_undef; |
|
|
998 | } |
|
|
999 | OUTPUT: |
|
|
1000 | RETVAL |
|
|
1001 | |
|
|
1002 | int |
|
|
1003 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
|
|
1004 | CODE: |
|
|
1005 | RETVAL = THIS->pty_ev.events; |
|
|
1006 | if (events != EVENT_UNDEF) |
|
|
1007 | THIS->pty_ev.set (events); |
|
|
1008 | OUTPUT: |
942 | RETVAL |
1009 | RETVAL |
943 | |
1010 | |
944 | U32 |
1011 | U32 |
945 | rxvt_term::parent () |
1012 | rxvt_term::parent () |
946 | CODE: |
1013 | CODE: |
… | |
… | |
1213 | else |
1280 | else |
1214 | THIS->rs [index] = 0; |
1281 | THIS->rs [index] = 0; |
1215 | } |
1282 | } |
1216 | } |
1283 | } |
1217 | |
1284 | |
|
|
1285 | const char * |
|
|
1286 | rxvt_term::x_resource (const char *name) |
|
|
1287 | CLEANUP: |
|
|
1288 | SvTAINTED_on (ST (0)); |
|
|
1289 | |
1218 | bool |
1290 | bool |
1219 | rxvt_term::option (U32 optval, int set = -1) |
1291 | rxvt_term::option (U32 optval, int set = -1) |
1220 | CODE: |
1292 | CODE: |
1221 | { |
1293 | { |
1222 | RETVAL = THIS->options & optval; |
1294 | RETVAL = THIS->options & optval; |
… | |
… | |
1249 | } |
1321 | } |
1250 | } |
1322 | } |
1251 | OUTPUT: |
1323 | OUTPUT: |
1252 | RETVAL |
1324 | RETVAL |
1253 | |
1325 | |
|
|
1326 | bool |
|
|
1327 | rxvt_term::parse_keysym (char *keysym, char *str) |
|
|
1328 | CODE: |
|
|
1329 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
|
|
1330 | THIS->keyboard->register_done (); |
|
|
1331 | OUTPUT: |
|
|
1332 | RETVAL |
|
|
1333 | |
1254 | void |
1334 | void |
1255 | rxvt_term::screen_cur (...) |
1335 | rxvt_term::screen_cur (...) |
1256 | PROTOTYPE: $;$$ |
1336 | PROTOTYPE: $;$$ |
1257 | ALIAS: |
1337 | ALIAS: |
1258 | screen_cur = 0 |
1338 | screen_cur = 0 |
… | |
… | |
1281 | if (ix) |
1361 | if (ix) |
1282 | THIS->want_refresh = 1; |
1362 | THIS->want_refresh = 1; |
1283 | } |
1363 | } |
1284 | } |
1364 | } |
1285 | |
1365 | |
|
|
1366 | char |
|
|
1367 | rxvt_term::cur_charset () |
|
|
1368 | CODE: |
|
|
1369 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1370 | OUTPUT: |
|
|
1371 | RETVAL |
|
|
1372 | |
1286 | int |
1373 | int |
1287 | rxvt_term::selection_grab (U32 eventtime) |
1374 | rxvt_term::selection_grab (U32 eventtime) |
1288 | |
1375 | |
1289 | void |
1376 | void |
1290 | rxvt_term::selection (SV *newtext = 0) |
1377 | rxvt_term::selection (SV *newtext = 0) |
… | |
… | |
1301 | |
1388 | |
1302 | THIS->selection.text = sv2wcs (newtext); |
1389 | THIS->selection.text = sv2wcs (newtext); |
1303 | THIS->selection.len = wcslen (THIS->selection.text); |
1390 | THIS->selection.len = wcslen (THIS->selection.text); |
1304 | } |
1391 | } |
1305 | } |
1392 | } |
|
|
1393 | |
|
|
1394 | void |
|
|
1395 | 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) |
|
|
1396 | |
|
|
1397 | void |
|
|
1398 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
|
|
1399 | |
|
|
1400 | void |
|
|
1401 | rxvt_term::scr_bell () |
1306 | |
1402 | |
1307 | void |
1403 | void |
1308 | rxvt_term::scr_add_lines (SV *string) |
1404 | rxvt_term::scr_add_lines (SV *string) |
1309 | CODE: |
1405 | CODE: |
1310 | { |
1406 | { |