--- rxvt-unicode/src/rxvtperl.xs 2006/01/17 16:22:41 1.71 +++ rxvt-unicode/src/rxvtperl.xs 2006/01/19 20:30:36 1.78 @@ -213,6 +213,7 @@ struct overlay { HV *self; + bool visible; rxvt_term *THIS; int x, y, w, h; int border; @@ -231,7 +232,7 @@ }; overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) -: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) +: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), visible(false) { if (border == 2) { @@ -302,24 +303,38 @@ void overlay::show () { - char key[33]; sprintf (key, "%32lx", (long)this); + if (visible) + return; + + visible = true; - HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); - hv_store (hv, key, 32, newSViv ((long)this), 0); + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); + av_push (av, newSViv ((long)this)); } void overlay::hide () { - SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); + if (!visible) + return; - if (ovs) - { - char key[33]; sprintf (key, "%32lx", (long)this); + visible = false; - HV *hv = (HV *)SvRV (*ovs); - hv_delete (hv, key, 32, G_DISCARD); - } + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); + + int i; + + for (i = AvFILL (av); i >= 0; i--) + if (SvIV (*av_fetch (av, i, 1)) == (long)this) + { + av_delete (av, i, G_DISCARD); + break; + } + + for (; i < AvFILL (av); i++) + av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); + + av_pop (av); } void overlay::swap () @@ -369,7 +384,7 @@ AV *av = (AV *)SvRV (rend); - for (int col = min (av_len (av) + 1, w - x - border); col--; ) + for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); } @@ -404,7 +419,13 @@ char *argv[] = { "", - "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", + "-e" + "BEGIN {" + " urxvt->bootstrap;" + " unshift @INC, '" LIBDIR "';" + "}" + "" + "use urxvt;" }; perl = perl_alloc (); @@ -429,7 +450,7 @@ { // 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 *)newHV ()), 0); + hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); } } @@ -444,20 +465,6 @@ } } -static void -swap_overlays (rxvt_term *term) -{ - HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); - - if (HvKEYS (hv)) - { - hv_iterinit (hv); - - while (HE *he = hv_iternext (hv)) - ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); - } -} - bool rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) { @@ -466,7 +473,12 @@ // pre-handling of some events if (htype == HOOK_REFRESH_END) - swap_overlays (term); + { + 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 (); + } swap (perl_environ, environ); @@ -531,6 +543,7 @@ # 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); @@ -544,31 +557,54 @@ case ButtonPress: case ButtonRelease: case MotionNotify: - setiv (time, xe->xmotion.time); - setiv (x, xe->xmotion.x); - setiv (y, xe->xmotion.y); - setiv (row, xe->xmotion.y / term->fheight); - setiv (col, xe->xmotion.x / term->fwidth); - setiv (x_root, xe->xmotion.x_root); - setiv (y_root, xe->xmotion.y_root); - setiv (state, xe->xmotion.state); - break; - } + 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); + 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; + } - switch (xe->type) - { - case KeyPress: - case KeyRelease: - setiv (keycode, xe->xkey.keycode); break; - case ButtonPress: - case ButtonRelease: - setiv (button, xe->xbutton.button); - 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; + } - case MotionNotify: - setiv (is_hint, xe->xmotion.is_hint); break; } @@ -619,7 +655,12 @@ // post-handling of some events if (htype == HOOK_REFRESH_BEGIN) - swap_overlays (term); + { + 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); @@ -843,7 +884,7 @@ term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); AV *envv = (AV *)SvRV (ST (0)); - for (int i = av_len (envv) + 1; i--; ) + for (int i = AvFILL (envv) + 1; i--; ) term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); term->envv->push_back (0); @@ -1276,7 +1317,7 @@ croak ("new_rend must be arrayref"); AV *av = (AV *)SvRV (new_rend); - int len = min (av_len (av) + 1 - start_ofs, max_len); + int len = min (AvFILL (av) + 1 - start_ofs, max_len); if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) croak ("new_rend array extends beyond horizontal margins"); @@ -1453,24 +1494,25 @@ else THIS->options &= ~optval; - switch (optval) - { - case Opt_skipBuiltinGlyphs: - THIS->set_fonts (); - THIS->scr_remap_chars (); - THIS->scr_touch (true); - THIS->want_refresh = 1; - break; - - case Opt_cursorUnderline: - THIS->want_refresh = 1; - break; + if (THIS->check_ev.is_active ()) // 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; + break; + + case Opt_cursorUnderline: + THIS->want_refresh = 1; + break; # case Opt_scrollBar_floating: # case Opt_scrollBar_right: # THIS->resize_all_windows (THIS->width, THIS->height, 1); # break; - } + } } } OUTPUT: @@ -1508,8 +1550,17 @@ if (items == 3) { - rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1); - rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); + rc.row = SvIV (ST (1)); + rc.col = SvIV (ST (2)); + + if (ix == 2 && rc.col == 0) + { + rc.row--; + rc.col = THIS->ncol; + } + + clamp_it (rc.col, 0, THIS->ncol); + clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); if (ix) THIS->want_refresh = 1; @@ -1676,6 +1727,14 @@ RETVAL = THIS; OUTPUT: RETVAL + +timer * +timer::after (NV delay) + CODE: + THIS->start (NOW + delay); + RETVAL = THIS; + OUTPUT: + RETVAL timer * timer::stop ()