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_USTRING_LEN: |
474 | case DT_STR_LEN: |
475 | { |
475 | { |
476 | unicode_t *ustr = va_arg (ap, unicode_t *); |
476 | char *str = va_arg (ap, char *); |
477 | int ulen = va_arg (ap, int); |
477 | int len = va_arg (ap, int); |
|
|
478 | |
|
|
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
480 | } |
|
|
481 | break; |
|
|
482 | |
|
|
483 | case DT_WCS_LEN: |
|
|
484 | { |
478 | wchar_t *wstr = new wchar_t [ulen]; |
485 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
486 | int wlen = va_arg (ap, int); |
479 | |
487 | |
480 | for (int i = ulen; i--; ) |
|
|
481 | wstr [i] = ustr [i]; |
|
|
482 | |
|
|
483 | XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); |
488 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
489 | } |
484 | |
490 | |
485 | delete [] wstr; |
491 | case DT_XEVENT: |
486 | } |
492 | { |
|
|
493 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
494 | HV *hv = newHV (); |
|
|
495 | |
|
|
496 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
497 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
498 | # undef set |
|
|
499 | |
|
|
500 | setiv (type, xe->type); |
|
|
501 | setiv (send_event, xe->xany.send_event); |
|
|
502 | setiv (serial, xe->xany.serial); |
|
|
503 | |
|
|
504 | switch (xe->type) |
|
|
505 | { |
|
|
506 | case KeyPress: |
|
|
507 | case KeyRelease: |
|
|
508 | case ButtonPress: |
|
|
509 | case ButtonRelease: |
|
|
510 | case MotionNotify: |
|
|
511 | setiv (time, xe->xmotion.time); |
|
|
512 | setiv (x, xe->xmotion.x); |
|
|
513 | setiv (y, xe->xmotion.y); |
|
|
514 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
515 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
516 | setiv (x_root, xe->xmotion.x_root); |
|
|
517 | setiv (y_root, xe->xmotion.y_root); |
|
|
518 | setiv (state, xe->xmotion.state); |
|
|
519 | break; |
|
|
520 | } |
|
|
521 | |
|
|
522 | switch (xe->type) |
|
|
523 | { |
|
|
524 | case KeyPress: |
|
|
525 | case KeyRelease: |
|
|
526 | setiv (keycode, xe->xkey.keycode); |
|
|
527 | break; |
|
|
528 | |
|
|
529 | case ButtonPress: |
|
|
530 | case ButtonRelease: |
|
|
531 | setiv (button, xe->xbutton.button); |
|
|
532 | break; |
|
|
533 | |
|
|
534 | case MotionNotify: |
|
|
535 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
536 | break; |
|
|
537 | } |
|
|
538 | |
|
|
539 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
540 | } |
|
|
541 | break; |
487 | |
542 | |
488 | case DT_END: |
543 | case DT_END: |
489 | { |
544 | { |
490 | va_end (ap); |
545 | va_end (ap); |
491 | |
546 | |
… | |
… | |
736 | RETVAL = *(int *)((char *)THIS + ix); |
791 | RETVAL = *(int *)((char *)THIS + ix); |
737 | OUTPUT: |
792 | OUTPUT: |
738 | RETVAL |
793 | RETVAL |
739 | |
794 | |
740 | U32 |
795 | U32 |
|
|
796 | rxvt_term::parent () |
|
|
797 | CODE: |
|
|
798 | RETVAL = (U32)THIS->parent [0]; |
|
|
799 | OUTPUT: |
|
|
800 | RETVAL |
|
|
801 | |
|
|
802 | U32 |
|
|
803 | rxvt_term::vt () |
|
|
804 | CODE: |
|
|
805 | RETVAL = (U32)THIS->vt; |
|
|
806 | OUTPUT: |
|
|
807 | RETVAL |
|
|
808 | |
|
|
809 | U32 |
741 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
810 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
742 | CODE: |
811 | CODE: |
743 | { |
812 | { |
744 | RETVAL = THIS->rstyle; |
813 | RETVAL = THIS->rstyle; |
745 | THIS->rstyle = new_rstyle; |
814 | THIS->rstyle = new_rstyle; |
… | |
… | |
986 | void |
1055 | void |
987 | rxvt_term::scr_add_lines (SV *string) |
1056 | rxvt_term::scr_add_lines (SV *string) |
988 | CODE: |
1057 | CODE: |
989 | { |
1058 | { |
990 | wchar_t *wstr = sv2wcs (string); |
1059 | wchar_t *wstr = sv2wcs (string); |
991 | int wlen = wcslen (wstr); |
|
|
992 | unicode_t *ustr = new unicode_t [wlen]; |
|
|
993 | int nlines = 0; |
|
|
994 | |
|
|
995 | for (int i = wlen; i--; ) |
|
|
996 | { |
|
|
997 | ustr [i] = wstr [i]; |
|
|
998 | nlines += ustr [i] == '\012'; |
|
|
999 | } |
|
|
1000 | |
|
|
1001 | THIS->scr_add_lines (ustr, nlines, wlen); |
1060 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1002 | |
|
|
1003 | free (wstr); |
1061 | free (wstr); |
1004 | delete [] ustr; |
|
|
1005 | } |
1062 | } |
1006 | |
1063 | |
1007 | void |
1064 | void |
1008 | rxvt_term::tt_write (SV *octets) |
1065 | rxvt_term::tt_write (SV *octets) |
1009 | INIT: |
1066 | INIT: |