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.34 by root, Fri Jan 6 21:06:09 2006 UTC vs.
Revision 1.70 by root, Tue Jan 17 09:34:21 2006 UTC

26#include <XSUB.h> 26#include <XSUB.h>
27#undef line_t 27#undef line_t
28 28
29#include "../config.h" 29#include "../config.h"
30 30
31#include <cstddef>
31#include <cstdarg> 32#include <cstdarg>
32 33
34#include "unistd.h"
35
36#include "iom.h"
33#include "rxvt.h" 37#include "rxvt.h"
34#include "iom.h" 38#include "keyboard.h"
35#include "rxvtutil.h" 39#include "rxvtutil.h"
36#include "rxvtperl.h" 40#include "rxvtperl.h"
37 41
38#include "perlxsi.c" 42#include "perlxsi.c"
43
44#ifdef HAVE_SCROLLBARS
45# define GRAB_CURSOR THIS->leftptr_cursor
46#else
47# define GRAB_CURSOR None
48#endif
39 49
40#undef LINENO 50#undef LINENO
41#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) 51#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
42#undef ROW 52#undef ROW
43#define ROW(n) THIS->row_buf [LINENO (n)] 53#define ROW(n) THIS->row_buf [LINENO (n)]
44 54
55#define ENABLE_PERL_FRILLS 1
56
45///////////////////////////////////////////////////////////////////////////// 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}
46 74
47static wchar_t * 75static wchar_t *
48sv2wcs (SV *sv) 76sv2wcs (SV *sv)
49{ 77{
50 STRLEN len; 78 STRLEN len;
101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 129 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
102 130
103 return (long)mg->mg_ptr; 131 return (long)mg->mg_ptr;
104} 132}
105 133
106#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 134#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self)
107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 135#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
108 136
109///////////////////////////////////////////////////////////////////////////// 137/////////////////////////////////////////////////////////////////////////////
110 138
111struct perl_watcher 139struct perl_watcher
290void 318void
291overlay::show () 319overlay::show ()
292{ 320{
293 char key[33]; sprintf (key, "%32lx", (long)this); 321 char key[33]; sprintf (key, "%32lx", (long)this);
294 322
295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); 323 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
296 hv_store (hv, key, 32, newSViv ((long)this), 0); 324 hv_store (hv, key, 32, newSViv ((long)this), 0);
297} 325}
298 326
299void 327void
300overlay::hide () 328overlay::hide ()
301{ 329{
302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); 330 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0);
303 331
304 if (ovs) 332 if (ovs)
305 { 333 {
306 char key[33]; sprintf (key, "%32lx", (long)this); 334 char key[33]; sprintf (key, "%32lx", (long)this);
307 335
321 for (int y = ov_h; y--; ) 349 for (int y = ov_h; y--; )
322 { 350 {
323 text_t *t1 = text [y]; 351 text_t *t1 = text [y];
324 rend_t *r1 = rend [y]; 352 rend_t *r1 = rend [y];
325 353
326 text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; 354 text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x;
327 rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; 355 rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x;
328 356
329 for (int x = ov_w; x--; ) 357 for (int x = ov_w; x--; )
330 { 358 {
331 text_t t = *t1; *t1++ = *t2; *t2++ = t; 359 text_t t = *t1; *t1++ = *t2; *t2++ = t;
332 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); 360 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t));
369 397
370struct rxvt_perl_interp rxvt_perl; 398struct rxvt_perl_interp rxvt_perl;
371 399
372static PerlInterpreter *perl; 400static PerlInterpreter *perl;
373 401
374rxvt_perl_interp::rxvt_perl_interp ()
375{
376}
377
378rxvt_perl_interp::~rxvt_perl_interp () 402rxvt_perl_interp::~rxvt_perl_interp ()
379{ 403{
380 if (perl) 404 if (perl)
381 { 405 {
382 perl_destruct (perl); 406 perl_destruct (perl);
383 perl_free (perl); 407 perl_free (perl);
384 } 408 }
385} 409}
386 410
387void 411void
388rxvt_perl_interp::init () 412rxvt_perl_interp::init (rxvt_term *term)
389{ 413{
390 if (!perl) 414 if (!perl)
391 { 415 {
416 rxvt_push_locale (""); // perl init destroys current locale
417
418 perl_environ = rxvt_environ;
419 swap (perl_environ, environ);
420
392 char *argv[] = { 421 char *argv[] = {
393 "", 422 "",
423 "-T",
394 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 424 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1",
395 }; 425 };
396 426
397 perl = perl_alloc (); 427 perl = perl_alloc ();
398 perl_construct (perl); 428 perl_construct (perl);
399 429
400 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 430 if (perl_parse (perl, xs_init, 3, argv, (char **)NULL)
401 || perl_run (perl)) 431 || perl_run (perl))
402 { 432 {
403 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 433 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
404 434
405 perl_destruct (perl); 435 perl_destruct (perl);
406 perl_free (perl); 436 perl_free (perl);
407 perl = 0; 437 perl = 0;
408 } 438 }
439
440 swap (perl_environ, environ);
441
442 rxvt_pop_locale ();
443 }
444
445 if (perl)
446 {
447 // runs outside of perls ENV
448 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
449 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
450 }
451}
452
453static void
454ungrab (rxvt_term *THIS)
455{
456 if (THIS->perl.grabtime)
457 {
458 XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime);
459 XUngrabPointer (THIS->display->display, THIS->perl.grabtime);
460 THIS->perl.grabtime = 0;
461 }
462}
463
464static void
465swap_overlays (rxvt_term *term)
466{
467 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
468
469 if (HvKEYS (hv))
470 {
471 hv_iterinit (hv);
472
473 while (HE *he = hv_iternext (hv))
474 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
409 } 475 }
410} 476}
411 477
412bool 478bool
413rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 479rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
414{ 480{
415 if (!perl) 481 if (!perl || !term->perl.self)
416 return false; 482 return false;
417 483
418 if (htype == HOOK_INIT) // first hook ever called 484 // pre-handling of some events
419 { 485 if (htype == HOOK_REFRESH_END)
420 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 486 swap_overlays (term);
421 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
422 }
423 else if (!term->self)
424 return false; // perl not initialized for this instance
425 else if (htype == HOOK_DESTROY)
426 {
427 // handled later
428 }
429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
430 {
431 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0));
432 487
433 if (HvKEYS (hv)) 488 swap (perl_environ, environ);
434 {
435 hv_iterinit (hv);
436 489
437 while (HE *he = hv_iternext (hv)) 490 bool event_consumed;
438 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
439 }
440 }
441 else if (!should_invoke [htype])
442 return false;
443 491
444 dSP; 492 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
445 va_list ap; 493 || term->perl.should_invoke [htype])
446 494 try
447 va_start (ap, htype);
448
449 ENTER;
450 SAVETMPS;
451
452 PUSHMARK (SP);
453
454 XPUSHs (sv_2mortal (newSVterm (term)));
455 XPUSHs (sv_2mortal (newSViv (htype)));
456
457 for (;;) {
458 data_type dt = (data_type)va_arg (ap, int);
459
460 switch (dt)
461 { 495 {
496 dSP;
497 va_list ap;
498
499 va_start (ap, htype);
500
501 ENTER;
502 SAVETMPS;
503
504 PUSHMARK (SP);
505
506 XPUSHs (sv_2mortal (newSVterm (term)));
507 XPUSHs (sv_2mortal (newSViv (htype)));
508
509 for (;;) {
510 data_type dt = (data_type)va_arg (ap, int);
511
512 switch (dt)
513 {
462 case DT_INT: 514 case DT_INT:
463 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 515 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
464 break; 516 break;
465 517
466 case DT_LONG: 518 case DT_LONG:
467 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 519 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
468 break; 520 break;
469 521
470 case DT_STR: 522 case DT_STR:
471 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 523 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
472 break; 524 break;
473 525
474 case DT_STR_LEN: 526 case DT_STR_LEN:
475 { 527 {
476 char *str = va_arg (ap, char *); 528 char *str = va_arg (ap, char *);
477 int len = va_arg (ap, int); 529 int len = va_arg (ap, int);
478 530
479 XPUSHs (sv_2mortal (newSVpvn (str, len))); 531 XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
480 } 532 }
481 break; 533 break;
482 534
483 case DT_WCS_LEN: 535 case DT_WCS_LEN:
484 { 536 {
485 wchar_t *wstr = va_arg (ap, wchar_t *); 537 wchar_t *wstr = va_arg (ap, wchar_t *);
486 int wlen = va_arg (ap, int); 538 int wlen = va_arg (ap, int);
487 539
488 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 540 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
489 } 541 }
490 break; 542 break;
491 543
492 case DT_XEVENT: 544 case DT_XEVENT:
493 { 545 {
494 XEvent *xe = va_arg (ap, XEvent *); 546 XEvent *xe = va_arg (ap, XEvent *);
495 HV *hv = newHV (); 547 HV *hv = newHV ();
496 548
497# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 549# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
498# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 550# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
499# undef set 551# undef set
500 552
501 setiv (type, xe->type); 553 setiv (type, xe->type);
502 setiv (send_event, xe->xany.send_event); 554 setiv (send_event, xe->xany.send_event);
503 setiv (serial, xe->xany.serial); 555 setiv (serial, xe->xany.serial);
504 556
505 switch (xe->type) 557 switch (xe->type)
506 { 558 {
507 case KeyPress: 559 case KeyPress:
508 case KeyRelease: 560 case KeyRelease:
509 case ButtonPress: 561 case ButtonPress:
510 case ButtonRelease: 562 case ButtonRelease:
511 case MotionNotify: 563 case MotionNotify:
512 setiv (time, xe->xmotion.time); 564 setiv (time, xe->xmotion.time);
513 setiv (x, xe->xmotion.x); 565 setiv (x, xe->xmotion.x);
514 setiv (y, xe->xmotion.y); 566 setiv (y, xe->xmotion.y);
515 setiv (row, xe->xmotion.y / term->fheight); 567 setiv (row, xe->xmotion.y / term->fheight);
516 setiv (col, xe->xmotion.x / term->fwidth); 568 setiv (col, xe->xmotion.x / term->fwidth);
517 setiv (x_root, xe->xmotion.x_root); 569 setiv (x_root, xe->xmotion.x_root);
518 setiv (y_root, xe->xmotion.y_root); 570 setiv (y_root, xe->xmotion.y_root);
519 setiv (state, xe->xmotion.state); 571 setiv (state, xe->xmotion.state);
572 break;
573 }
574
575 switch (xe->type)
576 {
577 case KeyPress:
578 case KeyRelease:
579 setiv (keycode, xe->xkey.keycode);
580 break;
581
582 case ButtonPress:
583 case ButtonRelease:
584 setiv (button, xe->xbutton.button);
585 break;
586
587 case MotionNotify:
588 setiv (is_hint, xe->xmotion.is_hint);
589 break;
590 }
591
592 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
593 }
520 break; 594 break;
595
596 case DT_END:
597 goto call;
598
599 default:
600 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
521 } 601 }
522
523 switch (xe->type)
524 {
525 case KeyPress:
526 case KeyRelease:
527 setiv (keycode, xe->xkey.keycode);
528 break;
529
530 case ButtonPress:
531 case ButtonRelease:
532 setiv (button, xe->xbutton.button);
533 break;
534
535 case MotionNotify:
536 setiv (is_hint, xe->xmotion.is_hint);
537 break;
538 }
539
540 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
541 } 602 }
542 break;
543 603
544 case DT_END: 604 call:
545 {
546 va_end (ap); 605 va_end (ap);
547 606
548 PUTBACK; 607 PUTBACK;
549 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); 608 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
550 SPAGAIN; 609 SPAGAIN;
551 610
552 if (count) 611 if (count)
553 { 612 {
554 SV *status = POPs; 613 SV *status = POPs;
555 count = SvTRUE (status); 614 count = SvTRUE (status);
556 } 615 }
557 616
558 PUTBACK; 617 PUTBACK;
559 FREETMPS; 618 FREETMPS;
560 LEAVE; 619 LEAVE;
561 620
562 if (SvTRUE (ERRSV)) 621 if (SvTRUE (ERRSV))
622 {
563 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 623 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
564 624 ungrab (term); // better lose the grab than the session
565 if (htype == HOOK_DESTROY)
566 {
567 clearSVptr ((SV *)term->self);
568 SvREFCNT_dec ((SV *)term->self);
569 } 625 }
570 626
571 return count; 627 event_consumed = !!count;
572 }
573
574 default:
575 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
576 } 628 }
629 catch (...)
630 {
631 swap (perl_environ, environ);
632 throw;
633 }
634 else
635 event_consumed = false;
636
637 // post-handling of some events
638 if (htype == HOOK_REFRESH_BEGIN)
639 swap_overlays (term);
640 else if (htype == HOOK_DESTROY)
641 {
642 clearSVptr ((SV *)term->perl.self);
643 SvREFCNT_dec ((SV *)term->perl.self);
577 } 644 }
645
646 swap (perl_environ, environ);
647
648 return event_consumed;
578} 649}
579 650
580///////////////////////////////////////////////////////////////////////////// 651/////////////////////////////////////////////////////////////////////////////
581 652
582MODULE = urxvt PACKAGE = urxvt 653MODULE = urxvt PACKAGE = urxvt
583 654
584PROTOTYPES: ENABLE 655PROTOTYPES: ENABLE
585 656
586BOOT: 657BOOT:
587{ 658{
588# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); 659 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
660 sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1));
661 sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1));
662 sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1));
663
589 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 664 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
590# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 665# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
591# include "hookinc.h" 666# include "hookinc.h"
592# undef def 667# undef def
593 668
669 HV *option = get_hv ("urxvt::OPTION", 1);
670# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
671# define nodef(name)
672# include "optinc.h"
673# undef nodef
674# undef def
675
676 HV *stash = gv_stashpv ("urxvt", 1);
677 struct {
678 const char *name;
679 IV iv;
680 } *civ, const_iv[] = {
681# define const_iv(name) { # name, (IV)name }
594 export_const (DEFAULT_RSTYLE); 682 const_iv (DEFAULT_RSTYLE),
595 export_const (OVERLAY_RSTYLE); 683 const_iv (OVERLAY_RSTYLE),
596 export_const (RS_Bold); 684 const_iv (RS_Bold),
597 export_const (RS_Italic); 685 const_iv (RS_Italic),
598 export_const (RS_Blink); 686 const_iv (RS_Blink),
599 export_const (RS_RVid); 687 const_iv (RS_RVid),
600 export_const (RS_Uline); 688 const_iv (RS_Uline),
601 689
602 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 690 const_iv (CurrentTime),
691 const_iv (ShiftMask),
692 const_iv (LockMask),
693 const_iv (ControlMask),
694 const_iv (Mod1Mask),
695 const_iv (Mod2Mask),
696 const_iv (Mod3Mask),
697 const_iv (Mod4Mask),
698 const_iv (Mod5Mask),
699 const_iv (Button1Mask),
700 const_iv (Button2Mask),
701 const_iv (Button3Mask),
702 const_iv (Button4Mask),
703 const_iv (Button5Mask),
704 const_iv (AnyModifier),
705
706 const_iv (EVENT_NONE),
707 const_iv (EVENT_READ),
708 const_iv (EVENT_WRITE),
709
710 const_iv (NoEventMask),
711 const_iv (KeyPressMask),
712 const_iv (KeyReleaseMask),
713 const_iv (ButtonPressMask),
714 const_iv (ButtonReleaseMask),
715 const_iv (EnterWindowMask),
716 const_iv (LeaveWindowMask),
717 const_iv (PointerMotionMask),
718 const_iv (PointerMotionHintMask),
719 const_iv (Button1MotionMask),
720 const_iv (Button2MotionMask),
721 const_iv (Button3MotionMask),
722 const_iv (Button4MotionMask),
723 const_iv (Button5MotionMask),
724 const_iv (ButtonMotionMask),
725 const_iv (KeymapStateMask),
726 const_iv (ExposureMask),
727 const_iv (VisibilityChangeMask),
728 const_iv (StructureNotifyMask),
729 const_iv (ResizeRedirectMask),
730 const_iv (SubstructureNotifyMask),
731 const_iv (SubstructureRedirectMask),
732 const_iv (FocusChangeMask),
733 const_iv (PropertyChangeMask),
734 const_iv (ColormapChangeMask),
735 const_iv (OwnerGrabButtonMask),
736
737 const_iv (KeyPress),
738 const_iv (KeyRelease),
739 const_iv (ButtonPress),
740 const_iv (ButtonRelease),
741 const_iv (MotionNotify),
742 const_iv (EnterNotify),
743 const_iv (LeaveNotify),
744 const_iv (FocusIn),
745 const_iv (FocusOut),
746 const_iv (KeymapNotify),
747 const_iv (Expose),
748 const_iv (GraphicsExpose),
749 const_iv (NoExpose),
750 const_iv (VisibilityNotify),
751 const_iv (CreateNotify),
752 const_iv (DestroyNotify),
753 const_iv (UnmapNotify),
754 const_iv (MapNotify),
755 const_iv (MapRequest),
756 const_iv (ReparentNotify),
757 const_iv (ConfigureNotify),
758 const_iv (ConfigureRequest),
759 const_iv (GravityNotify),
760 const_iv (ResizeRequest),
761 const_iv (CirculateNotify),
762 const_iv (CirculateRequest),
763 const_iv (PropertyNotify),
764 const_iv (SelectionClear),
765 const_iv (SelectionRequest),
766 const_iv (SelectionNotify),
767 const_iv (ColormapNotify),
768 const_iv (ClientMessage),
769 const_iv (MappingNotify),
770 };
771
772 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
773 civ-- > const_iv; )
774 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
603} 775}
776
777void
778warn (const char *msg)
779 CODE:
780 rxvt_warn ("%s", msg);
781
782void
783fatal (const char *msg)
784 CODE:
785 rxvt_fatal ("%s", msg);
604 786
605SV * 787SV *
606new (...) 788untaint (SV *sv)
607 CODE: 789 CODE:
608{ 790 RETVAL = newSVsv (sv);
609 stringvec *argv = new stringvec; 791 SvTAINTED_off (RETVAL);
610 bool success; 792 OUTPUT:
611
612 for (int i = 0; i < items ;i++)
613 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
614
615 rxvt_term *term = new rxvt_term;
616
617 term->argv = argv;
618
619 try
620 {
621 if (!term->init (argv->size (), argv->begin ()))
622 term = 0;
623 }
624 catch (const class rxvt_failure_exception &e)
625 {
626 term->destroy ();
627 croak ("exception caught while initializing new terminal instance");
628 }
629
630 RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef;
631}
632 OUTPUT:
633 RETVAL 793 RETVAL
634 794
635void 795void
636set_should_invoke (int htype, int value) 796_exit (int status)
637 CODE:
638 rxvt_perl.should_invoke [htype] = value;
639 797
640void 798bool
641warn (const char *msg) 799safe ()
642 CODE: 800 CODE:
643 rxvt_warn ("%s", msg); 801 RETVAL = !rxvt_tainted ();
644 802 OUTPUT:
645void 803 RETVAL
646fatal (const char *msg)
647 CODE:
648 rxvt_fatal ("%s", msg);
649 804
650NV 805NV
651NOW () 806NOW ()
652 CODE: 807 CODE:
653 RETVAL = NOW; 808 RETVAL = NOW;
702 OUTPUT: 857 OUTPUT:
703 RETVAL 858 RETVAL
704 859
705MODULE = urxvt PACKAGE = urxvt::term 860MODULE = urxvt PACKAGE = urxvt::term
706 861
862SV *
863_new (...)
864 CODE:
865{
866 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
867 croak ("first argument to urxvt::term->_new must be arrayref");
868
869 rxvt_term *term = new rxvt_term;
870
871 term->argv = new stringvec;
872 term->envv = new stringvec;
873
874 for (int i = 1; i < items; i++)
875 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
876
877 AV *envv = (AV *)SvRV (ST (0));
878 for (int i = av_len (envv) + 1; i--; )
879 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1))));
880
881 term->envv->push_back (0);
882
883 bool success;
884
885 try
886 {
887 success = term->init (term->argv->size (), term->argv->begin ());
888 }
889 catch (const class rxvt_failure_exception &e)
890 {
891 success = false;
892 }
893
894 if (!success)
895 {
896 term->destroy ();
897 croak ("error while initializing new terminal instance");
898 }
899
900 RETVAL = term && term->perl.self
901 ? newSVterm (term) : &PL_sv_undef;
902}
903 OUTPUT:
904 RETVAL
905
707void 906void
708rxvt_term::destroy () 907rxvt_term::destroy ()
908
909#if ENABLE_PERL_FRILLS
910
911void
912rxvt_term::XListProperties (U32 window)
913 PPCODE:
914{
915 int count;
916 Atom *props = XListProperties (THIS->display->display, (Window)window, &count);
917
918 EXTEND (SP, count);
919 while (count--)
920 PUSHs (newSVuv ((U32)props [count]));
921
922 XFree (props);
923}
924
925void
926rxvt_term::XGetWindowProperty (U32 window, U32 property)
927 PPCODE:
928{
929 Atom type;
930 int format;
931 unsigned long nitems;
932 unsigned long bytes_after;
933 unsigned char *prop;
934 XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property,
935 0, 1<<30, 0, AnyPropertyType,
936 &type, &format, &nitems, &bytes_after, &prop);
937 if (type != None)
938 {
939 EXTEND (SP, 3);
940 PUSHs (newSVuv ((U32)type));
941 PUSHs (newSViv (format));
942 PUSHs (newSVpvn ((char *)prop, nitems * format / 8));
943 XFree (prop);
944 }
945}
946
947void
948rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data)
949 CODE:
950{
951 STRLEN len;
952 char *data_ = SvPVbyte (data, len);
953
954 XChangeProperty (THIS->display->display, (Window)window, (Atom)property,
955 type, format, PropModeReplace,
956 (unsigned char *)data, len * 8 / format);
957}
958
959void
960rxvt_term::XDeleteProperty (U32 window, U32 property)
961 CODE:
962 XDeleteProperty (THIS->display->display, (Window)window, (Atom)property);
963
964U32
965rxvt_term::DefaultRootWindow ()
966 CODE:
967 RETVAL = (U32)THIS->display->root;
968 OUTPUT:
969 RETVAL
970
971U32
972rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height)
973 CODE:
974 RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent,
975 x, y, width, height, 0,
976 THIS->pix_colors_focused[Color_border],
977 THIS->pix_colors_focused[Color_border]);
978 OUTPUT:
979 RETVAL
980
981void
982rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0)
983 CODE:
984 XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y);
985
986void
987rxvt_term::XMapWindow (U32 window)
988 CODE:
989 XMapWindow (THIS->display->display, (Window)window);
990
991void
992rxvt_term::XUnmapWindow (U32 window)
993 CODE:
994 XUnmapWindow (THIS->display->display, (Window)window);
995
996#endif
997
998void
999rxvt_term::set_should_invoke (int htype, int inc)
1000 CODE:
1001 THIS->perl.should_invoke [htype] += inc;
1002
1003void
1004rxvt_term::grab_button (int button, U32 modifiers)
1005 CODE:
1006 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
1007 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1008 GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
1009
1010bool
1011rxvt_term::grab (U32 eventtime, int sync = 0)
1012 CODE:
1013{
1014 int mode = sync ? GrabModeSync : GrabModeAsync;
1015
1016 THIS->perl.grabtime = 0;
1017
1018 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
1019 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1020 mode, mode, None, GRAB_CURSOR, eventtime))
1021 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
1022 THIS->perl.grabtime = eventtime;
1023 else
1024 XUngrabPointer (THIS->display->display, eventtime);
1025
1026 RETVAL = !!THIS->perl.grabtime;
1027}
1028 OUTPUT:
1029 RETVAL
1030
1031void
1032rxvt_term::allow_events_async ()
1033 CODE:
1034 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime);
1035
1036void
1037rxvt_term::allow_events_sync ()
1038 CODE:
1039 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime);
1040
1041void
1042rxvt_term::allow_events_replay ()
1043 CODE:
1044 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime);
1045 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime);
1046
1047void
1048rxvt_term::ungrab ()
1049 CODE:
1050 ungrab (THIS);
709 1051
710int 1052int
711rxvt_term::strwidth (SV *str) 1053rxvt_term::strwidth (SV *str)
712 CODE: 1054 CODE:
713{ 1055{
732 char *mbstr = rxvt_wcstombs (wstr); 1074 char *mbstr = rxvt_wcstombs (wstr);
733 rxvt_pop_locale (); 1075 rxvt_pop_locale ();
734 1076
735 free (wstr); 1077 free (wstr);
736 1078
737 RETVAL = newSVpv (mbstr, 0); 1079 RETVAL = taint_if (newSVpv (mbstr, 0), str);
738 free (mbstr); 1080 free (mbstr);
739} 1081}
740 OUTPUT: 1082 OUTPUT:
741 RETVAL 1083 RETVAL
742 1084
749 1091
750 rxvt_push_locale (THIS->locale); 1092 rxvt_push_locale (THIS->locale);
751 wchar_t *wstr = rxvt_mbstowcs (data, len); 1093 wchar_t *wstr = rxvt_mbstowcs (data, len);
752 rxvt_pop_locale (); 1094 rxvt_pop_locale ();
753 1095
754 RETVAL = wcs2sv (wstr); 1096 RETVAL = taint_if (wcs2sv (wstr), octets);
755 free (wstr); 1097 free (wstr);
756} 1098}
757 OUTPUT: 1099 OUTPUT:
758 RETVAL 1100 RETVAL
759 1101
760# very portable, especially on objects as opposed to pods 1102#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
761#define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0)
762 1103
763#define TERM_OFFSET_width TERM_OFFSET(width) 1104#define TERM_OFFSET_width TERM_OFFSET(width)
764#define TERM_OFFSET_height TERM_OFFSET(height) 1105#define TERM_OFFSET_height TERM_OFFSET(height)
765#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 1106#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
766#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 1107#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
769#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1110#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
770#define TERM_OFFSET_focus TERM_OFFSET(focus) 1111#define TERM_OFFSET_focus TERM_OFFSET(focus)
771#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1112#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
772#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1113#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
773#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1114#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
774#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) 1115#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
775 1116
776int 1117int
777rxvt_term::width () 1118rxvt_term::width ()
778 ALIAS: 1119 ALIAS:
779 width = TERM_OFFSET_width 1120 width = TERM_OFFSET_width
785 ncol = TERM_OFFSET_ncol 1126 ncol = TERM_OFFSET_ncol
786 focus = TERM_OFFSET_focus 1127 focus = TERM_OFFSET_focus
787 mapped = TERM_OFFSET_mapped 1128 mapped = TERM_OFFSET_mapped
788 saveLines = TERM_OFFSET_saveLines 1129 saveLines = TERM_OFFSET_saveLines
789 total_rows = TERM_OFFSET_total_rows 1130 total_rows = TERM_OFFSET_total_rows
790 nsaved = TERM_OFFSET_nsaved 1131 top_row = TERM_OFFSET_top_row
791 CODE: 1132 CODE:
792 RETVAL = *(int *)((char *)THIS + ix); 1133 RETVAL = *(int *)((char *)THIS + ix);
793 OUTPUT: 1134 OUTPUT:
1135 RETVAL
1136
1137unsigned int
1138rxvt_term::ModLevel3Mask ()
1139 ALIAS:
1140 ModLevel3Mask = 0
1141 ModMetaMask = 1
1142 ModNumLockMask = 2
1143 CODE:
1144 switch (ix)
1145 {
1146 case 0: RETVAL = THIS->ModLevel3Mask; break;
1147 case 1: RETVAL = THIS->ModMetaMask; break;
1148 case 2: RETVAL = THIS->ModNumLockMask; break;
1149 }
1150 OUTPUT:
1151 RETVAL
1152
1153char *
1154rxvt_term::display_id ()
1155 ALIAS:
1156 display_id = 0
1157 locale = 1
1158 CODE:
1159 switch (ix)
1160 {
1161 case 0: RETVAL = THIS->display->id; break;
1162 case 1: RETVAL = THIS->locale; break;
1163 }
1164 OUTPUT:
1165 RETVAL
1166
1167SV *
1168rxvt_term::_env ()
1169 CODE:
1170{
1171 if (THIS->envv)
1172 {
1173 AV *av = newAV ();
1174
1175 for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i)
1176 if (*i)
1177 av_push (av, newSVpv (*i, 0));
1178
1179 RETVAL = newRV_noinc ((SV *)av);
1180 }
1181 else
1182 RETVAL = &PL_sv_undef;
1183}
1184 OUTPUT:
1185 RETVAL
1186
1187int
1188rxvt_term::pty_ev_events (int events = EVENT_UNDEF)
1189 CODE:
1190 RETVAL = THIS->pty_ev.events;
1191 if (events != EVENT_UNDEF)
1192 THIS->pty_ev.set (events);
1193 OUTPUT:
794 RETVAL 1194 RETVAL
795 1195
796U32 1196U32
797rxvt_term::parent () 1197rxvt_term::parent ()
798 CODE: 1198 CODE:
805 CODE: 1205 CODE:
806 RETVAL = (U32)THIS->vt; 1206 RETVAL = (U32)THIS->vt;
807 OUTPUT: 1207 OUTPUT:
808 RETVAL 1208 RETVAL
809 1209
1210void
1211rxvt_term::vt_emask_add (U32 emask)
1212 CODE:
1213 THIS->vt_emask_perl |= emask;
1214 THIS->vt_select_input ();
1215
810U32 1216U32
811rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 1217rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
812 CODE: 1218 CODE:
813{
814 RETVAL = THIS->rstyle; 1219 RETVAL = THIS->rstyle;
815 THIS->rstyle = new_rstyle; 1220 THIS->rstyle = new_rstyle;
816}
817 OUTPUT: 1221 OUTPUT:
818 RETVAL 1222 RETVAL
819 1223
820int 1224int
821rxvt_term::view_start (int newval = -1) 1225rxvt_term::view_start (int newval = 1)
1226 PROTOTYPE: $;$
822 CODE: 1227 CODE:
823{ 1228{
824 RETVAL = THIS->view_start; 1229 RETVAL = THIS->view_start;
825 1230
826 if (newval >= 0) 1231 if (newval <= 0)
827 { 1232 THIS->scr_changeview (max (newval, THIS->top_row));
828 THIS->view_start = min (newval, THIS->nsaved);
829 THIS->scr_changeview (RETVAL);
830 }
831} 1233}
832 OUTPUT: 1234 OUTPUT:
833 RETVAL 1235 RETVAL
834 1236
835void 1237void
839 1241
840void 1242void
841rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1243rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
842 PPCODE: 1244 PPCODE:
843{ 1245{
844 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1246 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
845 XSRETURN_EMPTY; 1247 XSRETURN_EMPTY;
846 1248
847 line_t &l = ROW(row_number); 1249 line_t &l = ROW(row_number);
848 1250
849 if (GIMME_V != G_VOID) 1251 if (GIMME_V != G_VOID)
851 wchar_t *wstr = new wchar_t [THIS->ncol]; 1253 wchar_t *wstr = new wchar_t [THIS->ncol];
852 1254
853 for (int col = 0; col < THIS->ncol; col++) 1255 for (int col = 0; col < THIS->ncol; col++)
854 wstr [col] = l.t [col]; 1256 wstr [col] = l.t [col];
855 1257
856 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); 1258 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol))));
857 1259
858 delete [] wstr; 1260 delete [] wstr;
859 } 1261 }
860 1262
861 if (new_text) 1263 if (new_text)
882 1284
883void 1285void
884rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1286rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
885 PPCODE: 1287 PPCODE:
886{ 1288{
887 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1289 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
888 XSRETURN_EMPTY; 1290 XSRETURN_EMPTY;
889 1291
890 line_t &l = ROW(row_number); 1292 line_t &l = ROW(row_number);
891 1293
892 if (GIMME_V != G_VOID) 1294 if (GIMME_V != G_VOID)
922 1324
923int 1325int
924rxvt_term::ROW_l (int row_number, int new_length = -1) 1326rxvt_term::ROW_l (int row_number, int new_length = -1)
925 CODE: 1327 CODE:
926{ 1328{
927 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1329 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
928 XSRETURN_EMPTY; 1330 XSRETURN_EMPTY;
929 1331
930 line_t &l = ROW(row_number); 1332 line_t &l = ROW(row_number);
931 RETVAL = l.l; 1333 RETVAL = l.l;
932 1334
938 1340
939bool 1341bool
940rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) 1342rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1)
941 CODE: 1343 CODE:
942{ 1344{
943 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1345 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
944 XSRETURN_EMPTY; 1346 XSRETURN_EMPTY;
945 1347
946 line_t &l = ROW(row_number); 1348 line_t &l = ROW(row_number);
947 RETVAL = l.is_longer (); 1349 RETVAL = l.is_longer ();
948 1350
982 else 1384 else
983 *r++ = *s; 1385 *r++ = *s;
984 1386
985 rxvt_pop_locale (); 1387 rxvt_pop_locale ();
986 1388
987 RETVAL = wcs2sv (rstr, r - rstr); 1389 RETVAL = taint_if (wcs2sv (rstr, r - rstr), string);
988 1390
989 delete [] rstr; 1391 delete [] rstr;
990} 1392}
991 OUTPUT: 1393 OUTPUT:
992 RETVAL 1394 RETVAL
1018 else if (IS_COMPOSE (*s)) 1420 else if (IS_COMPOSE (*s))
1019 r += rxvt_composite.expand (*s, r); 1421 r += rxvt_composite.expand (*s, r);
1020 else 1422 else
1021 *r++ = *s; 1423 *r++ = *s;
1022 1424
1023 RETVAL = wcs2sv (rstr, r - rstr); 1425 RETVAL = taint_if (wcs2sv (rstr, r - rstr), text);
1024 1426
1025 delete [] rstr; 1427 delete [] rstr;
1026} 1428}
1027 OUTPUT: 1429 OUTPUT:
1028 RETVAL 1430 RETVAL
1050 1452
1051 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1453 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
1052 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); 1454 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);
1053 1455
1054 if (GIMME_V != G_VOID) 1456 if (GIMME_V != G_VOID)
1055 XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); 1457 XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef);
1056 1458
1057 if (newval) 1459 if (newval)
1058 { 1460 {
1059 if (SvOK (newval)) 1461 if (SvOK (newval))
1060 { 1462 {
1065 else 1467 else
1066 THIS->rs [index] = 0; 1468 THIS->rs [index] = 0;
1067 } 1469 }
1068} 1470}
1069 1471
1472const char *
1473rxvt_term::x_resource (const char *name)
1474 CLEANUP:
1475 SvTAINTED_on (ST (0));
1476
1477bool
1478rxvt_term::option (U32 optval, int set = -1)
1479 CODE:
1480{
1481 RETVAL = THIS->options & optval;
1482
1483 if (set >= 0)
1484 {
1485 if (set)
1486 THIS->options |= optval;
1487 else
1488 THIS->options &= ~optval;
1489
1490 switch (optval)
1491 {
1492 case Opt_skipBuiltinGlyphs:
1493 THIS->set_fonts ();
1494 THIS->scr_remap_chars ();
1495 THIS->scr_touch (true);
1496 THIS->want_refresh = 1;
1497 break;
1498
1499 case Opt_cursorUnderline:
1500 THIS->want_refresh = 1;
1501 break;
1502
1503# case Opt_scrollBar_floating:
1504# case Opt_scrollBar_right:
1505# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1506# break;
1507 }
1508 }
1509}
1510 OUTPUT:
1511 RETVAL
1512
1513bool
1514rxvt_term::parse_keysym (char *keysym, char *str)
1515 CODE:
1516 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1517 THIS->keyboard->register_done ();
1518 OUTPUT:
1519 RETVAL
1520
1070void 1521void
1071rxvt_term::cur (...) 1522rxvt_term::screen_cur (...)
1072 PROTOTYPE: $;$$ 1523 PROTOTYPE: $;$$
1073 ALIAS: 1524 ALIAS:
1074 screen_cur = 0 1525 screen_cur = 0
1075 selection_beg = 1 1526 selection_beg = 1
1076 selection_end = 2 1527 selection_end = 2
1089 PUSHs (sv_2mortal (newSViv (rc.col))); 1540 PUSHs (sv_2mortal (newSViv (rc.col)));
1090 } 1541 }
1091 1542
1092 if (items == 3) 1543 if (items == 3)
1093 { 1544 {
1094 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 1545 rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1);
1095 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); 1546 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1);
1096 1547
1097 if (ix) 1548 if (ix)
1098 THIS->want_refresh = 1; 1549 THIS->want_refresh = 1;
1099 } 1550 }
1100} 1551}
1101 1552
1553char
1554rxvt_term::cur_charset ()
1555 CODE:
1556 RETVAL = THIS->charsets [THIS->screen.charset];
1557 OUTPUT:
1558 RETVAL
1559
1560#void
1561#rxvt_term::selection_clear ()
1562
1563void
1564rxvt_term::selection_make (U32 eventtime, bool rect = false)
1565 CODE:
1566 THIS->selection.op = SELECTION_CONT;
1567 THIS->selection.rect = rect;
1568 THIS->selection_make (eventtime);
1569
1102int 1570int
1103rxvt_term::selection_grab (int eventtime = CurrentTime) 1571rxvt_term::selection_grab (U32 eventtime)
1104 1572
1105void 1573void
1106rxvt_term::selection (SV *newtext = 0) 1574rxvt_term::selection (SV *newtext = 0)
1107 PPCODE: 1575 PPCODE:
1108{ 1576{
1109 if (GIMME_V != G_VOID) 1577 if (GIMME_V != G_VOID)
1578 XPUSHs (THIS->selection.text
1110 XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); 1579 ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))
1580 : &PL_sv_undef);
1111 1581
1112 if (newtext) 1582 if (newtext)
1113 { 1583 {
1114 free (THIS->selection.text); 1584 free (THIS->selection.text);
1115 1585
1116 THIS->selection.text = sv2wcs (newtext); 1586 THIS->selection.text = sv2wcs (newtext);
1117 THIS->selection.len = wcslen (THIS->selection.text); 1587 THIS->selection.len = wcslen (THIS->selection.text);
1118 } 1588 }
1119} 1589}
1590
1591void
1592rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline)
1593
1594void
1595rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1596
1597void
1598rxvt_term::scr_bell ()
1120 1599
1121void 1600void
1122rxvt_term::scr_add_lines (SV *string) 1601rxvt_term::scr_add_lines (SV *string)
1123 CODE: 1602 CODE:
1124{ 1603{
1146 char *old_cmdbuf_endp = THIS->cmdbuf_endp; 1625 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1147 1626
1148 THIS->cmdbuf_ptr = str; 1627 THIS->cmdbuf_ptr = str;
1149 THIS->cmdbuf_endp = str + len; 1628 THIS->cmdbuf_endp = str + len;
1150 1629
1630 rxvt_push_locale (THIS->locale);
1151 THIS->cmd_parse (); 1631 THIS->cmd_parse ();
1632 rxvt_pop_locale ();
1152 1633
1153 THIS->cmdbuf_ptr = old_cmdbuf_ptr; 1634 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1154 THIS->cmdbuf_endp = old_cmdbuf_endp; 1635 THIS->cmdbuf_endp = old_cmdbuf_endp;
1155} 1636}
1156 1637

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines