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.67 by root, Sun Jan 15 06:02:41 2006 UTC vs.
Revision 1.77 by root, Thu Jan 19 17:55:27 2006 UTC

39#include "rxvtutil.h" 39#include "rxvtutil.h"
40#include "rxvtperl.h" 40#include "rxvtperl.h"
41 41
42#include "perlxsi.c" 42#include "perlxsi.c"
43 43
44#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 44#ifdef HAVE_SCROLLBARS
45# define GRAB_CURSOR THIS->leftptr_cursor 45# define GRAB_CURSOR THIS->leftptr_cursor
46#else 46#else
47# define GRAB_CURSOR None 47# define GRAB_CURSOR None
48#endif 48#endif
49 49
53#define ROW(n) THIS->row_buf [LINENO (n)] 53#define ROW(n) THIS->row_buf [LINENO (n)]
54 54
55#define ENABLE_PERL_FRILLS 1 55#define ENABLE_PERL_FRILLS 1
56 56
57///////////////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////////////
58
59static SV *
60taint (SV *sv)
61{
62 SvTAINT (sv);
63 return sv;
64}
65
66static SV *
67taint_if (SV *sv, SV *src)
68{
69 if (SvTAINTED (src))
70 SvTAINT (sv);
71
72 return sv;
73}
74 58
75static wchar_t * 59static wchar_t *
76sv2wcs (SV *sv) 60sv2wcs (SV *sv)
77{ 61{
78 STRLEN len; 62 STRLEN len;
227 211
228#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 212#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
229 213
230struct overlay { 214struct overlay {
231 HV *self; 215 HV *self;
216 bool visible;
232 rxvt_term *THIS; 217 rxvt_term *THIS;
233 int x, y, w, h; 218 int x, y, w, h;
234 int border; 219 int border;
235 text_t **text; 220 text_t **text;
236 rend_t **rend; 221 rend_t **rend;
245 230
246 void set (int x, int y, SV *str, SV *rend); 231 void set (int x, int y, SV *str, SV *rend);
247}; 232};
248 233
249overlay::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)
250: 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)
251{ 236{
252 if (border == 2) 237 if (border == 2)
253 { 238 {
254 w += 2; 239 w += 2;
255 h += 2; 240 h += 2;
316} 301}
317 302
318void 303void
319overlay::show () 304overlay::show ()
320{ 305{
321 char key[33]; sprintf (key, "%32lx", (long)this); 306 if (visible)
307 return;
322 308
309 visible = true;
310
323 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));
324 hv_store (hv, key, 32, newSViv ((long)this), 0); 312 av_push (av, newSViv ((long)this));
325} 313}
326 314
327void 315void
328overlay::hide () 316overlay::hide ()
329{ 317{
318 if (!visible)
319 return;
320
321 visible = false;
322
330 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));
331 324
332 if (ovs) 325 int i;
326
327 for (i = AvFILL (av); i >= 0; i--)
328 if (SvIV (*av_fetch (av, i, 1)) == (long)this)
333 { 329 {
334 char key[33]; sprintf (key, "%32lx", (long)this);
335
336 HV *hv = (HV *)SvRV (*ovs);
337 hv_delete (hv, key, 32, G_DISCARD); 330 av_delete (av, i, G_DISCARD);
331 break;
338 } 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);
339} 338}
340 339
341void overlay::swap () 340void overlay::swap ()
342{ 341{
343 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));
383 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) 382 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
384 croak ("rend must be arrayref"); 383 croak ("rend must be arrayref");
385 384
386 AV *av = (AV *)SvRV (rend); 385 AV *av = (AV *)SvRV (rend);
387 386
388 for (int col = min (av_len (av) + 1, w - x - border); col--; ) 387 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
389 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 388 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
390 } 389 }
391 390
392 THIS->want_refresh = 1; 391 THIS->want_refresh = 1;
393} 392}
407 perl_free (perl); 406 perl_free (perl);
408 } 407 }
409} 408}
410 409
411void 410void
412rxvt_perl_interp::init () 411rxvt_perl_interp::init (rxvt_term *term)
413{ 412{
414 if (!perl) 413 if (!perl)
415 { 414 {
415 rxvt_push_locale (""); // perl init destroys current locale
416
416 perl_environ = rxvt_environ; 417 perl_environ = rxvt_environ;
417 swap (perl_environ, environ); 418 swap (perl_environ, environ);
418 419
419 char *argv[] = { 420 char *argv[] = {
420 "", 421 "",
421 "-T", 422 "-e"
422 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 423 "BEGIN {"
424 " urxvt->bootstrap;"
425 " unshift @INC, '" LIBDIR "';"
426 "}"
427 ""
428 "use urxvt;"
423 }; 429 };
424 430
425 perl = perl_alloc (); 431 perl = perl_alloc ();
426 perl_construct (perl); 432 perl_construct (perl);
427 433
428 if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) 434 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL)
429 || perl_run (perl)) 435 || perl_run (perl))
430 { 436 {
431 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 437 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
432 438
433 perl_destruct (perl); 439 perl_destruct (perl);
434 perl_free (perl); 440 perl_free (perl);
435 perl = 0; 441 perl = 0;
436 } 442 }
437 443
438 swap (perl_environ, environ); 444 swap (perl_environ, environ);
445
446 rxvt_pop_locale ();
447 }
448
449 if (perl)
450 {
451 // runs outside of perls ENV
452 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
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) 471 if (!perl || !term->perl.self)
471 return false; 472 return false;
472 473
473 if (htype == HOOK_INIT) // first hook ever called 474 // pre-handling of some events
475 if (htype == HOOK_REFRESH_END)
474 { 476 {
475 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 477 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
476 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 478
479 for (int i = 0; i <= AvFILL (av); i++)
480 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
477 } 481 }
478 else if (!term->perl.self) 482
479 return false; // perl not initialized for this instance 483 swap (perl_environ, environ);
484
485 bool event_consumed;
486
487 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
488 || term->perl.should_invoke [htype])
489 try
490 {
491 dSP;
492 va_list ap;
493
494 va_start (ap, htype);
495
496 ENTER;
497 SAVETMPS;
498
499 PUSHMARK (SP);
500
501 XPUSHs (sv_2mortal (newSVterm (term)));
502 XPUSHs (sv_2mortal (newSViv (htype)));
503
504 for (;;) {
505 data_type dt = (data_type)va_arg (ap, int);
506
507 switch (dt)
508 {
509 case DT_INT:
510 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
511 break;
512
513 case DT_LONG:
514 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
515 break;
516
517 case DT_STR:
518 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
519 break;
520
521 case DT_STR_LEN:
522 {
523 char *str = va_arg (ap, char *);
524 int len = va_arg (ap, int);
525
526 XPUSHs (sv_2mortal (newSVpvn (str, len)));
527 }
528 break;
529
530 case DT_WCS_LEN:
531 {
532 wchar_t *wstr = va_arg (ap, wchar_t *);
533 int wlen = va_arg (ap, int);
534
535 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
536 }
537 break;
538
539 case DT_XEVENT:
540 {
541 XEvent *xe = va_arg (ap, XEvent *);
542 HV *hv = newHV ();
543
544# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 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)
547# undef set
548
549 setiv (type, xe->type);
550 setiv (send_event, xe->xany.send_event);
551 setiv (serial, xe->xany.serial);
552
553 switch (xe->type)
554 {
555 case KeyPress:
556 case KeyRelease:
557 case ButtonPress:
558 case ButtonRelease:
559 case MotionNotify:
560 setuv (window, xe->xmotion.window);
561 setuv (root, xe->xmotion.root);
562 setuv (subwindow, xe->xmotion.subwindow);
563 setuv (time, xe->xmotion.time);
564 setiv (x, xe->xmotion.x);
565 setiv (y, xe->xmotion.y);
566 setiv (row, xe->xmotion.y / term->fheight);
567 setiv (col, xe->xmotion.x / term->fwidth);
568 setiv (x_root, xe->xmotion.x_root);
569 setiv (y_root, xe->xmotion.y_root);
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
589 break;
590
591 case MapNotify:
592 case UnmapNotify:
593 case ConfigureNotify:
594 setuv (event, xe->xconfigure.event);
595 setuv (window, xe->xconfigure.window);
596
597 switch (xe->type)
598 {
599 case ConfigureNotify:
600 setiv (x, xe->xconfigure.x);
601 setiv (y, xe->xconfigure.y);
602 setiv (width, xe->xconfigure.width);
603 setiv (height, xe->xconfigure.height);
604 setuv (above, xe->xconfigure.above);
605 break;
606 }
607
608 break;
609 }
610
611 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
612 }
613 break;
614
615 case DT_END:
616 goto call;
617
618 default:
619 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
620 }
621 }
622
623 call:
624 va_end (ap);
625
626 PUTBACK;
627 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
628 SPAGAIN;
629
630 if (count)
631 {
632 SV *status = POPs;
633 count = SvTRUE (status);
634 }
635
636 PUTBACK;
637 FREETMPS;
638 LEAVE;
639
640 if (SvTRUE (ERRSV))
641 {
642 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
643 ungrab (term); // better lose the grab than the session
644 }
645
646 event_consumed = !!count;
647 }
648 catch (...)
649 {
650 swap (perl_environ, environ);
651 throw;
652 }
653 else
654 event_consumed = false;
655
656 // post-handling of some events
657 if (htype == HOOK_REFRESH_BEGIN)
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 }
480 else if (htype == HOOK_DESTROY) 664 else if (htype == HOOK_DESTROY)
481 { 665 {
482 // handled later 666 clearSVptr ((SV *)term->perl.self);
667 SvREFCNT_dec ((SV *)term->perl.self);
483 } 668 }
484 else
485 {
486 if (htype == HOOK_REFRESH_END)
487 swap_overlays (term);
488
489 if (!term->perl.should_invoke [htype])
490 {
491 if (htype == HOOK_REFRESH_BEGIN)
492 swap_overlays (term);
493
494 return false;
495 }
496 }
497 669
498 swap (perl_environ, environ); 670 swap (perl_environ, environ);
499 671
500 try 672 return event_consumed;
501 {
502 dSP;
503 va_list ap;
504
505 va_start (ap, htype);
506
507 ENTER;
508 SAVETMPS;
509
510 PUSHMARK (SP);
511
512 XPUSHs (sv_2mortal (newSVterm (term)));
513 XPUSHs (sv_2mortal (newSViv (htype)));
514
515 for (;;) {
516 data_type dt = (data_type)va_arg (ap, int);
517
518 switch (dt)
519 {
520 case DT_INT:
521 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
522 break;
523
524 case DT_LONG:
525 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
526 break;
527
528 case DT_STR:
529 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
530 break;
531
532 case DT_STR_LEN:
533 {
534 char *str = va_arg (ap, char *);
535 int len = va_arg (ap, int);
536
537 XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
538 }
539 break;
540
541 case DT_WCS_LEN:
542 {
543 wchar_t *wstr = va_arg (ap, wchar_t *);
544 int wlen = va_arg (ap, int);
545
546 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
547 }
548 break;
549
550 case DT_XEVENT:
551 {
552 XEvent *xe = va_arg (ap, XEvent *);
553 HV *hv = newHV ();
554
555# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
556# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
557# undef set
558
559 setiv (type, xe->type);
560 setiv (send_event, xe->xany.send_event);
561 setiv (serial, xe->xany.serial);
562
563 switch (xe->type)
564 {
565 case KeyPress:
566 case KeyRelease:
567 case ButtonPress:
568 case ButtonRelease:
569 case MotionNotify:
570 setiv (time, xe->xmotion.time);
571 setiv (x, xe->xmotion.x);
572 setiv (y, xe->xmotion.y);
573 setiv (row, xe->xmotion.y / term->fheight);
574 setiv (col, xe->xmotion.x / term->fwidth);
575 setiv (x_root, xe->xmotion.x_root);
576 setiv (y_root, xe->xmotion.y_root);
577 setiv (state, xe->xmotion.state);
578 break;
579 }
580
581 switch (xe->type)
582 {
583 case KeyPress:
584 case KeyRelease:
585 setiv (keycode, xe->xkey.keycode);
586 break;
587
588 case ButtonPress:
589 case ButtonRelease:
590 setiv (button, xe->xbutton.button);
591 break;
592
593 case MotionNotify:
594 setiv (is_hint, xe->xmotion.is_hint);
595 break;
596 }
597
598 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
599 }
600 break;
601
602 case DT_END:
603 {
604 va_end (ap);
605
606 PUTBACK;
607 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
608 SPAGAIN;
609
610 if (count)
611 {
612 SV *status = POPs;
613 count = SvTRUE (status);
614 }
615
616 PUTBACK;
617 FREETMPS;
618 LEAVE;
619
620 if (SvTRUE (ERRSV))
621 {
622 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
623 ungrab (term); // better lose the grab than the session
624 }
625
626 if (htype == HOOK_REFRESH_BEGIN)
627 swap_overlays (term);
628 else if (htype == HOOK_DESTROY)
629 {
630 clearSVptr ((SV *)term->perl.self);
631 SvREFCNT_dec ((SV *)term->perl.self);
632 }
633
634 swap (perl_environ, environ);
635 return count;
636 }
637
638 default:
639 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
640 }
641 }
642 }
643 catch (...)
644 {
645 swap (perl_environ, environ);
646 throw;
647 }
648} 673}
649 674
650///////////////////////////////////////////////////////////////////////////// 675/////////////////////////////////////////////////////////////////////////////
651 676
652MODULE = urxvt PACKAGE = urxvt 677MODULE = urxvt PACKAGE = urxvt
781void 806void
782fatal (const char *msg) 807fatal (const char *msg)
783 CODE: 808 CODE:
784 rxvt_fatal ("%s", msg); 809 rxvt_fatal ("%s", msg);
785 810
786SV *
787untaint (SV *sv)
788 CODE:
789 RETVAL = newSVsv (sv);
790 SvTAINTED_off (RETVAL);
791 OUTPUT:
792 RETVAL
793
794void 811void
795_exit (int status) 812_exit (int status)
796
797bool
798safe ()
799 CODE:
800 RETVAL = !rxvt_tainted ();
801 OUTPUT:
802 RETVAL
803 813
804NV 814NV
805NOW () 815NOW ()
806 CODE: 816 CODE:
807 RETVAL = NOW; 817 RETVAL = NOW;
872 882
873 for (int i = 1; i < items; i++) 883 for (int i = 1; i < items; i++)
874 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); 884 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
875 885
876 AV *envv = (AV *)SvRV (ST (0)); 886 AV *envv = (AV *)SvRV (ST (0));
877 for (int i = av_len (envv) + 1; i--; ) 887 for (int i = AvFILL (envv) + 1; i--; )
878 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))));
879 889
880 term->envv->push_back (0); 890 term->envv->push_back (0);
881 891
882 bool success; 892 bool success;
1073 char *mbstr = rxvt_wcstombs (wstr); 1083 char *mbstr = rxvt_wcstombs (wstr);
1074 rxvt_pop_locale (); 1084 rxvt_pop_locale ();
1075 1085
1076 free (wstr); 1086 free (wstr);
1077 1087
1078 RETVAL = taint_if (newSVpv (mbstr, 0), str); 1088 RETVAL = newSVpv (mbstr, 0);
1079 free (mbstr); 1089 free (mbstr);
1080} 1090}
1081 OUTPUT: 1091 OUTPUT:
1082 RETVAL 1092 RETVAL
1083 1093
1090 1100
1091 rxvt_push_locale (THIS->locale); 1101 rxvt_push_locale (THIS->locale);
1092 wchar_t *wstr = rxvt_mbstowcs (data, len); 1102 wchar_t *wstr = rxvt_mbstowcs (data, len);
1093 rxvt_pop_locale (); 1103 rxvt_pop_locale ();
1094 1104
1095 RETVAL = taint_if (wcs2sv (wstr), octets); 1105 RETVAL = wcs2sv (wstr);
1096 free (wstr); 1106 free (wstr);
1097} 1107}
1098 OUTPUT: 1108 OUTPUT:
1099 RETVAL 1109 RETVAL
1100 1110
1252 wchar_t *wstr = new wchar_t [THIS->ncol]; 1262 wchar_t *wstr = new wchar_t [THIS->ncol];
1253 1263
1254 for (int col = 0; col < THIS->ncol; col++) 1264 for (int col = 0; col < THIS->ncol; col++)
1255 wstr [col] = l.t [col]; 1265 wstr [col] = l.t [col];
1256 1266
1257 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); 1267 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1258 1268
1259 delete [] wstr; 1269 delete [] wstr;
1260 } 1270 }
1261 1271
1262 if (new_text) 1272 if (new_text)
1305 { 1315 {
1306 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1316 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
1307 croak ("new_rend must be arrayref"); 1317 croak ("new_rend must be arrayref");
1308 1318
1309 AV *av = (AV *)SvRV (new_rend); 1319 AV *av = (AV *)SvRV (new_rend);
1310 int len = min (av_len (av) + 1 - start_ofs, max_len); 1320 int len = min (AvFILL (av) + 1 - start_ofs, max_len);
1311 1321
1312 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1322 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
1313 croak ("new_rend array extends beyond horizontal margins"); 1323 croak ("new_rend array extends beyond horizontal margins");
1314 1324
1315 for (int col = start_col; col < start_col + len; col++) 1325 for (int col = start_col; col < start_col + len; col++)
1383 else 1393 else
1384 *r++ = *s; 1394 *r++ = *s;
1385 1395
1386 rxvt_pop_locale (); 1396 rxvt_pop_locale ();
1387 1397
1388 RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); 1398 RETVAL = wcs2sv (rstr, r - rstr);
1389 1399
1390 delete [] rstr; 1400 delete [] rstr;
1391} 1401}
1392 OUTPUT: 1402 OUTPUT:
1393 RETVAL 1403 RETVAL
1419 else if (IS_COMPOSE (*s)) 1429 else if (IS_COMPOSE (*s))
1420 r += rxvt_composite.expand (*s, r); 1430 r += rxvt_composite.expand (*s, r);
1421 else 1431 else
1422 *r++ = *s; 1432 *r++ = *s;
1423 1433
1424 RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); 1434 RETVAL = wcs2sv (rstr, r - rstr);
1425 1435
1426 delete [] rstr; 1436 delete [] rstr;
1427} 1437}
1428 OUTPUT: 1438 OUTPUT:
1429 RETVAL 1439 RETVAL
1451 1461
1452 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1462 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
1453 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); 1463 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);
1454 1464
1455 if (GIMME_V != G_VOID) 1465 if (GIMME_V != G_VOID)
1456 XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); 1466 XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef);
1457 1467
1458 if (newval) 1468 if (newval)
1459 { 1469 {
1460 if (SvOK (newval)) 1470 if (SvOK (newval))
1461 { 1471 {
1468 } 1478 }
1469} 1479}
1470 1480
1471const char * 1481const char *
1472rxvt_term::x_resource (const char *name) 1482rxvt_term::x_resource (const char *name)
1473 CLEANUP:
1474 SvTAINTED_on (ST (0));
1475 1483
1476bool 1484bool
1477rxvt_term::option (U32 optval, int set = -1) 1485rxvt_term::option (U32 optval, int set = -1)
1478 CODE: 1486 CODE:
1479{ 1487{
1539 PUSHs (sv_2mortal (newSViv (rc.col))); 1547 PUSHs (sv_2mortal (newSViv (rc.col)));
1540 } 1548 }
1541 1549
1542 if (items == 3) 1550 if (items == 3)
1543 { 1551 {
1552 rc.row = SvIV (ST (1));
1553 rc.col = SvIV (ST (2));
1554
1555 if (ix == 2 && rc.col == 0)
1556 {
1557 rc.row--;
1558 rc.col = THIS->ncol;
1559 }
1560
1561 clamp_it (rc.col, 0, THIS->ncol);
1544 rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1); 1562 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1545 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1);
1546 1563
1547 if (ix) 1564 if (ix)
1548 THIS->want_refresh = 1; 1565 THIS->want_refresh = 1;
1549 } 1566 }
1550} 1567}
1573rxvt_term::selection (SV *newtext = 0) 1590rxvt_term::selection (SV *newtext = 0)
1574 PPCODE: 1591 PPCODE:
1575{ 1592{
1576 if (GIMME_V != G_VOID) 1593 if (GIMME_V != G_VOID)
1577 XPUSHs (THIS->selection.text 1594 XPUSHs (THIS->selection.text
1578 ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) 1595 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))
1579 : &PL_sv_undef); 1596 : &PL_sv_undef);
1580 1597
1581 if (newtext) 1598 if (newtext)
1582 { 1599 {
1583 free (THIS->selection.text); 1600 free (THIS->selection.text);
1709 RETVAL = THIS; 1726 RETVAL = THIS;
1710 OUTPUT: 1727 OUTPUT:
1711 RETVAL 1728 RETVAL
1712 1729
1713timer * 1730timer *
1731timer::after (NV delay)
1732 CODE:
1733 THIS->start (NOW + delay);
1734 RETVAL = THIS;
1735 OUTPUT:
1736 RETVAL
1737
1738timer *
1714timer::stop () 1739timer::stop ()
1715 CODE: 1740 CODE:
1716 THIS->stop (); 1741 THIS->stop ();
1717 RETVAL = THIS; 1742 RETVAL = THIS;
1718 OUTPUT: 1743 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines