ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtperl.xs
(Generate patch)

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.34 by root, Fri Jan 6 21:06:09 2006 UTC vs.
Revision 1.38 by root, Sat Jan 7 21:22:02 2006 UTC

26#include <XSUB.h> 26#include <XSUB.h>
27#undef line_t 27#undef line_t
28 28
29#include "../config.h" 29#include "../config.h"
30 30
31#include <cstddef>
31#include <cstdarg> 32#include <cstdarg>
32 33
33#include "rxvt.h" 34#include "rxvt.h"
34#include "iom.h" 35#include "iom.h"
35#include "rxvtutil.h" 36#include "rxvtutil.h"
101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 102 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
102 103
103 return (long)mg->mg_ptr; 104 return (long)mg->mg_ptr;
104} 105}
105 106
106#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 107#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self)
107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 108#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
108 109
109///////////////////////////////////////////////////////////////////////////// 110/////////////////////////////////////////////////////////////////////////////
110 111
111struct perl_watcher 112struct perl_watcher
290void 291void
291overlay::show () 292overlay::show ()
292{ 293{
293 char key[33]; sprintf (key, "%32lx", (long)this); 294 char key[33]; sprintf (key, "%32lx", (long)this);
294 295
295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); 296 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
296 hv_store (hv, key, 32, newSViv ((long)this), 0); 297 hv_store (hv, key, 32, newSViv ((long)this), 0);
297} 298}
298 299
299void 300void
300overlay::hide () 301overlay::hide ()
301{ 302{
302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); 303 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0);
303 304
304 if (ovs) 305 if (ovs)
305 { 306 {
306 char key[33]; sprintf (key, "%32lx", (long)this); 307 char key[33]; sprintf (key, "%32lx", (long)this);
307 308
415 if (!perl) 416 if (!perl)
416 return false; 417 return false;
417 418
418 if (htype == HOOK_INIT) // first hook ever called 419 if (htype == HOOK_INIT) // first hook ever called
419 { 420 {
420 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 421 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
421 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 422 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
422 } 423 }
423 else if (!term->self) 424 else if (!term->perl.self)
424 return false; // perl not initialized for this instance 425 return false; // perl not initialized for this instance
425 else if (htype == HOOK_DESTROY) 426 else if (htype == HOOK_DESTROY)
426 { 427 {
427 // handled later 428 // handled later
428 } 429 }
429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 430 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
430 { 431 {
431 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); 432 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
432 433
433 if (HvKEYS (hv)) 434 if (HvKEYS (hv))
434 { 435 {
435 hv_iterinit (hv); 436 hv_iterinit (hv);
436 437
562 if (SvTRUE (ERRSV)) 563 if (SvTRUE (ERRSV))
563 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 564 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
564 565
565 if (htype == HOOK_DESTROY) 566 if (htype == HOOK_DESTROY)
566 { 567 {
567 clearSVptr ((SV *)term->self); 568 clearSVptr ((SV *)term->perl.self);
568 SvREFCNT_dec ((SV *)term->self); 569 SvREFCNT_dec ((SV *)term->perl.self);
569 } 570 }
570 571
571 return count; 572 return count;
572 } 573 }
573 574
583 584
584PROTOTYPES: ENABLE 585PROTOTYPES: ENABLE
585 586
586BOOT: 587BOOT:
587{ 588{
589 HV *stash = gv_stashpv ("urxvt", 1);
588# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); 590# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name));
591
589 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 592 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
590# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 593# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
591# include "hookinc.h" 594# include "hookinc.h"
592# undef def 595# undef def
593 596
597
594 export_const (DEFAULT_RSTYLE); 598 export_const_iv (DEFAULT_RSTYLE);
595 export_const (OVERLAY_RSTYLE); 599 export_const_iv (OVERLAY_RSTYLE);
596 export_const (RS_Bold); 600 export_const_iv (RS_Bold);
597 export_const (RS_Italic); 601 export_const_iv (RS_Italic);
598 export_const (RS_Blink); 602 export_const_iv (RS_Blink);
599 export_const (RS_RVid); 603 export_const_iv (RS_RVid);
600 export_const (RS_Uline); 604 export_const_iv (RS_Uline);
601 605
602 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 606 export_const_iv (CurrentTime);
607 export_const_iv (ShiftMask);
608 export_const_iv (LockMask);
609 export_const_iv (ControlMask);
610 export_const_iv (Mod1Mask);
611 export_const_iv (Mod2Mask);
612 export_const_iv (Mod3Mask);
613 export_const_iv (Mod4Mask);
614 export_const_iv (Mod5Mask);
615 export_const_iv (Button1Mask);
616 export_const_iv (Button2Mask);
617 export_const_iv (Button3Mask);
618 export_const_iv (Button4Mask);
619 export_const_iv (Button5Mask);
620 export_const_iv (AnyModifier);
621
622 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
603} 623}
604 624
605SV * 625SV *
606new (...) 626new (...)
607 CODE: 627 CODE:
625 { 645 {
626 term->destroy (); 646 term->destroy ();
627 croak ("exception caught while initializing new terminal instance"); 647 croak ("exception caught while initializing new terminal instance");
628 } 648 }
629 649
630 RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; 650 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
631} 651}
632 OUTPUT: 652 OUTPUT:
633 RETVAL 653 RETVAL
634 654
635void 655void
704 724
705MODULE = urxvt PACKAGE = urxvt::term 725MODULE = urxvt PACKAGE = urxvt::term
706 726
707void 727void
708rxvt_term::destroy () 728rxvt_term::destroy ()
729
730void
731rxvt_term::grab_button (int button, U32 modifiers)
732 CODE:
733 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
734 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
735 GrabModeSync, GrabModeSync, None, None);
736
737bool
738rxvt_term::grab (U32 eventtime, int sync = 0)
739 CODE:
740{
741 int mode = sync ? GrabModeSync : GrabModeAsync;
742
743 THIS->perl.grabtime = 0;
744
745 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
746 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
747 mode, mode, None, None, eventtime))
748 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
749 THIS->perl.grabtime = eventtime;
750 else
751 XUngrabPointer (THIS->display->display, eventtime);
752
753 RETVAL = !!THIS->perl.grabtime;
754}
755 OUTPUT:
756 RETVAL
757
758void
759rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime)
760 CODE:
761 XAllowEvents (THIS->display->display, AsyncBoth, eventtime);
762
763void
764rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime)
765 CODE:
766 XAllowEvents (THIS->display->display, SyncBoth, eventtime);
767
768void
769rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime)
770 CODE:
771 XAllowEvents (THIS->display->display, ReplayPointer, eventtime);
772 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime);
773
774void
775rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime)
776 CODE:
777 THIS->perl.grabtime = 0;
778 XUngrabKeyboard (THIS->display->display, eventtime);
779 XUngrabPointer (THIS->display->display, eventtime);
709 780
710int 781int
711rxvt_term::strwidth (SV *str) 782rxvt_term::strwidth (SV *str)
712 CODE: 783 CODE:
713{ 784{
755 free (wstr); 826 free (wstr);
756} 827}
757 OUTPUT: 828 OUTPUT:
758 RETVAL 829 RETVAL
759 830
760# very portable, especially on objects as opposed to pods 831#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
761#define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0)
762 832
763#define TERM_OFFSET_width TERM_OFFSET(width) 833#define TERM_OFFSET_width TERM_OFFSET(width)
764#define TERM_OFFSET_height TERM_OFFSET(height) 834#define TERM_OFFSET_height TERM_OFFSET(height)
765#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 835#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
766#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 836#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
791 CODE: 861 CODE:
792 RETVAL = *(int *)((char *)THIS + ix); 862 RETVAL = *(int *)((char *)THIS + ix);
793 OUTPUT: 863 OUTPUT:
794 RETVAL 864 RETVAL
795 865
866unsigned int
867rxvt_term::ModLevel3Mask ()
868 ALIAS:
869 ModLevel3Mask = 0
870 ModMetaMask = 1
871 ModNumLockMask = 2
872 CODE:
873 switch (ix)
874 {
875 case 0: RETVAL = THIS->ModLevel3Mask; break;
876 case 1: RETVAL = THIS->ModMetaMask; break;
877 case 2: RETVAL = THIS->ModNumLockMask; break;
878 }
879 OUTPUT:
880 RETVAL
881
796U32 882U32
797rxvt_term::parent () 883rxvt_term::parent ()
798 CODE: 884 CODE:
799 RETVAL = (U32)THIS->parent [0]; 885 RETVAL = (U32)THIS->parent [0];
800 OUTPUT: 886 OUTPUT:
1098 THIS->want_refresh = 1; 1184 THIS->want_refresh = 1;
1099 } 1185 }
1100} 1186}
1101 1187
1102int 1188int
1103rxvt_term::selection_grab (int eventtime = CurrentTime) 1189rxvt_term::selection_grab (U32 eventtime)
1104 1190
1105void 1191void
1106rxvt_term::selection (SV *newtext = 0) 1192rxvt_term::selection (SV *newtext = 0)
1107 PPCODE: 1193 PPCODE:
1108{ 1194{
1146 char *old_cmdbuf_endp = THIS->cmdbuf_endp; 1232 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1147 1233
1148 THIS->cmdbuf_ptr = str; 1234 THIS->cmdbuf_ptr = str;
1149 THIS->cmdbuf_endp = str + len; 1235 THIS->cmdbuf_endp = str + len;
1150 1236
1237 rxvt_push_locale (THIS->locale);
1151 THIS->cmd_parse (); 1238 THIS->cmd_parse ();
1239 rxvt_pop_locale ();
1152 1240
1153 THIS->cmdbuf_ptr = old_cmdbuf_ptr; 1241 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1154 THIS->cmdbuf_endp = old_cmdbuf_endp; 1242 THIS->cmdbuf_endp = old_cmdbuf_endp;
1155} 1243}
1156 1244

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines