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.42 by root, Sun Jan 8 08:43:11 2006 UTC vs.
Revision 1.78 by root, Thu Jan 19 20:30:36 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 (bool tainted) 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 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1",
418 "-T", 422 "-e"
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, 2 + !!tainted, 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);
454 }
455}
456
457static void
458ungrab (rxvt_term *THIS)
459{
460 if (THIS->perl.grabtime)
461 {
462 XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime);
463 XUngrabPointer (THIS->display->display, THIS->perl.grabtime);
464 THIS->perl.grabtime = 0;
433 } 465 }
434} 466}
435 467
436bool 468bool
437rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 469rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
438{ 470{
439 if (!perl) 471 if (!perl || !term->perl.self)
440 return false; 472 return false;
441 473
442 if (htype == HOOK_INIT) // first hook ever called 474 // pre-handling of some events
475 if (htype == HOOK_REFRESH_END)
443 { 476 {
444 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));
445 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 ();
446 } 481 }
447 else if (!term->perl.self) 482
448 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 }
449 else if (htype == HOOK_DESTROY) 664 else if (htype == HOOK_DESTROY)
450 { 665 {
451 // handled later 666 clearSVptr ((SV *)term->perl.self);
667 SvREFCNT_dec ((SV *)term->perl.self);
452 } 668 }
453 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
454 {
455 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
456 669
457 if (HvKEYS (hv)) 670 swap (perl_environ, environ);
458 {
459 hv_iterinit (hv);
460 671
461 while (HE *he = hv_iternext (hv)) 672 return event_consumed;
462 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
463 }
464 }
465 else if (!should_invoke [htype])
466 return false;
467
468 dSP;
469 va_list ap;
470
471 va_start (ap, htype);
472
473 ENTER;
474 SAVETMPS;
475
476 PUSHMARK (SP);
477
478 XPUSHs (sv_2mortal (newSVterm (term)));
479 XPUSHs (sv_2mortal (newSViv (htype)));
480
481 for (;;) {
482 data_type dt = (data_type)va_arg (ap, int);
483
484 switch (dt)
485 {
486 case DT_INT:
487 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
488 break;
489
490 case DT_LONG:
491 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
492 break;
493
494 case DT_STR:
495 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
496 break;
497
498 case DT_STR_LEN:
499 {
500 char *str = va_arg (ap, char *);
501 int len = va_arg (ap, int);
502
503 XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
504 }
505 break;
506
507 case DT_WCS_LEN:
508 {
509 wchar_t *wstr = va_arg (ap, wchar_t *);
510 int wlen = va_arg (ap, int);
511
512 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
513 }
514 break;
515
516 case DT_XEVENT:
517 {
518 XEvent *xe = va_arg (ap, XEvent *);
519 HV *hv = newHV ();
520
521# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
522# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
523# undef set
524
525 setiv (type, xe->type);
526 setiv (send_event, xe->xany.send_event);
527 setiv (serial, xe->xany.serial);
528
529 switch (xe->type)
530 {
531 case KeyPress:
532 case KeyRelease:
533 case ButtonPress:
534 case ButtonRelease:
535 case MotionNotify:
536 setiv (time, xe->xmotion.time);
537 setiv (x, xe->xmotion.x);
538 setiv (y, xe->xmotion.y);
539 setiv (row, xe->xmotion.y / term->fheight);
540 setiv (col, xe->xmotion.x / term->fwidth);
541 setiv (x_root, xe->xmotion.x_root);
542 setiv (y_root, xe->xmotion.y_root);
543 setiv (state, xe->xmotion.state);
544 break;
545 }
546
547 switch (xe->type)
548 {
549 case KeyPress:
550 case KeyRelease:
551 setiv (keycode, xe->xkey.keycode);
552 break;
553
554 case ButtonPress:
555 case ButtonRelease:
556 setiv (button, xe->xbutton.button);
557 break;
558
559 case MotionNotify:
560 setiv (is_hint, xe->xmotion.is_hint);
561 break;
562 }
563
564 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
565 }
566 break;
567
568 case DT_END:
569 {
570 va_end (ap);
571
572 PUTBACK;
573 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
574 SPAGAIN;
575
576 if (count)
577 {
578 SV *status = POPs;
579 count = SvTRUE (status);
580 }
581
582 PUTBACK;
583 FREETMPS;
584 LEAVE;
585
586 if (SvTRUE (ERRSV))
587 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
588
589 if (htype == HOOK_DESTROY)
590 {
591 clearSVptr ((SV *)term->perl.self);
592 SvREFCNT_dec ((SV *)term->perl.self);
593 }
594
595 return count;
596 }
597
598 default:
599 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
600 }
601 }
602} 673}
603 674
604///////////////////////////////////////////////////////////////////////////// 675/////////////////////////////////////////////////////////////////////////////
605 676
606MODULE = urxvt PACKAGE = urxvt 677MODULE = urxvt PACKAGE = urxvt
607 678
608PROTOTYPES: ENABLE 679PROTOTYPES: ENABLE
609 680
610BOOT: 681BOOT:
611{ 682{
612 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));
613 687
614 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 688 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
615# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 689# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
616# include "hookinc.h" 690# include "hookinc.h"
617# undef def 691# undef def
622# include "optinc.h" 696# include "optinc.h"
623# undef nodef 697# undef nodef
624# undef def 698# undef def
625 699
626 HV *stash = gv_stashpv ("urxvt", 1); 700 HV *stash = gv_stashpv ("urxvt", 1);
627# 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 }
628 export_const_iv (DEFAULT_RSTYLE); 706 const_iv (DEFAULT_RSTYLE),
629 export_const_iv (OVERLAY_RSTYLE); 707 const_iv (OVERLAY_RSTYLE),
630 export_const_iv (RS_Bold); 708 const_iv (RS_Bold),
631 export_const_iv (RS_Italic); 709 const_iv (RS_Italic),
632 export_const_iv (RS_Blink); 710 const_iv (RS_Blink),
633 export_const_iv (RS_RVid); 711 const_iv (RS_RVid),
634 export_const_iv (RS_Uline); 712 const_iv (RS_Uline),
635 713
636 export_const_iv (CurrentTime); 714 const_iv (CurrentTime),
637 export_const_iv (ShiftMask); 715 const_iv (ShiftMask),
638 export_const_iv (LockMask); 716 const_iv (LockMask),
639 export_const_iv (ControlMask); 717 const_iv (ControlMask),
640 export_const_iv (Mod1Mask); 718 const_iv (Mod1Mask),
641 export_const_iv (Mod2Mask); 719 const_iv (Mod2Mask),
642 export_const_iv (Mod3Mask); 720 const_iv (Mod3Mask),
643 export_const_iv (Mod4Mask); 721 const_iv (Mod4Mask),
644 export_const_iv (Mod5Mask); 722 const_iv (Mod5Mask),
645 export_const_iv (Button1Mask); 723 const_iv (Button1Mask),
646 export_const_iv (Button2Mask); 724 const_iv (Button2Mask),
647 export_const_iv (Button3Mask); 725 const_iv (Button3Mask),
648 export_const_iv (Button4Mask); 726 const_iv (Button4Mask),
649 export_const_iv (Button5Mask); 727 const_iv (Button5Mask),
650 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));
651} 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
652 870
653SV * 871SV *
654new (...) 872_new (...)
655 CODE: 873 CODE:
656{ 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
657 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
658 bool success; 892 bool success;
659
660 for (int i = 0; i < items ;i++)
661 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
662
663 rxvt_term *term = new rxvt_term;
664
665 term->argv = argv;
666 893
667 try 894 try
668 { 895 {
669 if (!term->init (argv->size (), argv->begin ())) 896 success = term->init (term->argv->size (), term->argv->begin ());
670 term = 0;
671 } 897 }
672 catch (const class rxvt_failure_exception &e) 898 catch (const class rxvt_failure_exception &e)
673 { 899 {
900 success = false;
901 }
902
903 if (!success)
904 {
674 term->destroy (); 905 term->destroy ();
675 croak ("exception caught while initializing new terminal instance"); 906 croak ("error while initializing new terminal instance");
676 } 907 }
677 908
678 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; 909 RETVAL = term && term->perl.self
910 ? newSVterm (term) : &PL_sv_undef;
679} 911}
680 OUTPUT: 912 OUTPUT:
681 RETVAL 913 RETVAL
682 914
683void 915void
684set_should_invoke (int htype, int value) 916rxvt_term::destroy ()
917
918#if ENABLE_PERL_FRILLS
919
920void
921rxvt_term::XListProperties (U32 window)
685 CODE: 922 PPCODE:
686 rxvt_perl.should_invoke [htype] = value; 923{
924 int count;
925 Atom *props = XListProperties (THIS->display->display, (Window)window, &count);
687 926
927 EXTEND (SP, count);
928 while (count--)
929 PUSHs (newSVuv ((U32)props [count]));
930
931 XFree (props);
932}
933
688void 934void
689warn (const char *msg) 935rxvt_term::XGetWindowProperty (U32 window, U32 property)
690 CODE: 936 PPCODE:
691 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}
692 955
693void 956void
694fatal (const char *msg) 957rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data)
695 CODE: 958 CODE:
696 rxvt_fatal ("%s", msg); 959{
960 STRLEN len;
961 char *data_ = SvPVbyte (data, len);
697 962
698NV 963 XChangeProperty (THIS->display->display, (Window)window, (Atom)property,
699NOW () 964 type, format, PropModeReplace,
965 (unsigned char *)data, len * 8 / format);
966}
967
968void
969rxvt_term::XDeleteProperty (U32 window, U32 property)
700 CODE: 970 CODE:
971 XDeleteProperty (THIS->display->display, (Window)window, (Atom)property);
972
973U32
974rxvt_term::DefaultRootWindow ()
975 CODE:
976 RETVAL = (U32)THIS->display->root;
977 OUTPUT:
701 RETVAL = NOW; 978 RETVAL
702 OUTPUT:
703 RETVAL
704 979
705int 980U32
706GET_BASEFG (int rend) 981rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height)
707 CODE: 982 CODE:
708 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]);
709 OUTPUT: 987 OUTPUT:
710 RETVAL 988 RETVAL
711 989
712int
713GET_BASEBG (int rend)
714 CODE:
715 RETVAL = GET_BASEBG (rend);
716 OUTPUT:
717 RETVAL
718
719int
720SET_FGCOLOR (int rend, int new_color)
721 CODE:
722 RETVAL = SET_FGCOLOR (rend, new_color);
723 OUTPUT:
724 RETVAL
725
726int
727SET_BGCOLOR (int rend, int new_color)
728 CODE:
729 RETVAL = SET_BGCOLOR (rend, new_color);
730 OUTPUT:
731 RETVAL
732
733int
734GET_CUSTOM (int rend)
735 CODE:
736 RETVAL = (rend && RS_customMask) >> RS_customShift;
737 OUTPUT:
738 RETVAL
739
740int
741SET_CUSTOM (int rend, int new_value)
742 CODE:
743{
744 if (!IN_RANGE_EXC (new_value, 0, RS_customCount))
745 croak ("custom value out of range, must be 0..%d", RS_customCount - 1);
746
747 RETVAL = (rend & ~RS_customMask)
748 | ((new_value << RS_customShift) & RS_customMask);
749}
750 OUTPUT:
751 RETVAL
752
753MODULE = urxvt PACKAGE = urxvt::term
754
755void 990void
756rxvt_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;
757 1011
758void 1012void
759rxvt_term::grab_button (int button, U32 modifiers) 1013rxvt_term::grab_button (int button, U32 modifiers)
760 CODE: 1014 CODE:
761 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, 1015 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
782} 1036}
783 OUTPUT: 1037 OUTPUT:
784 RETVAL 1038 RETVAL
785 1039
786void 1040void
787rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) 1041rxvt_term::allow_events_async ()
788 CODE: 1042 CODE:
789 XAllowEvents (THIS->display->display, AsyncBoth, eventtime); 1043 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime);
790 1044
791void 1045void
792rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) 1046rxvt_term::allow_events_sync ()
793 CODE: 1047 CODE:
794 XAllowEvents (THIS->display->display, SyncBoth, eventtime); 1048 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime);
795 1049
796void 1050void
797rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) 1051rxvt_term::allow_events_replay ()
798 CODE: 1052 CODE:
799 XAllowEvents (THIS->display->display, ReplayPointer, eventtime); 1053 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime);
800 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); 1054 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime);
801 1055
802void 1056void
803rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) 1057rxvt_term::ungrab ()
804 CODE: 1058 CODE:
805 THIS->perl.grabtime = 0; 1059 ungrab (THIS);
806 XUngrabKeyboard (THIS->display->display, eventtime);
807 XUngrabPointer (THIS->display->display, eventtime);
808 1060
809int 1061int
810rxvt_term::strwidth (SV *str) 1062rxvt_term::strwidth (SV *str)
811 CODE: 1063 CODE:
812{ 1064{
831 char *mbstr = rxvt_wcstombs (wstr); 1083 char *mbstr = rxvt_wcstombs (wstr);
832 rxvt_pop_locale (); 1084 rxvt_pop_locale ();
833 1085
834 free (wstr); 1086 free (wstr);
835 1087
836 RETVAL = taint_if (newSVpv (mbstr, 0), str); 1088 RETVAL = newSVpv (mbstr, 0);
837 free (mbstr); 1089 free (mbstr);
838} 1090}
839 OUTPUT: 1091 OUTPUT:
840 RETVAL 1092 RETVAL
841 1093
848 1100
849 rxvt_push_locale (THIS->locale); 1101 rxvt_push_locale (THIS->locale);
850 wchar_t *wstr = rxvt_mbstowcs (data, len); 1102 wchar_t *wstr = rxvt_mbstowcs (data, len);
851 rxvt_pop_locale (); 1103 rxvt_pop_locale ();
852 1104
853 RETVAL = taint_if (wcs2sv (wstr), octets); 1105 RETVAL = wcs2sv (wstr);
854 free (wstr); 1106 free (wstr);
855} 1107}
856 OUTPUT: 1108 OUTPUT:
857 RETVAL 1109 RETVAL
858 1110
867#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1119#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
868#define TERM_OFFSET_focus TERM_OFFSET(focus) 1120#define TERM_OFFSET_focus TERM_OFFSET(focus)
869#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1121#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
870#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1122#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
871#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1123#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
872#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) 1124#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
873 1125
874int 1126int
875rxvt_term::width () 1127rxvt_term::width ()
876 ALIAS: 1128 ALIAS:
877 width = TERM_OFFSET_width 1129 width = TERM_OFFSET_width
883 ncol = TERM_OFFSET_ncol 1135 ncol = TERM_OFFSET_ncol
884 focus = TERM_OFFSET_focus 1136 focus = TERM_OFFSET_focus
885 mapped = TERM_OFFSET_mapped 1137 mapped = TERM_OFFSET_mapped
886 saveLines = TERM_OFFSET_saveLines 1138 saveLines = TERM_OFFSET_saveLines
887 total_rows = TERM_OFFSET_total_rows 1139 total_rows = TERM_OFFSET_total_rows
888 nsaved = TERM_OFFSET_nsaved 1140 top_row = TERM_OFFSET_top_row
889 CODE: 1141 CODE:
890 RETVAL = *(int *)((char *)THIS + ix); 1142 RETVAL = *(int *)((char *)THIS + ix);
891 OUTPUT: 1143 OUTPUT:
892 RETVAL 1144 RETVAL
893 1145
905 case 2: RETVAL = THIS->ModNumLockMask; break; 1157 case 2: RETVAL = THIS->ModNumLockMask; break;
906 } 1158 }
907 OUTPUT: 1159 OUTPUT:
908 RETVAL 1160 RETVAL
909 1161
1162char *
1163rxvt_term::display_id ()
1164 ALIAS:
1165 display_id = 0
1166 locale = 1
1167 CODE:
1168 switch (ix)
1169 {
1170 case 0: RETVAL = THIS->display->id; break;
1171 case 1: RETVAL = THIS->locale; break;
1172 }
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:
1203 RETVAL
1204
910U32 1205U32
911rxvt_term::parent () 1206rxvt_term::parent ()
912 CODE: 1207 CODE:
913 RETVAL = (U32)THIS->parent [0]; 1208 RETVAL = (U32)THIS->parent [0];
914 OUTPUT: 1209 OUTPUT:
919 CODE: 1214 CODE:
920 RETVAL = (U32)THIS->vt; 1215 RETVAL = (U32)THIS->vt;
921 OUTPUT: 1216 OUTPUT:
922 RETVAL 1217 RETVAL
923 1218
1219void
1220rxvt_term::vt_emask_add (U32 emask)
1221 CODE:
1222 THIS->vt_emask_perl |= emask;
1223 THIS->vt_select_input ();
1224
924U32 1225U32
925rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 1226rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
926 CODE: 1227 CODE:
927{
928 RETVAL = THIS->rstyle; 1228 RETVAL = THIS->rstyle;
929 THIS->rstyle = new_rstyle; 1229 THIS->rstyle = new_rstyle;
930}
931 OUTPUT: 1230 OUTPUT:
932 RETVAL 1231 RETVAL
933 1232
934int 1233int
935rxvt_term::view_start (int newval = -1) 1234rxvt_term::view_start (int newval = 1)
1235 PROTOTYPE: $;$
936 CODE: 1236 CODE:
937{ 1237{
938 RETVAL = THIS->view_start; 1238 RETVAL = THIS->view_start;
939 1239
940 if (newval >= 0) 1240 if (newval <= 0)
941 { 1241 THIS->scr_changeview (max (newval, THIS->top_row));
942 THIS->view_start = min (newval, THIS->nsaved);
943 THIS->scr_changeview (RETVAL);
944 }
945} 1242}
946 OUTPUT: 1243 OUTPUT:
947 RETVAL 1244 RETVAL
948 1245
949void 1246void
953 1250
954void 1251void
955rxvt_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)
956 PPCODE: 1253 PPCODE:
957{ 1254{
958 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1255 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
959 XSRETURN_EMPTY; 1256 XSRETURN_EMPTY;
960 1257
961 line_t &l = ROW(row_number); 1258 line_t &l = ROW(row_number);
962 1259
963 if (GIMME_V != G_VOID) 1260 if (GIMME_V != G_VOID)
965 wchar_t *wstr = new wchar_t [THIS->ncol]; 1262 wchar_t *wstr = new wchar_t [THIS->ncol];
966 1263
967 for (int col = 0; col < THIS->ncol; col++) 1264 for (int col = 0; col < THIS->ncol; col++)
968 wstr [col] = l.t [col]; 1265 wstr [col] = l.t [col];
969 1266
970 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); 1267 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
971 1268
972 delete [] wstr; 1269 delete [] wstr;
973 } 1270 }
974 1271
975 if (new_text) 1272 if (new_text)
996 1293
997void 1294void
998rxvt_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)
999 PPCODE: 1296 PPCODE:
1000{ 1297{
1001 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1298 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1002 XSRETURN_EMPTY; 1299 XSRETURN_EMPTY;
1003 1300
1004 line_t &l = ROW(row_number); 1301 line_t &l = ROW(row_number);
1005 1302
1006 if (GIMME_V != G_VOID) 1303 if (GIMME_V != G_VOID)
1018 { 1315 {
1019 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1316 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
1020 croak ("new_rend must be arrayref"); 1317 croak ("new_rend must be arrayref");
1021 1318
1022 AV *av = (AV *)SvRV (new_rend); 1319 AV *av = (AV *)SvRV (new_rend);
1023 int len = min (av_len (av) + 1 - start_ofs, max_len); 1320 int len = min (AvFILL (av) + 1 - start_ofs, max_len);
1024 1321
1025 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1322 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
1026 croak ("new_rend array extends beyond horizontal margins"); 1323 croak ("new_rend array extends beyond horizontal margins");
1027 1324
1028 for (int col = start_col; col < start_col + len; col++) 1325 for (int col = start_col; col < start_col + len; col++)
1036 1333
1037int 1334int
1038rxvt_term::ROW_l (int row_number, int new_length = -1) 1335rxvt_term::ROW_l (int row_number, int new_length = -1)
1039 CODE: 1336 CODE:
1040{ 1337{
1041 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1338 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1042 XSRETURN_EMPTY; 1339 XSRETURN_EMPTY;
1043 1340
1044 line_t &l = ROW(row_number); 1341 line_t &l = ROW(row_number);
1045 RETVAL = l.l; 1342 RETVAL = l.l;
1046 1343
1052 1349
1053bool 1350bool
1054rxvt_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)
1055 CODE: 1352 CODE:
1056{ 1353{
1057 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1354 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1058 XSRETURN_EMPTY; 1355 XSRETURN_EMPTY;
1059 1356
1060 line_t &l = ROW(row_number); 1357 line_t &l = ROW(row_number);
1061 RETVAL = l.is_longer (); 1358 RETVAL = l.is_longer ();
1062 1359
1096 else 1393 else
1097 *r++ = *s; 1394 *r++ = *s;
1098 1395
1099 rxvt_pop_locale (); 1396 rxvt_pop_locale ();
1100 1397
1101 RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); 1398 RETVAL = wcs2sv (rstr, r - rstr);
1102 1399
1103 delete [] rstr; 1400 delete [] rstr;
1104} 1401}
1105 OUTPUT: 1402 OUTPUT:
1106 RETVAL 1403 RETVAL
1132 else if (IS_COMPOSE (*s)) 1429 else if (IS_COMPOSE (*s))
1133 r += rxvt_composite.expand (*s, r); 1430 r += rxvt_composite.expand (*s, r);
1134 else 1431 else
1135 *r++ = *s; 1432 *r++ = *s;
1136 1433
1137 RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); 1434 RETVAL = wcs2sv (rstr, r - rstr);
1138 1435
1139 delete [] rstr; 1436 delete [] rstr;
1140} 1437}
1141 OUTPUT: 1438 OUTPUT:
1142 RETVAL 1439 RETVAL
1164 1461
1165 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1462 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
1166 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);
1167 1464
1168 if (GIMME_V != G_VOID) 1465 if (GIMME_V != G_VOID)
1169 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);
1170 1467
1171 if (newval) 1468 if (newval)
1172 { 1469 {
1173 if (SvOK (newval)) 1470 if (SvOK (newval))
1174 { 1471 {
1179 else 1476 else
1180 THIS->rs [index] = 0; 1477 THIS->rs [index] = 0;
1181 } 1478 }
1182} 1479}
1183 1480
1481const char *
1482rxvt_term::x_resource (const char *name)
1483
1184bool 1484bool
1185rxvt_term::option (U32 optval, int set = -1) 1485rxvt_term::option (U32 optval, int set = -1)
1186 CODE: 1486 CODE:
1187{ 1487{
1188 RETVAL = THIS->options & optval; 1488 RETVAL = THIS->options & optval;
1192 if (set) 1492 if (set)
1193 THIS->options |= optval; 1493 THIS->options |= optval;
1194 else 1494 else
1195 THIS->options &= ~optval; 1495 THIS->options &= ~optval;
1196 1496
1497 if (THIS->check_ev.is_active ()) // avoid doing this before START
1197 switch (optval) 1498 switch (optval)
1198 { 1499 {
1199 case Opt_skipBuiltinGlyphs: 1500 case Opt_skipBuiltinGlyphs:
1200 THIS->set_fonts (); 1501 THIS->set_fonts ();
1201 THIS->scr_remap_chars (); 1502 THIS->scr_remap_chars ();
1202 THIS->scr_touch (true); 1503 THIS->scr_touch (true);
1203 THIS->want_refresh = 1; 1504 THIS->want_refresh = 1;
1204 break; 1505 break;
1205 1506
1206 case Opt_cursorUnderline: 1507 case Opt_cursorUnderline:
1207 THIS->want_refresh = 1; 1508 THIS->want_refresh = 1;
1208 break; 1509 break;
1209 1510
1210# case Opt_scrollBar_floating: 1511# case Opt_scrollBar_floating:
1211# case Opt_scrollBar_right: 1512# case Opt_scrollBar_right:
1212# THIS->resize_all_windows (THIS->width, THIS->height, 1); 1513# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1213# break; 1514# break;
1214 } 1515 }
1215 } 1516 }
1216} 1517}
1217 OUTPUT: 1518 OUTPUT:
1218 RETVAL 1519 RETVAL
1219 1520
1521bool
1522rxvt_term::parse_keysym (char *keysym, char *str)
1523 CODE:
1524 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1525 THIS->keyboard->register_done ();
1526 OUTPUT:
1527 RETVAL
1528
1220void 1529void
1221rxvt_term::cur (...) 1530rxvt_term::screen_cur (...)
1222 PROTOTYPE: $;$$ 1531 PROTOTYPE: $;$$
1223 ALIAS: 1532 ALIAS:
1224 screen_cur = 0 1533 screen_cur = 0
1225 selection_beg = 1 1534 selection_beg = 1
1226 selection_end = 2 1535 selection_end = 2
1239 PUSHs (sv_2mortal (newSViv (rc.col))); 1548 PUSHs (sv_2mortal (newSViv (rc.col)));
1240 } 1549 }
1241 1550
1242 if (items == 3) 1551 if (items == 3)
1243 { 1552 {
1244 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 1553 rc.row = SvIV (ST (1));
1245 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); 1554 rc.col = SvIV (ST (2));
1555
1556 if (ix == 2 && rc.col == 0)
1557 {
1558 rc.row--;
1559 rc.col = THIS->ncol;
1560 }
1561
1562 clamp_it (rc.col, 0, THIS->ncol);
1563 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1246 1564
1247 if (ix) 1565 if (ix)
1248 THIS->want_refresh = 1; 1566 THIS->want_refresh = 1;
1249 } 1567 }
1250} 1568}
1251 1569
1570char
1571rxvt_term::cur_charset ()
1572 CODE:
1573 RETVAL = THIS->charsets [THIS->screen.charset];
1574 OUTPUT:
1575 RETVAL
1576
1577#void
1578#rxvt_term::selection_clear ()
1579
1580void
1581rxvt_term::selection_make (U32 eventtime, bool rect = false)
1582 CODE:
1583 THIS->selection.op = SELECTION_CONT;
1584 THIS->selection.rect = rect;
1585 THIS->selection_make (eventtime);
1586
1252int 1587int
1253rxvt_term::selection_grab (U32 eventtime) 1588rxvt_term::selection_grab (U32 eventtime)
1254 1589
1255void 1590void
1256rxvt_term::selection (SV *newtext = 0) 1591rxvt_term::selection (SV *newtext = 0)
1257 PPCODE: 1592 PPCODE:
1258{ 1593{
1259 if (GIMME_V != G_VOID) 1594 if (GIMME_V != G_VOID)
1595 XPUSHs (THIS->selection.text
1260 XPUSHs (taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))); 1596 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))
1597 : &PL_sv_undef);
1261 1598
1262 if (newtext) 1599 if (newtext)
1263 { 1600 {
1264 free (THIS->selection.text); 1601 free (THIS->selection.text);
1265 1602
1266 THIS->selection.text = sv2wcs (newtext); 1603 THIS->selection.text = sv2wcs (newtext);
1267 THIS->selection.len = wcslen (THIS->selection.text); 1604 THIS->selection.len = wcslen (THIS->selection.text);
1268 } 1605 }
1269} 1606}
1607
1608void
1609rxvt_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)
1610
1611void
1612rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1613
1614void
1615rxvt_term::scr_bell ()
1270 1616
1271void 1617void
1272rxvt_term::scr_add_lines (SV *string) 1618rxvt_term::scr_add_lines (SV *string)
1273 CODE: 1619 CODE:
1274{ 1620{
1381 RETVAL = THIS; 1727 RETVAL = THIS;
1382 OUTPUT: 1728 OUTPUT:
1383 RETVAL 1729 RETVAL
1384 1730
1385timer * 1731timer *
1732timer::after (NV delay)
1733 CODE:
1734 THIS->start (NOW + delay);
1735 RETVAL = THIS;
1736 OUTPUT:
1737 RETVAL
1738
1739timer *
1386timer::stop () 1740timer::stop ()
1387 CODE: 1741 CODE:
1388 THIS->stop (); 1742 THIS->stop ();
1389 RETVAL = THIS; 1743 RETVAL = THIS;
1390 OUTPUT: 1744 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines