… | |
… | |
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 "unistd.h" |
|
|
35 | |
34 | #include "iom.h" |
36 | #include "iom.h" |
35 | #include "rxvt.h" |
37 | #include "rxvt.h" |
36 | #include "keyboard.h" |
38 | #include "keyboard.h" |
37 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
38 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
39 | |
41 | |
40 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
41 | |
43 | |
42 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
44 | #ifdef HAVE_SCROLLBARS |
43 | # define GRAB_CURSOR THIS->leftptr_cursor |
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
44 | #else |
46 | #else |
45 | # define GRAB_CURSOR None |
47 | # define GRAB_CURSOR None |
46 | #endif |
48 | #endif |
47 | |
49 | |
48 | #undef LINENO |
50 | #undef LINENO |
49 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
50 | #undef ROW |
52 | #undef ROW |
51 | #define ROW(n) THIS->row_buf [LINENO (n)] |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
54 | |
|
|
55 | #define ENABLE_PERL_FRILLS 1 |
52 | |
56 | |
53 | ///////////////////////////////////////////////////////////////////////////// |
57 | ///////////////////////////////////////////////////////////////////////////// |
54 | |
58 | |
55 | static SV * |
59 | static SV * |
56 | taint (SV *sv) |
60 | taint (SV *sv) |
… | |
… | |
345 | for (int y = ov_h; y--; ) |
349 | for (int y = ov_h; y--; ) |
346 | { |
350 | { |
347 | text_t *t1 = text [y]; |
351 | text_t *t1 = text [y]; |
348 | rend_t *r1 = rend [y]; |
352 | rend_t *r1 = rend [y]; |
349 | |
353 | |
350 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
354 | text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x; |
351 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
355 | rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x; |
352 | |
356 | |
353 | for (int x = ov_w; x--; ) |
357 | for (int x = ov_w; x--; ) |
354 | { |
358 | { |
355 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
359 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
356 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
360 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
… | |
… | |
403 | perl_free (perl); |
407 | perl_free (perl); |
404 | } |
408 | } |
405 | } |
409 | } |
406 | |
410 | |
407 | void |
411 | void |
408 | rxvt_perl_interp::init () |
412 | rxvt_perl_interp::init (rxvt_term *term) |
409 | { |
413 | { |
410 | if (!perl) |
414 | if (!perl) |
411 | { |
415 | { |
|
|
416 | rxvt_push_locale (""); // perl init destroys current locale |
|
|
417 | |
412 | perl_environ = rxvt_environ; |
418 | perl_environ = rxvt_environ; |
413 | swap (perl_environ, environ); |
419 | swap (perl_environ, environ); |
414 | |
420 | |
415 | char *argv[] = { |
421 | char *argv[] = { |
416 | "", |
422 | "", |
… | |
… | |
430 | perl_free (perl); |
436 | perl_free (perl); |
431 | perl = 0; |
437 | perl = 0; |
432 | } |
438 | } |
433 | |
439 | |
434 | swap (perl_environ, environ); |
440 | swap (perl_environ, environ); |
|
|
441 | |
|
|
442 | rxvt_pop_locale (); |
|
|
443 | } |
|
|
444 | |
|
|
445 | if (perl) |
|
|
446 | { |
|
|
447 | // runs outside of perls ENV |
|
|
448 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
449 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
435 | } |
450 | } |
436 | } |
451 | } |
437 | |
452 | |
438 | static void |
453 | static void |
439 | ungrab (rxvt_term *THIS) |
454 | ungrab (rxvt_term *THIS) |
… | |
… | |
444 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
459 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
445 | THIS->perl.grabtime = 0; |
460 | THIS->perl.grabtime = 0; |
446 | } |
461 | } |
447 | } |
462 | } |
448 | |
463 | |
|
|
464 | static void |
|
|
465 | swap_overlays (rxvt_term *term) |
|
|
466 | { |
|
|
467 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
468 | |
|
|
469 | if (HvKEYS (hv)) |
|
|
470 | { |
|
|
471 | hv_iterinit (hv); |
|
|
472 | |
|
|
473 | while (HE *he = hv_iternext (hv)) |
|
|
474 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
475 | } |
|
|
476 | } |
|
|
477 | |
449 | bool |
478 | bool |
450 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
479 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
451 | { |
480 | { |
452 | if (!perl) |
481 | if (!perl || !term->perl.self) |
453 | return false; |
482 | return false; |
454 | |
483 | |
455 | if (htype == HOOK_INIT) // first hook ever called |
484 | // pre-handling of some events |
456 | { |
485 | if (htype == HOOK_REFRESH_END) |
457 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
486 | swap_overlays (term); |
458 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
487 | |
459 | } |
488 | swap (perl_environ, environ); |
460 | else if (!term->perl.self) |
489 | |
461 | return false; // perl not initialized for this instance |
490 | bool event_consumed; |
462 | else if (htype == HOOK_DESTROY) |
491 | |
463 | { |
492 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
464 | // handled later |
493 | || term->perl.should_invoke [htype]) |
465 | } |
494 | try |
466 | else |
|
|
467 | { |
|
|
468 | if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
469 | { |
495 | { |
470 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
496 | dSP; |
|
|
497 | va_list ap; |
471 | |
498 | |
472 | if (HvKEYS (hv)) |
499 | va_start (ap, htype); |
|
|
500 | |
|
|
501 | ENTER; |
|
|
502 | SAVETMPS; |
|
|
503 | |
|
|
504 | PUSHMARK (SP); |
|
|
505 | |
|
|
506 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
507 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
508 | |
|
|
509 | for (;;) { |
|
|
510 | data_type dt = (data_type)va_arg (ap, int); |
|
|
511 | |
|
|
512 | switch (dt) |
473 | { |
513 | { |
474 | hv_iterinit (hv); |
|
|
475 | |
|
|
476 | while (HE *he = hv_iternext (hv)) |
|
|
477 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
478 | } |
|
|
479 | |
|
|
480 | } |
|
|
481 | |
|
|
482 | if (!should_invoke [htype]) |
|
|
483 | return false; |
|
|
484 | } |
|
|
485 | |
|
|
486 | swap (perl_environ, environ); |
|
|
487 | |
|
|
488 | try |
|
|
489 | { |
|
|
490 | dSP; |
|
|
491 | va_list ap; |
|
|
492 | |
|
|
493 | va_start (ap, htype); |
|
|
494 | |
|
|
495 | ENTER; |
|
|
496 | SAVETMPS; |
|
|
497 | |
|
|
498 | PUSHMARK (SP); |
|
|
499 | |
|
|
500 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
501 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
502 | |
|
|
503 | for (;;) { |
|
|
504 | data_type dt = (data_type)va_arg (ap, int); |
|
|
505 | |
|
|
506 | switch (dt) |
|
|
507 | { |
|
|
508 | case DT_INT: |
514 | case DT_INT: |
509 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
515 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
510 | break; |
516 | break; |
511 | |
517 | |
512 | case DT_LONG: |
518 | case DT_LONG: |
513 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
519 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
514 | break; |
520 | break; |
515 | |
521 | |
516 | case DT_STR: |
522 | case DT_STR: |
517 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
523 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
518 | break; |
524 | break; |
519 | |
525 | |
520 | case DT_STR_LEN: |
526 | case DT_STR_LEN: |
521 | { |
527 | { |
522 | char *str = va_arg (ap, char *); |
528 | char *str = va_arg (ap, char *); |
523 | int len = va_arg (ap, int); |
529 | int len = va_arg (ap, int); |
524 | |
530 | |
525 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
531 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
526 | } |
532 | } |
527 | break; |
533 | break; |
528 | |
534 | |
529 | case DT_WCS_LEN: |
535 | case DT_WCS_LEN: |
530 | { |
536 | { |
531 | wchar_t *wstr = va_arg (ap, wchar_t *); |
537 | wchar_t *wstr = va_arg (ap, wchar_t *); |
532 | int wlen = va_arg (ap, int); |
538 | int wlen = va_arg (ap, int); |
533 | |
539 | |
534 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
540 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
535 | } |
541 | } |
536 | break; |
542 | break; |
537 | |
543 | |
538 | case DT_XEVENT: |
544 | case DT_XEVENT: |
539 | { |
545 | { |
540 | XEvent *xe = va_arg (ap, XEvent *); |
546 | XEvent *xe = va_arg (ap, XEvent *); |
541 | HV *hv = newHV (); |
547 | HV *hv = newHV (); |
542 | |
548 | |
543 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
549 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
544 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
550 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
545 | # undef set |
551 | # undef set |
546 | |
552 | |
547 | setiv (type, xe->type); |
553 | setiv (type, xe->type); |
548 | setiv (send_event, xe->xany.send_event); |
554 | setiv (send_event, xe->xany.send_event); |
549 | setiv (serial, xe->xany.serial); |
555 | setiv (serial, xe->xany.serial); |
550 | |
556 | |
551 | switch (xe->type) |
557 | switch (xe->type) |
552 | { |
558 | { |
553 | case KeyPress: |
559 | case KeyPress: |
554 | case KeyRelease: |
560 | case KeyRelease: |
555 | case ButtonPress: |
561 | case ButtonPress: |
556 | case ButtonRelease: |
562 | case ButtonRelease: |
557 | case MotionNotify: |
563 | case MotionNotify: |
558 | setiv (time, xe->xmotion.time); |
564 | setiv (time, xe->xmotion.time); |
559 | setiv (x, xe->xmotion.x); |
565 | setiv (x, xe->xmotion.x); |
560 | setiv (y, xe->xmotion.y); |
566 | setiv (y, xe->xmotion.y); |
561 | setiv (row, xe->xmotion.y / term->fheight); |
567 | setiv (row, xe->xmotion.y / term->fheight); |
562 | setiv (col, xe->xmotion.x / term->fwidth); |
568 | setiv (col, xe->xmotion.x / term->fwidth); |
563 | setiv (x_root, xe->xmotion.x_root); |
569 | setiv (x_root, xe->xmotion.x_root); |
564 | setiv (y_root, xe->xmotion.y_root); |
570 | setiv (y_root, xe->xmotion.y_root); |
565 | setiv (state, xe->xmotion.state); |
571 | setiv (state, xe->xmotion.state); |
566 | break; |
572 | break; |
567 | } |
573 | } |
568 | |
574 | |
569 | switch (xe->type) |
575 | switch (xe->type) |
570 | { |
576 | { |
571 | case KeyPress: |
577 | case KeyPress: |
572 | case KeyRelease: |
578 | case KeyRelease: |
573 | setiv (keycode, xe->xkey.keycode); |
579 | setiv (keycode, xe->xkey.keycode); |
574 | break; |
580 | break; |
575 | |
581 | |
576 | case ButtonPress: |
582 | case ButtonPress: |
577 | case ButtonRelease: |
583 | case ButtonRelease: |
578 | setiv (button, xe->xbutton.button); |
584 | setiv (button, xe->xbutton.button); |
579 | break; |
585 | break; |
580 | |
586 | |
581 | case MotionNotify: |
587 | case MotionNotify: |
582 | setiv (is_hint, xe->xmotion.is_hint); |
588 | setiv (is_hint, xe->xmotion.is_hint); |
583 | break; |
589 | break; |
584 | } |
590 | } |
585 | |
591 | |
586 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
592 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
587 | } |
593 | } |
588 | break; |
594 | break; |
589 | |
595 | |
590 | case DT_END: |
596 | case DT_END: |
591 | { |
597 | goto call; |
592 | va_end (ap); |
|
|
593 | |
598 | |
594 | PUTBACK; |
|
|
595 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
596 | SPAGAIN; |
|
|
597 | |
|
|
598 | if (count) |
|
|
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; |
|
|
622 | } |
|
|
623 | |
|
|
624 | default: |
599 | default: |
625 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
600 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
626 | } |
601 | } |
|
|
602 | } |
|
|
603 | |
|
|
604 | call: |
|
|
605 | va_end (ap); |
|
|
606 | |
|
|
607 | PUTBACK; |
|
|
608 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
609 | SPAGAIN; |
|
|
610 | |
|
|
611 | if (count) |
|
|
612 | { |
|
|
613 | SV *status = POPs; |
|
|
614 | count = SvTRUE (status); |
|
|
615 | } |
|
|
616 | |
|
|
617 | PUTBACK; |
|
|
618 | FREETMPS; |
|
|
619 | LEAVE; |
|
|
620 | |
|
|
621 | if (SvTRUE (ERRSV)) |
|
|
622 | { |
|
|
623 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
624 | ungrab (term); // better lose the grab than the session |
|
|
625 | } |
|
|
626 | |
|
|
627 | event_consumed = !!count; |
627 | } |
628 | } |
|
|
629 | catch (...) |
|
|
630 | { |
|
|
631 | swap (perl_environ, environ); |
|
|
632 | throw; |
|
|
633 | } |
|
|
634 | else |
|
|
635 | event_consumed = false; |
|
|
636 | |
|
|
637 | // post-handling of some events |
|
|
638 | if (htype == HOOK_REFRESH_BEGIN) |
|
|
639 | swap_overlays (term); |
|
|
640 | else if (htype == HOOK_DESTROY) |
|
|
641 | { |
|
|
642 | clearSVptr ((SV *)term->perl.self); |
|
|
643 | SvREFCNT_dec ((SV *)term->perl.self); |
628 | } |
644 | } |
629 | catch (...) |
645 | |
630 | { |
|
|
631 | swap (perl_environ, environ); |
646 | swap (perl_environ, environ); |
632 | throw; |
647 | |
633 | } |
648 | return event_consumed; |
634 | } |
649 | } |
635 | |
650 | |
636 | ///////////////////////////////////////////////////////////////////////////// |
651 | ///////////////////////////////////////////////////////////////////////////// |
637 | |
652 | |
638 | MODULE = urxvt PACKAGE = urxvt |
653 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
657 | # include "optinc.h" |
672 | # include "optinc.h" |
658 | # undef nodef |
673 | # undef nodef |
659 | # undef def |
674 | # undef def |
660 | |
675 | |
661 | HV *stash = gv_stashpv ("urxvt", 1); |
676 | HV *stash = gv_stashpv ("urxvt", 1); |
662 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
677 | struct { |
|
|
678 | const char *name; |
|
|
679 | IV iv; |
|
|
680 | } *civ, const_iv[] = { |
|
|
681 | # define const_iv(name) { # name, (IV)name } |
663 | export_const_iv (DEFAULT_RSTYLE); |
682 | const_iv (DEFAULT_RSTYLE), |
664 | export_const_iv (OVERLAY_RSTYLE); |
683 | const_iv (OVERLAY_RSTYLE), |
665 | export_const_iv (RS_Bold); |
684 | const_iv (RS_Bold), |
666 | export_const_iv (RS_Italic); |
685 | const_iv (RS_Italic), |
667 | export_const_iv (RS_Blink); |
686 | const_iv (RS_Blink), |
668 | export_const_iv (RS_RVid); |
687 | const_iv (RS_RVid), |
669 | export_const_iv (RS_Uline); |
688 | const_iv (RS_Uline), |
670 | |
689 | |
671 | export_const_iv (CurrentTime); |
690 | const_iv (CurrentTime), |
672 | export_const_iv (ShiftMask); |
691 | const_iv (ShiftMask), |
673 | export_const_iv (LockMask); |
692 | const_iv (LockMask), |
674 | export_const_iv (ControlMask); |
693 | const_iv (ControlMask), |
675 | export_const_iv (Mod1Mask); |
694 | const_iv (Mod1Mask), |
676 | export_const_iv (Mod2Mask); |
695 | const_iv (Mod2Mask), |
677 | export_const_iv (Mod3Mask); |
696 | const_iv (Mod3Mask), |
678 | export_const_iv (Mod4Mask); |
697 | const_iv (Mod4Mask), |
679 | export_const_iv (Mod5Mask); |
698 | const_iv (Mod5Mask), |
680 | export_const_iv (Button1Mask); |
699 | const_iv (Button1Mask), |
681 | export_const_iv (Button2Mask); |
700 | const_iv (Button2Mask), |
682 | export_const_iv (Button3Mask); |
701 | const_iv (Button3Mask), |
683 | export_const_iv (Button4Mask); |
702 | const_iv (Button4Mask), |
684 | export_const_iv (Button5Mask); |
703 | const_iv (Button5Mask), |
685 | export_const_iv (AnyModifier); |
704 | const_iv (AnyModifier), |
686 | |
705 | |
687 | export_const_iv (EVENT_NONE); |
706 | const_iv (EVENT_NONE), |
688 | export_const_iv (EVENT_READ); |
707 | const_iv (EVENT_READ), |
689 | export_const_iv (EVENT_WRITE); |
708 | const_iv (EVENT_WRITE), |
690 | } |
|
|
691 | |
709 | |
692 | void |
710 | const_iv (NoEventMask), |
693 | set_should_invoke (int htype, int value) |
711 | const_iv (KeyPressMask), |
694 | CODE: |
712 | const_iv (KeyReleaseMask), |
695 | rxvt_perl.should_invoke [htype] = value; |
713 | const_iv (ButtonPressMask), |
|
|
714 | const_iv (ButtonReleaseMask), |
|
|
715 | const_iv (EnterWindowMask), |
|
|
716 | const_iv (LeaveWindowMask), |
|
|
717 | const_iv (PointerMotionMask), |
|
|
718 | const_iv (PointerMotionHintMask), |
|
|
719 | const_iv (Button1MotionMask), |
|
|
720 | const_iv (Button2MotionMask), |
|
|
721 | const_iv (Button3MotionMask), |
|
|
722 | const_iv (Button4MotionMask), |
|
|
723 | const_iv (Button5MotionMask), |
|
|
724 | const_iv (ButtonMotionMask), |
|
|
725 | const_iv (KeymapStateMask), |
|
|
726 | const_iv (ExposureMask), |
|
|
727 | const_iv (VisibilityChangeMask), |
|
|
728 | const_iv (StructureNotifyMask), |
|
|
729 | const_iv (ResizeRedirectMask), |
|
|
730 | const_iv (SubstructureNotifyMask), |
|
|
731 | const_iv (SubstructureRedirectMask), |
|
|
732 | const_iv (FocusChangeMask), |
|
|
733 | const_iv (PropertyChangeMask), |
|
|
734 | const_iv (ColormapChangeMask), |
|
|
735 | const_iv (OwnerGrabButtonMask), |
|
|
736 | |
|
|
737 | const_iv (KeyPress), |
|
|
738 | const_iv (KeyRelease), |
|
|
739 | const_iv (ButtonPress), |
|
|
740 | const_iv (ButtonRelease), |
|
|
741 | const_iv (MotionNotify), |
|
|
742 | const_iv (EnterNotify), |
|
|
743 | const_iv (LeaveNotify), |
|
|
744 | const_iv (FocusIn), |
|
|
745 | const_iv (FocusOut), |
|
|
746 | const_iv (KeymapNotify), |
|
|
747 | const_iv (Expose), |
|
|
748 | const_iv (GraphicsExpose), |
|
|
749 | const_iv (NoExpose), |
|
|
750 | const_iv (VisibilityNotify), |
|
|
751 | const_iv (CreateNotify), |
|
|
752 | const_iv (DestroyNotify), |
|
|
753 | const_iv (UnmapNotify), |
|
|
754 | const_iv (MapNotify), |
|
|
755 | const_iv (MapRequest), |
|
|
756 | const_iv (ReparentNotify), |
|
|
757 | const_iv (ConfigureNotify), |
|
|
758 | const_iv (ConfigureRequest), |
|
|
759 | const_iv (GravityNotify), |
|
|
760 | const_iv (ResizeRequest), |
|
|
761 | const_iv (CirculateNotify), |
|
|
762 | const_iv (CirculateRequest), |
|
|
763 | const_iv (PropertyNotify), |
|
|
764 | const_iv (SelectionClear), |
|
|
765 | const_iv (SelectionRequest), |
|
|
766 | const_iv (SelectionNotify), |
|
|
767 | const_iv (ColormapNotify), |
|
|
768 | const_iv (ClientMessage), |
|
|
769 | const_iv (MappingNotify), |
|
|
770 | }; |
|
|
771 | |
|
|
772 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
|
|
773 | civ-- > const_iv; ) |
|
|
774 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
775 | } |
696 | |
776 | |
697 | void |
777 | void |
698 | warn (const char *msg) |
778 | warn (const char *msg) |
699 | CODE: |
779 | CODE: |
700 | rxvt_warn ("%s", msg); |
780 | rxvt_warn ("%s", msg); |
… | |
… | |
709 | CODE: |
789 | CODE: |
710 | RETVAL = newSVsv (sv); |
790 | RETVAL = newSVsv (sv); |
711 | SvTAINTED_off (RETVAL); |
791 | SvTAINTED_off (RETVAL); |
712 | OUTPUT: |
792 | OUTPUT: |
713 | RETVAL |
793 | RETVAL |
|
|
794 | |
|
|
795 | void |
|
|
796 | _exit (int status) |
714 | |
797 | |
715 | bool |
798 | bool |
716 | safe () |
799 | safe () |
717 | CODE: |
800 | CODE: |
718 | RETVAL = !rxvt_tainted (); |
801 | RETVAL = !rxvt_tainted (); |
… | |
… | |
820 | OUTPUT: |
903 | OUTPUT: |
821 | RETVAL |
904 | RETVAL |
822 | |
905 | |
823 | void |
906 | void |
824 | rxvt_term::destroy () |
907 | rxvt_term::destroy () |
|
|
908 | |
|
|
909 | #if ENABLE_PERL_FRILLS |
|
|
910 | |
|
|
911 | void |
|
|
912 | rxvt_term::XListProperties (U32 window) |
|
|
913 | PPCODE: |
|
|
914 | { |
|
|
915 | int count; |
|
|
916 | Atom *props = XListProperties (THIS->display->display, (Window)window, &count); |
|
|
917 | |
|
|
918 | EXTEND (SP, count); |
|
|
919 | while (count--) |
|
|
920 | PUSHs (newSVuv ((U32)props [count])); |
|
|
921 | |
|
|
922 | XFree (props); |
|
|
923 | } |
|
|
924 | |
|
|
925 | void |
|
|
926 | rxvt_term::XGetWindowProperty (U32 window, U32 property) |
|
|
927 | PPCODE: |
|
|
928 | { |
|
|
929 | Atom type; |
|
|
930 | int format; |
|
|
931 | unsigned long nitems; |
|
|
932 | unsigned long bytes_after; |
|
|
933 | unsigned char *prop; |
|
|
934 | XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
935 | 0, 1<<30, 0, AnyPropertyType, |
|
|
936 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
937 | if (type != None) |
|
|
938 | { |
|
|
939 | EXTEND (SP, 3); |
|
|
940 | PUSHs (newSVuv ((U32)type)); |
|
|
941 | PUSHs (newSViv (format)); |
|
|
942 | PUSHs (newSVpvn ((char *)prop, nitems * format / 8)); |
|
|
943 | XFree (prop); |
|
|
944 | } |
|
|
945 | } |
|
|
946 | |
|
|
947 | void |
|
|
948 | rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data) |
|
|
949 | CODE: |
|
|
950 | { |
|
|
951 | STRLEN len; |
|
|
952 | char *data_ = SvPVbyte (data, len); |
|
|
953 | |
|
|
954 | XChangeProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
955 | type, format, PropModeReplace, |
|
|
956 | (unsigned char *)data, len * 8 / format); |
|
|
957 | } |
|
|
958 | |
|
|
959 | void |
|
|
960 | rxvt_term::XDeleteProperty (U32 window, U32 property) |
|
|
961 | CODE: |
|
|
962 | XDeleteProperty (THIS->display->display, (Window)window, (Atom)property); |
|
|
963 | |
|
|
964 | U32 |
|
|
965 | rxvt_term::DefaultRootWindow () |
|
|
966 | CODE: |
|
|
967 | RETVAL = (U32)THIS->display->root; |
|
|
968 | OUTPUT: |
|
|
969 | RETVAL |
|
|
970 | |
|
|
971 | U32 |
|
|
972 | rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height) |
|
|
973 | CODE: |
|
|
974 | RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent, |
|
|
975 | x, y, width, height, 0, |
|
|
976 | THIS->pix_colors_focused[Color_border], |
|
|
977 | THIS->pix_colors_focused[Color_border]); |
|
|
978 | OUTPUT: |
|
|
979 | RETVAL |
|
|
980 | |
|
|
981 | void |
|
|
982 | rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0) |
|
|
983 | CODE: |
|
|
984 | XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y); |
|
|
985 | |
|
|
986 | void |
|
|
987 | rxvt_term::XMapWindow (U32 window) |
|
|
988 | CODE: |
|
|
989 | XMapWindow (THIS->display->display, (Window)window); |
|
|
990 | |
|
|
991 | void |
|
|
992 | rxvt_term::XUnmapWindow (U32 window) |
|
|
993 | CODE: |
|
|
994 | XUnmapWindow (THIS->display->display, (Window)window); |
|
|
995 | |
|
|
996 | #endif |
|
|
997 | |
|
|
998 | void |
|
|
999 | rxvt_term::set_should_invoke (int htype, int inc) |
|
|
1000 | CODE: |
|
|
1001 | THIS->perl.should_invoke [htype] += inc; |
825 | |
1002 | |
826 | void |
1003 | void |
827 | rxvt_term::grab_button (int button, U32 modifiers) |
1004 | rxvt_term::grab_button (int button, U32 modifiers) |
828 | CODE: |
1005 | CODE: |
829 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1006 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
… | |
… | |
933 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1110 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
934 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1111 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
935 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1112 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
936 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1113 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
937 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1114 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
938 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
1115 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
939 | |
1116 | |
940 | int |
1117 | int |
941 | rxvt_term::width () |
1118 | rxvt_term::width () |
942 | ALIAS: |
1119 | ALIAS: |
943 | width = TERM_OFFSET_width |
1120 | width = TERM_OFFSET_width |
… | |
… | |
949 | ncol = TERM_OFFSET_ncol |
1126 | ncol = TERM_OFFSET_ncol |
950 | focus = TERM_OFFSET_focus |
1127 | focus = TERM_OFFSET_focus |
951 | mapped = TERM_OFFSET_mapped |
1128 | mapped = TERM_OFFSET_mapped |
952 | saveLines = TERM_OFFSET_saveLines |
1129 | saveLines = TERM_OFFSET_saveLines |
953 | total_rows = TERM_OFFSET_total_rows |
1130 | total_rows = TERM_OFFSET_total_rows |
954 | nsaved = TERM_OFFSET_nsaved |
1131 | top_row = TERM_OFFSET_top_row |
955 | CODE: |
1132 | CODE: |
956 | RETVAL = *(int *)((char *)THIS + ix); |
1133 | RETVAL = *(int *)((char *)THIS + ix); |
957 | OUTPUT: |
1134 | OUTPUT: |
958 | RETVAL |
1135 | RETVAL |
959 | |
1136 | |
… | |
… | |
1028 | CODE: |
1205 | CODE: |
1029 | RETVAL = (U32)THIS->vt; |
1206 | RETVAL = (U32)THIS->vt; |
1030 | OUTPUT: |
1207 | OUTPUT: |
1031 | RETVAL |
1208 | RETVAL |
1032 | |
1209 | |
|
|
1210 | void |
|
|
1211 | rxvt_term::vt_emask_add (U32 emask) |
|
|
1212 | CODE: |
|
|
1213 | THIS->vt_emask_perl |= emask; |
|
|
1214 | THIS->vt_select_input (); |
|
|
1215 | |
1033 | U32 |
1216 | U32 |
1034 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
1217 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
1035 | CODE: |
1218 | CODE: |
1036 | { |
|
|
1037 | RETVAL = THIS->rstyle; |
1219 | RETVAL = THIS->rstyle; |
1038 | THIS->rstyle = new_rstyle; |
1220 | THIS->rstyle = new_rstyle; |
1039 | } |
|
|
1040 | OUTPUT: |
1221 | OUTPUT: |
1041 | RETVAL |
1222 | RETVAL |
1042 | |
1223 | |
1043 | int |
1224 | int |
1044 | rxvt_term::view_start (int newval = -1) |
1225 | rxvt_term::view_start (int newval = 1) |
|
|
1226 | PROTOTYPE: $;$ |
1045 | CODE: |
1227 | CODE: |
1046 | { |
1228 | { |
1047 | RETVAL = THIS->view_start; |
1229 | RETVAL = THIS->view_start; |
1048 | |
1230 | |
1049 | if (newval >= 0) |
1231 | if (newval <= 0) |
1050 | { |
1232 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1051 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
1052 | THIS->scr_changeview (RETVAL); |
|
|
1053 | } |
|
|
1054 | } |
1233 | } |
1055 | OUTPUT: |
1234 | OUTPUT: |
1056 | RETVAL |
1235 | RETVAL |
1057 | |
1236 | |
1058 | void |
1237 | void |
… | |
… | |
1062 | |
1241 | |
1063 | void |
1242 | void |
1064 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1243 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1065 | PPCODE: |
1244 | PPCODE: |
1066 | { |
1245 | { |
1067 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1246 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1068 | XSRETURN_EMPTY; |
1247 | XSRETURN_EMPTY; |
1069 | |
1248 | |
1070 | line_t &l = ROW(row_number); |
1249 | line_t &l = ROW(row_number); |
1071 | |
1250 | |
1072 | if (GIMME_V != G_VOID) |
1251 | if (GIMME_V != G_VOID) |
… | |
… | |
1105 | |
1284 | |
1106 | void |
1285 | void |
1107 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1286 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1108 | PPCODE: |
1287 | PPCODE: |
1109 | { |
1288 | { |
1110 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1289 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1111 | XSRETURN_EMPTY; |
1290 | XSRETURN_EMPTY; |
1112 | |
1291 | |
1113 | line_t &l = ROW(row_number); |
1292 | line_t &l = ROW(row_number); |
1114 | |
1293 | |
1115 | if (GIMME_V != G_VOID) |
1294 | if (GIMME_V != G_VOID) |
… | |
… | |
1145 | |
1324 | |
1146 | int |
1325 | int |
1147 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1326 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1148 | CODE: |
1327 | CODE: |
1149 | { |
1328 | { |
1150 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1329 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1151 | XSRETURN_EMPTY; |
1330 | XSRETURN_EMPTY; |
1152 | |
1331 | |
1153 | line_t &l = ROW(row_number); |
1332 | line_t &l = ROW(row_number); |
1154 | RETVAL = l.l; |
1333 | RETVAL = l.l; |
1155 | |
1334 | |
… | |
… | |
1161 | |
1340 | |
1162 | bool |
1341 | bool |
1163 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1342 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1164 | CODE: |
1343 | CODE: |
1165 | { |
1344 | { |
1166 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1345 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1167 | XSRETURN_EMPTY; |
1346 | XSRETURN_EMPTY; |
1168 | |
1347 | |
1169 | line_t &l = ROW(row_number); |
1348 | line_t &l = ROW(row_number); |
1170 | RETVAL = l.is_longer (); |
1349 | RETVAL = l.is_longer (); |
1171 | |
1350 | |
… | |
… | |
1361 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1540 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1362 | } |
1541 | } |
1363 | |
1542 | |
1364 | if (items == 3) |
1543 | if (items == 3) |
1365 | { |
1544 | { |
1366 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1545 | rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1); |
1367 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1546 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1368 | |
1547 | |
1369 | if (ix) |
1548 | if (ix) |
1370 | THIS->want_refresh = 1; |
1549 | THIS->want_refresh = 1; |
1371 | } |
1550 | } |
… | |
… | |
1375 | rxvt_term::cur_charset () |
1554 | rxvt_term::cur_charset () |
1376 | CODE: |
1555 | CODE: |
1377 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1556 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1378 | OUTPUT: |
1557 | OUTPUT: |
1379 | RETVAL |
1558 | RETVAL |
|
|
1559 | |
|
|
1560 | #void |
|
|
1561 | #rxvt_term::selection_clear () |
|
|
1562 | |
|
|
1563 | void |
|
|
1564 | rxvt_term::selection_make (U32 eventtime, bool rect = false) |
|
|
1565 | CODE: |
|
|
1566 | THIS->selection.op = SELECTION_CONT; |
|
|
1567 | THIS->selection.rect = rect; |
|
|
1568 | THIS->selection_make (eventtime); |
1380 | |
1569 | |
1381 | int |
1570 | int |
1382 | rxvt_term::selection_grab (U32 eventtime) |
1571 | rxvt_term::selection_grab (U32 eventtime) |
1383 | |
1572 | |
1384 | void |
1573 | void |