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.48 by root, Mon Jan 9 05:08:02 2006 UTC vs.
Revision 1.77 by root, Thu Jan 19 17:55:27 2006 UTC

29#include "../config.h" 29#include "../config.h"
30 30
31#include <cstddef> 31#include <cstddef>
32#include <cstdarg> 32#include <cstdarg>
33 33
34#include "unistd.h"
35
36#include "iom.h"
34#include "rxvt.h" 37#include "rxvt.h"
35#include "iom.h" 38#include "keyboard.h"
36#include "rxvtutil.h" 39#include "rxvtutil.h"
37#include "rxvtperl.h" 40#include "rxvtperl.h"
38 41
39#include "perlxsi.c" 42#include "perlxsi.c"
40 43
41#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 44#ifdef HAVE_SCROLLBARS
42# define GRAB_CURSOR THIS->leftptr_cursor 45# define GRAB_CURSOR THIS->leftptr_cursor
43#else 46#else
44# define GRAB_CURSOR None 47# define GRAB_CURSOR None
45#endif 48#endif
46 49
47#undef LINENO 50#undef LINENO
48#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)
49#undef ROW 52#undef ROW
50#define ROW(n) THIS->row_buf [LINENO (n)] 53#define ROW(n) THIS->row_buf [LINENO (n)]
51 54
55#define ENABLE_PERL_FRILLS 1
56
52///////////////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////////////
53
54static SV *
55taint (SV *sv)
56{
57 SvTAINT (sv);
58 return sv;
59}
60
61static SV *
62taint_if (SV *sv, SV *src)
63{
64 if (SvTAINTED (src))
65 SvTAINT (sv);
66
67 return sv;
68}
69 58
70static wchar_t * 59static wchar_t *
71sv2wcs (SV *sv) 60sv2wcs (SV *sv)
72{ 61{
73 STRLEN len; 62 STRLEN len;
222 211
223#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 212#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
224 213
225struct overlay { 214struct overlay {
226 HV *self; 215 HV *self;
216 bool visible;
227 rxvt_term *THIS; 217 rxvt_term *THIS;
228 int x, y, w, h; 218 int x, y, w, h;
229 int border; 219 int border;
230 text_t **text; 220 text_t **text;
231 rend_t **rend; 221 rend_t **rend;
240 230
241 void set (int x, int y, SV *str, SV *rend); 231 void set (int x, int y, SV *str, SV *rend);
242}; 232};
243 233
244overlay::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)
245: 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)
246{ 236{
247 if (border == 2) 237 if (border == 2)
248 { 238 {
249 w += 2; 239 w += 2;
250 h += 2; 240 h += 2;
311} 301}
312 302
313void 303void
314overlay::show () 304overlay::show ()
315{ 305{
316 char key[33]; sprintf (key, "%32lx", (long)this); 306 if (visible)
307 return;
317 308
309 visible = true;
310
318 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));
319 hv_store (hv, key, 32, newSViv ((long)this), 0); 312 av_push (av, newSViv ((long)this));
320} 313}
321 314
322void 315void
323overlay::hide () 316overlay::hide ()
324{ 317{
318 if (!visible)
319 return;
320
321 visible = false;
322
325 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));
326 324
327 if (ovs) 325 int i;
326
327 for (i = AvFILL (av); i >= 0; i--)
328 if (SvIV (*av_fetch (av, i, 1)) == (long)this)
328 { 329 {
329 char key[33]; sprintf (key, "%32lx", (long)this);
330
331 HV *hv = (HV *)SvRV (*ovs);
332 hv_delete (hv, key, 32, G_DISCARD); 330 av_delete (av, i, G_DISCARD);
331 break;
333 } 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);
334} 338}
335 339
336void overlay::swap () 340void overlay::swap ()
337{ 341{
338 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));
344 for (int y = ov_h; y--; ) 348 for (int y = ov_h; y--; )
345 { 349 {
346 text_t *t1 = text [y]; 350 text_t *t1 = text [y];
347 rend_t *r1 = rend [y]; 351 rend_t *r1 = rend [y];
348 352
349 text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; 353 text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x;
350 rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; 354 rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x;
351 355
352 for (int x = ov_w; x--; ) 356 for (int x = ov_w; x--; )
353 { 357 {
354 text_t t = *t1; *t1++ = *t2; *t2++ = t; 358 text_t t = *t1; *t1++ = *t2; *t2++ = t;
355 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); 359 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t));
378 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) 382 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
379 croak ("rend must be arrayref"); 383 croak ("rend must be arrayref");
380 384
381 AV *av = (AV *)SvRV (rend); 385 AV *av = (AV *)SvRV (rend);
382 386
383 for (int col = min (av_len (av) + 1, w - x - border); col--; ) 387 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
384 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 388 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
385 } 389 }
386 390
387 THIS->want_refresh = 1; 391 THIS->want_refresh = 1;
388} 392}
391///////////////////////////////////////////////////////////////////////////// 395/////////////////////////////////////////////////////////////////////////////
392 396
393struct rxvt_perl_interp rxvt_perl; 397struct rxvt_perl_interp rxvt_perl;
394 398
395static PerlInterpreter *perl; 399static PerlInterpreter *perl;
396
397rxvt_perl_interp::rxvt_perl_interp ()
398{
399}
400 400
401rxvt_perl_interp::~rxvt_perl_interp () 401rxvt_perl_interp::~rxvt_perl_interp ()
402{ 402{
403 if (perl) 403 if (perl)
404 { 404 {
406 perl_free (perl); 406 perl_free (perl);
407 } 407 }
408} 408}
409 409
410void 410void
411rxvt_perl_interp::init () 411rxvt_perl_interp::init (rxvt_term *term)
412{ 412{
413 if (!perl) 413 if (!perl)
414 { 414 {
415 rxvt_push_locale (""); // perl init destroys current locale
416
417 perl_environ = rxvt_environ;
418 swap (perl_environ, environ);
419
415 char *argv[] = { 420 char *argv[] = {
416 "", 421 "",
417 "-T", 422 "-e"
418 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 423 "BEGIN {"
424 " urxvt->bootstrap;"
425 " unshift @INC, '" LIBDIR "';"
426 "}"
427 ""
428 "use urxvt;"
419 }; 429 };
420 430
421 perl = perl_alloc (); 431 perl = perl_alloc ();
422 perl_construct (perl); 432 perl_construct (perl);
423 433
424 if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) 434 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL)
425 || perl_run (perl)) 435 || perl_run (perl))
426 { 436 {
427 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 437 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
428 438
429 perl_destruct (perl); 439 perl_destruct (perl);
430 perl_free (perl); 440 perl_free (perl);
431 perl = 0; 441 perl = 0;
432 } 442 }
443
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);
433 } 454 }
434} 455}
435 456
436static void 457static void
437ungrab (rxvt_term *THIS) 458ungrab (rxvt_term *THIS)
445} 466}
446 467
447bool 468bool
448rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 469rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
449{ 470{
450 if (!perl) 471 if (!perl || !term->perl.self)
451 return false; 472 return false;
452 473
453 if (htype == HOOK_INIT) // first hook ever called 474 // pre-handling of some events
475 if (htype == HOOK_REFRESH_END)
454 { 476 {
455 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));
456 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 ();
457 } 481 }
458 else if (!term->perl.self) 482
459 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 }
460 else if (htype == HOOK_DESTROY) 664 else if (htype == HOOK_DESTROY)
461 { 665 {
462 // handled later 666 clearSVptr ((SV *)term->perl.self);
667 SvREFCNT_dec ((SV *)term->perl.self);
463 } 668 }
464 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
465 {
466 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
467 669
468 if (HvKEYS (hv)) 670 swap (perl_environ, environ);
469 {
470 hv_iterinit (hv);
471 671
472 while (HE *he = hv_iternext (hv)) 672 return event_consumed;
473 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
474 }
475 }
476 else if (!should_invoke [htype])
477 return false;
478
479 dSP;
480 va_list ap;
481
482 va_start (ap, htype);
483
484 ENTER;
485 SAVETMPS;
486
487 PUSHMARK (SP);
488
489 XPUSHs (sv_2mortal (newSVterm (term)));
490 XPUSHs (sv_2mortal (newSViv (htype)));
491
492 for (;;) {
493 data_type dt = (data_type)va_arg (ap, int);
494
495 switch (dt)
496 {
497 case DT_INT:
498 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
499 break;
500
501 case DT_LONG:
502 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
503 break;
504
505 case DT_STR:
506 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
507 break;
508
509 case DT_STR_LEN:
510 {
511 char *str = va_arg (ap, char *);
512 int len = va_arg (ap, int);
513
514 XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
515 }
516 break;
517
518 case DT_WCS_LEN:
519 {
520 wchar_t *wstr = va_arg (ap, wchar_t *);
521 int wlen = va_arg (ap, int);
522
523 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
524 }
525 break;
526
527 case DT_XEVENT:
528 {
529 XEvent *xe = va_arg (ap, XEvent *);
530 HV *hv = newHV ();
531
532# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
533# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
534# undef set
535
536 setiv (type, xe->type);
537 setiv (send_event, xe->xany.send_event);
538 setiv (serial, xe->xany.serial);
539
540 switch (xe->type)
541 {
542 case KeyPress:
543 case KeyRelease:
544 case ButtonPress:
545 case ButtonRelease:
546 case MotionNotify:
547 setiv (time, xe->xmotion.time);
548 setiv (x, xe->xmotion.x);
549 setiv (y, xe->xmotion.y);
550 setiv (row, xe->xmotion.y / term->fheight);
551 setiv (col, xe->xmotion.x / term->fwidth);
552 setiv (x_root, xe->xmotion.x_root);
553 setiv (y_root, xe->xmotion.y_root);
554 setiv (state, xe->xmotion.state);
555 break;
556 }
557
558 switch (xe->type)
559 {
560 case KeyPress:
561 case KeyRelease:
562 setiv (keycode, xe->xkey.keycode);
563 break;
564
565 case ButtonPress:
566 case ButtonRelease:
567 setiv (button, xe->xbutton.button);
568 break;
569
570 case MotionNotify:
571 setiv (is_hint, xe->xmotion.is_hint);
572 break;
573 }
574
575 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
576 }
577 break;
578
579 case DT_END:
580 {
581 va_end (ap);
582
583 PUTBACK;
584 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
585 SPAGAIN;
586
587 if (count)
588 {
589 SV *status = POPs;
590 count = SvTRUE (status);
591 }
592
593 PUTBACK;
594 FREETMPS;
595 LEAVE;
596
597 if (SvTRUE (ERRSV))
598 {
599 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
600 ungrab (term); // better lose the grab than the session
601 }
602
603 if (htype == HOOK_DESTROY)
604 {
605 clearSVptr ((SV *)term->perl.self);
606 SvREFCNT_dec ((SV *)term->perl.self);
607 }
608
609 return count;
610 }
611
612 default:
613 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
614 }
615 }
616} 673}
617 674
618///////////////////////////////////////////////////////////////////////////// 675/////////////////////////////////////////////////////////////////////////////
619 676
620MODULE = urxvt PACKAGE = urxvt 677MODULE = urxvt PACKAGE = urxvt
621 678
622PROTOTYPES: ENABLE 679PROTOTYPES: ENABLE
623 680
624BOOT: 681BOOT:
625{ 682{
626 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); 683 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
684 sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1));
685 sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1));
686 sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1));
627 687
628 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 688 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
629# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 689# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
630# include "hookinc.h" 690# include "hookinc.h"
631# undef def 691# undef def
636# include "optinc.h" 696# include "optinc.h"
637# undef nodef 697# undef nodef
638# undef def 698# undef def
639 699
640 HV *stash = gv_stashpv ("urxvt", 1); 700 HV *stash = gv_stashpv ("urxvt", 1);
641# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); 701 struct {
702 const char *name;
703 IV iv;
704 } *civ, const_iv[] = {
705# define const_iv(name) { # name, (IV)name }
642 export_const_iv (DEFAULT_RSTYLE); 706 const_iv (DEFAULT_RSTYLE),
643 export_const_iv (OVERLAY_RSTYLE); 707 const_iv (OVERLAY_RSTYLE),
644 export_const_iv (RS_Bold); 708 const_iv (RS_Bold),
645 export_const_iv (RS_Italic); 709 const_iv (RS_Italic),
646 export_const_iv (RS_Blink); 710 const_iv (RS_Blink),
647 export_const_iv (RS_RVid); 711 const_iv (RS_RVid),
648 export_const_iv (RS_Uline); 712 const_iv (RS_Uline),
649 713
650 export_const_iv (CurrentTime); 714 const_iv (CurrentTime),
651 export_const_iv (ShiftMask); 715 const_iv (ShiftMask),
652 export_const_iv (LockMask); 716 const_iv (LockMask),
653 export_const_iv (ControlMask); 717 const_iv (ControlMask),
654 export_const_iv (Mod1Mask); 718 const_iv (Mod1Mask),
655 export_const_iv (Mod2Mask); 719 const_iv (Mod2Mask),
656 export_const_iv (Mod3Mask); 720 const_iv (Mod3Mask),
657 export_const_iv (Mod4Mask); 721 const_iv (Mod4Mask),
658 export_const_iv (Mod5Mask); 722 const_iv (Mod5Mask),
659 export_const_iv (Button1Mask); 723 const_iv (Button1Mask),
660 export_const_iv (Button2Mask); 724 const_iv (Button2Mask),
661 export_const_iv (Button3Mask); 725 const_iv (Button3Mask),
662 export_const_iv (Button4Mask); 726 const_iv (Button4Mask),
663 export_const_iv (Button5Mask); 727 const_iv (Button5Mask),
664 export_const_iv (AnyModifier); 728 const_iv (AnyModifier),
729
730 const_iv (EVENT_NONE),
731 const_iv (EVENT_READ),
732 const_iv (EVENT_WRITE),
733
734 const_iv (NoEventMask),
735 const_iv (KeyPressMask),
736 const_iv (KeyReleaseMask),
737 const_iv (ButtonPressMask),
738 const_iv (ButtonReleaseMask),
739 const_iv (EnterWindowMask),
740 const_iv (LeaveWindowMask),
741 const_iv (PointerMotionMask),
742 const_iv (PointerMotionHintMask),
743 const_iv (Button1MotionMask),
744 const_iv (Button2MotionMask),
745 const_iv (Button3MotionMask),
746 const_iv (Button4MotionMask),
747 const_iv (Button5MotionMask),
748 const_iv (ButtonMotionMask),
749 const_iv (KeymapStateMask),
750 const_iv (ExposureMask),
751 const_iv (VisibilityChangeMask),
752 const_iv (StructureNotifyMask),
753 const_iv (ResizeRedirectMask),
754 const_iv (SubstructureNotifyMask),
755 const_iv (SubstructureRedirectMask),
756 const_iv (FocusChangeMask),
757 const_iv (PropertyChangeMask),
758 const_iv (ColormapChangeMask),
759 const_iv (OwnerGrabButtonMask),
760
761 const_iv (KeyPress),
762 const_iv (KeyRelease),
763 const_iv (ButtonPress),
764 const_iv (ButtonRelease),
765 const_iv (MotionNotify),
766 const_iv (EnterNotify),
767 const_iv (LeaveNotify),
768 const_iv (FocusIn),
769 const_iv (FocusOut),
770 const_iv (KeymapNotify),
771 const_iv (Expose),
772 const_iv (GraphicsExpose),
773 const_iv (NoExpose),
774 const_iv (VisibilityNotify),
775 const_iv (CreateNotify),
776 const_iv (DestroyNotify),
777 const_iv (UnmapNotify),
778 const_iv (MapNotify),
779 const_iv (MapRequest),
780 const_iv (ReparentNotify),
781 const_iv (ConfigureNotify),
782 const_iv (ConfigureRequest),
783 const_iv (GravityNotify),
784 const_iv (ResizeRequest),
785 const_iv (CirculateNotify),
786 const_iv (CirculateRequest),
787 const_iv (PropertyNotify),
788 const_iv (SelectionClear),
789 const_iv (SelectionRequest),
790 const_iv (SelectionNotify),
791 const_iv (ColormapNotify),
792 const_iv (ClientMessage),
793 const_iv (MappingNotify),
794 };
795
796 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
797 civ-- > const_iv; )
798 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
665} 799}
800
801void
802warn (const char *msg)
803 CODE:
804 rxvt_warn ("%s", msg);
805
806void
807fatal (const char *msg)
808 CODE:
809 rxvt_fatal ("%s", msg);
810
811void
812_exit (int status)
813
814NV
815NOW ()
816 CODE:
817 RETVAL = NOW;
818 OUTPUT:
819 RETVAL
820
821int
822GET_BASEFG (int rend)
823 CODE:
824 RETVAL = GET_BASEFG (rend);
825 OUTPUT:
826 RETVAL
827
828int
829GET_BASEBG (int rend)
830 CODE:
831 RETVAL = GET_BASEBG (rend);
832 OUTPUT:
833 RETVAL
834
835int
836SET_FGCOLOR (int rend, int new_color)
837 CODE:
838 RETVAL = SET_FGCOLOR (rend, new_color);
839 OUTPUT:
840 RETVAL
841
842int
843SET_BGCOLOR (int rend, int new_color)
844 CODE:
845 RETVAL = SET_BGCOLOR (rend, new_color);
846 OUTPUT:
847 RETVAL
848
849int
850GET_CUSTOM (int rend)
851 CODE:
852 RETVAL = (rend && RS_customMask) >> RS_customShift;
853 OUTPUT:
854 RETVAL
855
856int
857SET_CUSTOM (int rend, int new_value)
858 CODE:
859{
860 if (!IN_RANGE_EXC (new_value, 0, RS_customCount))
861 croak ("custom value out of range, must be 0..%d", RS_customCount - 1);
862
863 RETVAL = (rend & ~RS_customMask)
864 | ((new_value << RS_customShift) & RS_customMask);
865}
866 OUTPUT:
867 RETVAL
868
869MODULE = urxvt PACKAGE = urxvt::term
666 870
667SV * 871SV *
668new (...) 872_new (...)
669 CODE: 873 CODE:
670{ 874{
875 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
876 croak ("first argument to urxvt::term->_new must be arrayref");
877
878 rxvt_term *term = new rxvt_term;
879
671 stringvec *argv = new stringvec; 880 term->argv = new stringvec;
881 term->envv = new stringvec;
882
883 for (int i = 1; i < items; i++)
884 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
885
886 AV *envv = (AV *)SvRV (ST (0));
887 for (int i = AvFILL (envv) + 1; i--; )
888 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1))));
889
890 term->envv->push_back (0);
891
672 bool success; 892 bool success;
673
674 for (int i = 0; i < items ;i++)
675 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
676
677 rxvt_term *term = new rxvt_term;
678
679 term->argv = argv;
680 893
681 try 894 try
682 { 895 {
683 if (!term->init (argv->size (), argv->begin ())) 896 success = term->init (term->argv->size (), term->argv->begin ());
684 term = 0;
685 } 897 }
686 catch (const class rxvt_failure_exception &e) 898 catch (const class rxvt_failure_exception &e)
687 { 899 {
900 success = false;
901 }
902
903 if (!success)
904 {
688 term->destroy (); 905 term->destroy ();
689 croak ("exception caught while initializing new terminal instance"); 906 croak ("error while initializing new terminal instance");
690 } 907 }
691 908
692 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; 909 RETVAL = term && term->perl.self
910 ? newSVterm (term) : &PL_sv_undef;
693} 911}
694 OUTPUT: 912 OUTPUT:
695 RETVAL 913 RETVAL
696 914
697void 915void
698set_should_invoke (int htype, int value) 916rxvt_term::destroy ()
917
918#if ENABLE_PERL_FRILLS
919
920void
921rxvt_term::XListProperties (U32 window)
699 CODE: 922 PPCODE:
700 rxvt_perl.should_invoke [htype] = value; 923{
924 int count;
925 Atom *props = XListProperties (THIS->display->display, (Window)window, &count);
701 926
927 EXTEND (SP, count);
928 while (count--)
929 PUSHs (newSVuv ((U32)props [count]));
930
931 XFree (props);
932}
933
702void 934void
703warn (const char *msg) 935rxvt_term::XGetWindowProperty (U32 window, U32 property)
704 CODE: 936 PPCODE:
705 rxvt_warn ("%s", msg); 937{
938 Atom type;
939 int format;
940 unsigned long nitems;
941 unsigned long bytes_after;
942 unsigned char *prop;
943 XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property,
944 0, 1<<30, 0, AnyPropertyType,
945 &type, &format, &nitems, &bytes_after, &prop);
946 if (type != None)
947 {
948 EXTEND (SP, 3);
949 PUSHs (newSVuv ((U32)type));
950 PUSHs (newSViv (format));
951 PUSHs (newSVpvn ((char *)prop, nitems * format / 8));
952 XFree (prop);
953 }
954}
706 955
707void 956void
708fatal (const char *msg) 957rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data)
709 CODE: 958 CODE:
710 rxvt_fatal ("%s", msg); 959{
960 STRLEN len;
961 char *data_ = SvPVbyte (data, len);
711 962
712SV * 963 XChangeProperty (THIS->display->display, (Window)window, (Atom)property,
713untaint (SV *sv) 964 type, format, PropModeReplace,
714 CODE: 965 (unsigned char *)data, len * 8 / format);
715 RETVAL = newSVsv (sv); 966}
716 SvTAINTED_off (RETVAL);
717 OUTPUT:
718 RETVAL
719 967
720bool 968void
721safe () 969rxvt_term::XDeleteProperty (U32 window, U32 property)
722 CODE: 970 CODE:
723 RETVAL = !rxvt_tainted (); 971 XDeleteProperty (THIS->display->display, (Window)window, (Atom)property);
724 OUTPUT:
725 RETVAL
726 972
727NV 973U32
728NOW () 974rxvt_term::DefaultRootWindow ()
729 CODE: 975 CODE:
976 RETVAL = (U32)THIS->display->root;
977 OUTPUT:
730 RETVAL = NOW; 978 RETVAL
731 OUTPUT:
732 RETVAL
733 979
734int 980U32
735GET_BASEFG (int rend) 981rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height)
736 CODE: 982 CODE:
737 RETVAL = GET_BASEFG (rend); 983 RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent,
984 x, y, width, height, 0,
985 THIS->pix_colors_focused[Color_border],
986 THIS->pix_colors_focused[Color_border]);
738 OUTPUT: 987 OUTPUT:
739 RETVAL 988 RETVAL
740 989
741int
742GET_BASEBG (int rend)
743 CODE:
744 RETVAL = GET_BASEBG (rend);
745 OUTPUT:
746 RETVAL
747
748int
749SET_FGCOLOR (int rend, int new_color)
750 CODE:
751 RETVAL = SET_FGCOLOR (rend, new_color);
752 OUTPUT:
753 RETVAL
754
755int
756SET_BGCOLOR (int rend, int new_color)
757 CODE:
758 RETVAL = SET_BGCOLOR (rend, new_color);
759 OUTPUT:
760 RETVAL
761
762int
763GET_CUSTOM (int rend)
764 CODE:
765 RETVAL = (rend && RS_customMask) >> RS_customShift;
766 OUTPUT:
767 RETVAL
768
769int
770SET_CUSTOM (int rend, int new_value)
771 CODE:
772{
773 if (!IN_RANGE_EXC (new_value, 0, RS_customCount))
774 croak ("custom value out of range, must be 0..%d", RS_customCount - 1);
775
776 RETVAL = (rend & ~RS_customMask)
777 | ((new_value << RS_customShift) & RS_customMask);
778}
779 OUTPUT:
780 RETVAL
781
782MODULE = urxvt PACKAGE = urxvt::term
783
784void 990void
785rxvt_term::destroy () 991rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0)
992 CODE:
993 XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y);
994
995void
996rxvt_term::XMapWindow (U32 window)
997 CODE:
998 XMapWindow (THIS->display->display, (Window)window);
999
1000void
1001rxvt_term::XUnmapWindow (U32 window)
1002 CODE:
1003 XUnmapWindow (THIS->display->display, (Window)window);
1004
1005#endif
1006
1007void
1008rxvt_term::set_should_invoke (int htype, int inc)
1009 CODE:
1010 THIS->perl.should_invoke [htype] += inc;
786 1011
787void 1012void
788rxvt_term::grab_button (int button, U32 modifiers) 1013rxvt_term::grab_button (int button, U32 modifiers)
789 CODE: 1014 CODE:
790 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, 1015 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
858 char *mbstr = rxvt_wcstombs (wstr); 1083 char *mbstr = rxvt_wcstombs (wstr);
859 rxvt_pop_locale (); 1084 rxvt_pop_locale ();
860 1085
861 free (wstr); 1086 free (wstr);
862 1087
863 RETVAL = taint_if (newSVpv (mbstr, 0), str); 1088 RETVAL = newSVpv (mbstr, 0);
864 free (mbstr); 1089 free (mbstr);
865} 1090}
866 OUTPUT: 1091 OUTPUT:
867 RETVAL 1092 RETVAL
868 1093
875 1100
876 rxvt_push_locale (THIS->locale); 1101 rxvt_push_locale (THIS->locale);
877 wchar_t *wstr = rxvt_mbstowcs (data, len); 1102 wchar_t *wstr = rxvt_mbstowcs (data, len);
878 rxvt_pop_locale (); 1103 rxvt_pop_locale ();
879 1104
880 RETVAL = taint_if (wcs2sv (wstr), octets); 1105 RETVAL = wcs2sv (wstr);
881 free (wstr); 1106 free (wstr);
882} 1107}
883 OUTPUT: 1108 OUTPUT:
884 RETVAL 1109 RETVAL
885 1110
894#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1119#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
895#define TERM_OFFSET_focus TERM_OFFSET(focus) 1120#define TERM_OFFSET_focus TERM_OFFSET(focus)
896#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1121#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
897#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1122#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
898#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1123#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
899#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) 1124#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
900 1125
901int 1126int
902rxvt_term::width () 1127rxvt_term::width ()
903 ALIAS: 1128 ALIAS:
904 width = TERM_OFFSET_width 1129 width = TERM_OFFSET_width
910 ncol = TERM_OFFSET_ncol 1135 ncol = TERM_OFFSET_ncol
911 focus = TERM_OFFSET_focus 1136 focus = TERM_OFFSET_focus
912 mapped = TERM_OFFSET_mapped 1137 mapped = TERM_OFFSET_mapped
913 saveLines = TERM_OFFSET_saveLines 1138 saveLines = TERM_OFFSET_saveLines
914 total_rows = TERM_OFFSET_total_rows 1139 total_rows = TERM_OFFSET_total_rows
915 nsaved = TERM_OFFSET_nsaved 1140 top_row = TERM_OFFSET_top_row
916 CODE: 1141 CODE:
917 RETVAL = *(int *)((char *)THIS + ix); 1142 RETVAL = *(int *)((char *)THIS + ix);
918 OUTPUT: 1143 OUTPUT:
919 RETVAL 1144 RETVAL
920 1145
934 OUTPUT: 1159 OUTPUT:
935 RETVAL 1160 RETVAL
936 1161
937char * 1162char *
938rxvt_term::display_id () 1163rxvt_term::display_id ()
1164 ALIAS:
1165 display_id = 0
1166 locale = 1
939 CODE: 1167 CODE:
1168 switch (ix)
1169 {
940 RETVAL = THIS->display->id; 1170 case 0: RETVAL = THIS->display->id; break;
1171 case 1: RETVAL = THIS->locale; break;
1172 }
941 OUTPUT: 1173 OUTPUT:
1174 RETVAL
1175
1176SV *
1177rxvt_term::_env ()
1178 CODE:
1179{
1180 if (THIS->envv)
1181 {
1182 AV *av = newAV ();
1183
1184 for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i)
1185 if (*i)
1186 av_push (av, newSVpv (*i, 0));
1187
1188 RETVAL = newRV_noinc ((SV *)av);
1189 }
1190 else
1191 RETVAL = &PL_sv_undef;
1192}
1193 OUTPUT:
1194 RETVAL
1195
1196int
1197rxvt_term::pty_ev_events (int events = EVENT_UNDEF)
1198 CODE:
1199 RETVAL = THIS->pty_ev.events;
1200 if (events != EVENT_UNDEF)
1201 THIS->pty_ev.set (events);
1202 OUTPUT:
942 RETVAL 1203 RETVAL
943 1204
944U32 1205U32
945rxvt_term::parent () 1206rxvt_term::parent ()
946 CODE: 1207 CODE:
953 CODE: 1214 CODE:
954 RETVAL = (U32)THIS->vt; 1215 RETVAL = (U32)THIS->vt;
955 OUTPUT: 1216 OUTPUT:
956 RETVAL 1217 RETVAL
957 1218
1219void
1220rxvt_term::vt_emask_add (U32 emask)
1221 CODE:
1222 THIS->vt_emask_perl |= emask;
1223 THIS->vt_select_input ();
1224
958U32 1225U32
959rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 1226rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
960 CODE: 1227 CODE:
961{
962 RETVAL = THIS->rstyle; 1228 RETVAL = THIS->rstyle;
963 THIS->rstyle = new_rstyle; 1229 THIS->rstyle = new_rstyle;
964}
965 OUTPUT: 1230 OUTPUT:
966 RETVAL 1231 RETVAL
967 1232
968int 1233int
969rxvt_term::view_start (int newval = -1) 1234rxvt_term::view_start (int newval = 1)
1235 PROTOTYPE: $;$
970 CODE: 1236 CODE:
971{ 1237{
972 RETVAL = THIS->view_start; 1238 RETVAL = THIS->view_start;
973 1239
974 if (newval >= 0) 1240 if (newval <= 0)
975 { 1241 THIS->scr_changeview (max (newval, THIS->top_row));
976 THIS->view_start = min (newval, THIS->nsaved);
977 THIS->scr_changeview (RETVAL);
978 }
979} 1242}
980 OUTPUT: 1243 OUTPUT:
981 RETVAL 1244 RETVAL
982 1245
983void 1246void
987 1250
988void 1251void
989rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1252rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
990 PPCODE: 1253 PPCODE:
991{ 1254{
992 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1255 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
993 XSRETURN_EMPTY; 1256 XSRETURN_EMPTY;
994 1257
995 line_t &l = ROW(row_number); 1258 line_t &l = ROW(row_number);
996 1259
997 if (GIMME_V != G_VOID) 1260 if (GIMME_V != G_VOID)
999 wchar_t *wstr = new wchar_t [THIS->ncol]; 1262 wchar_t *wstr = new wchar_t [THIS->ncol];
1000 1263
1001 for (int col = 0; col < THIS->ncol; col++) 1264 for (int col = 0; col < THIS->ncol; col++)
1002 wstr [col] = l.t [col]; 1265 wstr [col] = l.t [col];
1003 1266
1004 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); 1267 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1005 1268
1006 delete [] wstr; 1269 delete [] wstr;
1007 } 1270 }
1008 1271
1009 if (new_text) 1272 if (new_text)
1030 1293
1031void 1294void
1032rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1295rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1033 PPCODE: 1296 PPCODE:
1034{ 1297{
1035 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1298 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1036 XSRETURN_EMPTY; 1299 XSRETURN_EMPTY;
1037 1300
1038 line_t &l = ROW(row_number); 1301 line_t &l = ROW(row_number);
1039 1302
1040 if (GIMME_V != G_VOID) 1303 if (GIMME_V != G_VOID)
1052 { 1315 {
1053 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1316 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
1054 croak ("new_rend must be arrayref"); 1317 croak ("new_rend must be arrayref");
1055 1318
1056 AV *av = (AV *)SvRV (new_rend); 1319 AV *av = (AV *)SvRV (new_rend);
1057 int len = min (av_len (av) + 1 - start_ofs, max_len); 1320 int len = min (AvFILL (av) + 1 - start_ofs, max_len);
1058 1321
1059 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1322 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
1060 croak ("new_rend array extends beyond horizontal margins"); 1323 croak ("new_rend array extends beyond horizontal margins");
1061 1324
1062 for (int col = start_col; col < start_col + len; col++) 1325 for (int col = start_col; col < start_col + len; col++)
1070 1333
1071int 1334int
1072rxvt_term::ROW_l (int row_number, int new_length = -1) 1335rxvt_term::ROW_l (int row_number, int new_length = -1)
1073 CODE: 1336 CODE:
1074{ 1337{
1075 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1338 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1076 XSRETURN_EMPTY; 1339 XSRETURN_EMPTY;
1077 1340
1078 line_t &l = ROW(row_number); 1341 line_t &l = ROW(row_number);
1079 RETVAL = l.l; 1342 RETVAL = l.l;
1080 1343
1086 1349
1087bool 1350bool
1088rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) 1351rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1)
1089 CODE: 1352 CODE:
1090{ 1353{
1091 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1354 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1092 XSRETURN_EMPTY; 1355 XSRETURN_EMPTY;
1093 1356
1094 line_t &l = ROW(row_number); 1357 line_t &l = ROW(row_number);
1095 RETVAL = l.is_longer (); 1358 RETVAL = l.is_longer ();
1096 1359
1130 else 1393 else
1131 *r++ = *s; 1394 *r++ = *s;
1132 1395
1133 rxvt_pop_locale (); 1396 rxvt_pop_locale ();
1134 1397
1135 RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); 1398 RETVAL = wcs2sv (rstr, r - rstr);
1136 1399
1137 delete [] rstr; 1400 delete [] rstr;
1138} 1401}
1139 OUTPUT: 1402 OUTPUT:
1140 RETVAL 1403 RETVAL
1166 else if (IS_COMPOSE (*s)) 1429 else if (IS_COMPOSE (*s))
1167 r += rxvt_composite.expand (*s, r); 1430 r += rxvt_composite.expand (*s, r);
1168 else 1431 else
1169 *r++ = *s; 1432 *r++ = *s;
1170 1433
1171 RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); 1434 RETVAL = wcs2sv (rstr, r - rstr);
1172 1435
1173 delete [] rstr; 1436 delete [] rstr;
1174} 1437}
1175 OUTPUT: 1438 OUTPUT:
1176 RETVAL 1439 RETVAL
1198 1461
1199 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1462 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
1200 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);
1201 1464
1202 if (GIMME_V != G_VOID) 1465 if (GIMME_V != G_VOID)
1203 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);
1204 1467
1205 if (newval) 1468 if (newval)
1206 { 1469 {
1207 if (SvOK (newval)) 1470 if (SvOK (newval))
1208 { 1471 {
1213 else 1476 else
1214 THIS->rs [index] = 0; 1477 THIS->rs [index] = 0;
1215 } 1478 }
1216} 1479}
1217 1480
1481const char *
1482rxvt_term::x_resource (const char *name)
1483
1218bool 1484bool
1219rxvt_term::option (U32 optval, int set = -1) 1485rxvt_term::option (U32 optval, int set = -1)
1220 CODE: 1486 CODE:
1221{ 1487{
1222 RETVAL = THIS->options & optval; 1488 RETVAL = THIS->options & optval;
1249 } 1515 }
1250} 1516}
1251 OUTPUT: 1517 OUTPUT:
1252 RETVAL 1518 RETVAL
1253 1519
1520bool
1521rxvt_term::parse_keysym (char *keysym, char *str)
1522 CODE:
1523 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1524 THIS->keyboard->register_done ();
1525 OUTPUT:
1526 RETVAL
1527
1254void 1528void
1255rxvt_term::screen_cur (...) 1529rxvt_term::screen_cur (...)
1256 PROTOTYPE: $;$$ 1530 PROTOTYPE: $;$$
1257 ALIAS: 1531 ALIAS:
1258 screen_cur = 0 1532 screen_cur = 0
1273 PUSHs (sv_2mortal (newSViv (rc.col))); 1547 PUSHs (sv_2mortal (newSViv (rc.col)));
1274 } 1548 }
1275 1549
1276 if (items == 3) 1550 if (items == 3)
1277 { 1551 {
1278 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 1552 rc.row = SvIV (ST (1));
1279 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 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);
1562 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1280 1563
1281 if (ix) 1564 if (ix)
1282 THIS->want_refresh = 1; 1565 THIS->want_refresh = 1;
1283 } 1566 }
1284} 1567}
1285 1568
1569char
1570rxvt_term::cur_charset ()
1571 CODE:
1572 RETVAL = THIS->charsets [THIS->screen.charset];
1573 OUTPUT:
1574 RETVAL
1575
1576#void
1577#rxvt_term::selection_clear ()
1578
1579void
1580rxvt_term::selection_make (U32 eventtime, bool rect = false)
1581 CODE:
1582 THIS->selection.op = SELECTION_CONT;
1583 THIS->selection.rect = rect;
1584 THIS->selection_make (eventtime);
1585
1286int 1586int
1287rxvt_term::selection_grab (U32 eventtime) 1587rxvt_term::selection_grab (U32 eventtime)
1288 1588
1289void 1589void
1290rxvt_term::selection (SV *newtext = 0) 1590rxvt_term::selection (SV *newtext = 0)
1291 PPCODE: 1591 PPCODE:
1292{ 1592{
1293 if (GIMME_V != G_VOID) 1593 if (GIMME_V != G_VOID)
1294 XPUSHs (THIS->selection.text 1594 XPUSHs (THIS->selection.text
1295 ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) 1595 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))
1296 : &PL_sv_undef); 1596 : &PL_sv_undef);
1297 1597
1298 if (newtext) 1598 if (newtext)
1299 { 1599 {
1300 free (THIS->selection.text); 1600 free (THIS->selection.text);
1301 1601
1302 THIS->selection.text = sv2wcs (newtext); 1602 THIS->selection.text = sv2wcs (newtext);
1303 THIS->selection.len = wcslen (THIS->selection.text); 1603 THIS->selection.len = wcslen (THIS->selection.text);
1304 } 1604 }
1305} 1605}
1606
1607void
1608rxvt_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)
1609
1610void
1611rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1612
1613void
1614rxvt_term::scr_bell ()
1306 1615
1307void 1616void
1308rxvt_term::scr_add_lines (SV *string) 1617rxvt_term::scr_add_lines (SV *string)
1309 CODE: 1618 CODE:
1310{ 1619{
1417 RETVAL = THIS; 1726 RETVAL = THIS;
1418 OUTPUT: 1727 OUTPUT:
1419 RETVAL 1728 RETVAL
1420 1729
1421timer * 1730timer *
1731timer::after (NV delay)
1732 CODE:
1733 THIS->start (NOW + delay);
1734 RETVAL = THIS;
1735 OUTPUT:
1736 RETVAL
1737
1738timer *
1422timer::stop () 1739timer::stop ()
1423 CODE: 1740 CODE:
1424 THIS->stop (); 1741 THIS->stop ();
1425 RETVAL = THIS; 1742 RETVAL = THIS;
1426 OUTPUT: 1743 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines