/*
 * This file was generated automatically by ExtUtils::ParseXS version 2.19 from the
 * contents of rxvtperl.xs. Do not edit this file, edit rxvtperl.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST! 
 *
 */

#line 1 "./rxvtperl.xs"
/*----------------------------------------------------------------------*
 * File:	rxvtperl.xs
 *----------------------------------------------------------------------*
 *
 * All portions of code are copyright by their respective author/s.
 * Copyright (c) 2005-2008,2011 Marc Lehmann <schmorp@schmorp.de>
 *
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------*/

#define line_t perl_line_t
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#undef line_t
#undef bool // perl defines it's own bool type, except with g++... what a trap

#include "../config.h"

#include <stddef.h>
#include <stdarg.h>

#include "unistd.h"

#include "ev_cpp.h"
#include "rxvt.h"
#include "keyboard.h"
#include "rxvtutil.h"
#include "rxvtperl.h"

#include "perlxsi.c"

#define GRAB_CURSOR THIS->scrollBar.leftptr_cursor

#undef LINENO
#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
#undef ROW
#define ROW(n) THIS->row_buf [LINENO (n)]

/////////////////////////////////////////////////////////////////////////////

typedef char *		octet_string;
typedef char *		utf8_string;

typedef int		render_repeat_mode;

#if HAVE_PIXBUF
typedef GdkPixbuf *	urxvt__pixbuf;
#endif
#if HAVE_IMG
typedef rxvt_img *	urxvt__img;
typedef rxvt_img::nv	rxvt_img__nv;

/////////////////////////////////////////////////////////////////////////////

static rgba
parse_rgba (SV *sv, rxvt_screen *s = 0)
{
  rgba c;

  if (SvROK (sv))
    {
      AV *av = (AV *)SvRV (sv);

      if (SvTYPE ((SV *)av) != SVt_PVAV)
        croak ("colour must be either a colour string, or an array,");

      int len = av_len (av) + 1;

      if (len != 1 && len != 3 && len != 4)
        croak ("component colour array must have 1, 3 or 4 components,");

      c.a = rgba::MAX_CC;

      c.r = c.g = c.b = float_to_component (SvIV (*av_fetch (av, 0, 0)));

      if (len >= 3)
        {
          c.g = float_to_component (SvIV (*av_fetch (av, 1, 0)));
          c.b = float_to_component (SvIV (*av_fetch (av, 2, 0)));

          if (len >= 4)
            c.a = float_to_component (SvIV (*av_fetch (av, 3, 0)));
        }
    }
  else if (s)
    {
      rxvt_color rc;
      rc.set (s, SvPVbyte_nolen (sv));
      rc.get (c);
    }
  else
    croak ("unable to parse colour,");

  return c;
}

/////////////////////////////////////////////////////////////////////////////
#endif

static wchar_t *
sv2wcs (SV *sv)
{
  STRLEN len;
  char *str = SvPVutf8 (sv, len);
  return rxvt_utf8towcs (str, len);
}

static SV *
wcs2sv (wchar_t *wstr, int len = -1)
{
  char *str = rxvt_wcstoutf8 (wstr, len);

  SV *sv = newSVpv (str, 0);
  SvUTF8_on (sv);
  free (str);

  return sv;
}

static SV *
newSVptr (void *ptr, const char *klass)
{
  HV *hv = newHV ();
  sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0);
  return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
}

static void
clearSVptr (SV *sv)
{
  if (SvROK (sv))
    sv = SvRV (sv);

  hv_clear ((HV *)sv);
  sv_unmagic (sv, PERL_MAGIC_ext);
}

static long
SvPTR (SV *sv, const char *klass)
{
  if (!sv_derived_from (sv, klass))
    croak ("object of type %s expected", klass);

  MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext);

  if (!mg)
    croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);

  return (long)mg->mg_ptr;
}

#define newSVterm(term) SvREFCNT_inc ((SV *)(term)->perl.self)
#define SvTERM(sv) (rxvt_term *)SvPTR ((sv), "urxvt::term")

/////////////////////////////////////////////////////////////////////////////

#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")

class overlay : overlay_base
{
  rxvt_term *THIS;
  AV *overlay_av;
  int border;

public:
  HV *self;

  overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
  ~overlay ();

  void show ();
  void hide ();

  void swap ();

  void set (int x, int y, SV *str, SV *rend);
};

overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border)
: THIS(THIS), border(border == 2), overlay_av (0)
{
  x = x_;
  y = y_;
  w = w_;
  h = h_;

  if (w < 0) w = 0;
  if (h < 0) h = 0;

  if (border == 2)
    {
      w += 2;
      h += 2;
    }

  text = new text_t *[h];
  rend = new rend_t *[h];

  for (int y = 0; y < h; y++)
    {
      text_t *tp = text[y] = new text_t[w];
      rend_t *rp = rend[y] = new rend_t[w];

      text_t t0, t1, t2;
      rend_t r = rstyle;

      if (border == 2)
        {
          if (y == 0)
            t0 = 0x2554, t1 = 0x2550, t2 = 0x2557;
          else if (y < h - 1)
            t0 = 0x2551, t1 = 0x0020, t2 = 0x2551;
          else
            t0 = 0x255a, t1 = 0x2550, t2 = 0x255d;

          *tp++ = t0;
          *rp++ = r;

          for (int x = w - 2; x-- > 0; )
            {
              *tp++ = t1;
              *rp++ = r;
            }

          *tp = t2;
          *rp = r;
        }
      else
        for (int x = w; x-- > 0; )
          {
            *tp++ = 0x0020;
            *rp++ = r;
          }
    }

  show ();
}

overlay::~overlay ()
{
  hide ();

  for (int y = h; y--; )
    {
      delete [] text[y];
      delete [] rend[y];
    }

  delete [] text;
  delete [] rend;
}

void
overlay::show ()
{
  if (overlay_av)
    return;

  overlay_av = (AV *)SvREFCNT_inc (SvRV (
        *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)
     ));
  av_push (overlay_av, newSViv ((long)this));

  THIS->want_refresh = 1;
  THIS->refresh_check ();
}

void
overlay::hide ()
{
  if (!overlay_av)
    return;

  int i;

  for (i = AvFILL (overlay_av); i >= 0; i--)
    if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this)
      break;

  for (; i < AvFILL (overlay_av); i++)
    av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0)));

  av_pop (overlay_av);

  SvREFCNT_dec (overlay_av);
  overlay_av = 0;

  THIS->want_refresh = 1;
  THIS->refresh_check ();
}

void overlay::swap ()
{
  int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
  int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h));

  int ov_w = min (w, THIS->ncol - ov_x);
  int ov_h = min (h, THIS->nrow - ov_y);

  // hide cursor if it is within the overlay area
  if (IN_RANGE_EXC (THIS->screen.cur.col - ov_x, 0, ov_w)
      && IN_RANGE_EXC (THIS->screen.cur.row - ov_y, 0, ov_h))
    THIS->screen.flags &= ~Screen_VisibleCursor;

  for (int y = ov_h; y--; )
    {
      text_t *t1 = text [y];
      rend_t *r1 = rend [y];

      text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x;
      rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x;

      for (int x = ov_w; x--; )
        {
          text_t t = *t1; *t1++ = *t2; *t2++ = t;
          rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t));
        }
    }

}

void overlay::set (int x, int y, SV *text, SV *rend)
{
  x += border;
  y += border;

  if (!IN_RANGE_EXC (y, 0, h - border))
    return;

  wchar_t *wtext = sv2wcs (text);

  for (int col = min (wcslen (wtext), w - x - border); col--; )
    this->text [y][x + col] = wtext [col];

  free (wtext);

  if (rend)
    {
      if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
        croak ("rend must be arrayref");

      AV *av = (AV *)SvRV (rend);

      for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
        this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
    }

  THIS->want_refresh = 1;
  THIS->refresh_check ();
}

/////////////////////////////////////////////////////////////////////////////

#include "iom_perl.h"

/////////////////////////////////////////////////////////////////////////////

struct rxvt_perl_interp rxvt_perl;

static PerlInterpreter *perl;

rxvt_perl_interp::~rxvt_perl_interp ()
{
  if (perl)
    {
      perl_destruct (perl);
      perl_free (perl);
      PERL_SYS_TERM ();
    }
}

void
rxvt_perl_interp::init ()
{
  if (!perl)
    {
      rxvt_push_locale (""); // perl init destroys current locale

      {
        perl_environ = rxvt_environ;
        localise_env set_environ (perl_environ);

        char *args[] = {
          "",
          "-e"
          "BEGIN {"
          "   urxvt->bootstrap;"
          "   unshift @INC, '" LIBDIR "';"
          "}"
          ""
          "use urxvt;"
        };
        int argc = ecb_array_length (args);
        char **argv = args;

        PERL_SYS_INIT3 (&argc, &argv, &environ);
        perl = perl_alloc ();
        perl_construct (perl);

        if (perl_parse (perl, xs_init, argc, argv, (char **)NULL)
            || perl_run (perl))
          {
            rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");

            perl_destruct (perl);
            perl_free (perl);
            perl = 0;
          }
      }

      rxvt_pop_locale ();
    }
}

void
rxvt_perl_interp::init (rxvt_term *term)
{
  init ();

  if (perl && !term->perl.self)
    {
      // runs outside of perls ENV
      term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
      hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
      hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
    }
}

void
rxvt_perl_interp::eval (const char *str)
{
  eval_pv (str, 1);
}

void
rxvt_perl_interp::usage (rxvt_term *term, int type)
{
  localise_env set_environ (perl_environ);

  ENTER;
  SAVETMPS;

  dSP;
  PUSHMARK (SP);
  EXTEND (SP, 2);
  PUSHs (sv_2mortal (newSVterm (term)));
  PUSHs (sv_2mortal (newSViv (type)));
  PUTBACK;
  call_pv ("urxvt::usage", G_VOID | G_DISCARD);

  FREETMPS;
  LEAVE;
}

uint8_t
rxvt_perl_interp::parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value)
{
  localise_env set_environ (perl_environ);

  ENTER;
  SAVETMPS;

  dSP;
  PUSHMARK (SP);
  EXTEND (SP, 6);
  PUSHs (sv_2mortal (newSVterm (term)));
  PUSHs (sv_2mortal (newSVpv (name, 0)));
  PUSHs (arg     ? &PL_sv_yes : &PL_sv_no);
  PUSHs (longopt ? &PL_sv_yes : &PL_sv_no);
  PUSHs (flag    ? &PL_sv_yes : &PL_sv_no);
  PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef);
  PUTBACK;
  call_pv ("urxvt::parse_resource", G_SCALAR);
  SPAGAIN;

  uint8_t ret = POPi;

  FREETMPS;
  LEAVE;

  return ret;
}

static void
ungrab (rxvt_term *THIS)
{
  if (THIS->perl.grabtime)
    {
      XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime);
      XUngrabPointer  (THIS->dpy, THIS->perl.grabtime);
      THIS->perl.grabtime = 0;
    }
}

bool
rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
{
  if (!perl || !term->perl.self)
    return false;

  localise_env set_environ (perl_environ);

  // pre-handling of some events
  if (htype == HOOK_REFRESH_END)
    {
      AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));

      for (int i = 0; i <= AvFILL (av); i++)
        ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
    }
  else if (htype == HOOK_DESTROY)
    {
      AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));

      for (int i = AvFILL (av); i >= 0; i--)
        {
          rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
          delete req;
        }
    }

  bool event_consumed;

  if (term->perl.should_invoke [htype])
    {
      dSP;
      va_list ap;

      va_start (ap, htype);

      ENTER;
      SAVETMPS;

      PUSHMARK (SP);

      EXTEND (SP, 2);
      PUSHs (sv_2mortal (newSVterm (term)));
      PUSHs (sv_2mortal (newSViv (htype)));

      for (;;) {
        data_type dt = (data_type)va_arg (ap, int);

        switch (dt)
          {
            case DT_INT:
              XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
              break;

            case DT_LONG:
              XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
              break;

            case DT_STR:
              XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
              break;

            case DT_STR_LEN:
              {
                char *str = va_arg (ap, char *);
                int len   = va_arg (ap, int);

                XPUSHs (sv_2mortal (newSVpvn (str, len)));
              }
              break;

            case DT_WCS_LEN:
              {
                wchar_t *wstr = va_arg (ap, wchar_t *);
                int wlen      = va_arg (ap, int);

                XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
              }
             break;

            case DT_LCS_LEN:
              {
                long *lstr = va_arg (ap, long *);
                int llen   = va_arg (ap, int);

                XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
              }
             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)
#               define setuv(name, val) hv_store (hv, # name,  sizeof (# name) - 1, newSVuv (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:
                      setuv (window,    xe->xmotion.window);
                      setuv (root,      xe->xmotion.root);
                      setuv (subwindow, xe->xmotion.subwindow);
                      setuv (time,      xe->xmotion.time);
                      setiv (x,         xe->xmotion.x);
                      setiv (y,         xe->xmotion.y);
                      setiv (row,       xe->xmotion.y / term->fheight + term->view_start);
                      setiv (col,       xe->xmotion.x / term->fwidth);
                      setiv (x_root,    xe->xmotion.x_root);
                      setiv (y_root,    xe->xmotion.y_root);
                      setuv (state,     xe->xmotion.state);

                      switch (xe->type)
                        {
                          case KeyPress:
                          case KeyRelease:
                            setuv (keycode, xe->xkey.keycode);
                            break;

                          case ButtonPress:
                          case ButtonRelease:
                            setuv (button,  xe->xbutton.button);
                            break;

                          case MotionNotify:
                            setiv (is_hint, xe->xmotion.is_hint);
                            break;
                        }

                      break;

                    case MapNotify:
                    case UnmapNotify:
                    case ConfigureNotify:
                      setuv (event,  xe->xconfigure.event);
                      setuv (window, xe->xconfigure.window);

                      switch (xe->type)
                        {
                          case ConfigureNotify:
                            setiv (x,      xe->xconfigure.x);
                            setiv (y,      xe->xconfigure.y);
                            setiv (width,  xe->xconfigure.width);
                            setiv (height, xe->xconfigure.height);
                            setuv (above,  xe->xconfigure.above);
                            break;
                        }

                      break;

                    case PropertyNotify:
                      setuv (window,       xe->xproperty.window);
                      setuv (atom,         xe->xproperty.atom);
                      setuv (time,         xe->xproperty.time);
                      setiv (state,        xe->xproperty.state);
                      break;

                    case ClientMessage:
                      setuv (window,       xe->xclient.window);
                      setuv (message_type, xe->xclient.message_type);
                      setuv (format,       xe->xclient.format);
                      setuv (l0,           xe->xclient.data.l[0]);
                      setuv (l1,           xe->xclient.data.l[1]);
                      setuv (l2,           xe->xclient.data.l[2]);
                      setuv (l3,           xe->xclient.data.l[3]);
                      setuv (l4,           xe->xclient.data.l[4]);
                      break;
                  }

                XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
              }
              break;

            case DT_END:
              goto call;

            default:
              rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
          }
      }

    call:
      va_end (ap);

      PUTBACK;
      int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
      SPAGAIN;

      if (count)
        {
          SV *status = POPs;
          count = SvTRUE (status);
        }

      PUTBACK;
      FREETMPS;
      LEAVE;

      if (SvTRUE (ERRSV))
        {
          rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
          ungrab (term); // better lose the grab than the session
        }

      event_consumed = !!count;
    }
  else
    event_consumed = false;

  // post-handling of some events
  if (htype == HOOK_REFRESH_BEGIN)
    {
      AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));

      for (int i = AvFILL (av); i >= 0; i--)
        ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
    }
  else if (htype == HOOK_DESTROY)
    {
      clearSVptr ((SV *)term->perl.self);
      SvREFCNT_dec ((SV *)term->perl.self);

      // don't allow further calls
      term->perl.self = 0;
    }

  return event_consumed;
}

void
rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
{
  localise_env set_environ (perl_environ);

  ENTER;
  SAVETMPS;

  dSP;
  XPUSHs (sv_2mortal (newSVpvn (data, len)));
  PUTBACK;
  call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);

  if (SvTRUE (ERRSV))
    rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));

  FREETMPS;
  LEAVE;
}

/////////////////////////////////////////////////////////////////////////////

#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#line 783 "./rxvtperl.c"

XS(XS_urxvt_log); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_log)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::log", "msg");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	msg = (const char *)SvPV_nolen(ST(0));
#line 999 "./rxvtperl.xs"
        rxvt_log ("%s", msg);
#line 800 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt_warn); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_warn)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::warn", "msg");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	msg = (const char *)SvPV_nolen(ST(0));
#line 1004 "./rxvtperl.xs"
        rxvt_warn ("%s", msg);
#line 821 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt_fatal); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_fatal)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::fatal", "msg");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	msg = (const char *)SvPV_nolen(ST(0));
#line 1009 "./rxvtperl.xs"
        rxvt_fatal ("%s", msg);
#line 842 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__exit); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__exit)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::_exit", "status");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	status = (int)SvIV(ST(0));

	_exit(status);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt_catch_fatal); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_catch_fatal)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::catch_fatal", "block");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	SV *	block = ST(0);
#line 1018 "./rxvtperl.xs"
        try
          {
            PUSHMARK (SP);
            PUTBACK;
            call_sv (block, G_VOID | G_DISCARD);
            SPAGAIN;
          }
        catch (const rxvt_failure_exception &e)
          {
            croak ("rxvt_fatal exception caught, trying to continue.");
          }
#line 893 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt_NOW); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_NOW)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 0)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::NOW", "");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	NV	RETVAL;
	dXSTARG;
#line 1033 "./rxvtperl.xs"
        RETVAL = ev::now ();
#line 915 "./rxvtperl.c"
	XSprePUSH; PUSHn((NV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_GET_BASEFG); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_GET_BASEFG)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::GET_BASEFG", "rend");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	RETVAL;
	dXSTARG;
	int	rend = (int)SvIV(ST(0));
#line 1040 "./rxvtperl.xs"
        RETVAL = GET_BASEFG (rend);
#line 939 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_GET_BASEBG); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_GET_BASEBG)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::GET_BASEBG", "rend");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	RETVAL;
	dXSTARG;
	int	rend = (int)SvIV(ST(0));
#line 1047 "./rxvtperl.xs"
        RETVAL = GET_BASEBG (rend);
#line 963 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_SET_FGCOLOR); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_SET_FGCOLOR)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::SET_FGCOLOR", "rend, new_color");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	RETVAL;
	dXSTARG;
	int	rend = (int)SvIV(ST(0));
	int	new_color = (int)SvIV(ST(1));
#line 1054 "./rxvtperl.xs"
        RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1));
#line 988 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_SET_BGCOLOR); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_SET_BGCOLOR)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::SET_BGCOLOR", "rend, new_color");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	RETVAL;
	dXSTARG;
	int	rend = (int)SvIV(ST(0));
	int	new_color = (int)SvIV(ST(1));
#line 1061 "./rxvtperl.xs"
        RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1));
#line 1013 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_GET_CUSTOM); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_GET_CUSTOM)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::GET_CUSTOM", "rend");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	RETVAL;
	dXSTARG;
	int	rend = (int)SvIV(ST(0));
#line 1068 "./rxvtperl.xs"
        RETVAL = (rend & RS_customMask) >> RS_customShift;
#line 1037 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_SET_CUSTOM); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_SET_CUSTOM)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::SET_CUSTOM", "rend, new_value");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	RETVAL;
	dXSTARG;
	int	rend = (int)SvIV(ST(0));
	int	new_value = (int)SvIV(ST(1));
#line 1075 "./rxvtperl.xs"
{
        if (!IN_RANGE_EXC (new_value, 0, RS_customCount))
          croak ("custom value out of range, must be 0..%d", RS_customCount - 1);

        RETVAL = (rend & ~RS_customMask)
               | ((new_value << RS_customShift) & RS_customMask);
}
#line 1068 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt_termlist); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt_termlist)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 0)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::termlist", "");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 1088 "./rxvtperl.xs"
{
        EXTEND (SP, rxvt_term::termlist.size ());

        for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
          if ((*t)->perl.self)
            PUSHs (sv_2mortal (newSVterm (*t)));
}
#line 1097 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__new_selection_request); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__new_selection_request)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::_new_selection_request", "term, selnum, tm, win, prop, cb");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	IV	RETVAL;
	dXSTARG;
	rxvt_term *	term = SvTERM (ST(0));
	int	selnum = (int)SvIV(ST(1));
	Time	tm = (Time)SvUV(ST(2));
	Window	win = (Window)SvUV(ST(3));
	Atom	prop = (Atom)SvUV(ST(4));
	SV *	cb = ST(5);
#line 1099 "./rxvtperl.xs"
        rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
        req->cb_sv = newSVsv (cb);
        AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
        av_push (av, newSViv ((IV)req));
        RETVAL = (IV)req;
#line 1130 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__delete_selection_request); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__delete_selection_request)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::_delete_selection_request", "req_");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	IV	req_ = (IV)SvIV(ST(0));
#line 1110 "./rxvtperl.xs"
        rxvt_selection *req = (rxvt_selection *)req_;
        AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
        int i;

        for (i = AvFILL (av); i >= 0; i--)
          if (SvIV (*av_fetch (av, i, 1)) == req_)
            break;

        for (; i < AvFILL (av); i++)
          av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));

        av_pop (av);

        delete req;
#line 1165 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term__new); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term__new)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::_new", "env, arg");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	SV *	RETVAL;
	AV *	env;
	AV *	arg;

	if (SvROK(ST(0)) && SvTYPE(SvRV(ST(0)))==SVt_PVAV)
	    env = (AV*)SvRV(ST(0));
	else
	    Perl_croak(aTHX_ "%s: %s is not an array reference",
			"urxvt::term::_new",
			"env");

	if (SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVAV)
	    arg = (AV*)SvRV(ST(1));
	else
	    Perl_croak(aTHX_ "%s: %s is not an array reference",
			"urxvt::term::_new",
			"arg");
#line 1130 "./rxvtperl.xs"
{
        rxvt_term *term = new rxvt_term;

	stringvec *argv = new stringvec;
        for (int i = 0; i <= AvFILL (arg); i++)
          argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));

	stringvec *envv = new stringvec;
        for (int i = AvFILL (env) + 1; i--; )
          envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));

        try
          {
            term->init (argv, envv);
          }
        catch (const class rxvt_failure_exception &e)
          {
            term->destroy ();
            croak ("error while initializing new terminal instance");
          }

        RETVAL = term && term->perl.self
                 ? newSVterm (term) : &PL_sv_undef;
}
#line 1225 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_destroy); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_destroy)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::destroy", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));

	THIS->destroy();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_set_should_invoke); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_set_should_invoke)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::set_should_invoke", "THIS, htype, inc");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	htype = (int)SvIV(ST(1));
	int	inc = (int)SvIV(ST(2));
#line 1163 "./rxvtperl.xs"
        uint8_t &count = THIS->perl.should_invoke [htype];
        uint8_t prev = count;
        count += inc;
        if (!prev != !count)
	  {
            // hook status changed, react
            switch (htype)
              {
                case HOOK_POSITION_CHANGE:
                  if (count)
                    THIS->get_window_origin (THIS->parent_x, THIS->parent_y);
              }
	  }
#line 1282 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_put_option_db); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_put_option_db)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::put_option_db", "THIS, specifier, value");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	octet_string        specifier = SvPVbyte_nolen (ST(1));
	octet_string        value = SvPVbyte_nolen (ST(2));
#line 1180 "./rxvtperl.xs"
        XrmPutStringResource (&THIS->option_db, specifier, value);
#line 1305 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_grab_button); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_grab_button)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::grab_button", "THIS, button, modifiers, window= THIS->vt");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	button = (int)SvIV(ST(1));
	U32	modifiers = (unsigned long)SvUV(ST(2));
	Window	window;

	if (items < 4)
	    window = THIS->vt;
	else {
	    window = (Window)SvUV(ST(3));
	}
#line 1185 "./rxvtperl.xs"
        RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1,
                              ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
                              GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
#line 1339 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_ungrab_button); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ungrab_button)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::ungrab_button", "THIS, button, modifiers, window= THIS->vt");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	button = (int)SvIV(ST(1));
	U32	modifiers = (unsigned long)SvUV(ST(2));
	Window	window;

	if (items < 4)
	    window = THIS->vt;
	else {
	    window = (Window)SvUV(ST(3));
	}
#line 1193 "./rxvtperl.xs"
        RETVAL = XUngrabButton (THIS->dpy, button, modifiers, window);
#line 1372 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XGrabKey); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XGrabKey)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XGrabKey", "THIS, keycode, modifiers, window= THIS->vt, owner_events= 1, pointer_mode= GrabModeAsync, keyboard_mode= GrabModeAsync");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	keycode = (int)SvIV(ST(1));
	U32	modifiers = (unsigned long)SvUV(ST(2));
	Window	window;
	int	owner_events;
	int	pointer_mode;
	int	keyboard_mode;

	if (items < 4)
	    window = THIS->vt;
	else {
	    window = (Window)SvUV(ST(3));
	}

	if (items < 5)
	    owner_events = 1;
	else {
	    owner_events = (int)SvIV(ST(4));
	}

	if (items < 6)
	    pointer_mode = GrabModeAsync;
	else {
	    pointer_mode = (int)SvIV(ST(5));
	}

	if (items < 7)
	    keyboard_mode = GrabModeAsync;
	else {
	    keyboard_mode = (int)SvIV(ST(6));
	}
#line 1200 "./rxvtperl.xs"
        XGrabKey (THIS->dpy, keycode, modifiers, window, owner_events, pointer_mode, keyboard_mode);
#line 1424 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XUngrabKey); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XUngrabKey)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XUngrabKey", "THIS, keycode, modifiers, window= THIS->vt");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	keycode = (int)SvIV(ST(1));
	U32	modifiers = (unsigned long)SvUV(ST(2));
	Window	window;

	if (items < 4)
	    window = THIS->vt;
	else {
	    window = (Window)SvUV(ST(3));
	}
#line 1205 "./rxvtperl.xs"
	XUngrabKey (THIS->dpy, keycode, modifiers, window);
#line 1454 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_grab); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_grab)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::grab", "THIS, eventtime, sync= 0");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	RETVAL;
	Time	eventtime = (Time)SvUV(ST(1));
	int	sync;

	if (items < 3)
	    sync = 0;
	else {
	    sync = (int)SvIV(ST(2));
	}
#line 1210 "./rxvtperl.xs"
{
        int mode = sync ? GrabModeSync : GrabModeAsync;

        THIS->perl.grabtime = 0;

        if (!XGrabPointer (THIS->dpy, THIS->vt, 0,
                           ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
                           mode, mode, None, GRAB_CURSOR, eventtime))
          if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime))
            THIS->perl.grabtime = eventtime;
          else
            XUngrabPointer (THIS->dpy, eventtime);

        RETVAL = !!THIS->perl.grabtime;
}
#line 1498 "./rxvtperl.c"
	ST(0) = boolSV(RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_allow_events_async); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_allow_events_async)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::allow_events_async", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
#line 1231 "./rxvtperl.xs"
        XAllowEvents (THIS->dpy, AsyncBoth,      THIS->perl.grabtime);
#line 1521 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_allow_events_sync); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_allow_events_sync)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::allow_events_sync", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
#line 1236 "./rxvtperl.xs"
        XAllowEvents (THIS->dpy, SyncBoth,       THIS->perl.grabtime);
#line 1542 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_allow_events_replay); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_allow_events_replay)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::allow_events_replay", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
#line 1241 "./rxvtperl.xs"
        XAllowEvents (THIS->dpy, ReplayPointer,  THIS->perl.grabtime);
        XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime);
#line 1564 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_ungrab); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ungrab)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::ungrab", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
#line 1247 "./rxvtperl.xs"
        ungrab (THIS);
#line 1585 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XStringToKeysym); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XStringToKeysym)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XStringToKeysym", "THIS, string");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	char *	string = (char *)SvPV_nolen(ST(1));
#line 1252 "./rxvtperl.xs"
        RETVAL = XStringToKeysym (string);
#line 1609 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XKeysymToString); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XKeysymToString)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XKeysymToString", "THIS, sym");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	char *	RETVAL;
	dXSTARG;
	int	sym = (int)SvIV(ST(1));
#line 1258 "./rxvtperl.xs"
        RETVAL = XKeysymToString (sym);
#line 1634 "./rxvtperl.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XKeysymToKeycode); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XKeysymToKeycode)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XKeysymToKeycode", "THIS, sym");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	sym = (int)SvIV(ST(1));
#line 1264 "./rxvtperl.xs"
        RETVAL = XKeysymToKeycode (THIS->dpy, sym);
#line 1659 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XKeycodeToKeysym); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XKeycodeToKeysym)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XKeycodeToKeysym", "THIS, code, index");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	code = (int)SvIV(ST(1));
	int	index = (int)SvIV(ST(2));
#line 1270 "./rxvtperl.xs"
        RETVAL = XKeycodeToKeysym (THIS->dpy, code, index);
#line 1685 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_strwidth); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_strwidth)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::strwidth", "THIS, str");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	SV *	str = ST(1);
#line 1276 "./rxvtperl.xs"
{
        wchar_t *wstr = sv2wcs (str);

	rxvt_push_locale (THIS->locale);
        RETVAL = 0;
        for (wchar_t *wc = wstr; *wc; wc++)
          {
            int w = WCWIDTH (*wc);

            if (w)
              RETVAL += max (w, 1);
          }
        rxvt_pop_locale ();

        free (wstr);
}
#line 1725 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_locale_encode); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_locale_encode)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::locale_encode", "THIS, str");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	RETVAL;
	SV *	str = ST(1);
#line 1298 "./rxvtperl.xs"
{
        wchar_t *wstr = sv2wcs (str);

	rxvt_push_locale (THIS->locale);
        char *mbstr = rxvt_wcstombs (wstr);
        rxvt_pop_locale ();

        free (wstr);

        RETVAL = newSVpv (mbstr, 0);
        free (mbstr);
}
#line 1760 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_locale_decode); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_locale_decode)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::locale_decode", "THIS, octets");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	RETVAL;
	SV *	octets = ST(1);
#line 1316 "./rxvtperl.xs"
{
	STRLEN len;
        char *data = SvPVbyte (octets, len);

	rxvt_push_locale (THIS->locale);
        wchar_t *wstr = rxvt_mbstowcs (data, len);
        rxvt_pop_locale ();

        RETVAL = wcs2sv (wstr);
        free (wstr);
}
#line 1795 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
#define TERM_OFFSET_width       TERM_OFFSET(width)
#define TERM_OFFSET_height      TERM_OFFSET(height)
#define TERM_OFFSET_fwidth      TERM_OFFSET(fwidth)
#define TERM_OFFSET_fheight     TERM_OFFSET(fheight)
#define TERM_OFFSET_fbase       TERM_OFFSET(fbase)
#define TERM_OFFSET_nrow        TERM_OFFSET(nrow)
#define TERM_OFFSET_ncol        TERM_OFFSET(ncol)
#define TERM_OFFSET_focus       TERM_OFFSET(focus)
#define TERM_OFFSET_mapped      TERM_OFFSET(mapped)
#define TERM_OFFSET_int_bwidth  TERM_OFFSET(int_bwidth)
#define TERM_OFFSET_ext_bwidth  TERM_OFFSET(ext_bwidth)
#define TERM_OFFSET_lineSpace   TERM_OFFSET(lineSpace)
#define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace)
#define TERM_OFFSET_saveLines   TERM_OFFSET(saveLines)
#define TERM_OFFSET_total_rows  TERM_OFFSET(total_rows)
#define TERM_OFFSET_top_row     TERM_OFFSET(top_row)

XS(XS_urxvt__term_width); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_width)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
#line 1369 "./rxvtperl.xs"
        RETVAL = *(int *)((char *)THIS + ix);
#line 1838 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_ModLevel3Mask); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ModLevel3Mask)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	unsigned int	RETVAL;
	dXSTARG;
#line 1382 "./rxvtperl.xs"
        switch (ix)
          {
            case 0: RETVAL = THIS->ModLevel3Mask;  break;
            case 1: RETVAL = THIS->ModMetaMask;    break;
            case 2: RETVAL = THIS->ModNumLockMask; break;
            case 3: RETVAL = THIS->current_screen; break;
#ifdef CURSOR_BLINK
            case 4: RETVAL = THIS->hidden_cursor;  break;
#endif
          }
#line 1872 "./rxvtperl.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_display_id); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_display_id)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	char *	RETVAL;
	dXSTARG;
#line 1401 "./rxvtperl.xs"
        switch (ix)
          {
            case 0: RETVAL = THIS->display->id; break;
            case 1: RETVAL = THIS->locale;      break;
          }
#line 1901 "./rxvtperl.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_envv); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_envv)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	RETVAL;
#line 1414 "./rxvtperl.xs"
{
	stringvec *vec = ix ? THIS->argv : THIS->envv;

        EXTEND (SP, vec->size ());

        for (char **i = vec->begin (); i != vec->end (); ++i)
          if (*i)
            PUSHs (sv_2mortal (newSVpv (*i, 0)));
}
#line 1935 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_pty_ev_events); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_pty_ev_events)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::pty_ev_events", "THIS, events= ev::UNDEF");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	events;

	if (items < 2)
	    events = ev::UNDEF;
	else {
	    events = (int)SvIV(ST(1));
	}
#line 1427 "./rxvtperl.xs"
        RETVAL = THIS->pty_ev.events;
        if (events != ev::UNDEF)
          THIS->pty_ev.set (events);
#line 1968 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_pty_fd); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_pty_fd)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::pty_fd", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
#line 1436 "./rxvtperl.xs"
        RETVAL = THIS->pty->pty;
#line 1992 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_parent); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_parent)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::parent", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	RETVAL;
	dXSTARG;
#line 1443 "./rxvtperl.xs"
        RETVAL = THIS->parent;
#line 2016 "./rxvtperl.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_parent_x); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_parent_x)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::parent_x", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
#line 1450 "./rxvtperl.xs"
        RETVAL = THIS->parent_x;
#line 2040 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_parent_y); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_parent_y)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::parent_y", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
#line 1457 "./rxvtperl.xs"
        RETVAL = THIS->parent_y;
#line 2064 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_vt); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_vt)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::vt", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	RETVAL;
	dXSTARG;
#line 1464 "./rxvtperl.xs"
        RETVAL = THIS->vt;
#line 2088 "./rxvtperl.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_vt_emask_add); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_vt_emask_add)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::vt_emask_add", "THIS, emask");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	U32	emask = (unsigned long)SvUV(ST(1));
#line 1471 "./rxvtperl.xs"
        THIS->vt_emask_perl |= emask;
        THIS->vt_select_input ();
#line 2112 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_rstyle); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_rstyle)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::rstyle", "THIS, new_rstyle= THIS->rstyle");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	U32	RETVAL;
	dXSTARG;
	U32	new_rstyle;

	if (items < 2)
	    new_rstyle = THIS->rstyle;
	else {
	    new_rstyle = (unsigned long)SvUV(ST(1));
	}
#line 1477 "./rxvtperl.xs"
        RETVAL = THIS->rstyle;
        THIS->rstyle = new_rstyle;
#line 2143 "./rxvtperl.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_view_start); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_view_start)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::view_start", "THIS, newval= 1");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	newval;

	if (items < 2)
	    newval = 1;
	else {
	    newval = (int)SvIV(ST(1));
	}
#line 1486 "./rxvtperl.xs"
{
        RETVAL = THIS->view_start;

        if (newval <= 0)
          THIS->scr_changeview (max (newval, THIS->top_row));
}
#line 2179 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_set_urgency); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_set_urgency)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::set_urgency", "THIS, enable");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	enable = (bool)SvTRUE(ST(1));

	THIS->set_urgency(enable);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_focus_in); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_focus_in)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::focus_in", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));

	THIS->focus_in();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_focus_out); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_focus_out)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::focus_out", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));

	THIS->focus_out();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_key_press); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_key_press)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items < 3 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS, state, keycode, time= CurrentTime");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	unsigned int	state = (unsigned int)SvUV(ST(1));
	unsigned int	keycode = (unsigned int)SvUV(ST(2));
	Time	time;

	if (items < 4)
	    time = CurrentTime;
	else {
	    time = (Time)SvUV(ST(3));
	}
#line 1509 "./rxvtperl.xs"
{
        XKeyEvent xkey;

        memset (&xkey, 0, sizeof (xkey));

        xkey.time      = time;
        xkey.state     = state;
        xkey.keycode   = keycode;

        xkey.type      = ix ? KeyRelease : KeyPress;
        xkey.display   = THIS->dpy;
        xkey.window    = THIS->vt;
        xkey.root      = THIS->display->root;
        xkey.subwindow = THIS->vt;

        if (ix)
          THIS->key_release (xkey);
        else
          THIS->key_press (xkey);
}
#line 2291 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_want_refresh); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_want_refresh)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::want_refresh", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
#line 1533 "./rxvtperl.xs"
        THIS->want_refresh = 1;
	THIS->refresh_check ();
#line 2313 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_ROW_t); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ROW_t)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::ROW_t", "THIS, row_number, new_text= 0, start_col= 0, start_ofs= 0, max_len= MAX_COLS");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	row_number = (int)SvIV(ST(1));
	SV *	new_text;
	int	start_col;
	int	start_ofs;
	int	max_len;

	if (items < 3)
	    new_text = 0;
	else {
	    new_text = ST(2);
	}

	if (items < 4)
	    start_col = 0;
	else {
	    start_col = (int)SvIV(ST(3));
	}

	if (items < 5)
	    start_ofs = 0;
	else {
	    start_ofs = (int)SvIV(ST(4));
	}

	if (items < 6)
	    max_len = MAX_COLS;
	else {
	    max_len = (int)SvIV(ST(5));
	}
#line 1539 "./rxvtperl.xs"
{
        if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
          XSRETURN_EMPTY;

        line_t &l = ROW(row_number);

        if (GIMME_V != G_VOID)
          {
            wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol);

            for (int col = 0; col < THIS->ncol; col++)
              wstr [col] = l.t [col];

            XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
          }

        if (new_text)
          {
            wchar_t *wstr = sv2wcs (new_text);

            int len = min (wcslen (wstr) - start_ofs, max_len);

            if (start_col < 0 || start_col + len > THIS->ncol)
              {
                free (wstr);
                croak ("new_text extends beyond horizontal margins");
              }

            for (int col = start_col; col < start_col + len; col++)
              {
                l.t [col] = wstr [start_ofs + col - start_col];
                l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col]));
              }

            free (wstr);
          }
}
#line 2401 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_ROW_r); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ROW_r)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::ROW_r", "THIS, row_number, new_rend= 0, start_col= 0, start_ofs= 0, max_len= MAX_COLS");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	row_number = (int)SvIV(ST(1));
	SV *	new_rend;
	int	start_col;
	int	start_ofs;
	int	max_len;

	if (items < 3)
	    new_rend = 0;
	else {
	    new_rend = ST(2);
	}

	if (items < 4)
	    start_col = 0;
	else {
	    start_col = (int)SvIV(ST(3));
	}

	if (items < 5)
	    start_ofs = 0;
	else {
	    start_ofs = (int)SvIV(ST(4));
	}

	if (items < 6)
	    max_len = MAX_COLS;
	else {
	    max_len = (int)SvIV(ST(5));
	}
#line 1580 "./rxvtperl.xs"
{
        if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
          XSRETURN_EMPTY;

        line_t &l = ROW(row_number);

        if (GIMME_V != G_VOID)
          {
            AV *av = newAV ();

            av_extend (av, THIS->ncol - 1);
            for (int col = 0; col < THIS->ncol; col++)
              av_store (av, col, newSViv (l.r [col]));

            XPUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
          }

        if (new_rend)
          {
            if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
              croak ("new_rend must be arrayref");

            AV *av = (AV *)SvRV (new_rend);
            int len = min (AvFILL (av) + 1 - start_ofs, max_len);

            if (start_col < 0 || start_col + len > THIS->ncol)
              croak ("new_rend array extends beyond horizontal margins");

            for (int col = start_col; col < start_col + len; col++)
              {
                rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask;

                l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col]));
              }
          }
}
#line 2489 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_ROW_l); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ROW_l)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::ROW_l", "THIS, row_number, new_length= -1");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	row_number = (int)SvIV(ST(1));
	int	new_length;

	if (items < 3)
	    new_length = -1;
	else {
	    new_length = (int)SvIV(ST(2));
	}
#line 1620 "./rxvtperl.xs"
{
        if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
          XSRETURN_EMPTY;

        line_t &l = ROW(row_number);
        RETVAL = l.l;

        if (new_length >= 0)
          l.l = new_length;
}
#line 2530 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_ROW_is_longer); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_ROW_is_longer)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::ROW_is_longer", "THIS, row_number, new_is_longer= -1");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	RETVAL;
	int	row_number = (int)SvIV(ST(1));
	int	new_is_longer;

	if (items < 3)
	    new_is_longer = -1;
	else {
	    new_is_longer = (int)SvIV(ST(2));
	}
#line 1636 "./rxvtperl.xs"
{
        if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
          XSRETURN_EMPTY;

        line_t &l = ROW(row_number);
        RETVAL = l.is_longer ();

        if (new_is_longer >= 0)
          l.is_longer (new_is_longer);
}
#line 2570 "./rxvtperl.c"
	ST(0) = boolSV(RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_special_encode); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_special_encode)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::special_encode", "THIS, string");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	RETVAL;
	SV *	string = ST(1);
#line 1652 "./rxvtperl.xs"
{
        wchar_t *wstr = sv2wcs (string);
        int wlen = wcslen (wstr);
        wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer

	rxvt_push_locale (THIS->locale);

        wchar_t *r = rstr;
        for (wchar_t *s = wstr; *s; s++)
          {
            int w = WCWIDTH (*s);

            if (w == 0)
              {
                if (r == rstr)
                  croak ("leading combining character unencodable");

                unicode_t n = rxvt_compose (r[-1], *s);
                if (n == NOCHAR)
                  n = rxvt_composite.compose (r[-1], *s);

                r[-1] = n;
              }
#if !UNICODE_3
            else if (*s >= 0x10000)
              *r++ = rxvt_composite.compose (*s);
#endif
            else
              *r++ = *s;

            // the *2 above only allows wcwidth <= 2
            if (w > 1)
              *r++ = NOCHAR;
          }

	rxvt_pop_locale ();

        RETVAL = wcs2sv (rstr, r - rstr);
}
#line 2633 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_special_decode); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_special_decode)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::special_decode", "THIS, text");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	RETVAL;
	SV *	text = ST(1);
#line 1697 "./rxvtperl.xs"
{
        wchar_t *wstr = sv2wcs (text);
        int dlen = 0;

        // find length
        for (wchar_t *s = wstr; *s; s++)
          if (*s == NOCHAR)
            ;
          else if (IS_COMPOSE (*s))
            dlen += rxvt_composite.expand (*s, 0);
          else
            dlen++;

        wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen);

        // decode
        wchar_t *r = rstr;
        for (wchar_t *s = wstr; *s; s++)
          if (*s == NOCHAR)
            ;
          else if (IS_COMPOSE (*s))
            r += rxvt_composite.expand (*s, r);
          else
            *r++ = *s;

        RETVAL = wcs2sv (rstr, r - rstr);
}
#line 2684 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term__resource); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term__resource)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::_resource", "THIS, name, index, newval= 0");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	char *	name = (char *)SvPV_nolen(ST(1));
	int	index = (int)SvIV(ST(2));
	SV *	newval;

	if (items < 4)
	    newval = 0;
	else {
	    newval = ST(3);
	}
#line 1730 "./rxvtperl.xs"
{
	static const struct resval { const char *name; int value; } *rs, rslist [] = {
#	  define def(name) { # name, Rs_ ## name },
#	  define reserve(name,count)
#	  include "rsinc.h"
#	  undef def
#	  undef reserve
        };

        rs = rslist + ecb_array_length (rslist);

        if (*name)
          {
            do {
              if (rs-- == rslist)
                croak ("no such resource '%s', requested", name);
            } while (strcmp (name, rs->name));

            index += rs->value;
          }
        else
          {
            --rs;
            name = "";
          }

        if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
          croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);

        if (GIMME_V != G_VOID)
          XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef);

        if (newval)
          {
            if (SvOK (newval))
              {
                char *str = strdup (SvPVbyte_nolen (newval));
                THIS->rs [index] = str;
                THIS->allocated.push_back (str);
              }
            else
              THIS->rs [index] = 0;
          }
}
#line 2761 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_x_resource); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_x_resource)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::x_resource", "THIS, name");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	const char *	RETVAL;
	dXSTARG;
	const char *	name = (const char *)SvPV_nolen(ST(1));

	RETVAL = THIS->x_resource(name);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_option); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_option)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::option", "THIS, optval, set= -1");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	RETVAL;
	U8	optval = (U8)SvUV(ST(1));
	int	set;

	if (items < 3)
	    set = -1;
	else {
	    set = (int)SvIV(ST(2));
	}
#line 1781 "./rxvtperl.xs"
{
	RETVAL = THIS->option (optval);

        if (set >= 0)
          {
            THIS->set_option (optval, set);

            if (THIS->init_done) // avoid doing this before START
              switch (optval)
                {
                  case Opt_skipBuiltinGlyphs:
                    THIS->set_fonts ();
                    THIS->scr_remap_chars ();
                    THIS->scr_touch (true);
                    THIS->want_refresh = 1;
                    THIS->refresh_check ();
                    break;
#ifdef CURSOR_BLINK
                  case Opt_cursorBlink:
                    THIS->cursor_blink_reset ();
                    break;
#endif

                  case Opt_cursorUnderline:
                    THIS->want_refresh = 1;
                    THIS->refresh_check ();
                    break;

                }
          }
}
#line 2846 "./rxvtperl.c"
	ST(0) = boolSV(RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_parse_keysym); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_parse_keysym)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::parse_keysym", "THIS, keysym, str");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	RETVAL;
	char *	keysym = (char *)SvPV_nolen(ST(1));
	char *	str = (char *)SvPV_nolen(ST(2));
#line 1822 "./rxvtperl.xs"
        RETVAL = 0 < THIS->parse_keysym (keysym, str);
        THIS->keyboard->register_done ();
#line 2873 "./rxvtperl.c"
	ST(0) = boolSV(RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_register_command); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_register_command)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::register_command", "THIS, keysym, state, str");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	keysym = (int)SvIV(ST(1));
	unsigned int	state = (unsigned int)SvUV(ST(2));
	SV *	str = ST(3);
#line 1830 "./rxvtperl.xs"
        wchar_t *wstr = sv2wcs (str);
        THIS->keyboard->register_user_translation (keysym, state, wstr);
        free (wstr);
#line 2901 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_screen_cur); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_screen_cur)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items < 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS, ...");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
#line 1843 "./rxvtperl.xs"
{
        row_col_t &rc = ix == 0 ? THIS->screen.cur
                      : ix == 1 ? THIS->selection.beg
                      : ix == 2 ? THIS->selection.end
                      :           THIS->selection.mark;

        if (GIMME_V != G_VOID)
          {
            EXTEND (SP, 2);
            PUSHs (sv_2mortal (newSViv (rc.row)));
            PUSHs (sv_2mortal (newSViv (rc.col)));
          }

        if (items >= 3)
          {
            rc.row = SvIV (ST (1));
            rc.col = SvIV (ST (2));

            if (ix == 2)
              {
                if (rc.col == 0)
                  {
                    // col == 0 means end of previous line
                    rc.row--;
                    rc.col = THIS->ncol;
                  }
                else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow)
                         && rc.col > ROW(rc.row).l)
                  {
                    // col >= length means while line and add newline
                    rc.col = THIS->ncol;
                  }
              }

            clamp_it (rc.col, 0, THIS->ncol);
            clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);

            if (ix)
              {
                THIS->selection.screen = THIS->current_screen;

                THIS->selection_changed ();
                THIS->refresh_check ();
              }
          }
}
#line 2970 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_selection_screen); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_selection_screen)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::selection_screen", "THIS, screen= -1");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	int	screen;

	if (items < 2)
	    screen = -1;
	else {
	    screen = (int)SvIV(ST(1));
	}
#line 1893 "./rxvtperl.xs"
        RETVAL = THIS->selection.screen;
        if (screen >= 0)
          THIS->selection.screen = screen;
#line 3003 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_selection_request); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_selection_request)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::selection_request", "THIS, tm, selnum");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Time	tm = (Time)SvUV(ST(1));
	int	selnum = (int)SvIV(ST(2));

	THIS->selection_request(tm, selnum);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_selection_clear); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_selection_clear)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::selection_clear", "THIS, clipboard= false");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	clipboard;

	if (items < 2)
	    clipboard = false;
	else {
	    clipboard = (bool)SvTRUE(ST(1));
	}

	THIS->selection_clear(clipboard);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_selection_make); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_selection_make)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::selection_make", "THIS, eventtime, rect= false");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Time	eventtime = (Time)SvUV(ST(1));
	bool	rect;

	if (items < 3)
	    rect = false;
	else {
	    rect = (bool)SvTRUE(ST(2));
	}
#line 1908 "./rxvtperl.xs"
        THIS->selection.op = SELECTION_CONT;
        THIS->selection.rect = rect;
        THIS->selection_make (eventtime);
#line 3084 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_selection_grab); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_selection_grab)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::selection_grab", "THIS, eventtime, clipboard= false");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	RETVAL;
	dXSTARG;
	Time	eventtime = (Time)SvUV(ST(1));
	bool	clipboard;

	if (items < 3)
	    clipboard = false;
	else {
	    clipboard = (bool)SvTRUE(ST(2));
	}

	RETVAL = THIS->selection_grab(eventtime, clipboard);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_selection); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_selection)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::selection", "THIS, newtext= 0, clipboard= false");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	newtext;
	bool	clipboard;

	if (items < 2)
	    newtext = 0;
	else {
	    newtext = ST(1);
	}

	if (items < 3)
	    clipboard = false;
	else {
	    clipboard = (bool)SvTRUE(ST(2));
	}
#line 1918 "./rxvtperl.xs"
{
        wchar_t * &text   = clipboard ? THIS->selection.clip_text : THIS->selection.text;
        unsigned int &len = clipboard ? THIS->selection.clip_len  : THIS->selection.len;

        if (GIMME_V != G_VOID)
          XPUSHs (text
                  ? sv_2mortal (wcs2sv (text, len))
                  : &PL_sv_undef);

        if (newtext)
          {
            free (text);

            text = sv2wcs (newtext);
            len = wcslen (text);
          }
}
#line 3168 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_cur_charset); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_cur_charset)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::cur_charset", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	char	RETVAL;
	dXSTARG;
#line 1939 "./rxvtperl.xs"
        RETVAL = THIS->charsets [THIS->screen.charset];
#line 3192 "./rxvtperl.c"
	XSprePUSH; PUSHp((char *)&RETVAL, 1);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_scr_xor_rect); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_scr_xor_rect)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 5 || items > 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::scr_xor_rect", "THIS, beg_row, beg_col, end_row, end_col, rstyle1= RS_RVid, rstyle2= RS_RVid | RS_Uline");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	beg_row = (int)SvIV(ST(1));
	int	beg_col = (int)SvIV(ST(2));
	int	end_row = (int)SvIV(ST(3));
	int	end_col = (int)SvIV(ST(4));
	U32	rstyle1;
	U32	rstyle2;

	if (items < 6)
	    rstyle1 = RS_RVid;
	else {
	    rstyle1 = (unsigned long)SvUV(ST(5));
	}

	if (items < 7)
	    rstyle2 = RS_RVid | RS_Uline;
	else {
	    rstyle2 = (unsigned long)SvUV(ST(6));
	}

	THIS->scr_xor_rect(beg_row, beg_col, end_row, end_col, rstyle1, rstyle2);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_scr_xor_span); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_scr_xor_span)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 5 || items > 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::scr_xor_span", "THIS, beg_row, beg_col, end_row, end_col, rstyle= RS_RVid");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	beg_row = (int)SvIV(ST(1));
	int	beg_col = (int)SvIV(ST(2));
	int	end_row = (int)SvIV(ST(3));
	int	end_col = (int)SvIV(ST(4));
	U32	rstyle;

	if (items < 6)
	    rstyle = RS_RVid;
	else {
	    rstyle = (unsigned long)SvUV(ST(5));
	}

	THIS->scr_xor_span(beg_row, beg_col, end_row, end_col, rstyle);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_scr_bell); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_scr_bell)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::scr_bell", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));

	THIS->scr_bell();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_scr_recolour); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_scr_recolour)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::scr_recolour", "THIS, refresh= true");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	refresh;

	if (items < 2)
	    refresh = true;
	else {
	    refresh = (bool)SvTRUE(ST(1));
	}

	THIS->scr_recolour(refresh);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_scr_change_screen); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_scr_change_screen)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::scr_change_screen", "THIS, screen");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	int	screen = (int)SvIV(ST(1));

	THIS->scr_change_screen(screen);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_scr_add_lines); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_scr_add_lines)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::scr_add_lines", "THIS, string");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	string = ST(1);
#line 1961 "./rxvtperl.xs"
{
        wchar_t *wstr = sv2wcs (string);
        THIS->scr_add_lines (wstr, wcslen (wstr));
        free (wstr);
}
#line 3356 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_tt_write); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_tt_write)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::tt_write", "THIS, octets");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	octets = ST(1);
#line 1970 "./rxvtperl.xs"
          STRLEN len;
          char *str = SvPVbyte (octets, len);
#line 3379 "./rxvtperl.c"

	THIS->tt_write(str, len);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_tt_paste); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_tt_paste)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::tt_paste", "THIS, octets");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	octets = ST(1);
#line 1978 "./rxvtperl.xs"
        STRLEN len;
        char *str = SvPVbyte (octets, len);
#line 3404 "./rxvtperl.c"

	THIS->tt_paste(str, len);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_cmd_parse); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_cmd_parse)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::cmd_parse", "THIS, octets");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	octets = ST(1);
#line 1986 "./rxvtperl.xs"
{
	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;

	rxvt_push_locale (THIS->locale);
        THIS->cmd_parse ();
	rxvt_pop_locale ();

        THIS->cmdbuf_ptr  = old_cmdbuf_ptr;
        THIS->cmdbuf_endp = old_cmdbuf_endp;
}
#line 3444 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_overlay); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_overlay)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 5 || items > 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::overlay", "THIS, x, y, w, h, rstyle= OVERLAY_RSTYLE, border= 2");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	SV *	RETVAL;
	int	x = (int)SvIV(ST(1));
	int	y = (int)SvIV(ST(2));
	int	w = (int)SvIV(ST(3));
	int	h = (int)SvIV(ST(4));
	int	rstyle;
	int	border;

	if (items < 6)
	    rstyle = OVERLAY_RSTYLE;
	else {
	    rstyle = (int)SvIV(ST(5));
	}

	if (items < 7)
	    border = 2;
	else {
	    border = (int)SvIV(ST(6));
	}
#line 2007 "./rxvtperl.xs"
{
        overlay *o = new overlay (THIS, x, y, w, h, rstyle, border);
        RETVAL = newSVptr ((void *)o, "urxvt::overlay");
        o->self = (HV *)SvRV (RETVAL);
}
#line 3488 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XListProperties); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XListProperties)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XListProperties", "THIS, window");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
#line 2022 "./rxvtperl.xs"
{
	int count;
	Atom *props = XListProperties (THIS->dpy, window, &count);

        EXTEND (SP, count);
        while (count--)
          PUSHs (newSVuv ((U32)props [count]));

        XFree (props);
}
#line 3523 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_XGetWindowProperty); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XGetWindowProperty)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XGetWindowProperty", "THIS, window, property");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
	Atom	property = (Atom)SvUV(ST(2));
#line 2036 "./rxvtperl.xs"
{
        Atom type;
        int format;
        unsigned long nitems;
        unsigned long bytes_after;
        unsigned char *prop;

	XGetWindowProperty (THIS->dpy, window, property,
                            0, 1<<24, 0, AnyPropertyType,
                            &type, &format, &nitems, &bytes_after, &prop);

        if (type != None)
          {
            int elemsize = format == 16 ? sizeof (short)
                         : format == 32 ? sizeof (long)
                         :                1;

            EXTEND (SP, 3);
            PUSHs (newSVuv ((U32)type));
            PUSHs (newSViv (format));
            PUSHs (newSVpvn ((char *)prop, nitems * elemsize));
            XFree (prop);
          }
}
#line 3572 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_XChangeProperty); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XChangeProperty)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XChangeProperty", "THIS, window, property, type, format, data");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
	Atom	property = (Atom)SvUV(ST(2));
	Atom	type = (Atom)SvUV(ST(3));
	int	format = (int)SvIV(ST(4));
	SV *	data = ST(5);
