… | |
… | |
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 | } |
482 | |
490 | |
483 | case DT_XEVENT: |
491 | case DT_XEVENT: |
484 | { |
492 | { |
485 | XEvent *xe = va_arg (ap, XEvent *); |
493 | XEvent *xe = va_arg (ap, XEvent *); |
486 | HV *hv = newHV (); |
494 | HV *hv = newHV (); |
… | |
… | |
530 | |
538 | |
531 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
539 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
532 | } |
540 | } |
533 | break; |
541 | break; |
534 | |
542 | |
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: |
543 | case DT_END: |
550 | { |
544 | { |
551 | va_end (ap); |
545 | va_end (ap); |
552 | |
546 | |
553 | PUTBACK; |
547 | PUTBACK; |
… | |
… | |
853 | |
847 | |
854 | if (GIMME_V != G_VOID) |
848 | if (GIMME_V != G_VOID) |
855 | { |
849 | { |
856 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
850 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
857 | |
851 | |
858 | for (int col = 0; col <THIS->ncol; col++) |
852 | for (int col = 0; col < THIS->ncol; col++) |
859 | wstr [col] = l.t [col]; |
853 | wstr [col] = l.t [col]; |
860 | |
854 | |
861 | XPUSHs (sv_2mortal (wcs2sv (wstr))); |
855 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
862 | |
856 | |
863 | delete [] wstr; |
857 | delete [] wstr; |
864 | } |
858 | } |
865 | |
859 | |
866 | if (new_text) |
860 | if (new_text) |
… | |
… | |
956 | } |
950 | } |
957 | OUTPUT: |
951 | OUTPUT: |
958 | RETVAL |
952 | RETVAL |
959 | |
953 | |
960 | SV * |
954 | SV * |
961 | rxvt_term::special_encode (SV *str) |
955 | rxvt_term::special_encode (SV *string) |
962 | CODE: |
956 | CODE: |
963 | abort ();//TODO |
957 | { |
|
|
958 | wchar_t *wstr = sv2wcs (string); |
|
|
959 | int wlen = wcslen (wstr); |
|
|
960 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
961 | |
|
|
962 | rxvt_push_locale (THIS->locale); |
|
|
963 | |
|
|
964 | wchar_t *r = rstr; |
|
|
965 | for (wchar_t *s = wstr; *s; s++) |
|
|
966 | if (wcwidth (*s) == 0) |
|
|
967 | { |
|
|
968 | if (r == rstr) |
|
|
969 | croak ("leading combining character unencodable"); |
|
|
970 | |
|
|
971 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
972 | if (n == NOCHAR) |
|
|
973 | n = rxvt_composite.compose (r[-1], *s); |
|
|
974 | |
|
|
975 | r[-1] = n; |
|
|
976 | } |
|
|
977 | #if !UNICODE_3 |
|
|
978 | else if (*s >= 0x10000) |
|
|
979 | *r++ = rxvt_composite.compose (*s); |
|
|
980 | #endif |
|
|
981 | else |
|
|
982 | *r++ = *s; |
|
|
983 | |
|
|
984 | rxvt_pop_locale (); |
|
|
985 | |
|
|
986 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
987 | |
|
|
988 | delete [] rstr; |
|
|
989 | } |
|
|
990 | OUTPUT: |
|
|
991 | RETVAL |
964 | |
992 | |
965 | SV * |
993 | SV * |
966 | rxvt_term::special_decode (SV *str) |
994 | rxvt_term::special_decode (SV *text) |
967 | CODE: |
995 | CODE: |
968 | abort ();//TODO |
996 | { |
|
|
997 | wchar_t *wstr = sv2wcs (text); |
|
|
998 | int wlen = wcslen (wstr); |
|
|
999 | int dlen = 0; |
|
|
1000 | |
|
|
1001 | // find length |
|
|
1002 | for (wchar_t *s = wstr; *s; s++) |
|
|
1003 | if (*s == NOCHAR) |
|
|
1004 | ; |
|
|
1005 | else if (IS_COMPOSE (*s)) |
|
|
1006 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1007 | else |
|
|
1008 | dlen++; |
|
|
1009 | |
|
|
1010 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1011 | |
|
|
1012 | // decode |
|
|
1013 | wchar_t *r = rstr; |
|
|
1014 | for (wchar_t *s = wstr; *s; s++) |
|
|
1015 | if (*s == NOCHAR) |
|
|
1016 | ; |
|
|
1017 | else if (IS_COMPOSE (*s)) |
|
|
1018 | r += rxvt_composite.expand (*s, r); |
|
|
1019 | else |
|
|
1020 | *r++ = *s; |
|
|
1021 | |
|
|
1022 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1023 | |
|
|
1024 | delete [] rstr; |
|
|
1025 | } |
|
|
1026 | OUTPUT: |
|
|
1027 | RETVAL |
969 | |
1028 | |
970 | void |
1029 | void |
971 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1030 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
972 | PPCODE: |
1031 | PPCODE: |
973 | { |
1032 | { |
… | |
… | |
1061 | void |
1120 | void |
1062 | rxvt_term::scr_add_lines (SV *string) |
1121 | rxvt_term::scr_add_lines (SV *string) |
1063 | CODE: |
1122 | CODE: |
1064 | { |
1123 | { |
1065 | wchar_t *wstr = sv2wcs (string); |
1124 | 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); |
1125 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1077 | |
|
|
1078 | free (wstr); |
1126 | free (wstr); |
1079 | delete [] ustr; |
|
|
1080 | } |
1127 | } |
1081 | |
1128 | |
1082 | void |
1129 | void |
1083 | rxvt_term::tt_write (SV *octets) |
1130 | rxvt_term::tt_write (SV *octets) |
1084 | INIT: |
1131 | INIT: |