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.41 by root, Sun Jan 8 03:07:05 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)]
54
55#define ENABLE_PERL_FRILLS 1
51 56
52///////////////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////////////
53 58
54static wchar_t * 59static wchar_t *
55sv2wcs (SV *sv) 60sv2wcs (SV *sv)
206 211
207#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 212#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
208 213
209struct overlay { 214struct overlay {
210 HV *self; 215 HV *self;
216 bool visible;
211 rxvt_term *THIS; 217 rxvt_term *THIS;
212 int x, y, w, h; 218 int x, y, w, h;
213 int border; 219 int border;
214 text_t **text; 220 text_t **text;
215 rend_t **rend; 221 rend_t **rend;
224 230
225 void set (int x, int y, SV *str, SV *rend); 231 void set (int x, int y, SV *str, SV *rend);
226}; 232};
227 233
228overlay::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)
229: 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)
230{ 236{
231 if (border == 2) 237 if (border == 2)
232 { 238 {
233 w += 2; 239 w += 2;
234 h += 2; 240 h += 2;
295} 301}
296 302
297void 303void
298overlay::show () 304overlay::show ()
299{ 305{
300 char key[33]; sprintf (key, "%32lx", (long)this); 306 if (visible)
307 return;
301 308
309 visible = true;
310
302 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));
303 hv_store (hv, key, 32, newSViv ((long)this), 0); 312 av_push (av, newSViv ((long)this));
304} 313}
305 314
306void 315void
307overlay::hide () 316overlay::hide ()
308{ 317{
318 if (!visible)
319 return;
320
321 visible = false;
322
309 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));
310 324
311 if (ovs) 325 int i;
326
327 for (i = AvFILL (av); i >= 0; i--)
328 if (SvIV (*av_fetch (av, i, 1)) == (long)this)
312 { 329 {
313 char key[33]; sprintf (key, "%32lx", (long)this);
314
315 HV *hv = (HV *)SvRV (*ovs);
316 hv_delete (hv, key, 32, G_DISCARD); 330 av_delete (av, i, G_DISCARD);
331 break;
317 } 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);
318} 338}
319 339
320void overlay::swap () 340void overlay::swap ()
321{ 341{
322 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));
328 for (int y = ov_h; y--; ) 348 for (int y = ov_h; y--; )
329 { 349 {
330 text_t *t1 = text [y]; 350 text_t *t1 = text [y];
331 rend_t *r1 = rend [y]; 351 rend_t *r1 = rend [y];
332 352
333 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;
334 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;
335 355
336 for (int x = ov_w; x--; ) 356 for (int x = ov_w; x--; )
337 { 357 {
338 text_t t = *t1; *t1++ = *t2; *t2++ = t; 358 text_t t = *t1; *t1++ = *t2; *t2++ = t;
339 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));
362 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) 382 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
363 croak ("rend must be arrayref"); 383 croak ("rend must be arrayref");
364 384
365 AV *av = (AV *)SvRV (rend); 385 AV *av = (AV *)SvRV (rend);
366 386
367 for (int col = min (av_len (av) + 1, w - x - border); col--; ) 387 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
368 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 388 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
369 } 389 }
370 390
371 THIS->want_refresh = 1; 391 THIS->want_refresh = 1;
372} 392}
375///////////////////////////////////////////////////////////////////////////// 395/////////////////////////////////////////////////////////////////////////////
376 396
377struct rxvt_perl_interp rxvt_perl; 397struct rxvt_perl_interp rxvt_perl;
378 398
379static PerlInterpreter *perl; 399static PerlInterpreter *perl;
380
381rxvt_perl_interp::rxvt_perl_interp ()
382{
383}
384 400
385rxvt_perl_interp::~rxvt_perl_interp () 401rxvt_perl_interp::~rxvt_perl_interp ()
386{ 402{
387 if (perl) 403 if (perl)
388 { 404 {
390 perl_free (perl); 406 perl_free (perl);
391 } 407 }
392} 408}
393 409
394void 410void
395rxvt_perl_interp::init () 411rxvt_perl_interp::init (rxvt_term *term)
396{ 412{
397 if (!perl) 413 if (!perl)
398 { 414 {
415 rxvt_push_locale (""); // perl init destroys current locale
416
417 perl_environ = rxvt_environ;
418 swap (perl_environ, environ);
419
399 char *argv[] = { 420 char *argv[] = {
400 "", 421 "",
401 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 422 "-e"
423 "BEGIN {"
424 " urxvt->bootstrap;"
425 " unshift @INC, '" LIBDIR "';"
426 "}"
427 ""
428 "use urxvt;"
402 }; 429 };
403 430
404 perl = perl_alloc (); 431 perl = perl_alloc ();
405 perl_construct (perl); 432 perl_construct (perl);
406 433
411 438
412 perl_destruct (perl); 439 perl_destruct (perl);
413 perl_free (perl); 440 perl_free (perl);
414 perl = 0; 441 perl = 0;
415 } 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;
416 } 465 }
417} 466}
418 467
419bool 468bool
420rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 469rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
421{ 470{
422 if (!perl) 471 if (!perl || !term->perl.self)
423 return false; 472 return false;
424 473
425 if (htype == HOOK_INIT) // first hook ever called 474 // pre-handling of some events
475 if (htype == HOOK_REFRESH_END)
426 { 476 {
427 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));
428 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 ();
429 } 481 }
430 else if (!term->perl.self) 482
431 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 }
432 else if (htype == HOOK_DESTROY) 664 else if (htype == HOOK_DESTROY)
433 { 665 {
434 // handled later 666 clearSVptr ((SV *)term->perl.self);
667 SvREFCNT_dec ((SV *)term->perl.self);
435 } 668 }
436 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
437 {
438 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
439 669
440 if (HvKEYS (hv)) 670 swap (perl_environ, environ);
441 {
442 hv_iterinit (hv);
443 671
444 while (HE *he = hv_iternext (hv)) 672 return event_consumed;
445 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
446 }
447 }
448 else if (!should_invoke [htype])
449 return false;
450
451 dSP;
452 va_list ap;
453
454 va_start (ap, htype);
455
456 ENTER;
457 SAVETMPS;
458
459 PUSHMARK (SP);
460
461 XPUSHs (sv_2mortal (newSVterm (term)));
462 XPUSHs (sv_2mortal (newSViv (htype)));
463
464 for (;;) {
465 data_type dt = (data_type)va_arg (ap, int);
466
467 switch (dt)
468 {
469 case DT_INT:
470 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
471 break;
472
473 case DT_LONG:
474 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
475 break;
476
477 case DT_STR:
478 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
479 break;
480
481 case DT_STR_LEN:
482 {
483 char *str = va_arg (ap, char *);
484 int len = va_arg (ap, int);
485
486 XPUSHs (sv_2mortal (newSVpvn (str, len)));
487 }
488 break;
489
490 case DT_WCS_LEN:
491 {
492 wchar_t *wstr = va_arg (ap, wchar_t *);
493 int wlen = va_arg (ap, int);
494
495 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
496 }
497 break;
498
499 case DT_XEVENT:
500 {
501 XEvent *xe = va_arg (ap, XEvent *);
502 HV *hv = newHV ();
503
504# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
505# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
506# undef set
507
508 setiv (type, xe->type);
509 setiv (send_event, xe->xany.send_event);
510 setiv (serial, xe->xany.serial);
511
512 switch (xe->type)
513 {
514 case KeyPress:
515 case KeyRelease:
516 case ButtonPress:
517 case ButtonRelease:
518 case MotionNotify:
519 setiv (time, xe->xmotion.time);
520 setiv (x, xe->xmotion.x);
521 setiv (y, xe->xmotion.y);
522 setiv (row, xe->xmotion.y / term->fheight);
523 setiv (col, xe->xmotion.x / term->fwidth);
524 setiv (x_root, xe->xmotion.x_root);
525 setiv (y_root, xe->xmotion.y_root);
526 setiv (state, xe->xmotion.state);
527 break;
528 }
529
530 switch (xe->type)
531 {
532 case KeyPress:
533 case KeyRelease:
534 setiv (keycode, xe->xkey.keycode);
535 break;
536
537 case ButtonPress:
538 case ButtonRelease:
539 setiv (button, xe->xbutton.button);
540 break;
541
542 case MotionNotify:
543 setiv (is_hint, xe->xmotion.is_hint);
544 break;
545 }
546
547 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
548 }
549 break;
550
551 case DT_END:
552 {
553 va_end (ap);
554
555 PUTBACK;
556 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
557 SPAGAIN;
558
559 if (count)
560 {
561 SV *status = POPs;
562 count = SvTRUE (status);
563 }
564
565 PUTBACK;
566 FREETMPS;
567 LEAVE;
568
569 if (SvTRUE (ERRSV))
570 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
571
572 if (htype == HOOK_DESTROY)
573 {
574 clearSVptr ((SV *)term->perl.self);
575 SvREFCNT_dec ((SV *)term->perl.self);
576 }
577
578 return count;
579 }
580
581 default:
582 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
583 }
584 }
585} 673}
586 674
587///////////////////////////////////////////////////////////////////////////// 675/////////////////////////////////////////////////////////////////////////////
588 676
589MODULE = urxvt PACKAGE = urxvt 677MODULE = urxvt PACKAGE = urxvt
590 678
591PROTOTYPES: ENABLE 679PROTOTYPES: ENABLE
592 680
593BOOT: 681BOOT:
594{ 682{
595 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));
596 687
597 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 688 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
598# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 689# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
599# include "hookinc.h" 690# include "hookinc.h"
600# undef def 691# undef def
605# include "optinc.h" 696# include "optinc.h"
606# undef nodef 697# undef nodef
607# undef def 698# undef def
608 699
609 HV *stash = gv_stashpv ("urxvt", 1); 700 HV *stash = gv_stashpv ("urxvt", 1);
610# 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 }
611 export_const_iv (DEFAULT_RSTYLE); 706 const_iv (DEFAULT_RSTYLE),
612 export_const_iv (OVERLAY_RSTYLE); 707 const_iv (OVERLAY_RSTYLE),
613 export_const_iv (RS_Bold); 708 const_iv (RS_Bold),
614 export_const_iv (RS_Italic); 709 const_iv (RS_Italic),
615 export_const_iv (RS_Blink); 710 const_iv (RS_Blink),
616 export_const_iv (RS_RVid); 711 const_iv (RS_RVid),
617 export_const_iv (RS_Uline); 712 const_iv (RS_Uline),
618 713
619 export_const_iv (CurrentTime); 714 const_iv (CurrentTime),
620 export_const_iv (ShiftMask); 715 const_iv (ShiftMask),
621 export_const_iv (LockMask); 716 const_iv (LockMask),
622 export_const_iv (ControlMask); 717 const_iv (ControlMask),
623 export_const_iv (Mod1Mask); 718 const_iv (Mod1Mask),
624 export_const_iv (Mod2Mask); 719 const_iv (Mod2Mask),
625 export_const_iv (Mod3Mask); 720 const_iv (Mod3Mask),
626 export_const_iv (Mod4Mask); 721 const_iv (Mod4Mask),
627 export_const_iv (Mod5Mask); 722 const_iv (Mod5Mask),
628 export_const_iv (Button1Mask); 723 const_iv (Button1Mask),
629 export_const_iv (Button2Mask); 724 const_iv (Button2Mask),
630 export_const_iv (Button3Mask); 725 const_iv (Button3Mask),
631 export_const_iv (Button4Mask); 726 const_iv (Button4Mask),
632 export_const_iv (Button5Mask); 727 const_iv (Button5Mask),
633 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));
634} 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
635 870
636SV * 871SV *
637new (...) 872_new (...)
638 CODE: 873 CODE:
639{ 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
640 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
641 bool success; 892 bool success;
642
643 for (int i = 0; i < items ;i++)
644 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
645
646 rxvt_term *term = new rxvt_term;
647
648 term->argv = argv;
649 893
650 try 894 try
651 { 895 {
652 if (!term->init (argv->size (), argv->begin ())) 896 success = term->init (term->argv->size (), term->argv->begin ());
653 term = 0;
654 } 897 }
655 catch (const class rxvt_failure_exception &e) 898 catch (const class rxvt_failure_exception &e)
656 { 899 {
900 success = false;
901 }
902
903 if (!success)
904 {
657 term->destroy (); 905 term->destroy ();
658 croak ("exception caught while initializing new terminal instance"); 906 croak ("error while initializing new terminal instance");
659 } 907 }
660 908
661 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; 909 RETVAL = term && term->perl.self
910 ? newSVterm (term) : &PL_sv_undef;
662} 911}
663 OUTPUT: 912 OUTPUT:
664 RETVAL 913 RETVAL
665 914
666void 915void
667set_should_invoke (int htype, int value) 916rxvt_term::destroy ()
917
918#if ENABLE_PERL_FRILLS
919
920void
921rxvt_term::XListProperties (U32 window)
668 CODE: 922 PPCODE:
669 rxvt_perl.should_invoke [htype] = value; 923{
924 int count;
925 Atom *props = XListProperties (THIS->display->display, (Window)window, &count);
670 926
927 EXTEND (SP, count);
928 while (count--)
929 PUSHs (newSVuv ((U32)props [count]));
930
931 XFree (props);
932}
933
671void 934void
672warn (const char *msg) 935rxvt_term::XGetWindowProperty (U32 window, U32 property)
673 CODE: 936 PPCODE:
674 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}
675 955
676void 956void
677fatal (const char *msg) 957rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data)
678 CODE: 958 CODE:
679 rxvt_fatal ("%s", msg); 959{
960 STRLEN len;
961 char *data_ = SvPVbyte (data, len);
680 962
681NV 963 XChangeProperty (THIS->display->display, (Window)window, (Atom)property,
682NOW () 964 type, format, PropModeReplace,
965 (unsigned char *)data, len * 8 / format);
966}
967
968void
969rxvt_term::XDeleteProperty (U32 window, U32 property)
683 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:
684 RETVAL = NOW; 978 RETVAL
685 OUTPUT:
686 RETVAL
687 979
688int 980U32
689GET_BASEFG (int rend) 981rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height)
690 CODE: 982 CODE:
691 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]);
692 OUTPUT: 987 OUTPUT:
693 RETVAL 988 RETVAL
694 989
695int
696GET_BASEBG (int rend)
697 CODE:
698 RETVAL = GET_BASEBG (rend);
699 OUTPUT:
700 RETVAL
701
702int
703SET_FGCOLOR (int rend, int new_color)
704 CODE:
705 RETVAL = SET_FGCOLOR (rend, new_color);
706 OUTPUT:
707 RETVAL
708
709int
710SET_BGCOLOR (int rend, int new_color)
711 CODE:
712 RETVAL = SET_BGCOLOR (rend, new_color);
713 OUTPUT:
714 RETVAL
715
716int
717GET_CUSTOM (int rend)
718 CODE:
719 RETVAL = (rend && RS_customMask) >> RS_customShift;
720 OUTPUT:
721 RETVAL
722
723int
724SET_CUSTOM (int rend, int new_value)
725 CODE:
726{
727 if (!IN_RANGE_EXC (new_value, 0, RS_customCount))
728 croak ("custom value out of range, must be 0..%d", RS_customCount - 1);
729
730 RETVAL = (rend & ~RS_customMask)
731 | ((new_value << RS_customShift) & RS_customMask);
732}
733 OUTPUT:
734 RETVAL
735
736MODULE = urxvt PACKAGE = urxvt::term
737
738void 990void
739rxvt_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;
740 1011
741void 1012void
742rxvt_term::grab_button (int button, U32 modifiers) 1013rxvt_term::grab_button (int button, U32 modifiers)
743 CODE: 1014 CODE:
744 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, 1015 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
765} 1036}
766 OUTPUT: 1037 OUTPUT:
767 RETVAL 1038 RETVAL
768 1039
769void 1040void
770rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) 1041rxvt_term::allow_events_async ()
771 CODE: 1042 CODE:
772 XAllowEvents (THIS->display->display, AsyncBoth, eventtime); 1043 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime);
773 1044
774void 1045void
775rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) 1046rxvt_term::allow_events_sync ()
776 CODE: 1047 CODE:
777 XAllowEvents (THIS->display->display, SyncBoth, eventtime); 1048 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime);
778 1049
779void 1050void
780rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) 1051rxvt_term::allow_events_replay ()
781 CODE: 1052 CODE:
782 XAllowEvents (THIS->display->display, ReplayPointer, eventtime); 1053 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime);
783 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); 1054 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime);
784 1055
785void 1056void
786rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) 1057rxvt_term::ungrab ()
787 CODE: 1058 CODE:
788 THIS->perl.grabtime = 0; 1059 ungrab (THIS);
789 XUngrabKeyboard (THIS->display->display, eventtime);
790 XUngrabPointer (THIS->display->display, eventtime);
791 1060
792int 1061int
793rxvt_term::strwidth (SV *str) 1062rxvt_term::strwidth (SV *str)
794 CODE: 1063 CODE:
795{ 1064{
850#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1119#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
851#define TERM_OFFSET_focus TERM_OFFSET(focus) 1120#define TERM_OFFSET_focus TERM_OFFSET(focus)
852#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1121#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
853#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1122#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
854#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1123#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
855#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) 1124#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
856 1125
857int 1126int
858rxvt_term::width () 1127rxvt_term::width ()
859 ALIAS: 1128 ALIAS:
860 width = TERM_OFFSET_width 1129 width = TERM_OFFSET_width
866 ncol = TERM_OFFSET_ncol 1135 ncol = TERM_OFFSET_ncol
867 focus = TERM_OFFSET_focus 1136 focus = TERM_OFFSET_focus
868 mapped = TERM_OFFSET_mapped 1137 mapped = TERM_OFFSET_mapped
869 saveLines = TERM_OFFSET_saveLines 1138 saveLines = TERM_OFFSET_saveLines
870 total_rows = TERM_OFFSET_total_rows 1139 total_rows = TERM_OFFSET_total_rows
871 nsaved = TERM_OFFSET_nsaved 1140 top_row = TERM_OFFSET_top_row
872 CODE: 1141 CODE:
873 RETVAL = *(int *)((char *)THIS + ix); 1142 RETVAL = *(int *)((char *)THIS + ix);
874 OUTPUT: 1143 OUTPUT:
875 RETVAL 1144 RETVAL
876 1145
888 case 2: RETVAL = THIS->ModNumLockMask; break; 1157 case 2: RETVAL = THIS->ModNumLockMask; break;
889 } 1158 }
890 OUTPUT: 1159 OUTPUT:
891 RETVAL 1160 RETVAL
892 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
893U32 1205U32
894rxvt_term::parent () 1206rxvt_term::parent ()
895 CODE: 1207 CODE:
896 RETVAL = (U32)THIS->parent [0]; 1208 RETVAL = (U32)THIS->parent [0];
897 OUTPUT: 1209 OUTPUT:
902 CODE: 1214 CODE:
903 RETVAL = (U32)THIS->vt; 1215 RETVAL = (U32)THIS->vt;
904 OUTPUT: 1216 OUTPUT:
905 RETVAL 1217 RETVAL
906 1218
1219void
1220rxvt_term::vt_emask_add (U32 emask)
1221 CODE:
1222 THIS->vt_emask_perl |= emask;
1223 THIS->vt_select_input ();
1224
907U32 1225U32
908rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 1226rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
909 CODE: 1227 CODE:
910{
911 RETVAL = THIS->rstyle; 1228 RETVAL = THIS->rstyle;
912 THIS->rstyle = new_rstyle; 1229 THIS->rstyle = new_rstyle;
913}
914 OUTPUT: 1230 OUTPUT:
915 RETVAL 1231 RETVAL
916 1232
917int 1233int
918rxvt_term::view_start (int newval = -1) 1234rxvt_term::view_start (int newval = 1)
1235 PROTOTYPE: $;$
919 CODE: 1236 CODE:
920{ 1237{
921 RETVAL = THIS->view_start; 1238 RETVAL = THIS->view_start;
922 1239
923 if (newval >= 0) 1240 if (newval <= 0)
924 { 1241 THIS->scr_changeview (max (newval, THIS->top_row));
925 THIS->view_start = min (newval, THIS->nsaved);
926 THIS->scr_changeview (RETVAL);
927 }
928} 1242}
929 OUTPUT: 1243 OUTPUT:
930 RETVAL 1244 RETVAL
931 1245
932void 1246void
936 1250
937void 1251void
938rxvt_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)
939 PPCODE: 1253 PPCODE:
940{ 1254{
941 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1255 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
942 XSRETURN_EMPTY; 1256 XSRETURN_EMPTY;
943 1257
944 line_t &l = ROW(row_number); 1258 line_t &l = ROW(row_number);
945 1259
946 if (GIMME_V != G_VOID) 1260 if (GIMME_V != G_VOID)
979 1293
980void 1294void
981rxvt_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)
982 PPCODE: 1296 PPCODE:
983{ 1297{
984 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1298 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
985 XSRETURN_EMPTY; 1299 XSRETURN_EMPTY;
986 1300
987 line_t &l = ROW(row_number); 1301 line_t &l = ROW(row_number);
988 1302
989 if (GIMME_V != G_VOID) 1303 if (GIMME_V != G_VOID)
1001 { 1315 {
1002 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1316 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
1003 croak ("new_rend must be arrayref"); 1317 croak ("new_rend must be arrayref");
1004 1318
1005 AV *av = (AV *)SvRV (new_rend); 1319 AV *av = (AV *)SvRV (new_rend);
1006 int len = min (av_len (av) + 1 - start_ofs, max_len); 1320 int len = min (AvFILL (av) + 1 - start_ofs, max_len);
1007 1321
1008 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1322 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
1009 croak ("new_rend array extends beyond horizontal margins"); 1323 croak ("new_rend array extends beyond horizontal margins");
1010 1324
1011 for (int col = start_col; col < start_col + len; col++) 1325 for (int col = start_col; col < start_col + len; col++)
1019 1333
1020int 1334int
1021rxvt_term::ROW_l (int row_number, int new_length = -1) 1335rxvt_term::ROW_l (int row_number, int new_length = -1)
1022 CODE: 1336 CODE:
1023{ 1337{
1024 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1338 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1025 XSRETURN_EMPTY; 1339 XSRETURN_EMPTY;
1026 1340
1027 line_t &l = ROW(row_number); 1341 line_t &l = ROW(row_number);
1028 RETVAL = l.l; 1342 RETVAL = l.l;
1029 1343
1035 1349
1036bool 1350bool
1037rxvt_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)
1038 CODE: 1352 CODE:
1039{ 1353{
1040 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1354 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1041 XSRETURN_EMPTY; 1355 XSRETURN_EMPTY;
1042 1356
1043 line_t &l = ROW(row_number); 1357 line_t &l = ROW(row_number);
1044 RETVAL = l.is_longer (); 1358 RETVAL = l.is_longer ();
1045 1359
1162 else 1476 else
1163 THIS->rs [index] = 0; 1477 THIS->rs [index] = 0;
1164 } 1478 }
1165} 1479}
1166 1480
1481const char *
1482rxvt_term::x_resource (const char *name)
1483
1167bool 1484bool
1168rxvt_term::option (U32 optval, int set = -1) 1485rxvt_term::option (U32 optval, int set = -1)
1169 CODE: 1486 CODE:
1170{ 1487{
1171 RETVAL = THIS->options & optval; 1488 RETVAL = THIS->options & optval;
1175 if (set) 1492 if (set)
1176 THIS->options |= optval; 1493 THIS->options |= optval;
1177 else 1494 else
1178 THIS->options &= ~optval; 1495 THIS->options &= ~optval;
1179 1496
1497 if (THIS->check_ev.is_active ()) // avoid doing this before START
1180 switch (optval) 1498 switch (optval)
1181 { 1499 {
1182 case Opt_skipBuiltinGlyphs: 1500 case Opt_skipBuiltinGlyphs:
1183 THIS->set_fonts (); 1501 THIS->set_fonts ();
1184 THIS->scr_remap_chars (); 1502 THIS->scr_remap_chars ();
1185 THIS->scr_touch (true); 1503 THIS->scr_touch (true);
1186 THIS->want_refresh = 1; 1504 THIS->want_refresh = 1;
1187 break; 1505 break;
1188 1506
1189 case Opt_cursorUnderline: 1507 case Opt_cursorUnderline:
1190 THIS->want_refresh = 1; 1508 THIS->want_refresh = 1;
1191 break; 1509 break;
1192 1510
1193# case Opt_scrollBar_floating: 1511# case Opt_scrollBar_floating:
1194# case Opt_scrollBar_right: 1512# case Opt_scrollBar_right:
1195# THIS->resize_all_windows (THIS->width, THIS->height, 1); 1513# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1196# break; 1514# break;
1197 } 1515 }
1198 } 1516 }
1199} 1517}
1200 OUTPUT: 1518 OUTPUT:
1201 RETVAL 1519 RETVAL
1202 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
1203void 1529void
1204rxvt_term::cur (...) 1530rxvt_term::screen_cur (...)
1205 PROTOTYPE: $;$$ 1531 PROTOTYPE: $;$$
1206 ALIAS: 1532 ALIAS:
1207 screen_cur = 0 1533 screen_cur = 0
1208 selection_beg = 1 1534 selection_beg = 1
1209 selection_end = 2 1535 selection_end = 2
1222 PUSHs (sv_2mortal (newSViv (rc.col))); 1548 PUSHs (sv_2mortal (newSViv (rc.col)));
1223 } 1549 }
1224 1550
1225 if (items == 3) 1551 if (items == 3)
1226 { 1552 {
1227 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 1553 rc.row = SvIV (ST (1));
1228 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);
1229 1564
1230 if (ix) 1565 if (ix)
1231 THIS->want_refresh = 1; 1566 THIS->want_refresh = 1;
1232 } 1567 }
1233} 1568}
1234 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
1235int 1587int
1236rxvt_term::selection_grab (U32 eventtime) 1588rxvt_term::selection_grab (U32 eventtime)
1237 1589
1238void 1590void
1239rxvt_term::selection (SV *newtext = 0) 1591rxvt_term::selection (SV *newtext = 0)
1240 PPCODE: 1592 PPCODE:
1241{ 1593{
1242 if (GIMME_V != G_VOID) 1594 if (GIMME_V != G_VOID)
1595 XPUSHs (THIS->selection.text
1243 XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); 1596 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))
1597 : &PL_sv_undef);
1244 1598
1245 if (newtext) 1599 if (newtext)
1246 { 1600 {
1247 free (THIS->selection.text); 1601 free (THIS->selection.text);
1248 1602
1249 THIS->selection.text = sv2wcs (newtext); 1603 THIS->selection.text = sv2wcs (newtext);
1250 THIS->selection.len = wcslen (THIS->selection.text); 1604 THIS->selection.len = wcslen (THIS->selection.text);
1251 } 1605 }
1252} 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 ()
1253 1616
1254void 1617void
1255rxvt_term::scr_add_lines (SV *string) 1618rxvt_term::scr_add_lines (SV *string)
1256 CODE: 1619 CODE:
1257{ 1620{
1364 RETVAL = THIS; 1727 RETVAL = THIS;
1365 OUTPUT: 1728 OUTPUT:
1366 RETVAL 1729 RETVAL
1367 1730
1368timer * 1731timer *
1732timer::after (NV delay)
1733 CODE:
1734 THIS->start (NOW + delay);
1735 RETVAL = THIS;
1736 OUTPUT:
1737 RETVAL
1738
1739timer *
1369timer::stop () 1740timer::stop ()
1370 CODE: 1741 CODE:
1371 THIS->stop (); 1742 THIS->stop ();
1372 RETVAL = THIS; 1743 RETVAL = THIS;
1373 OUTPUT: 1744 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines