--- rxvt-unicode/src/rxvtperl.xs 2006/01/06 02:58:02 1.28 +++ rxvt-unicode/src/rxvtperl.xs 2006/01/06 18:33:30 1.32 @@ -3,7 +3,7 @@ *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. - * Copyright (c) 2005-2005 Marc Lehmann + * Copyright (c) 2005-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -467,23 +467,78 @@ XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); break; - case DT_STRING: + case DT_STR: XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); break; - case DT_USTRING_LEN: + case DT_STR_LEN: { - unicode_t *ustr = va_arg (ap, unicode_t *); - int ulen = va_arg (ap, int); - wchar_t *wstr = new wchar_t [ulen]; + char *str = va_arg (ap, char *); + int len = va_arg (ap, int); - for (int i = ulen; i--; ) - wstr [i] = ustr [i]; + XPUSHs (sv_2mortal (newSVpvn (str, len))); + } + break; - XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); + case DT_WCS_LEN: + { + wchar_t *wstr = va_arg (ap, wchar_t *); + int wlen = va_arg (ap, int); - delete [] wstr; + XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); + } + + case DT_XEVENT: + { + XEvent *xe = va_arg (ap, XEvent *); + HV *hv = newHV (); + +# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) +# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) +# undef set + + setiv (type, xe->type); + setiv (send_event, xe->xany.send_event); + setiv (serial, xe->xany.serial); + + switch (xe->type) + { + case KeyPress: + case KeyRelease: + case ButtonPress: + case ButtonRelease: + case MotionNotify: + setiv (time, xe->xmotion.time); + setiv (x, xe->xmotion.x); + setiv (y, xe->xmotion.y); + setiv (row, xe->xmotion.y / term->fheight); + setiv (col, xe->xmotion.x / term->fwidth); + setiv (x_root, xe->xmotion.x_root); + setiv (y_root, xe->xmotion.y_root); + setiv (state, xe->xmotion.state); + break; + } + + switch (xe->type) + { + case KeyPress: + case KeyRelease: + setiv (keycode, xe->xkey.keycode); + break; + + case ButtonPress: + case ButtonRelease: + setiv (button, xe->xbutton.button); + break; + + case MotionNotify: + setiv (is_hint, xe->xmotion.is_hint); + break; + } + + XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); } + break; case DT_END: { @@ -738,6 +793,20 @@ RETVAL U32 +rxvt_term::parent () + CODE: + RETVAL = (U32)THIS->parent [0]; + OUTPUT: + RETVAL + +U32 +rxvt_term::vt () + CODE: + RETVAL = (U32)THIS->vt; + OUTPUT: + RETVAL + +U32 rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) CODE: { @@ -988,20 +1057,8 @@ CODE: { wchar_t *wstr = sv2wcs (string); - int wlen = wcslen (wstr); - unicode_t *ustr = new unicode_t [wlen]; - int nlines = 0; - - for (int i = wlen; i--; ) - { - ustr [i] = wstr [i]; - nlines += ustr [i] == '\012'; - } - - THIS->scr_add_lines (ustr, nlines, wlen); - + THIS->scr_add_lines (wstr, wcslen (wstr)); free (wstr); - delete [] ustr; } void