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. |
… | |
… | |
469 | |
469 | |
470 | case DT_STRING: |
470 | case DT_STRING: |
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: |
|
|
475 | { |
|
|
476 | char *str = va_arg (ap, char *); |
|
|
477 | int len = va_arg (ap, int); |
|
|
478 | |
|
|
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
480 | } |
|
|
481 | break; |
|
|
482 | |
|
|
483 | case DT_XEVENT: |
|
|
484 | { |
|
|
485 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
486 | HV *hv = newHV (); |
|
|
487 | |
|
|
488 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
489 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
490 | # undef set |
|
|
491 | |
|
|
492 | setiv (type, xe->type); |
|
|
493 | setiv (send_event, xe->xany.send_event); |
|
|
494 | setiv (serial, xe->xany.serial); |
|
|
495 | |
|
|
496 | switch (xe->type) |
|
|
497 | { |
|
|
498 | case KeyPress: |
|
|
499 | case KeyRelease: |
|
|
500 | case ButtonPress: |
|
|
501 | case ButtonRelease: |
|
|
502 | case MotionNotify: |
|
|
503 | setiv (time, xe->xmotion.time); |
|
|
504 | setiv (x, xe->xmotion.x); |
|
|
505 | setiv (y, xe->xmotion.y); |
|
|
506 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
507 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
508 | setiv (x_root, xe->xmotion.x_root); |
|
|
509 | setiv (y_root, xe->xmotion.y_root); |
|
|
510 | setiv (state, xe->xmotion.state); |
|
|
511 | break; |
|
|
512 | } |
|
|
513 | |
|
|
514 | switch (xe->type) |
|
|
515 | { |
|
|
516 | case KeyPress: |
|
|
517 | case KeyRelease: |
|
|
518 | setiv (keycode, xe->xkey.keycode); |
|
|
519 | break; |
|
|
520 | |
|
|
521 | case ButtonPress: |
|
|
522 | case ButtonRelease: |
|
|
523 | setiv (button, xe->xbutton.button); |
|
|
524 | break; |
|
|
525 | |
|
|
526 | case MotionNotify: |
|
|
527 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
528 | break; |
|
|
529 | } |
|
|
530 | |
|
|
531 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
532 | } |
|
|
533 | break; |
|
|
534 | |
474 | case DT_USTRING_LEN: |
535 | case DT_USTRING_LEN: |
475 | { |
536 | { |
476 | unicode_t *ustr = va_arg (ap, unicode_t *); |
537 | unicode_t *ustr = va_arg (ap, unicode_t *); |
477 | int ulen = va_arg (ap, int); |
538 | int ulen = va_arg (ap, int); |
478 | wchar_t *wstr = new wchar_t [ulen]; |
539 | wchar_t *wstr = new wchar_t [ulen]; |
… | |
… | |
544 | export_const (RS_Uline); |
605 | export_const (RS_Uline); |
545 | |
606 | |
546 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
607 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
547 | } |
608 | } |
548 | |
609 | |
|
|
610 | SV * |
|
|
611 | new (...) |
|
|
612 | CODE: |
|
|
613 | { |
|
|
614 | stringvec *argv = new stringvec; |
|
|
615 | bool success; |
|
|
616 | |
|
|
617 | for (int i = 0; i < items ;i++) |
|
|
618 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
619 | |
|
|
620 | rxvt_term *term = new rxvt_term; |
|
|
621 | |
|
|
622 | term->argv = argv; |
|
|
623 | |
|
|
624 | try |
|
|
625 | { |
|
|
626 | if (!term->init (argv->size (), argv->begin ())) |
|
|
627 | term = 0; |
|
|
628 | } |
|
|
629 | catch (const class rxvt_failure_exception &e) |
|
|
630 | { |
|
|
631 | term->destroy (); |
|
|
632 | croak ("exception caught while initializing new terminal instance"); |
|
|
633 | } |
|
|
634 | |
|
|
635 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
|
|
636 | } |
|
|
637 | OUTPUT: |
|
|
638 | RETVAL |
|
|
639 | |
549 | void |
640 | void |
550 | set_should_invoke (int htype, int value) |
641 | set_should_invoke (int htype, int value) |
551 | CODE: |
642 | CODE: |
552 | rxvt_perl.should_invoke [htype] = value; |
643 | rxvt_perl.should_invoke [htype] = value; |
553 | |
644 | |
… | |
… | |
615 | } |
706 | } |
616 | OUTPUT: |
707 | OUTPUT: |
617 | RETVAL |
708 | RETVAL |
618 | |
709 | |
619 | MODULE = urxvt PACKAGE = urxvt::term |
710 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
711 | |
|
|
712 | void |
|
|
713 | rxvt_term::destroy () |
620 | |
714 | |
621 | int |
715 | int |
622 | rxvt_term::strwidth (SV *str) |
716 | rxvt_term::strwidth (SV *str) |
623 | CODE: |
717 | CODE: |
624 | { |
718 | { |
… | |
… | |
703 | RETVAL = *(int *)((char *)THIS + ix); |
797 | RETVAL = *(int *)((char *)THIS + ix); |
704 | OUTPUT: |
798 | OUTPUT: |
705 | RETVAL |
799 | RETVAL |
706 | |
800 | |
707 | U32 |
801 | U32 |
|
|
802 | rxvt_term::parent () |
|
|
803 | CODE: |
|
|
804 | RETVAL = (U32)THIS->parent [0]; |
|
|
805 | OUTPUT: |
|
|
806 | RETVAL |
|
|
807 | |
|
|
808 | U32 |
|
|
809 | rxvt_term::vt () |
|
|
810 | CODE: |
|
|
811 | RETVAL = (U32)THIS->vt; |
|
|
812 | OUTPUT: |
|
|
813 | RETVAL |
|
|
814 | |
|
|
815 | U32 |
708 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
816 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
709 | CODE: |
817 | CODE: |
710 | { |
818 | { |
711 | RETVAL = THIS->rstyle; |
819 | RETVAL = THIS->rstyle; |
712 | THIS->rstyle = new_rstyle; |
820 | THIS->rstyle = new_rstyle; |
… | |
… | |
977 | STRLEN len; |
1085 | STRLEN len; |
978 | char *str = SvPVbyte (octets, len); |
1086 | char *str = SvPVbyte (octets, len); |
979 | C_ARGS: |
1087 | C_ARGS: |
980 | str, len |
1088 | str, len |
981 | |
1089 | |
|
|
1090 | void |
|
|
1091 | rxvt_term::cmd_parse (SV *octets) |
|
|
1092 | CODE: |
|
|
1093 | { |
|
|
1094 | STRLEN len; |
|
|
1095 | char *str = SvPVbyte (octets, len); |
|
|
1096 | |
|
|
1097 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1098 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1099 | |
|
|
1100 | THIS->cmdbuf_ptr = str; |
|
|
1101 | THIS->cmdbuf_endp = str + len; |
|
|
1102 | |
|
|
1103 | THIS->cmd_parse (); |
|
|
1104 | |
|
|
1105 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1106 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1107 | } |
|
|
1108 | |
982 | SV * |
1109 | SV * |
983 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
1110 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
984 | CODE: |
1111 | CODE: |
985 | { |
1112 | { |
986 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
1113 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |