ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtperl.xs
(Generate patch)

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.73 by root, Wed Jan 18 09:40:53 2006 UTC vs.
Revision 1.78 by root, Thu Jan 19 20:30:36 2006 UTC

211 211
212#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 212#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
213 213
214struct overlay { 214struct overlay {
215 HV *self; 215 HV *self;
216 bool visible;
216 rxvt_term *THIS; 217 rxvt_term *THIS;
217 int x, y, w, h; 218 int x, y, w, h;
218 int border; 219 int border;
219 text_t **text; 220 text_t **text;
220 rend_t **rend; 221 rend_t **rend;
229 230
230 void set (int x, int y, SV *str, SV *rend); 231 void set (int x, int y, SV *str, SV *rend);
231}; 232};
232 233
233overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) 234overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border)
234: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) 235: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), visible(false)
235{ 236{
236 if (border == 2) 237 if (border == 2)
237 { 238 {
238 w += 2; 239 w += 2;
239 h += 2; 240 h += 2;
300} 301}
301 302
302void 303void
303overlay::show () 304overlay::show ()
304{ 305{
305 char key[33]; sprintf (key, "%32lx", (long)this); 306 if (visible)
307 return;
306 308
309 visible = true;
310
307 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); 311 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
308 hv_store (hv, key, 32, newSViv ((long)this), 0); 312 av_push (av, newSViv ((long)this));
309} 313}
310 314
311void 315void
312overlay::hide () 316overlay::hide ()
313{ 317{
318 if (!visible)
319 return;
320
321 visible = false;
322
314 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); 323 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
315 324
316 if (ovs) 325 int i;
326
327 for (i = AvFILL (av); i >= 0; i--)
328 if (SvIV (*av_fetch (av, i, 1)) == (long)this)
317 { 329 {
318 char key[33]; sprintf (key, "%32lx", (long)this);
319
320 HV *hv = (HV *)SvRV (*ovs);
321 hv_delete (hv, key, 32, G_DISCARD); 330 av_delete (av, i, G_DISCARD);
331 break;
322 } 332 }
333
334 for (; i < AvFILL (av); i++)
335 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
336
337 av_pop (av);
323} 338}
324 339
325void overlay::swap () 340void overlay::swap ()
326{ 341{
327 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 342 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
367 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) 382 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
368 croak ("rend must be arrayref"); 383 croak ("rend must be arrayref");
369 384
370 AV *av = (AV *)SvRV (rend); 385 AV *av = (AV *)SvRV (rend);
371 386
372 for (int col = min (av_len (av) + 1, w - x - border); col--; ) 387 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
373 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 388 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
374 } 389 }
375 390
376 THIS->want_refresh = 1; 391 THIS->want_refresh = 1;
377} 392}
433 448
434 if (perl) 449 if (perl)
435 { 450 {
436 // runs outside of perls ENV 451 // runs outside of perls ENV
437 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 452 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
438 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 453 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
439 } 454 }
440} 455}
441 456
442static void 457static void
443ungrab (rxvt_term *THIS) 458ungrab (rxvt_term *THIS)
448 XUngrabPointer (THIS->display->display, THIS->perl.grabtime); 463 XUngrabPointer (THIS->display->display, THIS->perl.grabtime);
449 THIS->perl.grabtime = 0; 464 THIS->perl.grabtime = 0;
450 } 465 }
451} 466}
452 467
453static void
454swap_overlays (rxvt_term *term)
455{
456 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
457
458 if (HvKEYS (hv))
459 {
460 hv_iterinit (hv);
461
462 while (HE *he = hv_iternext (hv))
463 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
464 }
465}
466
467bool 468bool
468rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 469rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
469{ 470{
470 if (!perl || !term->perl.self) 471 if (!perl || !term->perl.self)
471 return false; 472 return false;
472 473
473 // pre-handling of some events 474 // pre-handling of some events
474 if (htype == HOOK_REFRESH_END) 475 if (htype == HOOK_REFRESH_END)
475 swap_overlays (term); 476 {
477 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
478
479 for (int i = 0; i <= AvFILL (av); i++)
480 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
481 }
476 482
477 swap (perl_environ, environ); 483 swap (perl_environ, environ);
478 484
479 bool event_consumed; 485 bool event_consumed;
480 486
535 XEvent *xe = va_arg (ap, XEvent *); 541 XEvent *xe = va_arg (ap, XEvent *);
536 HV *hv = newHV (); 542 HV *hv = newHV ();
537 543
538# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 544# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
539# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 545# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
546# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
540# undef set 547# undef set
541 548
542 setiv (type, xe->type); 549 setiv (type, xe->type);
543 setiv (send_event, xe->xany.send_event); 550 setiv (send_event, xe->xany.send_event);
544 setiv (serial, xe->xany.serial); 551 setiv (serial, xe->xany.serial);
548 case KeyPress: 555 case KeyPress:
549 case KeyRelease: 556 case KeyRelease:
550 case ButtonPress: 557 case ButtonPress:
551 case ButtonRelease: 558 case ButtonRelease:
552 case MotionNotify: 559 case MotionNotify:
560 setuv (window, xe->xmotion.window);
561 setuv (root, xe->xmotion.root);
562 setuv (subwindow, xe->xmotion.subwindow);
553 setiv (time, xe->xmotion.time); 563 setuv (time, xe->xmotion.time);
554 setiv (x, xe->xmotion.x); 564 setiv (x, xe->xmotion.x);
555 setiv (y, xe->xmotion.y); 565 setiv (y, xe->xmotion.y);
556 setiv (row, xe->xmotion.y / term->fheight); 566 setiv (row, xe->xmotion.y / term->fheight);
557 setiv (col, xe->xmotion.x / term->fwidth); 567 setiv (col, xe->xmotion.x / term->fwidth);
558 setiv (x_root, xe->xmotion.x_root); 568 setiv (x_root, xe->xmotion.x_root);
559 setiv (y_root, xe->xmotion.y_root); 569 setiv (y_root, xe->xmotion.y_root);
560 setiv (state, xe->xmotion.state); 570 setuv (state, xe->xmotion.state);
571
572 switch (xe->type)
573 {
574 case KeyPress:
575 case KeyRelease:
576 setuv (keycode, xe->xkey.keycode);
577 break;
578
579 case ButtonPress:
580 case ButtonRelease:
581 setuv (button, xe->xbutton.button);
582 break;
583
584 case MotionNotify:
585 setiv (is_hint, xe->xmotion.is_hint);
586 break;
587 }
588
561 break; 589 break;
562 }
563 590
591 case MapNotify:
592 case UnmapNotify:
593 case ConfigureNotify:
594 setuv (event, xe->xconfigure.event);
595 setuv (window, xe->xconfigure.window);
596
564 switch (xe->type) 597 switch (xe->type)
565 { 598 {
566 case KeyPress: 599 case ConfigureNotify:
567 case KeyRelease: 600 setiv (x, xe->xconfigure.x);
568 setiv (keycode, xe->xkey.keycode); 601 setiv (y, xe->xconfigure.y);
602 setiv (width, xe->xconfigure.width);
603 setiv (height, xe->xconfigure.height);
604 setuv (above, xe->xconfigure.above);
569 break; 605 break;
570
571 case ButtonPress:
572 case ButtonRelease:
573 setiv (button, xe->xbutton.button);
574 break; 606 }
575 607
576 case MotionNotify:
577 setiv (is_hint, xe->xmotion.is_hint);
578 break; 608 break;
579 } 609 }
580 610
581 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 611 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
582 } 612 }
623 else 653 else
624 event_consumed = false; 654 event_consumed = false;
625 655
626 // post-handling of some events 656 // post-handling of some events
627 if (htype == HOOK_REFRESH_BEGIN) 657 if (htype == HOOK_REFRESH_BEGIN)
628 swap_overlays (term); 658 {
659 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
660
661 for (int i = AvFILL (av); i >= 0; i--)
662 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
663 }
629 else if (htype == HOOK_DESTROY) 664 else if (htype == HOOK_DESTROY)
630 { 665 {
631 clearSVptr ((SV *)term->perl.self); 666 clearSVptr ((SV *)term->perl.self);
632 SvREFCNT_dec ((SV *)term->perl.self); 667 SvREFCNT_dec ((SV *)term->perl.self);
633 } 668 }
847 882
848 for (int i = 1; i < items; i++) 883 for (int i = 1; i < items; i++)
849 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); 884 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
850 885
851 AV *envv = (AV *)SvRV (ST (0)); 886 AV *envv = (AV *)SvRV (ST (0));
852 for (int i = av_len (envv) + 1; i--; ) 887 for (int i = AvFILL (envv) + 1; i--; )
853 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); 888 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1))));
854 889
855 term->envv->push_back (0); 890 term->envv->push_back (0);
856 891
857 bool success; 892 bool success;
1280 { 1315 {
1281 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1316 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
1282 croak ("new_rend must be arrayref"); 1317 croak ("new_rend must be arrayref");
1283 1318
1284 AV *av = (AV *)SvRV (new_rend); 1319 AV *av = (AV *)SvRV (new_rend);
1285 int len = min (av_len (av) + 1 - start_ofs, max_len); 1320 int len = min (AvFILL (av) + 1 - start_ofs, max_len);
1286 1321
1287 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1322 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
1288 croak ("new_rend array extends beyond horizontal margins"); 1323 croak ("new_rend array extends beyond horizontal margins");
1289 1324
1290 for (int col = start_col; col < start_col + len; col++) 1325 for (int col = start_col; col < start_col + len; col++)
1457 if (set) 1492 if (set)
1458 THIS->options |= optval; 1493 THIS->options |= optval;
1459 else 1494 else
1460 THIS->options &= ~optval; 1495 THIS->options &= ~optval;
1461 1496
1497 if (THIS->check_ev.is_active ()) // avoid doing this before START
1462 switch (optval) 1498 switch (optval)
1463 { 1499 {
1464 case Opt_skipBuiltinGlyphs: 1500 case Opt_skipBuiltinGlyphs:
1465 THIS->set_fonts (); 1501 THIS->set_fonts ();
1466 THIS->scr_remap_chars (); 1502 THIS->scr_remap_chars ();
1467 THIS->scr_touch (true); 1503 THIS->scr_touch (true);
1468 THIS->want_refresh = 1; 1504 THIS->want_refresh = 1;
1469 break; 1505 break;
1470 1506
1471 case Opt_cursorUnderline: 1507 case Opt_cursorUnderline:
1472 THIS->want_refresh = 1; 1508 THIS->want_refresh = 1;
1473 break; 1509 break;
1474 1510
1475# case Opt_scrollBar_floating: 1511# case Opt_scrollBar_floating:
1476# case Opt_scrollBar_right: 1512# case Opt_scrollBar_right:
1477# THIS->resize_all_windows (THIS->width, THIS->height, 1); 1513# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1478# break; 1514# break;
1479 } 1515 }
1480 } 1516 }
1481} 1517}
1482 OUTPUT: 1518 OUTPUT:
1483 RETVAL 1519 RETVAL
1484 1520
1691 RETVAL = THIS; 1727 RETVAL = THIS;
1692 OUTPUT: 1728 OUTPUT:
1693 RETVAL 1729 RETVAL
1694 1730
1695timer * 1731timer *
1732timer::after (NV delay)
1733 CODE:
1734 THIS->start (NOW + delay);
1735 RETVAL = THIS;
1736 OUTPUT:
1737 RETVAL
1738
1739timer *
1696timer::stop () 1740timer::stop ()
1697 CODE: 1741 CODE:
1698 THIS->stop (); 1742 THIS->stop ();
1699 RETVAL = THIS; 1743 RETVAL = THIS;
1700 OUTPUT: 1744 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines