--- rxvt-unicode/src/rxvtperl.xs 2006/01/06 01:16:58 1.27 +++ rxvt-unicode/src/rxvtperl.xs 2006/01/06 05:28:55 1.30 @@ -471,6 +471,67 @@ XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); break; + case DT_STRING_LEN: + { + char *str = va_arg (ap, char *); + int len = va_arg (ap, int); + + XPUSHs (sv_2mortal (newSVpvn (str, len))); + } + break; + + 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_USTRING_LEN: { unicode_t *ustr = va_arg (ap, unicode_t *); @@ -546,6 +607,36 @@ sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); } +SV * +new (...) + CODE: +{ + stringvec *argv = new stringvec; + bool success; + + for (int i = 0; i < items ;i++) + argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); + + rxvt_term *term = new rxvt_term; + + term->argv = argv; + + try + { + if (!term->init (argv->size (), argv->begin ())) + term = 0; + } + catch (const class rxvt_failure_exception &e) + { + term->destroy (); + croak ("exception caught while initializing new terminal instance"); + } + + RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; +} + OUTPUT: + RETVAL + void set_should_invoke (int htype, int value) CODE: @@ -618,6 +709,9 @@ MODULE = urxvt PACKAGE = urxvt::term +void +rxvt_term::destroy () + int rxvt_term::strwidth (SV *str) CODE: @@ -705,6 +799,13 @@ RETVAL U32 +rxvt_term::vt () + CODE: + RETVAL = THIS->vt; + OUTPUT: + RETVAL + +U32 rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) CODE: { @@ -979,6 +1080,25 @@ C_ARGS: str, len +void +rxvt_term::cmd_parse (SV *octets) + CODE: +{ + STRLEN len; + char *str = SvPVbyte (octets, len); + + char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; + char *old_cmdbuf_endp = THIS->cmdbuf_endp; + + THIS->cmdbuf_ptr = str; + THIS->cmdbuf_endp = str + len; + + THIS->cmd_parse (); + + THIS->cmdbuf_ptr = old_cmdbuf_ptr; + THIS->cmdbuf_endp = old_cmdbuf_endp; +} + SV * rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) CODE: