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.41 by root, Sun Jan 8 03:07:05 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"
36#include "rxvtperl.h" 37#include "rxvtperl.h"
37 38
38#include "perlxsi.c" 39#include "perlxsi.c"
39 40
41#if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
42# define GRAB_CURSOR THIS->leftptr_cursor
43#else
44# define GRAB_CURSOR None
45#endif
46
40#undef LINENO 47#undef LINENO
41#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) 48#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
42#undef ROW 49#undef ROW
43#define ROW(n) THIS->row_buf [LINENO (n)] 50#define ROW(n) THIS->row_buf [LINENO (n)]
44 51
101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 108 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
102 109
103 return (long)mg->mg_ptr; 110 return (long)mg->mg_ptr;
104} 111}
105 112
106#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 113#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self)
107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 114#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
108 115
109///////////////////////////////////////////////////////////////////////////// 116/////////////////////////////////////////////////////////////////////////////
110 117
111struct perl_watcher 118struct perl_watcher
290void 297void
291overlay::show () 298overlay::show ()
292{ 299{
293 char key[33]; sprintf (key, "%32lx", (long)this); 300 char key[33]; sprintf (key, "%32lx", (long)this);
294 301
295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); 302 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); 303 hv_store (hv, key, 32, newSViv ((long)this), 0);
297} 304}
298 305
299void 306void
300overlay::hide () 307overlay::hide ()
301{ 308{
302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); 309 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0);
303 310
304 if (ovs) 311 if (ovs)
305 { 312 {
306 char key[33]; sprintf (key, "%32lx", (long)this); 313 char key[33]; sprintf (key, "%32lx", (long)this);
307 314
415 if (!perl) 422 if (!perl)
416 return false; 423 return false;
417 424
418 if (htype == HOOK_INIT) // first hook ever called 425 if (htype == HOOK_INIT) // first hook ever called
419 { 426 {
420 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 427 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
421 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 428 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
422 } 429 }
423 else if (!term->self) 430 else if (!term->perl.self)
424 return false; // perl not initialized for this instance 431 return false; // perl not initialized for this instance
425 else if (htype == HOOK_DESTROY) 432 else if (htype == HOOK_DESTROY)
426 { 433 {
427 // handled later 434 // handled later
428 } 435 }
429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 436 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
430 { 437 {
431 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); 438 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
432 439
433 if (HvKEYS (hv)) 440 if (HvKEYS (hv))
434 { 441 {
435 hv_iterinit (hv); 442 hv_iterinit (hv);
436 443
562 if (SvTRUE (ERRSV)) 569 if (SvTRUE (ERRSV))
563 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 570 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
564 571
565 if (htype == HOOK_DESTROY) 572 if (htype == HOOK_DESTROY)
566 { 573 {
567 clearSVptr ((SV *)term->self); 574 clearSVptr ((SV *)term->perl.self);
568 SvREFCNT_dec ((SV *)term->self); 575 SvREFCNT_dec ((SV *)term->perl.self);
569 } 576 }
570 577
571 return count; 578 return count;
572 } 579 }
573 580
583 590
584PROTOTYPES: ENABLE 591PROTOTYPES: ENABLE
585 592
586BOOT: 593BOOT:
587{ 594{
588# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); 595 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
596
589 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 597 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
590# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 598# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
591# include "hookinc.h" 599# include "hookinc.h"
592# undef def 600# undef def
593 601
602 HV *option = get_hv ("urxvt::OPTION", 1);
603# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
604# define nodef(name)
605# include "optinc.h"
606# undef nodef
607# undef def
608
609 HV *stash = gv_stashpv ("urxvt", 1);
610# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name));
594 export_const (DEFAULT_RSTYLE); 611 export_const_iv (DEFAULT_RSTYLE);
595 export_const (OVERLAY_RSTYLE); 612 export_const_iv (OVERLAY_RSTYLE);
596 export_const (RS_Bold); 613 export_const_iv (RS_Bold);
597 export_const (RS_Italic); 614 export_const_iv (RS_Italic);
598 export_const (RS_Blink); 615 export_const_iv (RS_Blink);
599 export_const (RS_RVid); 616 export_const_iv (RS_RVid);
600 export_const (RS_Uline); 617 export_const_iv (RS_Uline);
601 618
602 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 619 export_const_iv (CurrentTime);
620 export_const_iv (ShiftMask);
621 export_const_iv (LockMask);
622 export_const_iv (ControlMask);
623 export_const_iv (Mod1Mask);
624 export_const_iv (Mod2Mask);
625 export_const_iv (Mod3Mask);
626 export_const_iv (Mod4Mask);
627 export_const_iv (Mod5Mask);
628 export_const_iv (Button1Mask);
629 export_const_iv (Button2Mask);
630 export_const_iv (Button3Mask);
631 export_const_iv (Button4Mask);
632 export_const_iv (Button5Mask);
633 export_const_iv (AnyModifier);
603} 634}
604 635
605SV * 636SV *
606new (...) 637new (...)
607 CODE: 638 CODE:
625 { 656 {
626 term->destroy (); 657 term->destroy ();
627 croak ("exception caught while initializing new terminal instance"); 658 croak ("exception caught while initializing new terminal instance");
628 } 659 }
629 660
630 RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; 661 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
631} 662}
632 OUTPUT: 663 OUTPUT:
633 RETVAL 664 RETVAL
634 665
635void 666void
704 735
705MODULE = urxvt PACKAGE = urxvt::term 736MODULE = urxvt PACKAGE = urxvt::term
706 737
707void 738void
708rxvt_term::destroy () 739rxvt_term::destroy ()
740
741void
742rxvt_term::grab_button (int button, U32 modifiers)
743 CODE:
744 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
745 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
746 GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
747
748bool
749rxvt_term::grab (U32 eventtime, int sync = 0)
750 CODE:
751{
752 int mode = sync ? GrabModeSync : GrabModeAsync;
753
754 THIS->perl.grabtime = 0;
755
756 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
757 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
758 mode, mode, None, GRAB_CURSOR, eventtime))
759 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
760 THIS->perl.grabtime = eventtime;
761 else
762 XUngrabPointer (THIS->display->display, eventtime);
763
764 RETVAL = !!THIS->perl.grabtime;
765}
766 OUTPUT:
767 RETVAL
768
769void
770rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime)
771 CODE:
772 XAllowEvents (THIS->display->display, AsyncBoth, eventtime);
773
774void
775rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime)
776 CODE:
777 XAllowEvents (THIS->display->display, SyncBoth, eventtime);
778
779void
780rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime)
781 CODE:
782 XAllowEvents (THIS->display->display, ReplayPointer, eventtime);
783 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime);
784
785void
786rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime)
787 CODE:
788 THIS->perl.grabtime = 0;
789 XUngrabKeyboard (THIS->display->display, eventtime);
790 XUngrabPointer (THIS->display->display, eventtime);
709 791
710int 792int
711rxvt_term::strwidth (SV *str) 793rxvt_term::strwidth (SV *str)
712 CODE: 794 CODE:
713{ 795{
755 free (wstr); 837 free (wstr);
756} 838}
757 OUTPUT: 839 OUTPUT:
758 RETVAL 840 RETVAL
759 841
760# very portable, especially on objects as opposed to pods 842#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
761#define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0)
762 843
763#define TERM_OFFSET_width TERM_OFFSET(width) 844#define TERM_OFFSET_width TERM_OFFSET(width)
764#define TERM_OFFSET_height TERM_OFFSET(height) 845#define TERM_OFFSET_height TERM_OFFSET(height)
765#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 846#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
766#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 847#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
791 CODE: 872 CODE:
792 RETVAL = *(int *)((char *)THIS + ix); 873 RETVAL = *(int *)((char *)THIS + ix);
793 OUTPUT: 874 OUTPUT:
794 RETVAL 875 RETVAL
795 876
877unsigned int
878rxvt_term::ModLevel3Mask ()
879 ALIAS:
880 ModLevel3Mask = 0
881 ModMetaMask = 1
882 ModNumLockMask = 2
883 CODE:
884 switch (ix)
885 {
886 case 0: RETVAL = THIS->ModLevel3Mask; break;
887 case 1: RETVAL = THIS->ModMetaMask; break;
888 case 2: RETVAL = THIS->ModNumLockMask; break;
889 }
890 OUTPUT:
891 RETVAL
892
796U32 893U32
797rxvt_term::parent () 894rxvt_term::parent ()
798 CODE: 895 CODE:
799 RETVAL = (U32)THIS->parent [0]; 896 RETVAL = (U32)THIS->parent [0];
800 OUTPUT: 897 OUTPUT:
1065 else 1162 else
1066 THIS->rs [index] = 0; 1163 THIS->rs [index] = 0;
1067 } 1164 }
1068} 1165}
1069 1166
1167bool
1168rxvt_term::option (U32 optval, int set = -1)
1169 CODE:
1170{
1171 RETVAL = THIS->options & optval;
1172
1173 if (set >= 0)
1174 {
1175 if (set)
1176 THIS->options |= optval;
1177 else
1178 THIS->options &= ~optval;
1179
1180 switch (optval)
1181 {
1182 case Opt_skipBuiltinGlyphs:
1183 THIS->set_fonts ();
1184 THIS->scr_remap_chars ();
1185 THIS->scr_touch (true);
1186 THIS->want_refresh = 1;
1187 break;
1188
1189 case Opt_cursorUnderline:
1190 THIS->want_refresh = 1;
1191 break;
1192
1193# case Opt_scrollBar_floating:
1194# case Opt_scrollBar_right:
1195# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1196# break;
1197 }
1198 }
1199}
1200 OUTPUT:
1201 RETVAL
1202
1070void 1203void
1071rxvt_term::cur (...) 1204rxvt_term::cur (...)
1072 PROTOTYPE: $;$$ 1205 PROTOTYPE: $;$$
1073 ALIAS: 1206 ALIAS:
1074 screen_cur = 0 1207 screen_cur = 0
1098 THIS->want_refresh = 1; 1231 THIS->want_refresh = 1;
1099 } 1232 }
1100} 1233}
1101 1234
1102int 1235int
1103rxvt_term::selection_grab (int eventtime = CurrentTime) 1236rxvt_term::selection_grab (U32 eventtime)
1104 1237
1105void 1238void
1106rxvt_term::selection (SV *newtext = 0) 1239rxvt_term::selection (SV *newtext = 0)
1107 PPCODE: 1240 PPCODE:
1108{ 1241{
1146 char *old_cmdbuf_endp = THIS->cmdbuf_endp; 1279 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1147 1280
1148 THIS->cmdbuf_ptr = str; 1281 THIS->cmdbuf_ptr = str;
1149 THIS->cmdbuf_endp = str + len; 1282 THIS->cmdbuf_endp = str + len;
1150 1283
1284 rxvt_push_locale (THIS->locale);
1151 THIS->cmd_parse (); 1285 THIS->cmd_parse ();
1286 rxvt_pop_locale ();
1152 1287
1153 THIS->cmdbuf_ptr = old_cmdbuf_ptr; 1288 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1154 THIS->cmdbuf_endp = old_cmdbuf_endp; 1289 THIS->cmdbuf_endp = old_cmdbuf_endp;
1155} 1290}
1156 1291

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines