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.78 by root, Thu Jan 19 20:30:36 2006 UTC vs.
Revision 1.100 by root, Mon Feb 20 20:44:22 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 55typedef int CHAINED UNUSED;
56 56
57///////////////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////////////
58 58
59static wchar_t * 59static wchar_t *
60sv2wcs (SV *sv) 60sv2wcs (SV *sv)
80new_ref (HV *hv, const char *klass) 80new_ref (HV *hv, const char *klass)
81{ 81{
82 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); 82 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
83} 83}
84 84
85//TODO: use magic
86static SV * 85static SV *
87newSVptr (void *ptr, const char *klass) 86newSVptr (void *ptr, const char *klass)
88{ 87{
89 HV *hv = newHV (); 88 HV *hv = newHV ();
90 sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); 89 sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0);
113 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 112 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
114 113
115 return (long)mg->mg_ptr; 114 return (long)mg->mg_ptr;
116} 115}
117 116
118#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) 117#define newSVterm(term) SvREFCNT_inc ((SV *)(term)->perl.self)
119#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 118#define SvTERM(sv) (rxvt_term *)SvPTR ((sv), "urxvt::term")
120 119
121///////////////////////////////////////////////////////////////////////////// 120/////////////////////////////////////////////////////////////////////////////
121
122#define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, "urxvt::watcher")
122 123
123struct perl_watcher 124struct perl_watcher
124{ 125{
125 SV *cbsv; 126 SV *cbsv;
126 HV *self; 127 HV *self;
127 128
128 perl_watcher () 129 perl_watcher ()
129 : cbsv (newSV (0)) 130 : cbsv (0)
130 { 131 {
131 } 132 }
132 133
133 ~perl_watcher () 134 ~perl_watcher ()
134 { 135 {
135 SvREFCNT_dec (cbsv); 136 SvREFCNT_dec (cbsv);
136 } 137 }
137 138
138 void cb (SV *cb) 139 void cb (SV *cb)
139 { 140 {
140 sv_setsv (cbsv, cb); 141 SvREFCNT_dec (cbsv);
142 cbsv = newSVsv (cb);
141 } 143 }
142 144
143 void invoke (const char *type, SV *self, int arg = -1); 145 void invoke (const char *type, SV *self, int arg = -1);
144}; 146};
145 147
168 170
169 if (SvTRUE (ERRSV)) 171 if (SvTRUE (ERRSV))
170 rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); 172 rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV));
171} 173}
172 174
173#define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") 175#define newSVtimer(timer) new_ref ((timer)->self, "urxvt::timer")
174#define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") 176#define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), "urxvt::timer")
175 177
176struct timer : time_watcher, perl_watcher 178struct timer : perl_watcher, time_watcher
177{ 179{
178 tstamp interval; 180 tstamp interval;
179 181
180 timer () 182 timer ()
181 : time_watcher (this, &timer::execute) 183 : time_watcher (this, &timer::execute)
189 191
190 invoke ("urxvt::timer", newSVtimer (this)); 192 invoke ("urxvt::timer", newSVtimer (this));
191 } 193 }
192}; 194};
193 195
194#define newSViow(iow) new_ref (iow->self, "urxvt::iow") 196#define newSViow(iow) new_ref ((iow)->self, "urxvt::iow")
195#define SvIOW(sv) (iow *)SvPTR (sv, "urxvt::iow") 197#define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), "urxvt::iow")
196 198
197struct iow : io_watcher, perl_watcher 199struct iow : perl_watcher, io_watcher
198{ 200{
199 iow () 201 iow ()
200 : io_watcher (this, &iow::execute) 202 : io_watcher (this, &iow::execute)
201 { 203 {
202 } 204 }
205 { 207 {
206 invoke ("urxvt::iow", newSViow (this), revents); 208 invoke ("urxvt::iow", newSViow (this), revents);
207 } 209 }
208}; 210};
209 211
212#define newSViw(iw) new_ref ((iw)->self, "urxvt::iw")
213#define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), "urxvt::iw")
214
215struct iw : perl_watcher, idle_watcher
216{
217 iw ()
218 : idle_watcher (this, &iw::execute)
219 {
220 }
221
222 void execute (idle_watcher &w)
223 {
224 invoke ("urxvt::iw", newSViw (this));
225 }
226};
227
228#define newSVpw(pw) new_ref ((pw)->self, "urxvt::pw")
229#define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), "urxvt::pw")
230
231struct pw : perl_watcher, child_watcher
232{
233 pw ()
234 : child_watcher (this, &pw::execute)
235 {
236 }
237
238 void execute (child_watcher &w, int status)
239 {
240 invoke ("urxvt::pw", newSVpw (this), status);
241 }
242};
243
210///////////////////////////////////////////////////////////////////////////// 244/////////////////////////////////////////////////////////////////////////////
211 245
212#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 246#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
213 247
214struct overlay { 248class overlay {
215 HV *self;
216 bool visible;
217 rxvt_term *THIS; 249 rxvt_term *THIS;
250 AV *overlay_av;
218 int x, y, w, h; 251 int x, y, w, h;
219 int border; 252 int border;
220 text_t **text; 253 text_t **text;
221 rend_t **rend; 254 rend_t **rend;
222 255
256public:
257 HV *self;
258
223 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); 259 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
224 ~overlay (); 260 ~overlay ();
225 261
226 void show (); 262 void show ();
227 void hide (); 263 void hide ();
230 266
231 void set (int x, int y, SV *str, SV *rend); 267 void set (int x, int y, SV *str, SV *rend);
232}; 268};
233 269
234overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) 270overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border)
235: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), visible(false) 271: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0)
236{ 272{
237 if (border == 2) 273 if (border == 2)
238 { 274 {
239 w += 2; 275 w += 2;
240 h += 2; 276 h += 2;
279 *rp++ = r; 315 *rp++ = r;
280 } 316 }
281 } 317 }
282 318
283 show (); 319 show ();
284 THIS->want_refresh = 1;
285} 320}
286 321
287overlay::~overlay () 322overlay::~overlay ()
288{ 323{
289 hide (); 324 hide ();
294 delete [] rend[y]; 329 delete [] rend[y];
295 } 330 }
296 331
297 delete [] text; 332 delete [] text;
298 delete [] rend; 333 delete [] rend;
334}
335
336void
337overlay::show ()
338{
339 if (overlay_av)
340 return;
341
342 overlay_av = (AV *)SvREFCNT_inc (SvRV (
343 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)
344 ));
345 av_push (overlay_av, newSViv ((long)this));
299 346
300 THIS->want_refresh = 1; 347 THIS->want_refresh = 1;
301} 348}
302 349
303void 350void
304overlay::show () 351overlay::hide ()
305{ 352{
306 if (visible) 353 if (!overlay_av)
307 return; 354 return;
308 355
309 visible = true;
310
311 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
312 av_push (av, newSViv ((long)this));
313}
314
315void
316overlay::hide ()
317{
318 if (!visible)
319 return;
320
321 visible = false;
322
323 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
324
325 int i; 356 int i;
326 357
327 for (i = AvFILL (av); i >= 0; i--) 358 for (i = AvFILL (overlay_av); i >= 0; i--)
328 if (SvIV (*av_fetch (av, i, 1)) == (long)this) 359 if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this)
329 { 360 {
330 av_delete (av, i, G_DISCARD); 361 av_delete (overlay_av, i, G_DISCARD);
331 break; 362 break;
332 } 363 }
333 364
334 for (; i < AvFILL (av); i++) 365 for (; i < AvFILL (overlay_av); i++)
335 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); 366 av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0)));
336 367
337 av_pop (av); 368 av_pop (overlay_av);
369
370 SvREFCNT_dec (overlay_av);
371 overlay_av = 0;
372
373 THIS->want_refresh = 1;
338} 374}
339 375
340void overlay::swap () 376void overlay::swap ()
341{ 377{
342 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 378 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
457static void 493static void
458ungrab (rxvt_term *THIS) 494ungrab (rxvt_term *THIS)
459{ 495{
460 if (THIS->perl.grabtime) 496 if (THIS->perl.grabtime)
461 { 497 {
462 XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); 498 XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime);
463 XUngrabPointer (THIS->display->display, THIS->perl.grabtime); 499 XUngrabPointer (THIS->dpy, THIS->perl.grabtime);
464 THIS->perl.grabtime = 0; 500 THIS->perl.grabtime = 0;
465 } 501 }
466} 502}
467 503
468bool 504bool
519 break; 555 break;
520 556
521 case DT_STR_LEN: 557 case DT_STR_LEN:
522 { 558 {
523 char *str = va_arg (ap, char *); 559 char *str = va_arg (ap, char *);
524 int len = va_arg (ap, int); 560 int len = va_arg (ap, int);
525 561
526 XPUSHs (sv_2mortal (newSVpvn (str, len))); 562 XPUSHs (sv_2mortal (newSVpvn (str, len)));
527 } 563 }
528 break; 564 break;
529 565
530 case DT_WCS_LEN: 566 case DT_WCS_LEN:
531 { 567 {
532 wchar_t *wstr = va_arg (ap, wchar_t *); 568 wchar_t *wstr = va_arg (ap, wchar_t *);
533 int wlen = va_arg (ap, int); 569 int wlen = va_arg (ap, int);
534 570
535 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 571 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
572 }
573 break;
574
575 case DT_LCS_LEN:
576 {
577 long *lstr = va_arg (ap, long *);
578 int llen = va_arg (ap, int);
579
580 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
536 } 581 }
537 break; 582 break;
538 583
539 case DT_XEVENT: 584 case DT_XEVENT:
540 { 585 {
541 XEvent *xe = va_arg (ap, XEvent *); 586 XEvent *xe = va_arg (ap, XEvent *);
542 HV *hv = newHV (); 587 HV *hv = newHV ();
543 588
544# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 589# 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) 590# 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) 591# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
547# undef set 592# undef set
548 593
549 setiv (type, xe->type); 594 setiv (type, xe->type);
550 setiv (send_event, xe->xany.send_event); 595 setiv (send_event, xe->xany.send_event);
551 setiv (serial, xe->xany.serial); 596 setiv (serial, xe->xany.serial);
552 597
561 setuv (root, xe->xmotion.root); 606 setuv (root, xe->xmotion.root);
562 setuv (subwindow, xe->xmotion.subwindow); 607 setuv (subwindow, xe->xmotion.subwindow);
563 setuv (time, xe->xmotion.time); 608 setuv (time, xe->xmotion.time);
564 setiv (x, xe->xmotion.x); 609 setiv (x, xe->xmotion.x);
565 setiv (y, xe->xmotion.y); 610 setiv (y, xe->xmotion.y);
566 setiv (row, xe->xmotion.y / term->fheight); 611 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
567 setiv (col, xe->xmotion.x / term->fwidth); 612 setiv (col, xe->xmotion.x / term->fwidth);
568 setiv (x_root, xe->xmotion.x_root); 613 setiv (x_root, xe->xmotion.x_root);
569 setiv (y_root, xe->xmotion.y_root); 614 setiv (y_root, xe->xmotion.y_root);
570 setuv (state, xe->xmotion.state); 615 setuv (state, xe->xmotion.state);
571 616
603 setiv (height, xe->xconfigure.height); 648 setiv (height, xe->xconfigure.height);
604 setuv (above, xe->xconfigure.above); 649 setuv (above, xe->xconfigure.above);
605 break; 650 break;
606 } 651 }
607 652
653 break;
654
655 case PropertyNotify:
656 setuv (window, xe->xproperty.window);
657 setuv (atom, xe->xproperty.atom);
658 setuv (time, xe->xproperty.time);
659 setiv (state, xe->xproperty.state);
660 break;
661
662 case ClientMessage:
663 setuv (window, xe->xclient.window);
664 setuv (message_type, xe->xclient.message_type);
665 setuv (format, xe->xclient.format);
666 setuv (l0, xe->xclient.data.l[0]);
667 setuv (l1, xe->xclient.data.l[1]);
668 setuv (l2, xe->xclient.data.l[2]);
669 setuv (l3, xe->xclient.data.l[3]);
670 setuv (l4, xe->xclient.data.l[4]);
608 break; 671 break;
609 } 672 }
610 673
611 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 674 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
612 } 675 }
663 } 726 }
664 else if (htype == HOOK_DESTROY) 727 else if (htype == HOOK_DESTROY)
665 { 728 {
666 clearSVptr ((SV *)term->perl.self); 729 clearSVptr ((SV *)term->perl.self);
667 SvREFCNT_dec ((SV *)term->perl.self); 730 SvREFCNT_dec ((SV *)term->perl.self);
731
732 // don't allow further calls
733 term->perl.self = 0;
668 } 734 }
669 735
670 swap (perl_environ, environ); 736 swap (perl_environ, environ);
671 737
672 return event_consumed; 738 return event_consumed;
696# include "optinc.h" 762# include "optinc.h"
697# undef nodef 763# undef nodef
698# undef def 764# undef def
699 765
700 HV *stash = gv_stashpv ("urxvt", 1); 766 HV *stash = gv_stashpv ("urxvt", 1);
701 struct { 767 static const struct {
702 const char *name; 768 const char *name;
703 IV iv; 769 IV iv;
704 } *civ, const_iv[] = { 770 } *civ, const_iv[] = {
705# define const_iv(name) { # name, (IV)name } 771# define const_iv(name) { # name, (IV)name }
706 const_iv (DEFAULT_RSTYLE), 772 const_iv (DEFAULT_RSTYLE),
789 const_iv (SelectionRequest), 855 const_iv (SelectionRequest),
790 const_iv (SelectionNotify), 856 const_iv (SelectionNotify),
791 const_iv (ColormapNotify), 857 const_iv (ColormapNotify),
792 const_iv (ClientMessage), 858 const_iv (ClientMessage),
793 const_iv (MappingNotify), 859 const_iv (MappingNotify),
860# if ENABLE_XIM_ONTHESPOT
861 const_iv (XIMReverse),
862 const_iv (XIMUnderline),
863 const_iv (XIMHighlight),
864 const_iv (XIMPrimary),
865 const_iv (XIMSecondary),
866 const_iv (XIMTertiary),
867 const_iv (XIMVisibleToForward),
868 const_iv (XIMVisibleToBackword),
869 const_iv (XIMVisibleToCenter),
870# if 0
871 const_iv (XIMForwardChar),
872 const_iv (XIMBackwardChar),
873 const_iv (XIMForwardWord),
874 const_iv (XIMBackwardWord),
875 const_iv (XIMCaretUp),
876 const_iv (XIMCaretDown),
877 const_iv (XIMNextLine),
878 const_iv (XIMPreviousLine),
879 const_iv (XIMLineStart),
880 const_iv (XIMLineEnd),
881 const_iv (XIMAbsolutePosition),
882 const_iv (XIMDontChange),
883# endif
884# endif
794 }; 885 };
795 886
796 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); 887 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
797 civ-- > const_iv; )
798 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 888 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
799} 889}
800 890
801void 891void
802warn (const char *msg) 892warn (const char *msg)
833 RETVAL 923 RETVAL
834 924
835int 925int
836SET_FGCOLOR (int rend, int new_color) 926SET_FGCOLOR (int rend, int new_color)
837 CODE: 927 CODE:
838 RETVAL = SET_FGCOLOR (rend, new_color); 928 RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1));
839 OUTPUT: 929 OUTPUT:
840 RETVAL 930 RETVAL
841 931
842int 932int
843SET_BGCOLOR (int rend, int new_color) 933SET_BGCOLOR (int rend, int new_color)
844 CODE: 934 CODE:
845 RETVAL = SET_BGCOLOR (rend, new_color); 935 RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1));
846 OUTPUT: 936 OUTPUT:
847 RETVAL 937 RETVAL
848 938
849int 939int
850GET_CUSTOM (int rend) 940GET_CUSTOM (int rend)
864 | ((new_value << RS_customShift) & RS_customMask); 954 | ((new_value << RS_customShift) & RS_customMask);
865} 955}
866 OUTPUT: 956 OUTPUT:
867 RETVAL 957 RETVAL
868 958
959void
960termlist ()
961 PPCODE:
962{
963 EXTEND (SP, rxvt_term::termlist.size ());
964
965 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
966 if ((*t)->perl.self)
967 PUSHs (sv_2mortal (newSVterm (*t)));
968}
969
869MODULE = urxvt PACKAGE = urxvt::term 970MODULE = urxvt PACKAGE = urxvt::term
870 971
871SV * 972SV *
872_new (...) 973_new (AV *env, AV *arg)
873 CODE: 974 CODE:
874{ 975{
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; 976 rxvt_term *term = new rxvt_term;
879 977
880 term->argv = new stringvec; 978 stringvec *argv = new stringvec;
881 term->envv = new stringvec; 979 stringvec *envv = new stringvec;
882 980
883 for (int i = 1; i < items; i++) 981 for (int i = 0; i <= AvFILL (arg); i++)
884 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); 982 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
885 983
886 AV *envv = (AV *)SvRV (ST (0));
887 for (int i = AvFILL (envv) + 1; i--; ) 984 for (int i = AvFILL (env) + 1; i--; )
888 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); 985 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
889 986
890 term->envv->push_back (0); 987 envv->push_back (0);
891 988
892 bool success; 989 bool success;
893 990
894 try 991 try
895 { 992 {
896 success = term->init (term->argv->size (), term->argv->begin ()); 993 success = term->init (argv, envv);
897 } 994 }
898 catch (const class rxvt_failure_exception &e) 995 catch (const class rxvt_failure_exception &e)
899 { 996 {
900 success = false; 997 success = false;
901 } 998 }
913 RETVAL 1010 RETVAL
914 1011
915void 1012void
916rxvt_term::destroy () 1013rxvt_term::destroy ()
917 1014
918#if ENABLE_PERL_FRILLS
919
920void
921rxvt_term::XListProperties (U32 window)
922 PPCODE:
923{
924 int count;
925 Atom *props = XListProperties (THIS->display->display, (Window)window, &count);
926
927 EXTEND (SP, count);
928 while (count--)
929 PUSHs (newSVuv ((U32)props [count]));
930
931 XFree (props);
932}
933
934void
935rxvt_term::XGetWindowProperty (U32 window, U32 property)
936 PPCODE:
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}
955
956void
957rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data)
958 CODE:
959{
960 STRLEN len;
961 char *data_ = SvPVbyte (data, len);
962
963 XChangeProperty (THIS->display->display, (Window)window, (Atom)property,
964 type, format, PropModeReplace,
965 (unsigned char *)data, len * 8 / format);
966}
967
968void
969rxvt_term::XDeleteProperty (U32 window, U32 property)
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:
978 RETVAL
979
980U32
981rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height)
982 CODE:
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]);
987 OUTPUT:
988 RETVAL
989
990void
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 1015void
1008rxvt_term::set_should_invoke (int htype, int inc) 1016rxvt_term::set_should_invoke (int htype, int inc)
1009 CODE: 1017 CODE:
1010 THIS->perl.should_invoke [htype] += inc; 1018 THIS->perl.should_invoke [htype] += inc;
1011 1019
1012void 1020void
1013rxvt_term::grab_button (int button, U32 modifiers) 1021rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
1014 CODE: 1022 CODE:
1015 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, 1023 XGrabButton (THIS->dpy, button, modifiers, window, 1,
1016 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 1024 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1017 GrabModeSync, GrabModeSync, None, GRAB_CURSOR); 1025 GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
1018 1026
1027void
1028rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt)
1029 CODE:
1030 XUngrabButton (THIS->dpy, button, modifiers, window);
1031
1032#if 0
1033
1034void
1035XGrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt)
1036 C_ARGS:
1037 THIS->dpy, keycode, modifiers, window, 1,
1038 GrabModeSync, GrabModeSync
1039
1040void
1041XUngrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt)
1042 C_ARGS: THIS->dpy, keycode, modifiers, window
1043
1044#endif
1045
1019bool 1046bool
1020rxvt_term::grab (U32 eventtime, int sync = 0) 1047rxvt_term::grab (Time eventtime, int sync = 0)
1021 CODE: 1048 CODE:
1022{ 1049{
1023 int mode = sync ? GrabModeSync : GrabModeAsync; 1050 int mode = sync ? GrabModeSync : GrabModeAsync;
1024 1051
1025 THIS->perl.grabtime = 0; 1052 THIS->perl.grabtime = 0;
1026 1053
1027 if (!XGrabPointer (THIS->display->display, THIS->vt, 0, 1054 if (!XGrabPointer (THIS->dpy, THIS->vt, 0,
1028 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 1055 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1029 mode, mode, None, GRAB_CURSOR, eventtime)) 1056 mode, mode, None, GRAB_CURSOR, eventtime))
1030 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) 1057 if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime))
1031 THIS->perl.grabtime = eventtime; 1058 THIS->perl.grabtime = eventtime;
1032 else 1059 else
1033 XUngrabPointer (THIS->display->display, eventtime); 1060 XUngrabPointer (THIS->dpy, eventtime);
1034 1061
1035 RETVAL = !!THIS->perl.grabtime; 1062 RETVAL = !!THIS->perl.grabtime;
1036} 1063}
1037 OUTPUT: 1064 OUTPUT:
1038 RETVAL 1065 RETVAL
1039 1066
1040void 1067void
1041rxvt_term::allow_events_async () 1068rxvt_term::allow_events_async ()
1042 CODE: 1069 CODE:
1043 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); 1070 XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime);
1044 1071
1045void 1072void
1046rxvt_term::allow_events_sync () 1073rxvt_term::allow_events_sync ()
1047 CODE: 1074 CODE:
1048 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); 1075 XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime);
1049 1076
1050void 1077void
1051rxvt_term::allow_events_replay () 1078rxvt_term::allow_events_replay ()
1052 CODE: 1079 CODE:
1053 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); 1080 XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime);
1054 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); 1081 XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime);
1055 1082
1056void 1083void
1057rxvt_term::ungrab () 1084rxvt_term::ungrab ()
1058 CODE: 1085 CODE:
1059 ungrab (THIS); 1086 ungrab (THIS);
1117#define TERM_OFFSET_fbase TERM_OFFSET(fbase) 1144#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
1118#define TERM_OFFSET_nrow TERM_OFFSET(nrow) 1145#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
1119#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1146#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
1120#define TERM_OFFSET_focus TERM_OFFSET(focus) 1147#define TERM_OFFSET_focus TERM_OFFSET(focus)
1121#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1148#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
1149#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth)
1150#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth)
1151#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace)
1122#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1152#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
1123#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1153#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
1124#define TERM_OFFSET_top_row TERM_OFFSET(top_row) 1154#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
1125 1155
1126int 1156int
1133 fbase = TERM_OFFSET_fbase 1163 fbase = TERM_OFFSET_fbase
1134 nrow = TERM_OFFSET_nrow 1164 nrow = TERM_OFFSET_nrow
1135 ncol = TERM_OFFSET_ncol 1165 ncol = TERM_OFFSET_ncol
1136 focus = TERM_OFFSET_focus 1166 focus = TERM_OFFSET_focus
1137 mapped = TERM_OFFSET_mapped 1167 mapped = TERM_OFFSET_mapped
1168 int_bwidth = TERM_OFFSET_int_bwidth
1169 ext_bwidth = TERM_OFFSET_ext_bwidth
1170 lineSpace = TERM_OFFSET_lineSpace
1138 saveLines = TERM_OFFSET_saveLines 1171 saveLines = TERM_OFFSET_saveLines
1139 total_rows = TERM_OFFSET_total_rows 1172 total_rows = TERM_OFFSET_total_rows
1140 top_row = TERM_OFFSET_top_row 1173 top_row = TERM_OFFSET_top_row
1141 CODE: 1174 CODE:
1142 RETVAL = *(int *)((char *)THIS + ix); 1175 RETVAL = *(int *)((char *)THIS + ix);
1147rxvt_term::ModLevel3Mask () 1180rxvt_term::ModLevel3Mask ()
1148 ALIAS: 1181 ALIAS:
1149 ModLevel3Mask = 0 1182 ModLevel3Mask = 0
1150 ModMetaMask = 1 1183 ModMetaMask = 1
1151 ModNumLockMask = 2 1184 ModNumLockMask = 2
1185 current_screen = 3
1186 hidden_cursor = 4
1152 CODE: 1187 CODE:
1153 switch (ix) 1188 switch (ix)
1154 { 1189 {
1155 case 0: RETVAL = THIS->ModLevel3Mask; break; 1190 case 0: RETVAL = THIS->ModLevel3Mask; break;
1156 case 1: RETVAL = THIS->ModMetaMask; break; 1191 case 1: RETVAL = THIS->ModMetaMask; break;
1157 case 2: RETVAL = THIS->ModNumLockMask; break; 1192 case 2: RETVAL = THIS->ModNumLockMask; break;
1193 case 3: RETVAL = THIS->current_screen; break;
1194 case 4: RETVAL = THIS->hidden_cursor; break;
1158 } 1195 }
1159 OUTPUT: 1196 OUTPUT:
1160 RETVAL 1197 RETVAL
1161 1198
1162char * 1199char *
1172 } 1209 }
1173 OUTPUT: 1210 OUTPUT:
1174 RETVAL 1211 RETVAL
1175 1212
1176SV * 1213SV *
1177rxvt_term::_env () 1214rxvt_term::envv ()
1215 ALIAS:
1216 argv = 1
1178 CODE: 1217 PPCODE:
1179{ 1218{
1180 if (THIS->envv) 1219 stringvec *vec = ix ? THIS->argv : THIS->envv;
1181 {
1182 AV *av = newAV ();
1183 1220
1221 EXTEND (SP, vec->size ());
1222
1184 for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) 1223 for (char **i = vec->begin (); i != vec->end (); ++i)
1185 if (*i) 1224 if (*i)
1186 av_push (av, newSVpv (*i, 0)); 1225 PUSHs (sv_2mortal (newSVpv (*i, 0)));
1187
1188 RETVAL = newRV_noinc ((SV *)av);
1189 }
1190 else
1191 RETVAL = &PL_sv_undef;
1192} 1226}
1193 OUTPUT:
1194 RETVAL
1195 1227
1196int 1228int
1197rxvt_term::pty_ev_events (int events = EVENT_UNDEF) 1229rxvt_term::pty_ev_events (int events = EVENT_UNDEF)
1198 CODE: 1230 CODE:
1199 RETVAL = THIS->pty_ev.events; 1231 RETVAL = THIS->pty_ev.events;
1200 if (events != EVENT_UNDEF) 1232 if (events != EVENT_UNDEF)
1201 THIS->pty_ev.set (events); 1233 THIS->pty_ev.set (events);
1202 OUTPUT: 1234 OUTPUT:
1203 RETVAL 1235 RETVAL
1204 1236
1205U32 1237int
1238rxvt_term::pty_fd ()
1239 CODE:
1240 RETVAL = THIS->pty->pty;
1241 OUTPUT:
1242 RETVAL
1243
1244Window
1206rxvt_term::parent () 1245rxvt_term::parent ()
1207 CODE: 1246 CODE:
1208 RETVAL = (U32)THIS->parent [0]; 1247 RETVAL = THIS->parent [0];
1209 OUTPUT: 1248 OUTPUT:
1210 RETVAL 1249 RETVAL
1211 1250
1212U32 1251Window
1213rxvt_term::vt () 1252rxvt_term::vt ()
1214 CODE: 1253 CODE:
1215 RETVAL = (U32)THIS->vt; 1254 RETVAL = THIS->vt;
1216 OUTPUT: 1255 OUTPUT:
1217 RETVAL 1256 RETVAL
1218 1257
1219void 1258void
1220rxvt_term::vt_emask_add (U32 emask) 1259rxvt_term::vt_emask_add (U32 emask)
1242} 1281}
1243 OUTPUT: 1282 OUTPUT:
1244 RETVAL 1283 RETVAL
1245 1284
1246void 1285void
1286rxvt_term::focus_in ()
1287
1288void
1289rxvt_term::focus_out ()
1290
1291void
1292rxvt_term::key_press (unsigned int state, unsigned int keycode, Time time = CurrentTime)
1293 ALIAS:
1294 key_release = 1
1295 CODE:
1296{
1297 XKeyEvent xkey;
1298
1299 memset (&xkey, 0, sizeof (xkey));
1300
1301 xkey.time = time;
1302 xkey.state = state;
1303 xkey.keycode = keycode;
1304
1305 xkey.type = ix ? KeyRelease : KeyPress;
1306 xkey.display = THIS->dpy;
1307 xkey.window = THIS->vt;
1308 xkey.root = THIS->display->root;
1309 xkey.subwindow = THIS->vt;
1310
1311 if (ix)
1312 THIS->key_release (xkey);
1313 else
1314 THIS->key_press (xkey);
1315}
1316
1317void
1247rxvt_term::want_refresh () 1318rxvt_term::want_refresh ()
1248 CODE: 1319 CODE:
1249 THIS->want_refresh = 1; 1320 THIS->want_refresh = 1;
1250 1321
1251void 1322void
1257 1328
1258 line_t &l = ROW(row_number); 1329 line_t &l = ROW(row_number);
1259 1330
1260 if (GIMME_V != G_VOID) 1331 if (GIMME_V != G_VOID)
1261 { 1332 {
1262 wchar_t *wstr = new wchar_t [THIS->ncol]; 1333 wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol);
1263 1334
1264 for (int col = 0; col < THIS->ncol; col++) 1335 for (int col = 0; col < THIS->ncol; col++)
1265 wstr [col] = l.t [col]; 1336 wstr [col] = l.t [col];
1266 1337
1267 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); 1338 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1268
1269 delete [] wstr;
1270 } 1339 }
1271 1340
1272 if (new_text) 1341 if (new_text)
1273 { 1342 {
1274 wchar_t *wstr = sv2wcs (new_text); 1343 wchar_t *wstr = sv2wcs (new_text);
1275 1344
1276 int len = min (wcslen (wstr) - start_ofs, max_len); 1345 int len = min (wcslen (wstr) - start_ofs, max_len);
1277 1346
1278 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1347 if (start_col < 0 || start_col + len > THIS->ncol)
1279 { 1348 {
1280 free (wstr); 1349 free (wstr);
1281 croak ("new_text extends beyond horizontal margins"); 1350 croak ("new_text extends beyond horizontal margins");
1282 } 1351 }
1283 1352
1317 croak ("new_rend must be arrayref"); 1386 croak ("new_rend must be arrayref");
1318 1387
1319 AV *av = (AV *)SvRV (new_rend); 1388 AV *av = (AV *)SvRV (new_rend);
1320 int len = min (AvFILL (av) + 1 - start_ofs, max_len); 1389 int len = min (AvFILL (av) + 1 - start_ofs, max_len);
1321 1390
1322 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1391 if (start_col < 0 || start_col + len > THIS->ncol)
1323 croak ("new_rend array extends beyond horizontal margins"); 1392 croak ("new_rend array extends beyond horizontal margins");
1324 1393
1325 for (int col = start_col; col < start_col + len; col++) 1394 for (int col = start_col; col < start_col + len; col++)
1326 { 1395 {
1327 rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; 1396 rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask;
1367rxvt_term::special_encode (SV *string) 1436rxvt_term::special_encode (SV *string)
1368 CODE: 1437 CODE:
1369{ 1438{
1370 wchar_t *wstr = sv2wcs (string); 1439 wchar_t *wstr = sv2wcs (string);
1371 int wlen = wcslen (wstr); 1440 int wlen = wcslen (wstr);
1372 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer 1441 wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer
1373 1442
1374 rxvt_push_locale (THIS->locale); 1443 rxvt_push_locale (THIS->locale);
1375 1444
1376 wchar_t *r = rstr; 1445 wchar_t *r = rstr;
1377 for (wchar_t *s = wstr; *s; s++) 1446 for (wchar_t *s = wstr; *s; s++)
1447 {
1448 int w = WCWIDTH (*s);
1449
1378 if (wcwidth (*s) == 0) 1450 if (w == 0)
1379 { 1451 {
1380 if (r == rstr) 1452 if (r == rstr)
1381 croak ("leading combining character unencodable"); 1453 croak ("leading combining character unencodable");
1382 1454
1383 unicode_t n = rxvt_compose (r[-1], *s); 1455 unicode_t n = rxvt_compose (r[-1], *s);
1384 if (n == NOCHAR) 1456 if (n == NOCHAR)
1385 n = rxvt_composite.compose (r[-1], *s); 1457 n = rxvt_composite.compose (r[-1], *s);
1386 1458
1387 r[-1] = n; 1459 r[-1] = n;
1388 } 1460 }
1389#if !UNICODE_3 1461#if !UNICODE_3
1390 else if (*s >= 0x10000) 1462 else if (*s >= 0x10000)
1391 *r++ = rxvt_composite.compose (*s); 1463 *r++ = rxvt_composite.compose (*s);
1392#endif 1464#endif
1393 else 1465 else
1394 *r++ = *s; 1466 *r++ = *s;
1467
1468 // the *2 above only allows wcwidth <= 2
1469 if (w > 1)
1470 *r++ = NOCHAR;
1471 }
1395 1472
1396 rxvt_pop_locale (); 1473 rxvt_pop_locale ();
1397 1474
1398 RETVAL = wcs2sv (rstr, r - rstr); 1475 RETVAL = wcs2sv (rstr, r - rstr);
1399
1400 delete [] rstr;
1401} 1476}
1402 OUTPUT: 1477 OUTPUT:
1403 RETVAL 1478 RETVAL
1404 1479
1405SV * 1480SV *
1417 else if (IS_COMPOSE (*s)) 1492 else if (IS_COMPOSE (*s))
1418 dlen += rxvt_composite.expand (*s, 0); 1493 dlen += rxvt_composite.expand (*s, 0);
1419 else 1494 else
1420 dlen++; 1495 dlen++;
1421 1496
1422 wchar_t *rstr = new wchar_t [dlen]; 1497 wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen);
1423 1498
1424 // decode 1499 // decode
1425 wchar_t *r = rstr; 1500 wchar_t *r = rstr;
1426 for (wchar_t *s = wstr; *s; s++) 1501 for (wchar_t *s = wstr; *s; s++)
1427 if (*s == NOCHAR) 1502 if (*s == NOCHAR)
1430 r += rxvt_composite.expand (*s, r); 1505 r += rxvt_composite.expand (*s, r);
1431 else 1506 else
1432 *r++ = *s; 1507 *r++ = *s;
1433 1508
1434 RETVAL = wcs2sv (rstr, r - rstr); 1509 RETVAL = wcs2sv (rstr, r - rstr);
1435
1436 delete [] rstr;
1437} 1510}
1438 OUTPUT: 1511 OUTPUT:
1439 RETVAL 1512 RETVAL
1440 1513
1441void 1514void
1442rxvt_term::_resource (char *name, int index, SV *newval = 0) 1515rxvt_term::_resource (char *name, int index, SV *newval = 0)
1443 PPCODE: 1516 PPCODE:
1444{ 1517{
1445 struct resval { const char *name; int value; } rslist [] = { 1518 static const struct resval { const char *name; int value; } *rs, rslist [] = {
1446# define def(name) { # name, Rs_ ## name }, 1519# define def(name) { # name, Rs_ ## name },
1447# define reserve(name,count) 1520# define reserve(name,count)
1448# include "rsinc.h" 1521# include "rsinc.h"
1449# undef def 1522# undef def
1450# undef reserve 1523# undef reserve
1451 }; 1524 };
1452 1525
1453 struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1526 rs = rslist + sizeof (rslist) / sizeof (rslist [0]);
1454 1527
1455 do { 1528 do {
1456 if (rs-- == rslist) 1529 if (rs-- == rslist)
1457 croak ("no such resource '%s', requested", name); 1530 croak ("no such resource '%s', requested", name);
1458 } while (strcmp (name, rs->name)); 1531 } while (strcmp (name, rs->name));
1551 if (items == 3) 1624 if (items == 3)
1552 { 1625 {
1553 rc.row = SvIV (ST (1)); 1626 rc.row = SvIV (ST (1));
1554 rc.col = SvIV (ST (2)); 1627 rc.col = SvIV (ST (2));
1555 1628
1556 if (ix == 2 && rc.col == 0) 1629 if (ix == 2)
1557 { 1630 {
1631 if (rc.col == 0)
1632 {
1633 // col == 0 means end of previous line
1558 rc.row--; 1634 rc.row--;
1559 rc.col = THIS->ncol; 1635 rc.col = THIS->ncol;
1636 }
1637 else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow)
1638 && rc.col > ROW(rc.row).l)
1639 {
1640 // col >= length means while line and add newline
1641 rc.col = THIS->ncol;
1642 }
1560 } 1643 }
1561 1644
1562 clamp_it (rc.col, 0, THIS->ncol); 1645 clamp_it (rc.col, 0, THIS->ncol);
1563 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1646 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1564 1647
1572 CODE: 1655 CODE:
1573 RETVAL = THIS->charsets [THIS->screen.charset]; 1656 RETVAL = THIS->charsets [THIS->screen.charset];
1574 OUTPUT: 1657 OUTPUT:
1575 RETVAL 1658 RETVAL
1576 1659
1577#void 1660void
1578#rxvt_term::selection_clear () 1661rxvt_term::selection_clear ()
1579 1662
1580void 1663void
1581rxvt_term::selection_make (U32 eventtime, bool rect = false) 1664rxvt_term::selection_make (Time eventtime, bool rect = false)
1582 CODE: 1665 CODE:
1583 THIS->selection.op = SELECTION_CONT; 1666 THIS->selection.op = SELECTION_CONT;
1584 THIS->selection.rect = rect; 1667 THIS->selection.rect = rect;
1585 THIS->selection_make (eventtime); 1668 THIS->selection_make (eventtime);
1586 1669
1587int 1670int
1588rxvt_term::selection_grab (U32 eventtime) 1671rxvt_term::selection_grab (Time eventtime)
1589 1672
1590void 1673void
1591rxvt_term::selection (SV *newtext = 0) 1674rxvt_term::selection (SV *newtext = 0)
1592 PPCODE: 1675 PPCODE:
1593{ 1676{
1611void 1694void
1612rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) 1695rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1613 1696
1614void 1697void
1615rxvt_term::scr_bell () 1698rxvt_term::scr_bell ()
1699
1700void
1701rxvt_term::scr_change_screen (int screen)
1616 1702
1617void 1703void
1618rxvt_term::scr_add_lines (SV *string) 1704rxvt_term::scr_add_lines (SV *string)
1619 CODE: 1705 CODE:
1620{ 1706{
1661 o->self = (HV *)SvRV (RETVAL); 1747 o->self = (HV *)SvRV (RETVAL);
1662} 1748}
1663 OUTPUT: 1749 OUTPUT:
1664 RETVAL 1750 RETVAL
1665 1751
1752#############################################################################
1753# Various X Utility Functions
1754#############################################################################
1755
1756void
1757rxvt_term::XListProperties (Window window)
1758 PPCODE:
1759{
1760 int count;
1761 Atom *props = XListProperties (THIS->dpy, window, &count);
1762
1763 EXTEND (SP, count);
1764 while (count--)
1765 PUSHs (newSVuv ((U32)props [count]));
1766
1767 XFree (props);
1768}
1769
1770void
1771rxvt_term::XGetWindowProperty (Window window, Atom property)
1772 PPCODE:
1773{
1774 Atom type;
1775 int format;
1776 unsigned long nitems;
1777 unsigned long bytes_after;
1778 unsigned char *prop;
1779
1780 XGetWindowProperty (THIS->dpy, window, property,
1781 0, 1<<24, 0, AnyPropertyType,
1782 &type, &format, &nitems, &bytes_after, &prop);
1783
1784 if (type != None)
1785 {
1786 int elemsize = format == 16 ? sizeof (short)
1787 : format == 32 ? sizeof (long)
1788 : 1;
1789
1790 EXTEND (SP, 3);
1791 PUSHs (newSVuv ((U32)type));
1792 PUSHs (newSViv (format));
1793 PUSHs (newSVpvn ((char *)prop, nitems * elemsize));
1794 XFree (prop);
1795 }
1796}
1797
1798void
1799rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data)
1800 CODE:
1801{
1802 STRLEN len;
1803 char *data_ = SvPVbyte (data, len);
1804
1805 int elemsize = format == 16 ? sizeof (short)
1806 : format == 32 ? sizeof (long)
1807 : 1;
1808
1809 XChangeProperty (THIS->dpy, window, property,
1810 type, format, PropModeReplace,
1811 (unsigned char *)data_, len / elemsize);
1812}
1813
1814Atom
1815XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE)
1816 C_ARGS: term->dpy, atom_name, only_if_exists
1817
1818char *
1819XGetAtomName (rxvt_term *term, Atom atom)
1820 C_ARGS: term->dpy, atom
1821 CLEANUP:
1822 XFree (RETVAL);
1823
1824void
1825XDeleteProperty (rxvt_term *term, Window window, Atom property)
1826 C_ARGS: term->dpy, window, property
1827
1828Window
1829rxvt_term::DefaultRootWindow ()
1830 CODE:
1831 RETVAL = THIS->display->root;
1832 OUTPUT:
1833 RETVAL
1834
1835#if 0
1836
1837Window
1838XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height)
1839 C_ARGS: term->dpy, (Window)parent,
1840 x, y, width, height, 0,
1841 term->pix_colors_focused[Color_border],
1842 term->pix_colors_focused[Color_border]
1843
1844#endif
1845
1846void
1847XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0)
1848 C_ARGS: term->dpy, window, parent, x, y
1849
1850void
1851XMapWindow (rxvt_term *term, Window window)
1852 C_ARGS: term->dpy, window
1853
1854void
1855XUnmapWindow (rxvt_term *term, Window window)
1856 C_ARGS: term->dpy, window
1857
1858void
1859XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height)
1860 C_ARGS: term->dpy, window, x, y, width, height
1861
1862void
1863rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0)
1864 CODE:
1865{
1866 XWindowAttributes attr;
1867 XGetWindowAttributes (THIS->dpy, window, &attr);
1868 XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events);
1869}
1870
1871void
1872rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y)
1873 PPCODE:
1874{
1875 int dx, dy;
1876 Window child;
1877
1878 if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child))
1879 {
1880 EXTEND (SP, 3);
1881 PUSHs (newSViv (dx));
1882 PUSHs (newSViv (dy));
1883 PUSHs (newSVuv (child));
1884 }
1885}
1886
1887#############################################################################
1888# urxvt::overlay
1889#############################################################################
1890
1666MODULE = urxvt PACKAGE = urxvt::overlay 1891MODULE = urxvt PACKAGE = urxvt::overlay
1667 1892
1668void 1893void
1669overlay::set (int x, int y, SV *text, SV *rend = 0) 1894overlay::set (int x, int y, SV *text, SV *rend = 0)
1670 1895
1674void 1899void
1675overlay::hide () 1900overlay::hide ()
1676 1901
1677void 1902void
1678overlay::DESTROY () 1903overlay::DESTROY ()
1904
1905#############################################################################
1906# urxvt::watcher
1907#############################################################################
1908
1909MODULE = urxvt PACKAGE = urxvt::watcher
1910
1911CHAINED
1912perl_watcher::cb (SV *cb)
1913 CODE:
1914 THIS->cb (cb);
1915 OUTPUT:
1916 RETVAL
1917
1918#############################################################################
1919# urxvt::timer
1920#############################################################################
1679 1921
1680MODULE = urxvt PACKAGE = urxvt::timer 1922MODULE = urxvt PACKAGE = urxvt::timer
1681 1923
1682SV * 1924SV *
1683timer::new () 1925timer::new ()
1684 CODE: 1926 CODE:
1685 timer *w = new timer; 1927 timer *w = new timer;
1686 w->start (NOW); 1928 w->start (NOW);
1687 RETVAL = newSVptr ((void *)w, "urxvt::timer"); 1929 RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::timer");
1688 w->self = (HV *)SvRV (RETVAL); 1930 w->self = (HV *)SvRV (RETVAL);
1689 OUTPUT:
1690 RETVAL
1691
1692timer *
1693timer::cb (SV *cb)
1694 CODE:
1695 THIS->cb (cb);
1696 RETVAL = THIS;
1697 OUTPUT: 1931 OUTPUT:
1698 RETVAL 1932 RETVAL
1699 1933
1700NV 1934NV
1701timer::at () 1935timer::at ()
1702 CODE: 1936 CODE:
1703 RETVAL = THIS->at; 1937 RETVAL = THIS->at;
1704 OUTPUT: 1938 OUTPUT:
1705 RETVAL 1939 RETVAL
1706 1940
1707timer * 1941CHAINED
1708timer::interval (NV interval) 1942timer::interval (NV interval)
1709 CODE: 1943 CODE:
1710 THIS->interval = interval; 1944 THIS->interval = interval;
1945 OUTPUT:
1711 RETVAL = THIS; 1946 RETVAL
1712 OUTPUT:
1713 RETVAL
1714 1947
1715timer * 1948CHAINED
1716timer::set (NV tstamp) 1949timer::set (NV tstamp)
1717 CODE: 1950 CODE:
1718 THIS->set (tstamp); 1951 THIS->set (tstamp);
1952 OUTPUT:
1719 RETVAL = THIS; 1953 RETVAL
1720 OUTPUT:
1721 RETVAL
1722 1954
1723timer * 1955CHAINED
1724timer::start (NV tstamp = THIS->at) 1956timer::start (NV tstamp = THIS->at)
1725 CODE: 1957 CODE:
1726 THIS->start (tstamp); 1958 THIS->start (tstamp);
1959 OUTPUT:
1727 RETVAL = THIS; 1960 RETVAL
1728 OUTPUT:
1729 RETVAL
1730 1961
1731timer * 1962CHAINED
1732timer::after (NV delay) 1963timer::after (NV delay)
1733 CODE: 1964 CODE:
1734 THIS->start (NOW + delay); 1965 THIS->start (NOW + delay);
1966 OUTPUT:
1735 RETVAL = THIS; 1967 RETVAL
1736 OUTPUT:
1737 RETVAL
1738 1968
1739timer * 1969CHAINED
1740timer::stop () 1970timer::stop ()
1741 CODE: 1971 CODE:
1742 THIS->stop (); 1972 THIS->stop ();
1743 RETVAL = THIS;
1744 OUTPUT: 1973 OUTPUT:
1745 RETVAL 1974 RETVAL
1746 1975
1747void 1976void
1748timer::DESTROY () 1977timer::DESTROY ()
1978
1979#############################################################################
1980# urxvt::iow
1981#############################################################################
1749 1982
1750MODULE = urxvt PACKAGE = urxvt::iow 1983MODULE = urxvt PACKAGE = urxvt::iow
1751 1984
1752SV * 1985SV *
1753iow::new () 1986iow::new ()
1754 CODE: 1987 CODE:
1755 iow *w = new iow; 1988 iow *w = new iow;
1756 RETVAL = newSVptr ((void *)w, "urxvt::iow"); 1989 RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::iow");
1757 w->self = (HV *)SvRV (RETVAL); 1990 w->self = (HV *)SvRV (RETVAL);
1758 OUTPUT: 1991 OUTPUT:
1759 RETVAL 1992 RETVAL
1760 1993
1761iow * 1994CHAINED
1762iow::cb (SV *cb)
1763 CODE:
1764 THIS->cb (cb);
1765 RETVAL = THIS;
1766 OUTPUT:
1767 RETVAL
1768
1769iow *
1770iow::fd (int fd) 1995iow::fd (int fd)
1771 CODE: 1996 CODE:
1772 THIS->fd = fd; 1997 THIS->fd = fd;
1998 OUTPUT:
1773 RETVAL = THIS; 1999 RETVAL
1774 OUTPUT:
1775 RETVAL
1776 2000
1777iow * 2001CHAINED
1778iow::events (short events) 2002iow::events (short events)
1779 CODE: 2003 CODE:
1780 THIS->events = events; 2004 THIS->events = events;
2005 OUTPUT:
1781 RETVAL = THIS; 2006 RETVAL
1782 OUTPUT:
1783 RETVAL
1784 2007
1785iow * 2008CHAINED
1786iow::start () 2009iow::start ()
1787 CODE: 2010 CODE:
1788 THIS->start (); 2011 THIS->start ();
2012 OUTPUT:
1789 RETVAL = THIS; 2013 RETVAL
1790 OUTPUT:
1791 RETVAL
1792 2014
1793iow * 2015CHAINED
1794iow::stop () 2016iow::stop ()
1795 CODE: 2017 CODE:
1796 THIS->stop (); 2018 THIS->stop ();
1797 RETVAL = THIS;
1798 OUTPUT: 2019 OUTPUT:
1799 RETVAL 2020 RETVAL
1800 2021
1801void 2022void
1802iow::DESTROY () 2023iow::DESTROY ()
1803 2024
2025#############################################################################
2026# urxvt::iw
2027#############################################################################
1804 2028
2029MODULE = urxvt PACKAGE = urxvt::iw
2030
2031SV *
2032iw::new ()
2033 CODE:
2034 iw *w = new iw;
2035 RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::iw");
2036 w->self = (HV *)SvRV (RETVAL);
2037 OUTPUT:
2038 RETVAL
2039
2040CHAINED
2041iw::start ()
2042 CODE:
2043 THIS->start ();
2044 OUTPUT:
2045 RETVAL
2046
2047CHAINED
2048iw::stop ()
2049 CODE:
2050 THIS->stop ();
2051 OUTPUT:
2052 RETVAL
2053
2054void
2055iw::DESTROY ()
2056
2057#############################################################################
2058# urxvt::pw
2059#############################################################################
2060
2061MODULE = urxvt PACKAGE = urxvt::pw
2062
2063SV *
2064pw::new ()
2065 CODE:
2066 pw *w = new pw;
2067 RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::pw");
2068 w->self = (HV *)SvRV (RETVAL);
2069 OUTPUT:
2070 RETVAL
2071
2072CHAINED
2073pw::start (int pid)
2074 CODE:
2075 THIS->start (pid);
2076 OUTPUT:
2077 RETVAL
2078
2079CHAINED
2080pw::stop ()
2081 CODE:
2082 THIS->stop ();
2083 OUTPUT:
2084 RETVAL
2085
2086void
2087pw::DESTROY ()
2088
2089

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines