… | |
… | |
469 | |
469 | |
470 | case DT_STRING: |
470 | case DT_STRING: |
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
472 | break; |
472 | break; |
473 | |
473 | |
|
|
474 | case DT_STRING_LEN: |
|
|
475 | { |
|
|
476 | char *str = va_arg (ap, char *); |
|
|
477 | int len = va_arg (ap, int); |
|
|
478 | |
|
|
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
480 | } |
|
|
481 | break; |
|
|
482 | |
|
|
483 | case DT_XEVENT: |
|
|
484 | { |
|
|
485 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
486 | HV *hv = newHV (); |
|
|
487 | |
|
|
488 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
489 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
490 | # undef set |
|
|
491 | |
|
|
492 | setiv (type, xe->type); |
|
|
493 | setiv (send_event, xe->xany.send_event); |
|
|
494 | setiv (serial, xe->xany.serial); |
|
|
495 | |
|
|
496 | switch (xe->type) |
|
|
497 | { |
|
|
498 | case KeyPress: |
|
|
499 | case KeyRelease: |
|
|
500 | case ButtonPress: |
|
|
501 | case ButtonRelease: |
|
|
502 | case MotionNotify: |
|
|
503 | setiv (time, xe->xmotion.time); |
|
|
504 | setiv (x, xe->xmotion.x); |
|
|
505 | setiv (y, xe->xmotion.y); |
|
|
506 | setiv (x_root, xe->xmotion.x_root); |
|
|
507 | setiv (y_root, xe->xmotion.y_root); |
|
|
508 | setiv (state, xe->xmotion.state); |
|
|
509 | break; |
|
|
510 | } |
|
|
511 | |
|
|
512 | switch (xe->type) |
|
|
513 | { |
|
|
514 | case KeyPress: |
|
|
515 | case KeyRelease: |
|
|
516 | setiv (keycode, xe->xkey.keycode); |
|
|
517 | break; |
|
|
518 | |
|
|
519 | case ButtonPress: |
|
|
520 | case ButtonRelease: |
|
|
521 | setiv (button, xe->xbutton.button); |
|
|
522 | break; |
|
|
523 | |
|
|
524 | case MotionNotify: |
|
|
525 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
526 | break; |
|
|
527 | } |
|
|
528 | |
|
|
529 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
530 | } |
|
|
531 | break; |
|
|
532 | |
474 | case DT_USTRING_LEN: |
533 | case DT_USTRING_LEN: |
475 | { |
534 | { |
476 | unicode_t *ustr = va_arg (ap, unicode_t *); |
535 | unicode_t *ustr = va_arg (ap, unicode_t *); |
477 | int ulen = va_arg (ap, int); |
536 | int ulen = va_arg (ap, int); |
478 | wchar_t *wstr = new wchar_t [ulen]; |
537 | wchar_t *wstr = new wchar_t [ulen]; |
… | |
… | |
544 | export_const (RS_Uline); |
603 | export_const (RS_Uline); |
545 | |
604 | |
546 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
605 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
547 | } |
606 | } |
548 | |
607 | |
|
|
608 | SV * |
|
|
609 | new (...) |
|
|
610 | CODE: |
|
|
611 | { |
|
|
612 | stringvec *argv = new stringvec; |
|
|
613 | bool success; |
|
|
614 | |
|
|
615 | for (int i = 0; i < items ;i++) |
|
|
616 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
617 | |
|
|
618 | rxvt_term *term = new rxvt_term; |
|
|
619 | |
|
|
620 | term->argv = argv; |
|
|
621 | |
|
|
622 | try |
|
|
623 | { |
|
|
624 | if (!term->init (argv->size (), argv->begin ())) |
|
|
625 | term = 0; |
|
|
626 | } |
|
|
627 | catch (const class rxvt_failure_exception &e) |
|
|
628 | { |
|
|
629 | term->destroy (); |
|
|
630 | croak ("exception caught while initializing new terminal instance"); |
|
|
631 | } |
|
|
632 | |
|
|
633 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
|
|
634 | } |
|
|
635 | OUTPUT: |
|
|
636 | RETVAL |
|
|
637 | |
549 | void |
638 | void |
550 | set_should_invoke (int htype, int value) |
639 | set_should_invoke (int htype, int value) |
551 | CODE: |
640 | CODE: |
552 | rxvt_perl.should_invoke [htype] = value; |
641 | rxvt_perl.should_invoke [htype] = value; |
553 | |
642 | |
… | |
… | |
615 | } |
704 | } |
616 | OUTPUT: |
705 | OUTPUT: |
617 | RETVAL |
706 | RETVAL |
618 | |
707 | |
619 | MODULE = urxvt PACKAGE = urxvt::term |
708 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
709 | |
|
|
710 | void |
|
|
711 | rxvt_term::destroy () |
620 | |
712 | |
621 | int |
713 | int |
622 | rxvt_term::strwidth (SV *str) |
714 | rxvt_term::strwidth (SV *str) |
623 | CODE: |
715 | CODE: |
624 | { |
716 | { |
… | |
… | |
733 | rxvt_term::want_refresh () |
825 | rxvt_term::want_refresh () |
734 | CODE: |
826 | CODE: |
735 | THIS->want_refresh = 1; |
827 | THIS->want_refresh = 1; |
736 | |
828 | |
737 | void |
829 | void |
738 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
830 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
739 | PPCODE: |
831 | PPCODE: |
740 | { |
832 | { |
741 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
833 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
742 | XSRETURN_EMPTY; |
834 | XSRETURN_EMPTY; |
743 | |
835 | |
… | |
… | |
757 | |
849 | |
758 | if (new_text) |
850 | if (new_text) |
759 | { |
851 | { |
760 | wchar_t *wstr = sv2wcs (new_text); |
852 | wchar_t *wstr = sv2wcs (new_text); |
761 | |
853 | |
762 | int len = wcslen (wstr); |
854 | int len = min (wcslen (wstr) - start_ofs, max_len); |
763 | |
855 | |
764 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
856 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
765 | { |
857 | { |
766 | free (wstr); |
858 | free (wstr); |
767 | croak ("new_text extends beyond horizontal margins"); |
859 | croak ("new_text extends beyond horizontal margins"); |
768 | } |
860 | } |
769 | |
861 | |
770 | for (int col = start_col; col < start_col + len; col++) |
862 | for (int col = start_col; col < start_col + len; col++) |
771 | { |
863 | { |
772 | l.t [col] = wstr [col - start_col]; |
864 | l.t [col] = wstr [start_ofs + col - start_col]; |
773 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
865 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
774 | } |
866 | } |
775 | |
867 | |
776 | free (wstr); |
868 | free (wstr); |
777 | } |
869 | } |
778 | } |
870 | } |
779 | |
871 | |
780 | void |
872 | void |
781 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
873 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
782 | PPCODE: |
874 | PPCODE: |
783 | { |
875 | { |
784 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
876 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
785 | XSRETURN_EMPTY; |
877 | XSRETURN_EMPTY; |
786 | |
878 | |
… | |
… | |
801 | { |
893 | { |
802 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
894 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
803 | croak ("new_rend must be arrayref"); |
895 | croak ("new_rend must be arrayref"); |
804 | |
896 | |
805 | AV *av = (AV *)SvRV (new_rend); |
897 | AV *av = (AV *)SvRV (new_rend); |
806 | int len = av_len (av) + 1; |
898 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
807 | |
899 | |
808 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
900 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
809 | croak ("new_rend array extends beyond horizontal margins"); |
901 | croak ("new_rend array extends beyond horizontal margins"); |
810 | |
902 | |
811 | for (int col = start_col; col < start_col + len; col++) |
903 | for (int col = start_col; col < start_col + len; col++) |
812 | { |
904 | { |
813 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
905 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
814 | |
906 | |
815 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
907 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
816 | } |
908 | } |
817 | } |
909 | } |
818 | } |
910 | } |
819 | |
911 | |
820 | int |
912 | int |
821 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
913 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
822 | CODE: |
914 | CODE: |
823 | { |
915 | { |
824 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
916 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
825 | XSRETURN_EMPTY; |
917 | XSRETURN_EMPTY; |
826 | |
918 | |
827 | line_t &l = ROW(row_number); |
919 | line_t &l = ROW(row_number); |
828 | RETVAL = l.l < 0 ? THIS->ncol : l.l; |
920 | RETVAL = l.l; |
829 | |
921 | |
830 | if (new_length >= -1) |
922 | if (new_length >= 0) |
831 | l.l = new_length; |
923 | l.l = new_length; |
832 | } |
924 | } |
833 | OUTPUT: |
925 | OUTPUT: |
834 | RETVAL |
926 | RETVAL |
835 | |
927 | |
836 | bool |
928 | bool |
837 | rxvt_term::ROW_is_longer (int row_number) |
929 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
838 | CODE: |
930 | CODE: |
839 | { |
931 | { |
840 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
932 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
841 | XSRETURN_EMPTY; |
933 | XSRETURN_EMPTY; |
842 | |
934 | |
843 | line_t &l = ROW(row_number); |
935 | line_t &l = ROW(row_number); |
844 | RETVAL = l.l < 0; |
936 | RETVAL = l.is_longer (); |
|
|
937 | |
|
|
938 | if (new_is_longer >= 0) |
|
|
939 | l.is_longer (new_is_longer); |
845 | } |
940 | } |
846 | OUTPUT: |
941 | OUTPUT: |
847 | RETVAL |
942 | RETVAL |
848 | |
943 | |
849 | SV * |
944 | SV * |
… | |
… | |
974 | STRLEN len; |
1069 | STRLEN len; |
975 | char *str = SvPVbyte (octets, len); |
1070 | char *str = SvPVbyte (octets, len); |
976 | C_ARGS: |
1071 | C_ARGS: |
977 | str, len |
1072 | str, len |
978 | |
1073 | |
|
|
1074 | void |
|
|
1075 | rxvt_term::cmd_parse (SV *octets) |
|
|
1076 | CODE: |
|
|
1077 | { |
|
|
1078 | STRLEN len; |
|
|
1079 | char *str = SvPVbyte (octets, len); |
|
|
1080 | |
|
|
1081 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1082 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1083 | |
|
|
1084 | THIS->cmdbuf_ptr = str; |
|
|
1085 | THIS->cmdbuf_endp = str + len; |
|
|
1086 | |
|
|
1087 | THIS->cmd_parse (); |
|
|
1088 | |
|
|
1089 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1090 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1091 | } |
|
|
1092 | |
979 | SV * |
1093 | SV * |
980 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
1094 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
981 | CODE: |
1095 | CODE: |
982 | { |
1096 | { |
983 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
1097 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |