1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtperl.xs |
2 | * File: rxvtperl.xs |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2005 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
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; |
… | |
… | |
797 | RETVAL = *(int *)((char *)THIS + ix); |
791 | RETVAL = *(int *)((char *)THIS + ix); |
798 | OUTPUT: |
792 | OUTPUT: |
799 | RETVAL |
793 | RETVAL |
800 | |
794 | |
801 | U32 |
795 | U32 |
|
|
796 | rxvt_term::parent () |
|
|
797 | CODE: |
|
|
798 | RETVAL = (U32)THIS->parent [0]; |
|
|
799 | OUTPUT: |
|
|
800 | RETVAL |
|
|
801 | |
|
|
802 | U32 |
802 | rxvt_term::vt () |
803 | rxvt_term::vt () |
803 | CODE: |
804 | CODE: |
804 | RETVAL = THIS->vt; |
805 | RETVAL = (U32)THIS->vt; |
805 | OUTPUT: |
806 | OUTPUT: |
806 | RETVAL |
807 | RETVAL |
807 | |
808 | |
808 | U32 |
809 | U32 |
809 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
810 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
… | |
… | |
1054 | void |
1055 | void |
1055 | rxvt_term::scr_add_lines (SV *string) |
1056 | rxvt_term::scr_add_lines (SV *string) |
1056 | CODE: |
1057 | CODE: |
1057 | { |
1058 | { |
1058 | wchar_t *wstr = sv2wcs (string); |
1059 | wchar_t *wstr = sv2wcs (string); |
1059 | int wlen = wcslen (wstr); |
|
|
1060 | unicode_t *ustr = new unicode_t [wlen]; |
|
|
1061 | int nlines = 0; |
|
|
1062 | |
|
|
1063 | for (int i = wlen; i--; ) |
|
|
1064 | { |
|
|
1065 | ustr [i] = wstr [i]; |
|
|
1066 | nlines += ustr [i] == '\012'; |
|
|
1067 | } |
|
|
1068 | |
|
|
1069 | THIS->scr_add_lines (ustr, nlines, wlen); |
1060 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1070 | |
|
|
1071 | free (wstr); |
1061 | free (wstr); |
1072 | delete [] ustr; |
|
|
1073 | } |
1062 | } |
1074 | |
1063 | |
1075 | void |
1064 | void |
1076 | rxvt_term::tt_write (SV *octets) |
1065 | rxvt_term::tt_write (SV *octets) |
1077 | INIT: |
1066 | INIT: |