… | |
… | |
465 | |
465 | |
466 | case DT_LONG: |
466 | case DT_LONG: |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
468 | break; |
468 | break; |
469 | |
469 | |
470 | case DT_STRING: |
470 | case DT_STR: |
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: |
474 | case DT_STR_LEN: |
475 | { |
475 | { |
476 | char *str = va_arg (ap, char *); |
476 | char *str = va_arg (ap, char *); |
477 | int len = va_arg (ap, int); |
477 | int len = va_arg (ap, int); |
478 | |
478 | |
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
480 | } |
480 | } |
481 | break; |
481 | break; |
|
|
482 | |
|
|
483 | case DT_WCS_LEN: |
|
|
484 | { |
|
|
485 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
486 | int wlen = va_arg (ap, int); |
|
|
487 | |
|
|
488 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
489 | } |
|
|
490 | break; |
482 | |
491 | |
483 | case DT_XEVENT: |
492 | case DT_XEVENT: |
484 | { |
493 | { |
485 | XEvent *xe = va_arg (ap, XEvent *); |
494 | XEvent *xe = va_arg (ap, XEvent *); |
486 | HV *hv = newHV (); |
495 | HV *hv = newHV (); |
… | |
… | |
530 | |
539 | |
531 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
540 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
532 | } |
541 | } |
533 | break; |
542 | break; |
534 | |
543 | |
535 | case DT_USTRING_LEN: |
|
|
536 | { |
|
|
537 | unicode_t *ustr = va_arg (ap, unicode_t *); |
|
|
538 | int ulen = va_arg (ap, int); |
|
|
539 | wchar_t *wstr = new wchar_t [ulen]; |
|
|
540 | |
|
|
541 | for (int i = ulen; i--; ) |
|
|
542 | wstr [i] = ustr [i]; |
|
|
543 | |
|
|
544 | XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); |
|
|
545 | |
|
|
546 | delete [] wstr; |
|
|
547 | } |
|
|
548 | |
|
|
549 | case DT_END: |
544 | case DT_END: |
550 | { |
545 | { |
551 | va_end (ap); |
546 | va_end (ap); |
552 | |
547 | |
553 | PUTBACK; |
548 | PUTBACK; |
… | |
… | |
709 | |
704 | |
710 | MODULE = urxvt PACKAGE = urxvt::term |
705 | MODULE = urxvt PACKAGE = urxvt::term |
711 | |
706 | |
712 | void |
707 | void |
713 | rxvt_term::destroy () |
708 | rxvt_term::destroy () |
|
|
709 | |
|
|
710 | void |
|
|
711 | rxvt_term::grab (int eventtime) |
|
|
712 | CODE: |
|
|
713 | { |
|
|
714 | return; |
|
|
715 | XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
716 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
717 | GrabModeAsync, GrabModeAsync, None, None, eventtime); |
|
|
718 | XGrabKeyboard (THIS->display->display, THIS->vt, 0, GrabModeAsync, GrabModeAsync, eventtime); |
|
|
719 | } |
714 | |
720 | |
715 | int |
721 | int |
716 | rxvt_term::strwidth (SV *str) |
722 | rxvt_term::strwidth (SV *str) |
717 | CODE: |
723 | CODE: |
718 | { |
724 | { |
… | |
… | |
853 | |
859 | |
854 | if (GIMME_V != G_VOID) |
860 | if (GIMME_V != G_VOID) |
855 | { |
861 | { |
856 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
862 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
857 | |
863 | |
858 | for (int col = 0; col <THIS->ncol; col++) |
864 | for (int col = 0; col < THIS->ncol; col++) |
859 | wstr [col] = l.t [col]; |
865 | wstr [col] = l.t [col]; |
860 | |
866 | |
861 | XPUSHs (sv_2mortal (wcs2sv (wstr))); |
867 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
862 | |
868 | |
863 | delete [] wstr; |
869 | delete [] wstr; |
864 | } |
870 | } |
865 | |
871 | |
866 | if (new_text) |
872 | if (new_text) |
… | |
… | |
956 | } |
962 | } |
957 | OUTPUT: |
963 | OUTPUT: |
958 | RETVAL |
964 | RETVAL |
959 | |
965 | |
960 | SV * |
966 | SV * |
961 | rxvt_term::special_encode (SV *str) |
967 | rxvt_term::special_encode (SV *string) |
962 | CODE: |
968 | CODE: |
963 | abort ();//TODO |
969 | { |
|
|
970 | wchar_t *wstr = sv2wcs (string); |
|
|
971 | int wlen = wcslen (wstr); |
|
|
972 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
973 | |
|
|
974 | rxvt_push_locale (THIS->locale); |
|
|
975 | |
|
|
976 | wchar_t *r = rstr; |
|
|
977 | for (wchar_t *s = wstr; *s; s++) |
|
|
978 | if (wcwidth (*s) == 0) |
|
|
979 | { |
|
|
980 | if (r == rstr) |
|
|
981 | croak ("leading combining character unencodable"); |
|
|
982 | |
|
|
983 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
984 | if (n == NOCHAR) |
|
|
985 | n = rxvt_composite.compose (r[-1], *s); |
|
|
986 | |
|
|
987 | r[-1] = n; |
|
|
988 | } |
|
|
989 | #if !UNICODE_3 |
|
|
990 | else if (*s >= 0x10000) |
|
|
991 | *r++ = rxvt_composite.compose (*s); |
|
|
992 | #endif |
|
|
993 | else |
|
|
994 | *r++ = *s; |
|
|
995 | |
|
|
996 | rxvt_pop_locale (); |
|
|
997 | |
|
|
998 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
999 | |
|
|
1000 | delete [] rstr; |
|
|
1001 | } |
|
|
1002 | OUTPUT: |
|
|
1003 | RETVAL |
964 | |
1004 | |
965 | SV * |
1005 | SV * |
966 | rxvt_term::special_decode (SV *str) |
1006 | rxvt_term::special_decode (SV *text) |
967 | CODE: |
1007 | CODE: |
968 | abort ();//TODO |
1008 | { |
|
|
1009 | wchar_t *wstr = sv2wcs (text); |
|
|
1010 | int wlen = wcslen (wstr); |
|
|
1011 | int dlen = 0; |
|
|
1012 | |
|
|
1013 | // find length |
|
|
1014 | for (wchar_t *s = wstr; *s; s++) |
|
|
1015 | if (*s == NOCHAR) |
|
|
1016 | ; |
|
|
1017 | else if (IS_COMPOSE (*s)) |
|
|
1018 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1019 | else |
|
|
1020 | dlen++; |
|
|
1021 | |
|
|
1022 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1023 | |
|
|
1024 | // decode |
|
|
1025 | wchar_t *r = rstr; |
|
|
1026 | for (wchar_t *s = wstr; *s; s++) |
|
|
1027 | if (*s == NOCHAR) |
|
|
1028 | ; |
|
|
1029 | else if (IS_COMPOSE (*s)) |
|
|
1030 | r += rxvt_composite.expand (*s, r); |
|
|
1031 | else |
|
|
1032 | *r++ = *s; |
|
|
1033 | |
|
|
1034 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1035 | |
|
|
1036 | delete [] rstr; |
|
|
1037 | } |
|
|
1038 | OUTPUT: |
|
|
1039 | RETVAL |
969 | |
1040 | |
970 | void |
1041 | void |
971 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1042 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
972 | PPCODE: |
1043 | PPCODE: |
973 | { |
1044 | { |
… | |
… | |
1061 | void |
1132 | void |
1062 | rxvt_term::scr_add_lines (SV *string) |
1133 | rxvt_term::scr_add_lines (SV *string) |
1063 | CODE: |
1134 | CODE: |
1064 | { |
1135 | { |
1065 | wchar_t *wstr = sv2wcs (string); |
1136 | wchar_t *wstr = sv2wcs (string); |
1066 | int wlen = wcslen (wstr); |
|
|
1067 | unicode_t *ustr = new unicode_t [wlen]; |
|
|
1068 | int nlines = 0; |
|
|
1069 | |
|
|
1070 | for (int i = wlen; i--; ) |
|
|
1071 | { |
|
|
1072 | ustr [i] = wstr [i]; |
|
|
1073 | nlines += ustr [i] == '\012'; |
|
|
1074 | } |
|
|
1075 | |
|
|
1076 | THIS->scr_add_lines (ustr, nlines, wlen); |
1137 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1077 | |
|
|
1078 | free (wstr); |
1138 | free (wstr); |
1079 | delete [] ustr; |
|
|
1080 | } |
1139 | } |
1081 | |
1140 | |
1082 | void |
1141 | void |
1083 | rxvt_term::tt_write (SV *octets) |
1142 | rxvt_term::tt_write (SV *octets) |
1084 | INIT: |
1143 | INIT: |
… | |
… | |
1098 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1157 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1099 | |
1158 | |
1100 | THIS->cmdbuf_ptr = str; |
1159 | THIS->cmdbuf_ptr = str; |
1101 | THIS->cmdbuf_endp = str + len; |
1160 | THIS->cmdbuf_endp = str + len; |
1102 | |
1161 | |
|
|
1162 | rxvt_push_locale (THIS->locale); |
1103 | THIS->cmd_parse (); |
1163 | THIS->cmd_parse (); |
|
|
1164 | rxvt_pop_locale (); |
1104 | |
1165 | |
1105 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1166 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1106 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1167 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1107 | } |
1168 | } |
1108 | |
1169 | |