… | |
… | |
51 | char *str = SvPVutf8 (sv, len); |
51 | char *str = SvPVutf8 (sv, len); |
52 | return rxvt_utf8towcs (str, len); |
52 | return rxvt_utf8towcs (str, len); |
53 | } |
53 | } |
54 | |
54 | |
55 | static SV * |
55 | static SV * |
|
|
56 | wcs2sv (wchar_t *wstr, int len = -1) |
|
|
57 | { |
|
|
58 | char *str = rxvt_wcstoutf8 (wstr, len); |
|
|
59 | |
|
|
60 | SV *sv = newSVpv (str, 0); |
|
|
61 | SvUTF8_on (sv); |
|
|
62 | free (str); |
|
|
63 | |
|
|
64 | return sv; |
|
|
65 | } |
|
|
66 | |
|
|
67 | static SV * |
56 | new_ref (HV *hv, const char *klass) |
68 | new_ref (HV *hv, const char *klass) |
57 | { |
69 | { |
58 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
70 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
59 | } |
71 | } |
60 | |
72 | |
… | |
… | |
457 | |
469 | |
458 | case DT_STRING: |
470 | case DT_STRING: |
459 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
460 | break; |
472 | break; |
461 | |
473 | |
|
|
474 | case DT_USTRING_LEN: |
|
|
475 | { |
|
|
476 | unicode_t *ustr = va_arg (ap, unicode_t *); |
|
|
477 | int ulen = va_arg (ap, int); |
|
|
478 | wchar_t *wstr = new wchar_t [ulen]; |
|
|
479 | |
|
|
480 | for (int i = ulen; i--; ) |
|
|
481 | wstr [i] = ustr [i]; |
|
|
482 | |
|
|
483 | XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); |
|
|
484 | |
|
|
485 | delete [] wstr; |
|
|
486 | } |
|
|
487 | |
462 | case DT_END: |
488 | case DT_END: |
463 | { |
489 | { |
464 | va_end (ap); |
490 | va_end (ap); |
465 | |
491 | |
466 | PUTBACK; |
492 | PUTBACK; |
… | |
… | |
634 | |
660 | |
635 | rxvt_push_locale (THIS->locale); |
661 | rxvt_push_locale (THIS->locale); |
636 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
662 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
637 | rxvt_pop_locale (); |
663 | rxvt_pop_locale (); |
638 | |
664 | |
639 | char *str = rxvt_wcstoutf8 (wstr); |
665 | RETVAL = wcs2sv (wstr); |
640 | free (wstr); |
666 | free (wstr); |
641 | |
|
|
642 | RETVAL = newSVpv (str, 0); |
|
|
643 | SvUTF8_on (RETVAL); |
|
|
644 | free (str); |
|
|
645 | } |
667 | } |
646 | OUTPUT: |
668 | OUTPUT: |
647 | RETVAL |
669 | RETVAL |
648 | |
670 | |
649 | # very portable, especially on objects as opposed to pods |
671 | # very portable, especially on objects as opposed to pods |
… | |
… | |
681 | RETVAL = *(int *)((char *)THIS + ix); |
703 | RETVAL = *(int *)((char *)THIS + ix); |
682 | OUTPUT: |
704 | OUTPUT: |
683 | RETVAL |
705 | RETVAL |
684 | |
706 | |
685 | U32 |
707 | U32 |
686 | rxvt_term::screen_rstyle (U32 new_rstyle = THIS->screen.s_rstyle) |
708 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
687 | CODE: |
709 | CODE: |
688 | { |
710 | { |
689 | RETVAL = THIS->screen.s_rstyle; |
711 | RETVAL = THIS->rstyle; |
690 | THIS->screen.s_rstyle = new_rstyle; |
712 | THIS->rstyle = new_rstyle; |
691 | } |
713 | } |
692 | OUTPUT: |
714 | OUTPUT: |
693 | RETVAL |
715 | RETVAL |
694 | |
716 | |
695 | int |
717 | int |
… | |
… | |
726 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
748 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
727 | |
749 | |
728 | for (int col = 0; col <THIS->ncol; col++) |
750 | for (int col = 0; col <THIS->ncol; col++) |
729 | wstr [col] = l.t [col]; |
751 | wstr [col] = l.t [col]; |
730 | |
752 | |
731 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
|
|
732 | free (wstr); |
|
|
733 | |
|
|
734 | SV *sv = newSVpv (str, 0); |
|
|
735 | SvUTF8_on (sv); |
|
|
736 | XPUSHs (sv_2mortal (sv)); |
753 | XPUSHs (sv_2mortal (wcs2sv (wstr))); |
737 | free (str); |
754 | |
|
|
755 | delete [] wstr; |
738 | } |
756 | } |
739 | |
757 | |
740 | if (new_text) |
758 | if (new_text) |
741 | { |
759 | { |
742 | wchar_t *wstr = sv2wcs (new_text); |
760 | wchar_t *wstr = sv2wcs (new_text); |
… | |
… | |
916 | void |
934 | void |
917 | rxvt_term::selection (SV *newtext = 0) |
935 | rxvt_term::selection (SV *newtext = 0) |
918 | PPCODE: |
936 | PPCODE: |
919 | { |
937 | { |
920 | if (GIMME_V != G_VOID) |
938 | if (GIMME_V != G_VOID) |
921 | { |
939 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
922 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
923 | SV *sv = newSVpv (sel, 0); |
|
|
924 | SvUTF8_on (sv); |
|
|
925 | free (sel); |
|
|
926 | XPUSHs (sv_2mortal (sv)); |
|
|
927 | } |
|
|
928 | |
940 | |
929 | if (newtext) |
941 | if (newtext) |
930 | { |
942 | { |
931 | free (THIS->selection.text); |
943 | free (THIS->selection.text); |
932 | |
944 | |
933 | THIS->selection.text = sv2wcs (newtext); |
945 | THIS->selection.text = sv2wcs (newtext); |
934 | THIS->selection.len = wcslen (THIS->selection.text); |
946 | THIS->selection.len = wcslen (THIS->selection.text); |
935 | } |
947 | } |
|
|
948 | } |
|
|
949 | |
|
|
950 | void |
|
|
951 | rxvt_term::scr_add_lines (SV *string) |
|
|
952 | CODE: |
|
|
953 | { |
|
|
954 | wchar_t *wstr = sv2wcs (string); |
|
|
955 | int wlen = wcslen (wstr); |
|
|
956 | unicode_t *ustr = new unicode_t [wlen]; |
|
|
957 | int nlines = 0; |
|
|
958 | |
|
|
959 | for (int i = wlen; i--; ) |
|
|
960 | { |
|
|
961 | ustr [i] = wstr [i]; |
|
|
962 | nlines += ustr [i] == '\012'; |
|
|
963 | } |
|
|
964 | |
|
|
965 | THIS->scr_add_lines (ustr, nlines, wlen); |
|
|
966 | |
|
|
967 | free (wstr); |
|
|
968 | delete [] ustr; |
936 | } |
969 | } |
937 | |
970 | |
938 | void |
971 | void |
939 | rxvt_term::tt_write (SV *octets) |
972 | rxvt_term::tt_write (SV *octets) |
940 | INIT: |
973 | INIT: |