#line 2064 "./rxvtperl.xs"
{
	STRLEN len;
        char *data_ = SvPVbyte (data, len);

        int elemsize = format == 16 ? sizeof (short)
                     : format == 32 ? sizeof (long)
                     :                1;

	XChangeProperty (THIS->dpy, window, property,
                         type, format, PropModeReplace,
                         (unsigned char *)data_, len / elemsize);
}
#line 3610 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XInternAtom); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XInternAtom)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XInternAtom", "term, atom_name, only_if_exists= FALSE");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	Atom	RETVAL;
	dXSTARG;
	rxvt_term *	term = SvTERM (ST(0));
	octet_string        atom_name = SvPVbyte_nolen (ST(1));
	int	only_if_exists;

	if (items < 3)
	    only_if_exists = FALSE;
	else {
	    only_if_exists = (int)SvIV(ST(2));
	}

	RETVAL = XInternAtom(term->dpy, atom_name, only_if_exists);
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XGetAtomName); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XGetAtomName)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XGetAtomName", "term, atom");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	RETVAL;
	dXSTARG;
	rxvt_term *	term = SvTERM (ST(0));
	Atom	atom = (Atom)SvUV(ST(1));

	RETVAL = XGetAtomName(term->dpy, atom);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
#line 2085 "./rxvtperl.xs"
        XFree (RETVAL);
#line 3668 "./rxvtperl.c"
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_XDeleteProperty); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XDeleteProperty)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XDeleteProperty", "term, window, property");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	term = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
	Atom	property = (Atom)SvUV(ST(2));

	XDeleteProperty(term->dpy, window, property);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_DefaultRootWindow); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_DefaultRootWindow)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::DefaultRootWindow", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	RETVAL;
	dXSTARG;
#line 2094 "./rxvtperl.xs"
        RETVAL = THIS->display->root;
#line 3713 "./rxvtperl.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}

#if 0
#define XSubPPtmpAAAA 1


XS(XS_urxvt__term_XCreateSimpleWindow); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XCreateSimpleWindow)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XCreateSimpleWindow", "term, parent, x, y, width, height");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	Window	RETVAL;
	dXSTARG;
	rxvt_term *	term = SvTERM (ST(0));
	Window	parent = (Window)SvUV(ST(1));
	int	x = (int)SvIV(ST(2));
	int	y = (int)SvIV(ST(3));
	unsigned int	width = (unsigned int)SvUV(ST(4));
	unsigned int	height = (unsigned int)SvUV(ST(5));

	RETVAL = XCreateSimpleWindow(term->dpy, (Window)parent,
                x, y, width, height, 0,
                term->pix_colors_focused[Color_border],
                term->pix_colors_focused[Color_border]);
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_urxvt__term_XReparentWindow); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XReparentWindow)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XReparentWindow", "term, window, parent, x= 0, y= 0");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	term = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
	Window	parent = (Window)SvUV(ST(2));
	int	x;
	int	y;

	if (items < 4)
	    x = 0;
	else {
	    x = (int)SvIV(ST(3));
	}

	if (items < 5)
	    y = 0;
	else {
	    y = (int)SvIV(ST(4));
	}

	XReparentWindow(term->dpy, window, parent, x, y);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XMapWindow); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XMapWindow)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XMapWindow", "term, window");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	term = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));

	XMapWindow(term->dpy, window);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XUnmapWindow); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XUnmapWindow)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XUnmapWindow", "term, window");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	term = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));

	XUnmapWindow(term->dpy, window);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XMoveResizeWindow); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XMoveResizeWindow)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XMoveResizeWindow", "term, window, x, y, width, height");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	term = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
	int	x = (int)SvIV(ST(2));
	int	y = (int)SvIV(ST(3));
	unsigned int	width = (unsigned int)SvUV(ST(4));
	unsigned int	height = (unsigned int)SvUV(ST(5));

	XMoveResizeWindow(term->dpy, window, x, y, width, height);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XChangeInput); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XChangeInput)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 3 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XChangeInput", "THIS, window, add_events, del_events= 0");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	window = (Window)SvUV(ST(1));
	U32	add_events = (unsigned long)SvUV(ST(2));
	U32	del_events;

	if (items < 4)
	    del_events = 0;
	else {
	    del_events = (unsigned long)SvUV(ST(3));
	}
#line 2128 "./rxvtperl.xs"
{
	XWindowAttributes attr;
        XGetWindowAttributes (THIS->dpy, window, &attr);
        XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events);
}
#line 3886 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__term_XTranslateCoordinates); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_XTranslateCoordinates)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::XTranslateCoordinates", "THIS, src, dst, x, y");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	Window	src = (Window)SvUV(ST(1));
	Window	dst = (Window)SvUV(ST(2));
	int	x = (int)SvIV(ST(3));
	int	y = (int)SvIV(ST(4));
#line 2137 "./rxvtperl.xs"
{
        int dx, dy;
        Window child;

        if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child))
          {
            EXTEND (SP, 3);
            PUSHs (newSViv (dx));
            PUSHs (newSViv (dy));
            PUSHs (newSVuv (child));
          }
}
#line 3924 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__term_has_render); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_has_render)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::has_render", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	RETVAL;
#line 2156 "./rxvtperl.xs"
        RETVAL = THIS->display->flags & DISPLAY_HAS_RENDER;
#line 3947 "./rxvtperl.c"
	ST(0) = boolSV(RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__term_background_geometry); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_background_geometry)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::background_geometry", "THIS, border= false");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	bool	border;

	if (items < 2)
	    border = false;
	else {
	    border = (bool)SvTRUE(ST(1));
	}
#line 2163 "./rxvtperl.xs"
	EXTEND (SP, 4);
        PUSHs (sv_2mortal (newSViv (THIS->parent_x + (border ? THIS->window_vt_x : 0))));
        PUSHs (sv_2mortal (newSViv (THIS->parent_y + (border ? THIS->window_vt_y : 0))));
        PUSHs (sv_2mortal (newSViv (border ? THIS->vt_width  : THIS->szHint.width )));
        PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height)));
#line 3983 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}

#if HAVE_IMG
#define XSubPPtmpAAAB 1


XS(XS_urxvt__term_new_img); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_new_img)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::new_img", "THIS, format= &PL_sv_undef, x= 0, y= 0, width= 1, height= 1");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	rxvt_img *	RETVAL;
	SV *	format;
	int	x;
	int	y;
	int	width;
	int	height;

	if (items < 2)
	    format = &PL_sv_undef;
	else {
	    format = ST(1);
	}

	if (items < 3)
	    x = 0;
	else {
	    x = (int)SvIV(ST(2));
	}

	if (items < 4)
	    y = 0;
	else {
	    y = (int)SvIV(ST(3));
	}

	if (items < 5)
	    width = 1;
	else {
	    width = (int)SvIV(ST(4));
	}

	if (items < 6)
	    height = 1;
	else {
	    height = (int)SvIV(ST(5));
	}
#line 2174 "./rxvtperl.xs"
        XRenderPictFormat *f = SvOK (format)
                             ? XRenderFindStandardFormat (THIS->dpy, SvIV (format))
                             : XRenderFindVisualFormat   (THIS->dpy, THIS->visual);
        RETVAL = new rxvt_img (THIS, f, x, y, width, height);
        RETVAL->alloc ();
#line 4048 "./rxvtperl.c"
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}

#if ENABLE_TRANSPARENCY
#define XSubPPtmpAAAC 1


XS(XS_urxvt__term_new_img_from_root); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_new_img_from_root)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::new_img_from_root", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	rxvt_img *	RETVAL;
#line 2187 "./rxvtperl.xs"
        RETVAL = rxvt_img::new_from_root (THIS);
#line 4076 "./rxvtperl.c"
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}

#endif
#if HAVE_PIXBUF
#define XSubPPtmpAAAD 1


XS(XS_urxvt__term_new_img_from_file); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_new_img_from_file)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::new_img_from_file", "THIS, filename");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	rxvt_img *	RETVAL;
	octet_string        filename = SvPVbyte_nolen (ST(1));
#line 2198 "./rxvtperl.xs"
        try
          {
            RETVAL = rxvt_img::new_from_file (THIS, filename);
          }
        catch (const class rxvt_failure_exception &e)
          {
            croak ("new_img_from_file failed");
          }
#line 4113 "./rxvtperl.c"
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}

#endif

XS(XS_urxvt__term_set_background); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__term_set_background)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::term::set_background", "THIS, img, border= false");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_term *	THIS = SvTERM (ST(0));
	rxvt_img *	img;
	bool	border;

        if (SvROK (ST(1)) && sv_derived_from (ST(1), "urxvt::img"))
          img = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(1))));
        else
          croak ("%s is not of type urxvt::img", "img");

	if (items < 3)
	    border = false;
	else {
	    border = (bool)SvTRUE(ST(2));
	}
#line 2214 "./rxvtperl.xs"
        delete THIS->bg_img;
        THIS->bg_img = 0;
        THIS->bg_flags = 0;

        if (img) // TODO: cannot be false
          {
            img = img->clone (); // own the img

            if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap
              img->sub_rect (0, 0,
                             border ? THIS->vt_width  : THIS->szHint.width,
                             border ? THIS->vt_height : THIS->szHint.height)
                 ->replace (img);

            // just in case, should usually be a nop
            img->reify ()
               ->replace (img);

            img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg])
               ->replace (img);

            THIS->bg_img = img;
            THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER;

            if (!border)
              THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT;
          }
#line 4177 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}

#endif

XS(XS_urxvt__overlay_set); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__overlay_set)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 4 || items > 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::overlay::set", "THIS, x, y, text, rend= 0");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	overlay *	THIS = SvOVERLAY (ST(0));
	int	x = (int)SvIV(ST(1));
	int	y = (int)SvIV(ST(2));
	SV *	text = ST(3);
	SV *	rend;

	if (items < 5)
	    rend = 0;
	else {
	    rend = ST(4);
	}

	THIS->set(x, y, text, rend);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__overlay_show); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__overlay_show)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::overlay::show", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	overlay *	THIS = SvOVERLAY (ST(0));

	THIS->show();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__overlay_hide); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__overlay_hide)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::overlay::hide", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	overlay *	THIS = SvOVERLAY (ST(0));

	THIS->hide();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__overlay_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__overlay_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::overlay::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	overlay *	THIS = SvOVERLAY (ST(0));

	delete THIS;
    }
    XSRETURN_EMPTY;
}


/* INCLUDE:  Including '$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |' from 'rxvtperl.xs' */


XS(XS_urxvt__watcher_cb); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__watcher_cb)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::watcher::cb", "THIS, cb");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	perl_watcher *	THIS = SvWATCHER (ST(0));
	IOM_CHAINED	RETVAL;
	SV *	cb = ST(1);
#line 45 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->cb (cb);
#line 4294 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_new); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_new)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::new", "CLASS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	CLASS = (char *)SvPV_nolen(ST(0));
	SV *	RETVAL;
#line 58 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        timer *w =  new timer;
        w->start (0);
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::timer");
        w->self = (HV *)SvRV (RETVAL);
#line 4322 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_at); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_at)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::at", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));
	NV	RETVAL;
	dXSTARG;
#line 69 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        RETVAL = THIS->remaining () + ev_now ();
#line 4347 "./rxvtperl.c"
	XSprePUSH; PUSHn((NV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_interval); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_interval)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::interval", "THIS, repeat");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));
	IOM_CHAINED	RETVAL;
	NV	repeat = (NV)SvNV(ST(1));
#line 76 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->repeat = repeat;
#line 4371 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_set); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_set)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::set", "THIS, tstamp, repeat= THIS->repeat");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));
	IOM_CHAINED	RETVAL;
	NV	tstamp = (NV)SvNV(ST(1));
	NV	repeat;

	if (items < 3)
	    repeat = THIS->repeat;
	else {
	    repeat = (NV)SvNV(ST(2));
	}
#line 83 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->set (tstamp, repeat);
#line 4404 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_start); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_start)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::start", "THIS, tstamp= ev::now (), repeat= THIS->repeat");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));
	IOM_CHAINED	RETVAL;
	NV	tstamp;
	NV	repeat;

	if (items < 2)
	    tstamp = ev::now ();
	else {
	    tstamp = (NV)SvNV(ST(1));
	}

	if (items < 3)
	    repeat = THIS->repeat;
	else {
	    repeat = (NV)SvNV(ST(2));
	}
#line 90 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->start (tstamp - ev::now (), repeat);
#line 4443 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_after); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_after)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::after", "THIS, delay, repeat= THIS->repeat");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));
	IOM_CHAINED	RETVAL;
	NV	delay = (NV)SvNV(ST(1));
	NV	repeat;

	if (items < 3)
	    repeat = THIS->repeat;
	else {
	    repeat = (NV)SvNV(ST(2));
	}
#line 97 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->start (delay, repeat);
#line 4476 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_stop); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_stop)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::stop", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));
	IOM_CHAINED	RETVAL;
#line 104 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->stop ();
#line 4501 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__timer_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__timer_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::timer::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	timer *	THIS = SvTIMER (ST(0));

	delete THIS;
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__iow_new); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iow_new)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iow::new", "CLASS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	CLASS = (char *)SvPV_nolen(ST(0));
	SV *	RETVAL;
#line 120 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        iow *w =  new iow;
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::iow");
        w->self = (HV *)SvRV (RETVAL);
#line 4548 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iow_fd); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iow_fd)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iow::fd", "THIS, fd");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iow *	THIS = SvIOW (ST(0));
	IOM_CHAINED	RETVAL;
	int	fd = (int)SvIV(ST(1));
#line 129 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->fd = fd;
#line 4573 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iow_events); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iow_events)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iow::events", "THIS, events");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iow *	THIS = SvIOW (ST(0));
	IOM_CHAINED	RETVAL;
	short	events = (short)SvIV(ST(1));
#line 136 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->events = events;
#line 4599 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iow_start); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iow_start)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iow::start", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iow *	THIS = SvIOW (ST(0));
	IOM_CHAINED	RETVAL;
#line 143 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->start ();
#line 4624 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iow_stop); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iow_stop)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iow::stop", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iow *	THIS = SvIOW (ST(0));
	IOM_CHAINED	RETVAL;
#line 150 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->stop ();
#line 4649 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iow_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iow_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iow::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iow *	THIS = SvIOW (ST(0));

	delete THIS;
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__iw_new); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iw_new)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iw::new", "CLASS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	CLASS = (char *)SvPV_nolen(ST(0));
	SV *	RETVAL;
#line 166 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        iw *w =  new iw;
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::iw");
        w->self = (HV *)SvRV (RETVAL);
#line 4696 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iw_start); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iw_start)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iw::start", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iw *	THIS = SvIW (ST(0));
	IOM_CHAINED	RETVAL;
#line 175 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->start ();
#line 4720 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iw_stop); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iw_stop)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iw::stop", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iw *	THIS = SvIW (ST(0));
	IOM_CHAINED	RETVAL;
#line 182 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->stop ();
#line 4745 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__iw_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__iw_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::iw::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	iw *	THIS = SvIW (ST(0));

	delete THIS;
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__pw_new); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pw_new)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pw::new", "CLASS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	CLASS = (char *)SvPV_nolen(ST(0));
	SV *	RETVAL;
#line 198 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        pw *w =  new pw;
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::pw");
        w->self = (HV *)SvRV (RETVAL);
#line 4792 "./rxvtperl.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__pw_start); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pw_start)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pw::start", "THIS, pid");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	pw *	THIS = SvPW (ST(0));
	IOM_CHAINED	RETVAL;
	int	pid = (int)SvIV(ST(1));
#line 207 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->start (pid);
#line 4817 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__pw_stop); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pw_stop)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pw::stop", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	pw *	THIS = SvPW (ST(0));
	IOM_CHAINED	RETVAL;
#line 214 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        THIS->stop ();
#line 4842 "./rxvtperl.c"
	ST(0) = newSVsv (ST(0));

	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_urxvt__pw_rpid); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pw_rpid)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pw::rpid", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	pw *	THIS = SvPW (ST(0));
	int	RETVAL;
	dXSTARG;
#line 221 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        RETVAL = THIS->rpid;
#line 4868 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__pw_rstatus); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pw_rstatus)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pw::rstatus", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	pw *	THIS = SvPW (ST(0));
	int	RETVAL;
	dXSTARG;
#line 228 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
        RETVAL = THIS->rstatus;
#line 4892 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__pw_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pw_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pw::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	pw *	THIS = SvPW (ST(0));

	delete THIS;
    }
    XSRETURN_EMPTY;
}


/* INCLUDE: Returning to 'rxvtperl.xs' from '$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |' */

#if HAVE_PIXBUF
#define XSubPPtmpAAAE 1


XS(XS_urxvt__pixbuf_new_from_file); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pixbuf_new_from_file)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pixbuf::new_from_file", "klass, filename");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	urxvt__pixbuf	RETVAL;
	SV *	klass = ST(0);
	octet_string        filename = SvPVbyte_nolen (ST(1));

	RETVAL = gdk_pixbuf_new_from_file(filename, 0);
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "urxvt::pixbuf", (void*)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__pixbuf_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__pixbuf_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::pixbuf::DESTROY", "self");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	urxvt__pixbuf	self;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    self = INT2PTR(urxvt__pixbuf,tmp);
	}
	else
	    Perl_croak(aTHX_ "%s: %s is not a reference",
			"urxvt::pixbuf::DESTROY",
			"self");
#line 2274 "./rxvtperl.xs"
        g_object_unref (self);
#line 4973 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}

#endif
#if HAVE_IMG
#define XSubPPtmpAAAF 1


XS(XS_urxvt__img_geometry); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_geometry)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::geometry", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_img *	THIS;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");
#line 2288 "./rxvtperl.xs"
        EXTEND (SP, 4);
        PUSHs (sv_2mortal (newSViv (THIS->x)));
        PUSHs (sv_2mortal (newSViv (THIS->y)));
        PUSHs (sv_2mortal (newSViv (THIS->w)));
        PUSHs (sv_2mortal (newSViv (THIS->h)));
#line 5009 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__img_x); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_x)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    dXSI32;
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	int	RETVAL;
	dXSTARG;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");
#line 2302 "./rxvtperl.xs"
        switch (ix)
          {
            case 0: RETVAL = THIS->x; break;
            case 1: RETVAL = THIS->y; break;
            case 2: RETVAL = THIS->w; break;
            case 3: RETVAL = THIS->h; break;
          }
#line 5045 "./rxvtperl.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__img_pm); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_pm)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::pm", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	Pixmap	RETVAL;
	dXSTARG;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");
#line 2315 "./rxvtperl.xs"
        RETVAL = THIS->pm;
#line 5074 "./rxvtperl.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_urxvt__img_fill); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_fill)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::fill", "THIS, c, x= 0, y= 0, w= THIS->w, h= THIS->h");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	SV *	c = ST(1);
	int	x;
	int	y;
	int	w;
	int	h;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	if (items < 3)
	    x = 0;
	else {
	    x = (int)SvIV(ST(2));
	}

	if (items < 4)
	    y = 0;
	else {
	    y = (int)SvIV(ST(3));
	}

	if (items < 5)
	    w = THIS->w;
	else {
	    w = (int)SvIV(ST(4));
	}

	if (items < 6)
	    h = THIS->h;
	else {
	    h = (int)SvIV(ST(5));
	}
#line 2323 "./rxvtperl.xs"
        rgba cc = parse_rgba (c, THIS->s);
#line 5130 "./rxvtperl.c"

	THIS->fill(cc, x, y, w, h);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");
#line 2329 "./rxvtperl.xs"
        delete THIS;
#line 5158 "./rxvtperl.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_add_alpha); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_add_alpha)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::add_alpha", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	THIS->add_alpha();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_unshare); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_unshare)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::unshare", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	THIS->unshare();
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_repeat_mode); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_repeat_mode)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1 || items > 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::repeat_mode", "THIS, repeat= 0");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	rxvt_img *	THIS;
	render_repeat_mode	repeat;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	if (items < 2)
	    repeat = 0;
	else {
	    if (SvOK (ST(1)))
	  {
		repeat = SvIV (ST(1));
	    if (repeat != RepeatNone && repeat != RepeatNormal && repeat != RepeatPad && repeat != RepeatReflect)
	      croak ("invalid repeat mode specified (%d)\n", repeat);
	  }
	else
	  repeat = RepeatNormal;
	}
#line 2340 "./rxvtperl.xs"
        if (items >= 2)
          THIS->repeat_mode (repeat);
        if (GIMME_V != G_VOID)
          XPUSHs (sv_2mortal (newSViv (THIS->repeat)));
#line 5253 "./rxvtperl.c"
	PUTBACK;
	return;
    }
}


XS(XS_urxvt__img_move); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_move)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::move", "THIS, dx, dy");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	int	dx = (int)SvIV(ST(1));
	int	dy = (int)SvIV(ST(2));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	THIS->move(dx, dy);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_brightness); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_brightness)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 4 || items > 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::brightness", "THIS, r, g, b, a= 1.");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img__nv	r = (rxvt_img__nv)SvNV(ST(1));
	rxvt_img__nv	g = (rxvt_img__nv)SvNV(ST(2));
	rxvt_img__nv	b = (rxvt_img__nv)SvNV(ST(3));
	rxvt_img__nv	a;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	if (items < 5)
	    a = 1.;
	else {
	    a = (rxvt_img__nv)SvNV(ST(4));
	}

	THIS->brightness(r, g, b, a);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_contrast); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_contrast)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 4 || items > 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::contrast", "THIS, r, g, b, a= 1.");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img__nv	r = (rxvt_img__nv)SvNV(ST(1));
	rxvt_img__nv	g = (rxvt_img__nv)SvNV(ST(2));
	rxvt_img__nv	b = (rxvt_img__nv)SvNV(ST(3));
	rxvt_img__nv	a;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	if (items < 5)
	    a = 1.;
	else {
	    a = (rxvt_img__nv)SvNV(ST(4));
	}

	THIS->contrast(r, g, b, a);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_draw); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_draw)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::draw", "THIS, img, op= PictOpOver, mask= 1.");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	img;
	int	op;
	rxvt_img__nv	mask;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

        if (SvROK (ST(1)) && sv_derived_from (ST(1), "urxvt::img"))
          img = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(1))));
        else
          croak ("%s is not of type urxvt::img", "img");

	if (items < 3)
	    op = PictOpOver;
	else {
	    op = (int)SvIV(ST(2));
	}

	if (items < 4)
	    mask = 1.;
	else {
	    mask = (rxvt_img__nv)SvNV(ST(3));
	}

	THIS->draw(img, op, mask);
    }
    XSRETURN_EMPTY;
}


XS(XS_urxvt__img_clone); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_clone)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::clone", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->clone();
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_reify); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_reify)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::reify", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->reify();
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_sub_rect); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_sub_rect)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::sub_rect", "THIS, x, y, width, height");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	int	x = (int)SvIV(ST(1));
	int	y = (int)SvIV(ST(2));
	int	width = (int)SvIV(ST(3));
	int	height = (int)SvIV(ST(4));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->sub_rect(x, y, width, height);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_blur); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_blur)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::blur", "THIS, rh, rv");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	int	rh = (int)SvIV(ST(1));
	int	rv = (int)SvIV(ST(2));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->blur(rh, rv);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_muladd); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_muladd)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::muladd", "THIS, mul, add");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	rxvt_img__nv	mul = (rxvt_img__nv)SvNV(ST(1));
	rxvt_img__nv	add = (rxvt_img__nv)SvNV(ST(2));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->muladd(mul, add);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_transform); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_transform)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 10)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::transform", "THIS, p11, p12, p13, p21, p22, p23, p31, p32, p33");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	rxvt_img__nv	p11 = (rxvt_img__nv)SvNV(ST(1));
	rxvt_img__nv	p12 = (rxvt_img__nv)SvNV(ST(2));
	rxvt_img__nv	p13 = (rxvt_img__nv)SvNV(ST(3));
	rxvt_img__nv	p21 = (rxvt_img__nv)SvNV(ST(4));
	rxvt_img__nv	p22 = (rxvt_img__nv)SvNV(ST(5));
	rxvt_img__nv	p23 = (rxvt_img__nv)SvNV(ST(6));
	rxvt_img__nv	p31 = (rxvt_img__nv)SvNV(ST(7));
	rxvt_img__nv	p32 = (rxvt_img__nv)SvNV(ST(8));
	rxvt_img__nv	p33 = (rxvt_img__nv)SvNV(ST(9));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");
#line 2375 "./rxvtperl.xs"
        rxvt_img::nv matrix[3][3] = {
          { p11, p12, p13 },
          { p21, p22, p23 },
          { p31, p32, p33 }
        };
#line 5589 "./rxvtperl.c"

	RETVAL = THIS->transform(matrix);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_scale); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_scale)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::scale", "THIS, new_width, new_height");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	int	new_width = (int)SvIV(ST(1));
	int	new_height = (int)SvIV(ST(2));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->scale(new_width, new_height);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_rotate); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_rotate)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::rotate", "THIS, x, y, phi");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	int	x = (int)SvIV(ST(1));
	int	y = (int)SvIV(ST(2));
	rxvt_img__nv	phi = (rxvt_img__nv)SvNV(ST(3));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->rotate(x, y, phi);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_tint); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_tint)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::tint", "THIS, c");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	SV *	c = ST(1);

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");
#line 2391 "./rxvtperl.xs"
        rgba cc = parse_rgba (c, THIS->s);
#line 5685 "./rxvtperl.c"

	RETVAL = THIS->tint(cc);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_shade); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_shade)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::shade", "THIS, factor");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	rxvt_img__nv	factor = (rxvt_img__nv)SvNV(ST(1));

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	RETVAL = THIS->shade(factor);
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}


XS(XS_urxvt__img_filter); /* prototype to pass -Wmissing-prototypes */
XS(XS_urxvt__img_filter)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 2 || items > 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "urxvt::img::filter", "THIS, name, params= &PL_sv_undef");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	rxvt_img *	THIS;
	rxvt_img *	RETVAL;
	octet_string        name = SvPVbyte_nolen (ST(1));
	SV *	params;

        if (SvROK (ST(0)) && sv_derived_from (ST(0), "urxvt::img"))
          THIS = INT2PTR (rxvt_img *, SvIV ((SV *) SvRV (ST(0))));
        else
          croak ("%s is not of type urxvt::img", "THIS");

	if (items < 3)
	    params = &PL_sv_undef;
	else {
	    params = ST(2);
	}
#line 2400 "./rxvtperl.xs"
        rxvt_img::nv *vparams = 0;
        int nparams = 0;

        if (SvOK (params))
	  {
            if (!SvROK (params) || SvTYPE (SvRV (params)) != SVt_PVAV)
              croak ("rxvt_img::filter: params must be an array reference with parameter values");

            nparams = av_len ((AV *)SvRV (params)) + 1;
            vparams = (rxvt_img::nv *)malloc (nparams * sizeof (rxvt_img::nv));

            for (int i = 0; i < nparams; ++i)
              vparams [i] = SvNV (*av_fetch ((AV *)SvRV (params), i, 1));
          }

        RETVAL = THIS->filter (name, nparams, vparams);
        free (vparams);
#line 5771 "./rxvtperl.c"
	ST(0) = sv_newmortal();
        sv_setref_pv (ST(0), "urxvt::img", (void *)RETVAL);

    }
    XSRETURN(1);
}

#endif
#ifdef __cplusplus
extern "C"
#endif
XS(boot_urxvt); /* prototype to pass -Wmissing-prototypes */
XS(boot_urxvt)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    char* file = __FILE__;

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
    XS_VERSION_BOOTCHECK ;

    {
        CV * cv ;

        newXSproto("urxvt::log", XS_urxvt_log, file, "$");
        newXSproto("urxvt::warn", XS_urxvt_warn, file, "$");
        newXSproto("urxvt::fatal", XS_urxvt_fatal, file, "$");
        newXSproto("urxvt::_exit", XS_urxvt__exit, file, "$");
        newXSproto("urxvt::catch_fatal", XS_urxvt_catch_fatal, file, "&");
        newXSproto("urxvt::NOW", XS_urxvt_NOW, file, "");
        newXSproto("urxvt::GET_BASEFG", XS_urxvt_GET_BASEFG, file, "$");
        newXSproto("urxvt::GET_BASEBG", XS_urxvt_GET_BASEBG, file, "$");
        newXSproto("urxvt::SET_FGCOLOR", XS_urxvt_SET_FGCOLOR, file, "$$");
        newXSproto("urxvt::SET_BGCOLOR", XS_urxvt_SET_BGCOLOR, file, "$$");
        newXSproto("urxvt::GET_CUSTOM", XS_urxvt_GET_CUSTOM, file, "$");
        newXSproto("urxvt::SET_CUSTOM", XS_urxvt_SET_CUSTOM, file, "$$");
        newXSproto("urxvt::termlist", XS_urxvt_termlist, file, "");
        newXSproto("urxvt::_new_selection_request", XS_urxvt__new_selection_request, file, "$$$$$$");
        newXSproto("urxvt::_delete_selection_request", XS_urxvt__delete_selection_request, file, "$");
        newXSproto("urxvt::term::_new", XS_urxvt__term__new, file, "$$");
        newXSproto("urxvt::term::destroy", XS_urxvt__term_destroy, file, "$");
        newXSproto("urxvt::term::set_should_invoke", XS_urxvt__term_set_should_invoke, file, "$$$");
        newXSproto("urxvt::term::put_option_db", XS_urxvt__term_put_option_db, file, "$$$");
        newXSproto("urxvt::term::grab_button", XS_urxvt__term_grab_button, file, "$$$;$");
        newXSproto("urxvt::term::ungrab_button", XS_urxvt__term_ungrab_button, file, "$$$;$");
        newXSproto("urxvt::term::XGrabKey", XS_urxvt__term_XGrabKey, file, "$$$;$$$$");
        newXSproto("urxvt::term::XUngrabKey", XS_urxvt__term_XUngrabKey, file, "$$$;$");
        newXSproto("urxvt::term::grab", XS_urxvt__term_grab, file, "$$;$");
        newXSproto("urxvt::term::allow_events_async", XS_urxvt__term_allow_events_async, file, "$");
        newXSproto("urxvt::term::allow_events_sync", XS_urxvt__term_allow_events_sync, file, "$");
        newXSproto("urxvt::term::allow_events_replay", XS_urxvt__term_allow_events_replay, file, "$");
        newXSproto("urxvt::term::ungrab", XS_urxvt__term_ungrab, file, "$");
        newXSproto("urxvt::term::XStringToKeysym", XS_urxvt__term_XStringToKeysym, file, "$$");
        newXSproto("urxvt::term::XKeysymToString", XS_urxvt__term_XKeysymToString, file, "$$");
        newXSproto("urxvt::term::XKeysymToKeycode", XS_urxvt__term_XKeysymToKeycode, file, "$$");
        newXSproto("urxvt::term::XKeycodeToKeysym", XS_urxvt__term_XKeycodeToKeysym, file, "$$$");
        newXSproto("urxvt::term::strwidth", XS_urxvt__term_strwidth, file, "$$");
        newXSproto("urxvt::term::locale_encode", XS_urxvt__term_locale_encode, file, "$$");
        newXSproto("urxvt::term::locale_decode", XS_urxvt__term_locale_decode, file, "$$");
        cv = newXS("urxvt::term::height", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_height ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::top_row", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_top_row ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::total_rows", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_total_rows ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::ext_bwidth", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_ext_bwidth ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::lineSpace", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_lineSpace ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::fheight", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_fheight ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::nrow", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_nrow ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::saveLines", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_saveLines ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::fwidth", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_fwidth ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::letterSpace", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_letterSpace ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::ncol", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_ncol ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::width", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_width ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::fbase", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_fbase ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::focus", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_focus ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::int_bwidth", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_int_bwidth ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::mapped", XS_urxvt__term_width, file);
        XSANY.any_i32 = TERM_OFFSET_mapped ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::ModMetaMask", XS_urxvt__term_ModLevel3Mask, file);
        XSANY.any_i32 = 1 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::ModLevel3Mask", XS_urxvt__term_ModLevel3Mask, file);
        XSANY.any_i32 = 0 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::hidden_cursor", XS_urxvt__term_ModLevel3Mask, file);
        XSANY.any_i32 = 4 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::ModNumLockMask", XS_urxvt__term_ModLevel3Mask, file);
        XSANY.any_i32 = 2 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::current_screen", XS_urxvt__term_ModLevel3Mask, file);
        XSANY.any_i32 = 3 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::display_id", XS_urxvt__term_display_id, file);
        XSANY.any_i32 = 0 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::locale", XS_urxvt__term_display_id, file);
        XSANY.any_i32 = 1 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::argv", XS_urxvt__term_envv, file);
        XSANY.any_i32 = 1 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::term::envv", XS_urxvt__term_envv, file);
        XSANY.any_i32 = 0 ;
        sv_setpv((SV*)cv, "$") ;
        newXSproto("urxvt::term::pty_ev_events", XS_urxvt__term_pty_ev_events, file, "$;$");
        newXSproto("urxvt::term::pty_fd", XS_urxvt__term_pty_fd, file, "$");
        newXSproto("urxvt::term::parent", XS_urxvt__term_parent, file, "$");
        newXSproto("urxvt::term::parent_x", XS_urxvt__term_parent_x, file, "$");
        newXSproto("urxvt::term::parent_y", XS_urxvt__term_parent_y, file, "$");
        newXSproto("urxvt::term::vt", XS_urxvt__term_vt, file, "$");
        newXSproto("urxvt::term::vt_emask_add", XS_urxvt__term_vt_emask_add, file, "$$");
        newXSproto("urxvt::term::rstyle", XS_urxvt__term_rstyle, file, "$;$");
        newXSproto("urxvt::term::view_start", XS_urxvt__term_view_start, file, "$;$");
        newXSproto("urxvt::term::set_urgency", XS_urxvt__term_set_urgency, file, "$$");
        newXSproto("urxvt::term::focus_in", XS_urxvt__term_focus_in, file, "$");
        newXSproto("urxvt::term::focus_out", XS_urxvt__term_focus_out, file, "$");
        cv = newXS("urxvt::term::key_press", XS_urxvt__term_key_press, file);
        XSANY.any_i32 = 0 ;
        sv_setpv((SV*)cv, "$$$;$") ;
        cv = newXS("urxvt::term::key_release", XS_urxvt__term_key_press, file);
        XSANY.any_i32 = 1 ;
        sv_setpv((SV*)cv, "$$$;$") ;
        newXSproto("urxvt::term::want_refresh", XS_urxvt__term_want_refresh, file, "$");
        newXSproto("urxvt::term::ROW_t", XS_urxvt__term_ROW_t, file, "$$;$$$$");
        newXSproto("urxvt::term::ROW_r", XS_urxvt__term_ROW_r, file, "$$;$$$$");
        newXSproto("urxvt::term::ROW_l", XS_urxvt__term_ROW_l, file, "$$;$");
        newXSproto("urxvt::term::ROW_is_longer", XS_urxvt__term_ROW_is_longer, file, "$$;$");
        newXSproto("urxvt::term::special_encode", XS_urxvt__term_special_encode, file, "$$");
        newXSproto("urxvt::term::special_decode", XS_urxvt__term_special_decode, file, "$$");
        newXSproto("urxvt::term::_resource", XS_urxvt__term__resource, file, "$$$;$");
        newXSproto("urxvt::term::x_resource", XS_urxvt__term_x_resource, file, "$$");
        newXSproto("urxvt::term::option", XS_urxvt__term_option, file, "$$;$");
        newXSproto("urxvt::term::parse_keysym", XS_urxvt__term_parse_keysym, file, "$$$");
        newXSproto("urxvt::term::register_command", XS_urxvt__term_register_command, file, "$$$$");
        cv = newXS("urxvt::term::selection_end", XS_urxvt__term_screen_cur, file);
        XSANY.any_i32 = 2 ;
        sv_setpv((SV*)cv, "$;$$") ;
        cv = newXS("urxvt::term::selection_mark", XS_urxvt__term_screen_cur, file);
        XSANY.any_i32 = 3 ;
        sv_setpv((SV*)cv, "$;$$") ;
        cv = newXS("urxvt::term::selection_beg", XS_urxvt__term_screen_cur, file);
        XSANY.any_i32 = 1 ;
        sv_setpv((SV*)cv, "$;$$") ;
        cv = newXS("urxvt::term::screen_cur", XS_urxvt__term_screen_cur, file);
        XSANY.any_i32 = 0 ;
        sv_setpv((SV*)cv, "$;$$") ;
        newXSproto("urxvt::term::selection_screen", XS_urxvt__term_selection_screen, file, "$;$");
        newXSproto("urxvt::term::selection_request", XS_urxvt__term_selection_request, file, "$$$");
        newXSproto("urxvt::term::selection_clear", XS_urxvt__term_selection_clear, file, "$;$");
        newXSproto("urxvt::term::selection_make", XS_urxvt__term_selection_make, file, "$$;$");
        newXSproto("urxvt::term::selection_grab", XS_urxvt__term_selection_grab, file, "$$;$");
        newXSproto("urxvt::term::selection", XS_urxvt__term_selection, file, "$;$$");
        newXSproto("urxvt::term::cur_charset", XS_urxvt__term_cur_charset, file, "$");
        newXSproto("urxvt::term::scr_xor_rect", XS_urxvt__term_scr_xor_rect, file, "$$$$$;$$");
        newXSproto("urxvt::term::scr_xor_span", XS_urxvt__term_scr_xor_span, file, "$$$$$;$");
        newXSproto("urxvt::term::scr_bell", XS_urxvt__term_scr_bell, file, "$");
        newXSproto("urxvt::term::scr_recolour", XS_urxvt__term_scr_recolour, file, "$;$");
        newXSproto("urxvt::term::scr_change_screen", XS_urxvt__term_scr_change_screen, file, "$$");
        newXSproto("urxvt::term::scr_add_lines", XS_urxvt__term_scr_add_lines, file, "$$");
        newXSproto("urxvt::term::tt_write", XS_urxvt__term_tt_write, file, "$$");
        newXSproto("urxvt::term::tt_paste", XS_urxvt__term_tt_paste, file, "$$");
        newXSproto("urxvt::term::cmd_parse", XS_urxvt__term_cmd_parse, file, "$$");
        newXSproto("urxvt::term::overlay", XS_urxvt__term_overlay, file, "$$$$$;$$");
        newXSproto("urxvt::term::XListProperties", XS_urxvt__term_XListProperties, file, "$$");
        newXSproto("urxvt::term::XGetWindowProperty", XS_urxvt__term_XGetWindowProperty, file, "$$$");
        newXSproto("urxvt::term::XChangeProperty", XS_urxvt__term_XChangeProperty, file, "$$$$$$");
        newXSproto("urxvt::term::XInternAtom", XS_urxvt__term_XInternAtom, file, "$$;$");
        newXSproto("urxvt::term::XGetAtomName", XS_urxvt__term_XGetAtomName, file, "$$");
        newXSproto("urxvt::term::XDeleteProperty", XS_urxvt__term_XDeleteProperty, file, "$$$");
        newXSproto("urxvt::term::DefaultRootWindow", XS_urxvt__term_DefaultRootWindow, file, "$");
#if XSubPPtmpAAAA
        newXSproto("urxvt::term::XCreateSimpleWindow", XS_urxvt__term_XCreateSimpleWindow, file, "$$$$$$");
#endif
        newXSproto("urxvt::term::XReparentWindow", XS_urxvt__term_XReparentWindow, file, "$$$;$$");
        newXSproto("urxvt::term::XMapWindow", XS_urxvt__term_XMapWindow, file, "$$");
        newXSproto("urxvt::term::XUnmapWindow", XS_urxvt__term_XUnmapWindow, file, "$$");
        newXSproto("urxvt::term::XMoveResizeWindow", XS_urxvt__term_XMoveResizeWindow, file, "$$$$$$");
        newXSproto("urxvt::term::XChangeInput", XS_urxvt__term_XChangeInput, file, "$$$;$");
        newXSproto("urxvt::term::XTranslateCoordinates", XS_urxvt__term_XTranslateCoordinates, file, "$$$$$");
        newXSproto("urxvt::term::has_render", XS_urxvt__term_has_render, file, "$");
        newXSproto("urxvt::term::background_geometry", XS_urxvt__term_background_geometry, file, "$;$");
#if XSubPPtmpAAAB
        newXSproto("urxvt::term::new_img", XS_urxvt__term_new_img, file, "$;$$$$$");
#if XSubPPtmpAAAC
        newXSproto("urxvt::term::new_img_from_root", XS_urxvt__term_new_img_from_root, file, "$");
#endif
#if XSubPPtmpAAAD
        newXSproto("urxvt::term::new_img_from_file", XS_urxvt__term_new_img_from_file, file, "$$");
#endif
        newXSproto("urxvt::term::set_background", XS_urxvt__term_set_background, file, "$$;$");
#endif
        newXSproto("urxvt::overlay::set", XS_urxvt__overlay_set, file, "$$$$;$");
        newXSproto("urxvt::overlay::show", XS_urxvt__overlay_show, file, "$");
        newXSproto("urxvt::overlay::hide", XS_urxvt__overlay_hide, file, "$");
        newXSproto("urxvt::overlay::DESTROY", XS_urxvt__overlay_DESTROY, file, "$");
        newXSproto("urxvt::watcher::cb", XS_urxvt__watcher_cb, file, "$$");
        newXSproto("urxvt::timer::new", XS_urxvt__timer_new, file, "$");
        newXSproto("urxvt::timer::at", XS_urxvt__timer_at, file, "$");
        newXSproto("urxvt::timer::interval", XS_urxvt__timer_interval, file, "$$");
        newXSproto("urxvt::timer::set", XS_urxvt__timer_set, file, "$$;$");
        newXSproto("urxvt::timer::start", XS_urxvt__timer_start, file, "$;$$");
        newXSproto("urxvt::timer::after", XS_urxvt__timer_after, file, "$$;$");
        newXSproto("urxvt::timer::stop", XS_urxvt__timer_stop, file, "$");
        newXSproto("urxvt::timer::DESTROY", XS_urxvt__timer_DESTROY, file, "$");
        newXSproto("urxvt::iow::new", XS_urxvt__iow_new, file, "$");
        newXSproto("urxvt::iow::fd", XS_urxvt__iow_fd, file, "$$");
        newXSproto("urxvt::iow::events", XS_urxvt__iow_events, file, "$$");
        newXSproto("urxvt::iow::start", XS_urxvt__iow_start, file, "$");
        newXSproto("urxvt::iow::stop", XS_urxvt__iow_stop, file, "$");
        newXSproto("urxvt::iow::DESTROY", XS_urxvt__iow_DESTROY, file, "$");
        newXSproto("urxvt::iw::new", XS_urxvt__iw_new, file, "$");
        newXSproto("urxvt::iw::start", XS_urxvt__iw_start, file, "$");
        newXSproto("urxvt::iw::stop", XS_urxvt__iw_stop, file, "$");
        newXSproto("urxvt::iw::DESTROY", XS_urxvt__iw_DESTROY, file, "$");
        newXSproto("urxvt::pw::new", XS_urxvt__pw_new, file, "$");
        newXSproto("urxvt::pw::start", XS_urxvt__pw_start, file, "$$");
        newXSproto("urxvt::pw::stop", XS_urxvt__pw_stop, file, "$");
        newXSproto("urxvt::pw::rpid", XS_urxvt__pw_rpid, file, "$");
        newXSproto("urxvt::pw::rstatus", XS_urxvt__pw_rstatus, file, "$");
        newXSproto("urxvt::pw::DESTROY", XS_urxvt__pw_DESTROY, file, "$");
#if XSubPPtmpAAAE
        newXSproto("urxvt::pixbuf::new_from_file", XS_urxvt__pixbuf_new_from_file, file, "$$");
        newXSproto("urxvt::pixbuf::DESTROY", XS_urxvt__pixbuf_DESTROY, file, "$");
#endif
#if XSubPPtmpAAAF
        newXSproto("urxvt::img::geometry", XS_urxvt__img_geometry, file, "$");
        cv = newXS("urxvt::img::w", XS_urxvt__img_x, file);
        XSANY.any_i32 = 2 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::img::h", XS_urxvt__img_x, file);
        XSANY.any_i32 = 3 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::img::y", XS_urxvt__img_x, file);
        XSANY.any_i32 = 1 ;
        sv_setpv((SV*)cv, "$") ;
        cv = newXS("urxvt::img::x", XS_urxvt__img_x, file);
        XSANY.any_i32 = 0 ;
        sv_setpv((SV*)cv, "$") ;
        newXSproto("urxvt::img::pm", XS_urxvt__img_pm, file, "$");
        newXSproto("urxvt::img::fill", XS_urxvt__img_fill, file, "$;$$$$");
        newXSproto("urxvt::img::DESTROY", XS_urxvt__img_DESTROY, file, "$");
        newXSproto("urxvt::img::add_alpha", XS_urxvt__img_add_alpha, file, "$");
        newXSproto("urxvt::img::unshare", XS_urxvt__img_unshare, file, "$");
        newXSproto("urxvt::img::repeat_mode", XS_urxvt__img_repeat_mode, file, "$;$");
        newXSproto("urxvt::img::move", XS_urxvt__img_move, file, "$$$");
        newXSproto("urxvt::img::brightness", XS_urxvt__img_brightness, file, "$$$$;$");
        newXSproto("urxvt::img::contrast", XS_urxvt__img_contrast, file, "$$$$;$");
        newXSproto("urxvt::img::draw", XS_urxvt__img_draw, file, "$$;$$");
        newXSproto("urxvt::img::clone", XS_urxvt__img_clone, file, "$");
        newXSproto("urxvt::img::reify", XS_urxvt__img_reify, file, "$");
        newXSproto("urxvt::img::sub_rect", XS_urxvt__img_sub_rect, file, "$$$$$");
        newXSproto("urxvt::img::blur", XS_urxvt__img_blur, file, "$$$");
        newXSproto("urxvt::img::muladd", XS_urxvt__img_muladd, file, "$$$");
        newXSproto("urxvt::img::transform", XS_urxvt__img_transform, file, "$$$$$$$$$$");
        newXSproto("urxvt::img::scale", XS_urxvt__img_scale, file, "$$$");
        newXSproto("urxvt::img::rotate", XS_urxvt__img_rotate, file, "$$$$");
        newXSproto("urxvt::img::tint", XS_urxvt__img_tint, file, "$$");
        newXSproto("urxvt::img::shade", XS_urxvt__img_shade, file, "$$");
        newXSproto("urxvt::img::filter", XS_urxvt__img_filter, file, "$$;$");
#endif
    }

    /* Initialisation Section */

#line 774 "./rxvtperl.xs"
{
  sv_setsv (get_sv ("urxvt::LIBDIR",   1), newSVpvn (LIBDIR,   sizeof (LIBDIR)   - 1));
  sv_setsv (get_sv ("urxvt::RESNAME",  1), newSVpvn (RESNAME,  sizeof (RESNAME)  - 1));
  sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1));
  sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1));

  AV *hookname = get_av ("urxvt::HOOKNAME", 1);
# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
# include "hookinc.h"
# undef def

  HV *option = get_hv ("urxvt::OPTION", 1);
# define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
# define nodef(name)
# include "optinc.h"
# undef nodef
# undef def

  HV *stash = gv_stashpv ("urxvt", 1);
  static const struct {
    const char *name;
    IV iv;
  } *civ, const_iv[] = {
#   define const_iv(name) { # name, (IV)name }
    const_iv (NUM_RESOURCES),
    const_iv (DEFAULT_RSTYLE),
    const_iv (OVERLAY_RSTYLE),
    const_iv (Color_Bits),
    const_iv (RS_bgShift), const_iv (RS_bgMask),
    const_iv (RS_fgShift), const_iv (RS_fgMask),
    const_iv (RS_Careful),
    const_iv (RS_fontCount),
    const_iv (RS_fontShift),
    const_iv (RS_fontMask),
    const_iv (RS_baseattrMask),
    const_iv (RS_attrMask),
    const_iv (RS_redraw),
    const_iv (RS_Sel),
    const_iv (RS_Bold),
    const_iv (RS_Italic),
    const_iv (RS_Blink),
    const_iv (RS_RVid),
    const_iv (RS_Uline),

    const_iv (CurrentTime),
    const_iv (ShiftMask),
    const_iv (LockMask),
    const_iv (ControlMask),
    const_iv (Mod1Mask),
    const_iv (Mod2Mask),
    const_iv (Mod3Mask),
    const_iv (Mod4Mask),
    const_iv (Mod5Mask),
    const_iv (Button1Mask),
    const_iv (Button2Mask),
    const_iv (Button3Mask),
    const_iv (Button4Mask),
    const_iv (Button5Mask),
    const_iv (AnyModifier),

    const_iv (NoSymbol),
    const_iv (GrabModeSync),
    const_iv (GrabModeAsync),

    const_iv (NoEventMask),
    const_iv (KeyPressMask),
    const_iv (KeyReleaseMask),
    const_iv (ButtonPressMask),
    const_iv (ButtonReleaseMask),
    const_iv (EnterWindowMask),
    const_iv (LeaveWindowMask),
    const_iv (PointerMotionMask),
    const_iv (PointerMotionHintMask),
    const_iv (Button1MotionMask),
    const_iv (Button2MotionMask),
    const_iv (Button3MotionMask),
    const_iv (Button4MotionMask),
    const_iv (Button5MotionMask),
    const_iv (ButtonMotionMask),
    const_iv (KeymapStateMask),
    const_iv (ExposureMask),
    const_iv (VisibilityChangeMask),
    const_iv (StructureNotifyMask),
    const_iv (ResizeRedirectMask),
    const_iv (SubstructureNotifyMask),
    const_iv (SubstructureRedirectMask),
    const_iv (FocusChangeMask),
    const_iv (PropertyChangeMask),
    const_iv (ColormapChangeMask),
    const_iv (OwnerGrabButtonMask),

    const_iv (KeyPress),
    const_iv (KeyRelease),
    const_iv (ButtonPress),
    const_iv (ButtonRelease),
    const_iv (MotionNotify),
    const_iv (EnterNotify),
    const_iv (LeaveNotify),
    const_iv (FocusIn),
    const_iv (FocusOut),
    const_iv (KeymapNotify),
    const_iv (Expose),
    const_iv (GraphicsExpose),
    const_iv (NoExpose),
    const_iv (VisibilityNotify),
    const_iv (CreateNotify),
    const_iv (DestroyNotify),
    const_iv (UnmapNotify),
    const_iv (MapNotify),
    const_iv (MapRequest),
    const_iv (ReparentNotify),
    const_iv (ConfigureNotify),
    const_iv (ConfigureRequest),
    const_iv (GravityNotify),
    const_iv (ResizeRequest),
    const_iv (CirculateNotify),
    const_iv (CirculateRequest),
    const_iv (PropertyNotify),
    const_iv (SelectionClear),
    const_iv (SelectionRequest),
    const_iv (SelectionNotify),
    const_iv (ColormapNotify),
    const_iv (ClientMessage),
    const_iv (MappingNotify),
#   if ENABLE_XIM_ONTHESPOT
    const_iv (XIMReverse),
    const_iv (XIMUnderline),
    const_iv (XIMHighlight),
    const_iv (XIMPrimary),
    const_iv (XIMSecondary),
    const_iv (XIMTertiary),
    const_iv (XIMVisibleToForward),
    const_iv (XIMVisibleToBackword),
    const_iv (XIMVisibleToCenter),
#if XRENDER
    const_iv (PictStandardARGB32),
    const_iv (PictStandardRGB24),
    const_iv (PictStandardA8),
    const_iv (PictStandardA4),
    const_iv (PictStandardA1),
    const_iv (RepeatNone),
    const_iv (RepeatNormal),
    const_iv (RepeatPad),
    const_iv (RepeatReflect),
    // all versions
    const_iv (PictOpClear),
    const_iv (PictOpSrc),
    const_iv (PictOpDst),
    const_iv (PictOpOver),
    const_iv (PictOpOverReverse),
    const_iv (PictOpIn),
    const_iv (PictOpInReverse),
    const_iv (PictOpOut),
    const_iv (PictOpOutReverse),
    const_iv (PictOpAtop),
    const_iv (PictOpAtopReverse),
    const_iv (PictOpXor),
    const_iv (PictOpAdd),
    const_iv (PictOpSaturate),
    // 0.2+
    const_iv (PictOpDisjointClear),
    const_iv (PictOpDisjointSrc),
    const_iv (PictOpDisjointDst),
    const_iv (PictOpDisjointOver),
    const_iv (PictOpDisjointOverReverse),
    const_iv (PictOpDisjointIn),
    const_iv (PictOpDisjointInReverse),
    const_iv (PictOpDisjointOut),
    const_iv (PictOpDisjointOutReverse),
    const_iv (PictOpDisjointAtop),
    const_iv (PictOpDisjointAtopReverse),
    const_iv (PictOpDisjointXor),
    const_iv (PictOpConjointClear),
    const_iv (PictOpConjointSrc),
    const_iv (PictOpConjointDst),
    const_iv (PictOpConjointOver),
    const_iv (PictOpConjointOverReverse),
    const_iv (PictOpConjointIn),
    const_iv (PictOpConjointInReverse),
    const_iv (PictOpConjointOut),
    const_iv (PictOpConjointOutReverse),
    const_iv (PictOpConjointAtop),
    const_iv (PictOpConjointAtopReverse),
    const_iv (PictOpConjointXor),
    // 0.11+
    const_iv (PictOpMultiply),
    const_iv (PictOpScreen),
    const_iv (PictOpOverlay),
    const_iv (PictOpDarken),
    const_iv (PictOpLighten),
    const_iv (PictOpColorDodge),
    const_iv (PictOpColorBurn),
    const_iv (PictOpHardLight),
    const_iv (PictOpSoftLight),
    const_iv (PictOpDifference),
    const_iv (PictOpExclusion),
    const_iv (PictOpHSLHue),
    const_iv (PictOpHSLSaturation),
    const_iv (PictOpHSLColor),
    const_iv (PictOpHSLLuminosity),
#endif
#   if 0
    const_iv (XIMForwardChar),
    const_iv (XIMBackwardChar),
    const_iv (XIMForwardWord),
    const_iv (XIMBackwardWord),
    const_iv (XIMCaretUp),
    const_iv (XIMCaretDown),
    const_iv (XIMNextLine),
    const_iv (XIMPreviousLine),
    const_iv (XIMLineStart),
    const_iv (XIMLineEnd),
    const_iv (XIMAbsolutePosition),
    const_iv (XIMDontChange),
#   endif
#   endif
  };

  for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
    newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
}

#if XSubPPtmpAAAA
#endif
#if XSubPPtmpAAAB
#if XSubPPtmpAAAC
#endif
#if XSubPPtmpAAAD
#endif
#endif
#line 6 "$PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |"
{
  {
    HV *stash     = gv_stashpv ("urxvt", 1);
    SV *baseclass = newSVpv ("urxvt::watcher", 0);

    static const struct {
      const char *name;
      IV iv;
    } *civ, iom_const_iv[] = {
#   define iom_const_iv(name) { # name, (IV)name }
      iom_const_iv (EV_NONE),
      iom_const_iv (EV_READ),
      iom_const_iv (EV_WRITE),
#   undef iom_const
    };

    for (civ = iom_const_iv + sizeof (iom_const_iv) / sizeof (iom_const_iv [0]); civ > iom_const_iv; civ--)
      newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));

    /* slightly dirty to put the same scalar into all those arrays, but */
    /* we do not expect users to modify them anyways */
    av_push (get_av ("urxvt" "::timer::ISA", 1), SvREFCNT_inc (baseclass));
    av_push (get_av ("urxvt"   "::iow::ISA", 1), SvREFCNT_inc (baseclass));
    av_push (get_av ("urxvt"    "::pw::ISA", 1), SvREFCNT_inc (baseclass));
    av_push (get_av ("urxvt"    "::iw::ISA", 1), SvREFCNT_inc (baseclass));

    SvREFCNT_dec (baseclass);
  }
}

#if XSubPPtmpAAAE
#endif
#if XSubPPtmpAAAF
#endif
#line 6336 "./rxvtperl.c"

    /* End of Initialisation Section */

    XSRETURN_YES;
}

