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.60 by root, Thu Jan 12 05:22:47 2006 UTC vs.
Revision 1.68 by root, Mon Jan 16 08:48:09 2006 UTC

50#undef LINENO 50#undef LINENO
51#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)
52#undef ROW 52#undef ROW
53#define ROW(n) THIS->row_buf [LINENO (n)] 53#define ROW(n) THIS->row_buf [LINENO (n)]
54 54
55#define ENABLE_PERL_FRILLS 1
56
55///////////////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////////////
56 58
57static SV * 59static SV *
58taint (SV *sv) 60taint (SV *sv)
59{ 61{
347 for (int y = ov_h; y--; ) 349 for (int y = ov_h; y--; )
348 { 350 {
349 text_t *t1 = text [y]; 351 text_t *t1 = text [y];
350 rend_t *r1 = rend [y]; 352 rend_t *r1 = rend [y];
351 353
352 text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; 354 text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x;
353 rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; 355 rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x;
354 356
355 for (int x = ov_w; x--; ) 357 for (int x = ov_w; x--; )
356 { 358 {
357 text_t t = *t1; *t1++ = *t2; *t2++ = t; 359 text_t t = *t1; *t1++ = *t2; *t2++ = t;
358 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); 360 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t));
405 perl_free (perl); 407 perl_free (perl);
406 } 408 }
407} 409}
408 410
409void 411void
410rxvt_perl_interp::init () 412rxvt_perl_interp::init (rxvt_term *term)
411{ 413{
412 if (!perl) 414 if (!perl)
413 { 415 {
416 rxvt_push_locale (""); // perl init destroys current locale
417
414 perl_environ = rxvt_environ; 418 perl_environ = rxvt_environ;
415 swap (perl_environ, environ); 419 swap (perl_environ, environ);
416 420
417 char *argv[] = { 421 char *argv[] = {
418 "", 422 "",
432 perl_free (perl); 436 perl_free (perl);
433 perl = 0; 437 perl = 0;
434 } 438 }
435 439
436 swap (perl_environ, environ); 440 swap (perl_environ, environ);
441
442 rxvt_pop_locale ();
437 } 443 }
444
445 // runs outside of perls ENV
446 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
447 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
438} 448}
439 449
440static void 450static void
441ungrab (rxvt_term *THIS) 451ungrab (rxvt_term *THIS)
442{ 452{
446 XUngrabPointer (THIS->display->display, THIS->perl.grabtime); 456 XUngrabPointer (THIS->display->display, THIS->perl.grabtime);
447 THIS->perl.grabtime = 0; 457 THIS->perl.grabtime = 0;
448 } 458 }
449} 459}
450 460
461static void
462swap_overlays (rxvt_term *term)
463{
464 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
465
466 if (HvKEYS (hv))
467 {
468 hv_iterinit (hv);
469
470 while (HE *he = hv_iternext (hv))
471 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
472 }
473}
474
451bool 475bool
452rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 476rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
453{ 477{
454 if (!perl) 478 if (!perl || !term->perl.self)
455 return false; 479 return false;
456 480
457 if (htype == HOOK_INIT) // first hook ever called 481 // pre-handling of some events
458 { 482 if (htype == HOOK_REFRESH_END)
459 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 483 swap_overlays (term);
460 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 484
461 } 485 swap (perl_environ, environ);
462 else if (!term->perl.self) 486
463 return false; // perl not initialized for this instance 487 bool event_consumed;
464 else if (htype == HOOK_DESTROY) 488
465 { 489 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
466 // handled later 490 || term->perl.should_invoke [htype])
467 } 491 try
468 else
469 {
470 if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
471 { 492 {
472 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 493 dSP;
494 va_list ap;
473 495
474 if (HvKEYS (hv)) 496 va_start (ap, htype);
497
498 ENTER;
499 SAVETMPS;
500
501 PUSHMARK (SP);
502
503 XPUSHs (sv_2mortal (newSVterm (term)));
504 XPUSHs (sv_2mortal (newSViv (htype)));
505
506 for (;;) {
507 data_type dt = (data_type)va_arg (ap, int);
508
509 switch (dt)
475 { 510 {
476 hv_iterinit (hv);
477
478 while (HE *he = hv_iternext (hv))
479 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
480 }
481
482 }
483
484 if (!should_invoke [htype])
485 return false;
486 }
487
488 swap (perl_environ, environ);
489
490 try
491 {
492 dSP;
493 va_list ap;
494
495 va_start (ap, htype);
496
497 ENTER;
498 SAVETMPS;
499
500 PUSHMARK (SP);
501
502 XPUSHs (sv_2mortal (newSVterm (term)));
503 XPUSHs (sv_2mortal (newSViv (htype)));
504
505 for (;;) {
506 data_type dt = (data_type)va_arg (ap, int);
507
508 switch (dt)
509 {
510 case DT_INT: 511 case DT_INT:
511 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 512 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
512 break; 513 break;
513 514
514 case DT_LONG: 515 case DT_LONG:
515 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 516 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
516 break; 517 break;
517 518
518 case DT_STR: 519 case DT_STR:
519 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); 520 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
520 break; 521 break;
521 522
522 case DT_STR_LEN: 523 case DT_STR_LEN:
523 { 524 {
524 char *str = va_arg (ap, char *); 525 char *str = va_arg (ap, char *);
525 int len = va_arg (ap, int); 526 int len = va_arg (ap, int);
526 527
527 XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); 528 XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
528 } 529 }
529 break; 530 break;
530 531
531 case DT_WCS_LEN: 532 case DT_WCS_LEN:
532 { 533 {
533 wchar_t *wstr = va_arg (ap, wchar_t *); 534 wchar_t *wstr = va_arg (ap, wchar_t *);
534 int wlen = va_arg (ap, int); 535 int wlen = va_arg (ap, int);
535 536
536 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); 537 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
537 } 538 }
538 break; 539 break;
539 540
540 case DT_XEVENT: 541 case DT_XEVENT:
541 { 542 {
542 XEvent *xe = va_arg (ap, XEvent *); 543 XEvent *xe = va_arg (ap, XEvent *);
543 HV *hv = newHV (); 544 HV *hv = newHV ();
544 545
545# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 546# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
546# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 547# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
547# undef set 548# undef set
548 549
549 setiv (type, xe->type); 550 setiv (type, xe->type);
550 setiv (send_event, xe->xany.send_event); 551 setiv (send_event, xe->xany.send_event);
551 setiv (serial, xe->xany.serial); 552 setiv (serial, xe->xany.serial);
552 553
553 switch (xe->type) 554 switch (xe->type)
554 { 555 {
555 case KeyPress: 556 case KeyPress:
556 case KeyRelease: 557 case KeyRelease:
557 case ButtonPress: 558 case ButtonPress:
558 case ButtonRelease: 559 case ButtonRelease:
559 case MotionNotify: 560 case MotionNotify:
560 setiv (time, xe->xmotion.time); 561 setiv (time, xe->xmotion.time);
561 setiv (x, xe->xmotion.x); 562 setiv (x, xe->xmotion.x);
562 setiv (y, xe->xmotion.y); 563 setiv (y, xe->xmotion.y);
563 setiv (row, xe->xmotion.y / term->fheight); 564 setiv (row, xe->xmotion.y / term->fheight);
564 setiv (col, xe->xmotion.x / term->fwidth); 565 setiv (col, xe->xmotion.x / term->fwidth);
565 setiv (x_root, xe->xmotion.x_root); 566 setiv (x_root, xe->xmotion.x_root);
566 setiv (y_root, xe->xmotion.y_root); 567 setiv (y_root, xe->xmotion.y_root);
567 setiv (state, xe->xmotion.state); 568 setiv (state, xe->xmotion.state);
568 break; 569 break;
569 } 570 }
570 571
571 switch (xe->type) 572 switch (xe->type)
572 { 573 {
573 case KeyPress: 574 case KeyPress:
574 case KeyRelease: 575 case KeyRelease:
575 setiv (keycode, xe->xkey.keycode); 576 setiv (keycode, xe->xkey.keycode);
576 break; 577 break;
577 578
578 case ButtonPress: 579 case ButtonPress:
579 case ButtonRelease: 580 case ButtonRelease:
580 setiv (button, xe->xbutton.button); 581 setiv (button, xe->xbutton.button);
581 break; 582 break;
582 583
583 case MotionNotify: 584 case MotionNotify:
584 setiv (is_hint, xe->xmotion.is_hint); 585 setiv (is_hint, xe->xmotion.is_hint);
585 break; 586 break;
586 } 587 }
587 588
588 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 589 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
589 } 590 }
590 break; 591 break;
591 592
592 case DT_END: 593 case DT_END:
593 { 594 goto call;
594 va_end (ap);
595 595
596 PUTBACK;
597 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
598 SPAGAIN;
599
600 if (count)
601 {
602 SV *status = POPs;
603 count = SvTRUE (status);
604 }
605
606 PUTBACK;
607 FREETMPS;
608 LEAVE;
609
610 if (SvTRUE (ERRSV))
611 {
612 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
613 ungrab (term); // better lose the grab than the session
614 }
615
616 if (htype == HOOK_DESTROY)
617 {
618 clearSVptr ((SV *)term->perl.self);
619 SvREFCNT_dec ((SV *)term->perl.self);
620 }
621
622 swap (perl_environ, environ);
623 return count;
624 }
625
626 default: 596 default:
627 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 597 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
628 } 598 }
599 }
600
601 call:
602 va_end (ap);
603
604 PUTBACK;
605 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
606 SPAGAIN;
607
608 if (count)
609 {
610 SV *status = POPs;
611 count = SvTRUE (status);
612 }
613
614 PUTBACK;
615 FREETMPS;
616 LEAVE;
617
618 if (SvTRUE (ERRSV))
619 {
620 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
621 ungrab (term); // better lose the grab than the session
622 }
623
624 event_consumed = !!count;
629 } 625 }
626 catch (...)
627 {
628 swap (perl_environ, environ);
629 throw;
630 }
631 else
632 event_consumed = false;
633
634 // post-handling of some events
635 if (htype == HOOK_REFRESH_BEGIN)
636 swap_overlays (term);
637 else if (htype == HOOK_DESTROY)
638 {
639 clearSVptr ((SV *)term->perl.self);
640 SvREFCNT_dec ((SV *)term->perl.self);
630 } 641 }
631 catch (...) 642
632 {
633 swap (perl_environ, environ); 643 swap (perl_environ, environ);
634 throw; 644
635 } 645 return event_consumed;
636} 646}
637 647
638///////////////////////////////////////////////////////////////////////////// 648/////////////////////////////////////////////////////////////////////////////
639 649
640MODULE = urxvt PACKAGE = urxvt 650MODULE = urxvt PACKAGE = urxvt
659# include "optinc.h" 669# include "optinc.h"
660# undef nodef 670# undef nodef
661# undef def 671# undef def
662 672
663 HV *stash = gv_stashpv ("urxvt", 1); 673 HV *stash = gv_stashpv ("urxvt", 1);
664# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); 674 struct {
675 const char *name;
676 IV iv;
677 } *civ, const_iv[] = {
678# define const_iv(name) { # name, (IV)name }
665 export_const_iv (DEFAULT_RSTYLE); 679 const_iv (DEFAULT_RSTYLE),
666 export_const_iv (OVERLAY_RSTYLE); 680 const_iv (OVERLAY_RSTYLE),
667 export_const_iv (RS_Bold); 681 const_iv (RS_Bold),
668 export_const_iv (RS_Italic); 682 const_iv (RS_Italic),
669 export_const_iv (RS_Blink); 683 const_iv (RS_Blink),
670 export_const_iv (RS_RVid); 684 const_iv (RS_RVid),
671 export_const_iv (RS_Uline); 685 const_iv (RS_Uline),
672 686
673 export_const_iv (CurrentTime); 687 const_iv (CurrentTime),
674 export_const_iv (ShiftMask); 688 const_iv (ShiftMask),
675 export_const_iv (LockMask); 689 const_iv (LockMask),
676 export_const_iv (ControlMask); 690 const_iv (ControlMask),
677 export_const_iv (Mod1Mask); 691 const_iv (Mod1Mask),
678 export_const_iv (Mod2Mask); 692 const_iv (Mod2Mask),
679 export_const_iv (Mod3Mask); 693 const_iv (Mod3Mask),
680 export_const_iv (Mod4Mask); 694 const_iv (Mod4Mask),
681 export_const_iv (Mod5Mask); 695 const_iv (Mod5Mask),
682 export_const_iv (Button1Mask); 696 const_iv (Button1Mask),
683 export_const_iv (Button2Mask); 697 const_iv (Button2Mask),
684 export_const_iv (Button3Mask); 698 const_iv (Button3Mask),
685 export_const_iv (Button4Mask); 699 const_iv (Button4Mask),
686 export_const_iv (Button5Mask); 700 const_iv (Button5Mask),
687 export_const_iv (AnyModifier); 701 const_iv (AnyModifier),
688 702
689 export_const_iv (EVENT_NONE); 703 const_iv (EVENT_NONE),
690 export_const_iv (EVENT_READ); 704 const_iv (EVENT_READ),
691 export_const_iv (EVENT_WRITE); 705 const_iv (EVENT_WRITE),
692}
693 706
694void 707 const_iv (NoEventMask),
695set_should_invoke (int htype, int value) 708 const_iv (KeyPressMask),
696 CODE: 709 const_iv (KeyReleaseMask),
697 rxvt_perl.should_invoke [htype] = value; 710 const_iv (ButtonPressMask),
711 const_iv (ButtonReleaseMask),
712 const_iv (EnterWindowMask),
713 const_iv (LeaveWindowMask),
714 const_iv (PointerMotionMask),
715 const_iv (PointerMotionHintMask),
716 const_iv (Button1MotionMask),
717 const_iv (Button2MotionMask),
718 const_iv (Button3MotionMask),
719 const_iv (Button4MotionMask),
720 const_iv (Button5MotionMask),
721 const_iv (ButtonMotionMask),
722 const_iv (KeymapStateMask),
723 const_iv (ExposureMask),
724 const_iv (VisibilityChangeMask),
725 const_iv (StructureNotifyMask),
726 const_iv (ResizeRedirectMask),
727 const_iv (SubstructureNotifyMask),
728 const_iv (SubstructureRedirectMask),
729 const_iv (FocusChangeMask),
730 const_iv (PropertyChangeMask),
731 const_iv (ColormapChangeMask),
732 const_iv (OwnerGrabButtonMask),
733
734 const_iv (KeyPress),
735 const_iv (KeyRelease),
736 const_iv (ButtonPress),
737 const_iv (ButtonRelease),
738 const_iv (MotionNotify),
739 const_iv (EnterNotify),
740 const_iv (LeaveNotify),
741 const_iv (FocusIn),
742 const_iv (FocusOut),
743 const_iv (KeymapNotify),
744 const_iv (Expose),
745 const_iv (GraphicsExpose),
746 const_iv (NoExpose),
747 const_iv (VisibilityNotify),
748 const_iv (CreateNotify),
749 const_iv (DestroyNotify),
750 const_iv (UnmapNotify),
751 const_iv (MapNotify),
752 const_iv (MapRequest),
753 const_iv (ReparentNotify),
754 const_iv (ConfigureNotify),
755 const_iv (ConfigureRequest),
756 const_iv (GravityNotify),
757 const_iv (ResizeRequest),
758 const_iv (CirculateNotify),
759 const_iv (CirculateRequest),
760 const_iv (PropertyNotify),
761 const_iv (SelectionClear),
762 const_iv (SelectionRequest),
763 const_iv (SelectionNotify),
764 const_iv (ColormapNotify),
765 const_iv (ClientMessage),
766 const_iv (MappingNotify),
767 };
768
769 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
770 civ-- > const_iv; )
771 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
772}
698 773
699void 774void
700warn (const char *msg) 775warn (const char *msg)
701 CODE: 776 CODE:
702 rxvt_warn ("%s", msg); 777 rxvt_warn ("%s", msg);
825 OUTPUT: 900 OUTPUT:
826 RETVAL 901 RETVAL
827 902
828void 903void
829rxvt_term::destroy () 904rxvt_term::destroy ()
905
906#if ENABLE_PERL_FRILLS
907
908void
909rxvt_term::XListProperties (U32 window)
910 PPCODE:
911{
912 int count;
913 Atom *props = XListProperties (THIS->display->display, (Window)window, &count);
914
915 EXTEND (SP, count);
916 while (count--)
917 PUSHs (newSVuv ((U32)props [count]));
918
919 XFree (props);
920}
921
922void
923rxvt_term::XGetWindowProperty (U32 window, U32 property)
924 PPCODE:
925{
926 Atom type;
927 int format;
928 unsigned long nitems;
929 unsigned long bytes_after;
930 unsigned char *prop;
931 XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property,
932 0, 1<<30, 0, AnyPropertyType,
933 &type, &format, &nitems, &bytes_after, &prop);
934 if (type != None)
935 {
936 EXTEND (SP, 3);
937 PUSHs (newSVuv ((U32)type));
938 PUSHs (newSViv (format));
939 PUSHs (newSVpvn ((char *)prop, nitems * format / 8));
940 XFree (prop);
941 }
942}
943
944void
945rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data)
946 CODE:
947{
948 STRLEN len;
949 char *data_ = SvPVbyte (data, len);
950
951 XChangeProperty (THIS->display->display, (Window)window, (Atom)property,
952 type, format, PropModeReplace,
953 (unsigned char *)data, len * 8 / format);
954}
955
956void
957rxvt_term::XDeleteProperty (U32 window, U32 property)
958 CODE:
959 XDeleteProperty (THIS->display->display, (Window)window, (Atom)property);
960
961U32
962rxvt_term::DefaultRootWindow ()
963 CODE:
964 RETVAL = (U32)THIS->display->root;
965 OUTPUT:
966 RETVAL
967
968U32
969rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height)
970 CODE:
971 RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent,
972 x, y, width, height, 0,
973 THIS->pix_colors_focused[Color_border],
974 THIS->pix_colors_focused[Color_border]);
975 OUTPUT:
976 RETVAL
977
978void
979rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0)
980 CODE:
981 XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y);
982
983void
984rxvt_term::XMapWindow (U32 window)
985 CODE:
986 XMapWindow (THIS->display->display, (Window)window);
987
988void
989rxvt_term::XUnmapWindow (U32 window)
990 CODE:
991 XUnmapWindow (THIS->display->display, (Window)window);
992
993#endif
994
995void
996rxvt_term::set_should_invoke (int htype, int inc)
997 CODE:
998 THIS->perl.should_invoke [htype] += inc;
830 999
831void 1000void
832rxvt_term::grab_button (int button, U32 modifiers) 1001rxvt_term::grab_button (int button, U32 modifiers)
833 CODE: 1002 CODE:
834 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, 1003 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
938#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1107#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
939#define TERM_OFFSET_focus TERM_OFFSET(focus) 1108#define TERM_OFFSET_focus TERM_OFFSET(focus)
940#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1109#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
941#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1110#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
942#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1111#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
943#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) 1112#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
944 1113
945int 1114int
946rxvt_term::width () 1115rxvt_term::width ()
947 ALIAS: 1116 ALIAS:
948 width = TERM_OFFSET_width 1117 width = TERM_OFFSET_width
954 ncol = TERM_OFFSET_ncol 1123 ncol = TERM_OFFSET_ncol
955 focus = TERM_OFFSET_focus 1124 focus = TERM_OFFSET_focus
956 mapped = TERM_OFFSET_mapped 1125 mapped = TERM_OFFSET_mapped
957 saveLines = TERM_OFFSET_saveLines 1126 saveLines = TERM_OFFSET_saveLines
958 total_rows = TERM_OFFSET_total_rows 1127 total_rows = TERM_OFFSET_total_rows
959 nsaved = TERM_OFFSET_nsaved 1128 top_row = TERM_OFFSET_top_row
960 CODE: 1129 CODE:
961 RETVAL = *(int *)((char *)THIS + ix); 1130 RETVAL = *(int *)((char *)THIS + ix);
962 OUTPUT: 1131 OUTPUT:
963 RETVAL 1132 RETVAL
964 1133
1033 CODE: 1202 CODE:
1034 RETVAL = (U32)THIS->vt; 1203 RETVAL = (U32)THIS->vt;
1035 OUTPUT: 1204 OUTPUT:
1036 RETVAL 1205 RETVAL
1037 1206
1207void
1208rxvt_term::vt_emask_add (U32 emask)
1209 CODE:
1210 THIS->vt_emask_perl |= emask;
1211 THIS->vt_select_input ();
1212
1038U32 1213U32
1039rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 1214rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
1040 CODE: 1215 CODE:
1041{
1042 RETVAL = THIS->rstyle; 1216 RETVAL = THIS->rstyle;
1043 THIS->rstyle = new_rstyle; 1217 THIS->rstyle = new_rstyle;
1044}
1045 OUTPUT: 1218 OUTPUT:
1046 RETVAL 1219 RETVAL
1047 1220
1048int 1221int
1049rxvt_term::view_start (int newval = -1) 1222rxvt_term::view_start (int newval = 1)
1223 PROTOTYPE: $;$
1050 CODE: 1224 CODE:
1051{ 1225{
1052 RETVAL = THIS->view_start; 1226 RETVAL = THIS->view_start;
1053 1227
1054 if (newval >= 0) 1228 if (newval <= 0)
1055 { 1229 THIS->scr_changeview (max (newval, THIS->top_row));
1056 THIS->view_start = min (newval, THIS->nsaved);
1057 THIS->scr_changeview (RETVAL);
1058 }
1059} 1230}
1060 OUTPUT: 1231 OUTPUT:
1061 RETVAL 1232 RETVAL
1062 1233
1063void 1234void
1067 1238
1068void 1239void
1069rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1240rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1070 PPCODE: 1241 PPCODE:
1071{ 1242{
1072 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1243 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1073 XSRETURN_EMPTY; 1244 XSRETURN_EMPTY;
1074 1245
1075 line_t &l = ROW(row_number); 1246 line_t &l = ROW(row_number);
1076 1247
1077 if (GIMME_V != G_VOID) 1248 if (GIMME_V != G_VOID)
1110 1281
1111void 1282void
1112rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1283rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1113 PPCODE: 1284 PPCODE:
1114{ 1285{
1115 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1286 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1116 XSRETURN_EMPTY; 1287 XSRETURN_EMPTY;
1117 1288
1118 line_t &l = ROW(row_number); 1289 line_t &l = ROW(row_number);
1119 1290
1120 if (GIMME_V != G_VOID) 1291 if (GIMME_V != G_VOID)
1150 1321
1151int 1322int
1152rxvt_term::ROW_l (int row_number, int new_length = -1) 1323rxvt_term::ROW_l (int row_number, int new_length = -1)
1153 CODE: 1324 CODE:
1154{ 1325{
1155 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1326 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1156 XSRETURN_EMPTY; 1327 XSRETURN_EMPTY;
1157 1328
1158 line_t &l = ROW(row_number); 1329 line_t &l = ROW(row_number);
1159 RETVAL = l.l; 1330 RETVAL = l.l;
1160 1331
1166 1337
1167bool 1338bool
1168rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) 1339rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1)
1169 CODE: 1340 CODE:
1170{ 1341{
1171 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1342 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1172 XSRETURN_EMPTY; 1343 XSRETURN_EMPTY;
1173 1344
1174 line_t &l = ROW(row_number); 1345 line_t &l = ROW(row_number);
1175 RETVAL = l.is_longer (); 1346 RETVAL = l.is_longer ();
1176 1347
1366 PUSHs (sv_2mortal (newSViv (rc.col))); 1537 PUSHs (sv_2mortal (newSViv (rc.col)));
1367 } 1538 }
1368 1539
1369 if (items == 3) 1540 if (items == 3)
1370 { 1541 {
1371 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 1542 rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1);
1372 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); 1543 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1);
1373 1544
1374 if (ix) 1545 if (ix)
1375 THIS->want_refresh = 1; 1546 THIS->want_refresh = 1;
1376 } 1547 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines