… | |
… | |
80 | new_ref (HV *hv, const char *klass) |
80 | new_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 |
|
|
86 | static SV * |
85 | static SV * |
87 | newSVptr (void *ptr, const char *klass) |
86 | newSVptr (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 | ///////////////////////////////////////////////////////////////////////////// |
122 | |
121 | |
123 | #define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, "urxvt::watcher") |
122 | #define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, "urxvt::watcher") |
124 | |
123 | |
… | |
… | |
171 | |
170 | |
172 | if (SvTRUE (ERRSV)) |
171 | if (SvTRUE (ERRSV)) |
173 | rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); |
172 | rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); |
174 | } |
173 | } |
175 | |
174 | |
176 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
175 | #define newSVtimer(timer) new_ref ((timer)->self, "urxvt::timer") |
177 | #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR (sv, "urxvt::timer") |
176 | #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), "urxvt::timer") |
178 | |
177 | |
179 | struct timer : perl_watcher, time_watcher |
178 | struct timer : perl_watcher, time_watcher |
180 | { |
179 | { |
181 | tstamp interval; |
180 | tstamp interval; |
182 | |
181 | |
… | |
… | |
192 | |
191 | |
193 | invoke ("urxvt::timer", newSVtimer (this)); |
192 | invoke ("urxvt::timer", newSVtimer (this)); |
194 | } |
193 | } |
195 | }; |
194 | }; |
196 | |
195 | |
197 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
196 | #define newSViow(iow) new_ref ((iow)->self, "urxvt::iow") |
198 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR (sv, "urxvt::iow") |
197 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), "urxvt::iow") |
199 | |
198 | |
200 | struct iow : perl_watcher, io_watcher |
199 | struct iow : perl_watcher, io_watcher |
201 | { |
200 | { |
202 | iow () |
201 | iow () |
203 | : io_watcher (this, &iow::execute) |
202 | : io_watcher (this, &iow::execute) |
… | |
… | |
208 | { |
207 | { |
209 | invoke ("urxvt::iow", newSViow (this), revents); |
208 | invoke ("urxvt::iow", newSViow (this), revents); |
210 | } |
209 | } |
211 | }; |
210 | }; |
212 | |
211 | |
213 | #define newSViw(iw) new_ref (iw->self, "urxvt::iw") |
212 | #define newSViw(iw) new_ref ((iw)->self, "urxvt::iw") |
214 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR (sv, "urxvt::iw") |
213 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), "urxvt::iw") |
215 | |
214 | |
216 | struct iw : perl_watcher, idle_watcher |
215 | struct iw : perl_watcher, idle_watcher |
217 | { |
216 | { |
218 | iw () |
217 | iw () |
219 | : idle_watcher (this, &iw::execute) |
218 | : idle_watcher (this, &iw::execute) |
… | |
… | |
224 | { |
223 | { |
225 | invoke ("urxvt::iw", newSViw (this)); |
224 | invoke ("urxvt::iw", newSViw (this)); |
226 | } |
225 | } |
227 | }; |
226 | }; |
228 | |
227 | |
229 | #define newSVpw(pw) new_ref (pw->self, "urxvt::pw") |
228 | #define newSVpw(pw) new_ref ((pw)->self, "urxvt::pw") |
230 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR (sv, "urxvt::pw") |
229 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), "urxvt::pw") |
231 | |
230 | |
232 | struct pw : perl_watcher, child_watcher |
231 | struct pw : perl_watcher, child_watcher |
233 | { |
232 | { |
234 | pw () |
233 | pw () |
235 | : child_watcher (this, &pw::execute) |
234 | : child_watcher (this, &pw::execute) |
… | |
… | |
244 | |
243 | |
245 | ///////////////////////////////////////////////////////////////////////////// |
244 | ///////////////////////////////////////////////////////////////////////////// |
246 | |
245 | |
247 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
246 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
248 | |
247 | |
249 | struct overlay { |
248 | class overlay { |
250 | HV *self; |
|
|
251 | bool visible; |
|
|
252 | rxvt_term *THIS; |
249 | rxvt_term *THIS; |
|
|
250 | AV *overlay_av; |
253 | int x, y, w, h; |
251 | int x, y, w, h; |
254 | int border; |
252 | int border; |
255 | text_t **text; |
253 | text_t **text; |
256 | rend_t **rend; |
254 | rend_t **rend; |
257 | |
255 | |
|
|
256 | public: |
|
|
257 | HV *self; |
|
|
258 | |
258 | 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); |
259 | ~overlay (); |
260 | ~overlay (); |
260 | |
261 | |
261 | void show (); |
262 | void show (); |
262 | void hide (); |
263 | void hide (); |
… | |
… | |
265 | |
266 | |
266 | void set (int x, int y, SV *str, SV *rend); |
267 | void set (int x, int y, SV *str, SV *rend); |
267 | }; |
268 | }; |
268 | |
269 | |
269 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
270 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
270 | : 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) |
271 | { |
272 | { |
272 | if (border == 2) |
273 | if (border == 2) |
273 | { |
274 | { |
274 | w += 2; |
275 | w += 2; |
275 | h += 2; |
276 | h += 2; |
… | |
… | |
314 | *rp++ = r; |
315 | *rp++ = r; |
315 | } |
316 | } |
316 | } |
317 | } |
317 | |
318 | |
318 | show (); |
319 | show (); |
319 | THIS->want_refresh = 1; |
|
|
320 | } |
320 | } |
321 | |
321 | |
322 | overlay::~overlay () |
322 | overlay::~overlay () |
323 | { |
323 | { |
324 | hide (); |
324 | hide (); |
… | |
… | |
329 | delete [] rend[y]; |
329 | delete [] rend[y]; |
330 | } |
330 | } |
331 | |
331 | |
332 | delete [] text; |
332 | delete [] text; |
333 | delete [] rend; |
333 | delete [] rend; |
|
|
334 | } |
|
|
335 | |
|
|
336 | void |
|
|
337 | overlay::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)); |
334 | |
346 | |
335 | THIS->want_refresh = 1; |
347 | THIS->want_refresh = 1; |
336 | } |
348 | } |
337 | |
349 | |
338 | void |
350 | void |
339 | overlay::show () |
351 | overlay::hide () |
340 | { |
352 | { |
341 | if (visible) |
353 | if (!overlay_av) |
342 | return; |
354 | return; |
343 | |
355 | |
344 | visible = true; |
|
|
345 | |
|
|
346 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
|
|
347 | av_push (av, newSViv ((long)this)); |
|
|
348 | } |
|
|
349 | |
|
|
350 | void |
|
|
351 | overlay::hide () |
|
|
352 | { |
|
|
353 | if (!visible) |
|
|
354 | return; |
|
|
355 | |
|
|
356 | visible = false; |
|
|
357 | |
|
|
358 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
|
|
359 | |
|
|
360 | int i; |
356 | int i; |
361 | |
357 | |
362 | for (i = AvFILL (av); i >= 0; i--) |
358 | for (i = AvFILL (overlay_av); i >= 0; i--) |
363 | if (SvIV (*av_fetch (av, i, 1)) == (long)this) |
359 | if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this) |
364 | { |
|
|
365 | av_delete (av, i, G_DISCARD); |
|
|
366 | break; |
360 | break; |
367 | } |
|
|
368 | |
361 | |
369 | for (; i < AvFILL (av); i++) |
362 | for (; i < AvFILL (overlay_av); i++) |
370 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
363 | av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0))); |
371 | |
364 | |
372 | av_pop (av); |
365 | av_pop (overlay_av); |
|
|
366 | |
|
|
367 | SvREFCNT_dec (overlay_av); |
|
|
368 | overlay_av = 0; |
|
|
369 | |
|
|
370 | THIS->want_refresh = 1; |
373 | } |
371 | } |
374 | |
372 | |
375 | void overlay::swap () |
373 | void overlay::swap () |
376 | { |
374 | { |
377 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
375 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
… | |
… | |
492 | static void |
490 | static void |
493 | ungrab (rxvt_term *THIS) |
491 | ungrab (rxvt_term *THIS) |
494 | { |
492 | { |
495 | if (THIS->perl.grabtime) |
493 | if (THIS->perl.grabtime) |
496 | { |
494 | { |
497 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
495 | XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime); |
498 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
496 | XUngrabPointer (THIS->dpy, THIS->perl.grabtime); |
499 | THIS->perl.grabtime = 0; |
497 | THIS->perl.grabtime = 0; |
500 | } |
498 | } |
501 | } |
499 | } |
502 | |
500 | |
503 | bool |
501 | bool |
… | |
… | |
556 | case DT_STR_LEN: |
554 | case DT_STR_LEN: |
557 | { |
555 | { |
558 | char *str = va_arg (ap, char *); |
556 | char *str = va_arg (ap, char *); |
559 | int len = va_arg (ap, int); |
557 | int len = va_arg (ap, int); |
560 | |
558 | |
561 | printf ("pushing str %p:%d\n", str,len);//D |
|
|
562 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
559 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
563 | } |
560 | } |
564 | break; |
561 | break; |
565 | |
562 | |
566 | case DT_WCS_LEN: |
563 | case DT_WCS_LEN: |
… | |
… | |
762 | # include "optinc.h" |
759 | # include "optinc.h" |
763 | # undef nodef |
760 | # undef nodef |
764 | # undef def |
761 | # undef def |
765 | |
762 | |
766 | HV *stash = gv_stashpv ("urxvt", 1); |
763 | HV *stash = gv_stashpv ("urxvt", 1); |
767 | struct { |
764 | static const struct { |
768 | const char *name; |
765 | const char *name; |
769 | IV iv; |
766 | IV iv; |
770 | } *civ, const_iv[] = { |
767 | } *civ, const_iv[] = { |
771 | # define const_iv(name) { # name, (IV)name } |
768 | # define const_iv(name) { # name, (IV)name } |
772 | const_iv (DEFAULT_RSTYLE), |
769 | const_iv (DEFAULT_RSTYLE), |
… | |
… | |
790 | const_iv (Button2Mask), |
787 | const_iv (Button2Mask), |
791 | const_iv (Button3Mask), |
788 | const_iv (Button3Mask), |
792 | const_iv (Button4Mask), |
789 | const_iv (Button4Mask), |
793 | const_iv (Button5Mask), |
790 | const_iv (Button5Mask), |
794 | const_iv (AnyModifier), |
791 | const_iv (AnyModifier), |
|
|
792 | |
|
|
793 | const_iv (NoSymbol), |
|
|
794 | const_iv (GrabModeSync), |
|
|
795 | const_iv (GrabModeAsync), |
795 | |
796 | |
796 | const_iv (EVENT_NONE), |
797 | const_iv (EVENT_NONE), |
797 | const_iv (EVENT_READ), |
798 | const_iv (EVENT_READ), |
798 | const_iv (EVENT_WRITE), |
799 | const_iv (EVENT_WRITE), |
799 | |
800 | |
… | |
… | |
865 | const_iv (XIMSecondary), |
866 | const_iv (XIMSecondary), |
866 | const_iv (XIMTertiary), |
867 | const_iv (XIMTertiary), |
867 | const_iv (XIMVisibleToForward), |
868 | const_iv (XIMVisibleToForward), |
868 | const_iv (XIMVisibleToBackword), |
869 | const_iv (XIMVisibleToBackword), |
869 | const_iv (XIMVisibleToCenter), |
870 | const_iv (XIMVisibleToCenter), |
870 | |
871 | # if 0 |
871 | const_iv (XIMForwardChar), |
872 | const_iv (XIMForwardChar), |
872 | const_iv (XIMBackwardChar), |
873 | const_iv (XIMBackwardChar), |
873 | const_iv (XIMForwardWord), |
874 | const_iv (XIMForwardWord), |
874 | const_iv (XIMBackwardWord), |
875 | const_iv (XIMBackwardWord), |
875 | const_iv (XIMCaretUp), |
876 | const_iv (XIMCaretUp), |
… | |
… | |
879 | const_iv (XIMLineStart), |
880 | const_iv (XIMLineStart), |
880 | const_iv (XIMLineEnd), |
881 | const_iv (XIMLineEnd), |
881 | const_iv (XIMAbsolutePosition), |
882 | const_iv (XIMAbsolutePosition), |
882 | const_iv (XIMDontChange), |
883 | const_iv (XIMDontChange), |
883 | # endif |
884 | # endif |
|
|
885 | # endif |
884 | }; |
886 | }; |
885 | |
887 | |
886 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
888 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
887 | civ-- > const_iv; ) |
|
|
888 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
889 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
889 | } |
890 | } |
890 | |
891 | |
891 | void |
892 | void |
892 | warn (const char *msg) |
893 | warn (const char *msg) |
… | |
… | |
923 | RETVAL |
924 | RETVAL |
924 | |
925 | |
925 | int |
926 | int |
926 | SET_FGCOLOR (int rend, int new_color) |
927 | SET_FGCOLOR (int rend, int new_color) |
927 | CODE: |
928 | CODE: |
928 | RETVAL = SET_FGCOLOR (rend, new_color); |
929 | RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
929 | OUTPUT: |
930 | OUTPUT: |
930 | RETVAL |
931 | RETVAL |
931 | |
932 | |
932 | int |
933 | int |
933 | SET_BGCOLOR (int rend, int new_color) |
934 | SET_BGCOLOR (int rend, int new_color) |
934 | CODE: |
935 | CODE: |
935 | RETVAL = SET_BGCOLOR (rend, new_color); |
936 | RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
936 | OUTPUT: |
937 | OUTPUT: |
937 | RETVAL |
938 | RETVAL |
938 | |
939 | |
939 | int |
940 | int |
940 | GET_CUSTOM (int rend) |
941 | GET_CUSTOM (int rend) |
… | |
… | |
954 | | ((new_value << RS_customShift) & RS_customMask); |
955 | | ((new_value << RS_customShift) & RS_customMask); |
955 | } |
956 | } |
956 | OUTPUT: |
957 | OUTPUT: |
957 | RETVAL |
958 | RETVAL |
958 | |
959 | |
|
|
960 | void |
|
|
961 | termlist () |
|
|
962 | PPCODE: |
|
|
963 | { |
|
|
964 | EXTEND (SP, rxvt_term::termlist.size ()); |
|
|
965 | |
|
|
966 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
967 | if ((*t)->perl.self) |
|
|
968 | PUSHs (sv_2mortal (newSVterm (*t))); |
|
|
969 | } |
|
|
970 | |
959 | MODULE = urxvt PACKAGE = urxvt::term |
971 | MODULE = urxvt PACKAGE = urxvt::term |
960 | |
972 | |
961 | SV * |
973 | SV * |
962 | _new (...) |
974 | _new (AV *env, AV *arg) |
963 | CODE: |
975 | CODE: |
964 | { |
976 | { |
965 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
966 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
967 | |
|
|
968 | rxvt_term *term = new rxvt_term; |
977 | rxvt_term *term = new rxvt_term; |
969 | |
978 | |
970 | stringvec *argv = new stringvec; |
979 | stringvec *argv = new stringvec; |
971 | stringvec *envv = new stringvec; |
980 | stringvec *envv = new stringvec; |
972 | |
981 | |
973 | for (int i = 1; i < items; i++) |
982 | for (int i = 0; i <= AvFILL (arg); i++) |
974 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
983 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
975 | |
984 | |
976 | AV *env = (AV *)SvRV (ST (0)); |
|
|
977 | for (int i = AvFILL (env) + 1; i--; ) |
985 | for (int i = AvFILL (env) + 1; i--; ) |
978 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
986 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
979 | |
987 | |
980 | envv->push_back (0); |
988 | envv->push_back (0); |
981 | |
989 | |
… | |
… | |
1008 | void |
1016 | void |
1009 | rxvt_term::set_should_invoke (int htype, int inc) |
1017 | rxvt_term::set_should_invoke (int htype, int inc) |
1010 | CODE: |
1018 | CODE: |
1011 | THIS->perl.should_invoke [htype] += inc; |
1019 | THIS->perl.should_invoke [htype] += inc; |
1012 | |
1020 | |
1013 | void |
1021 | int |
1014 | rxvt_term::grab_button (int button, U32 modifiers) |
1022 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1015 | CODE: |
1023 | CODE: |
1016 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1024 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1017 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1025 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1018 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
1026 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
1027 | OUTPUT: RETVAL |
|
|
1028 | |
|
|
1029 | int |
|
|
1030 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
|
|
1031 | CODE: |
|
|
1032 | RETVAL = XUngrabButton (THIS->dpy, button, modifiers, window); |
|
|
1033 | OUTPUT: RETVAL |
|
|
1034 | |
|
|
1035 | void |
|
|
1036 | rxvt_term::XGrabKey (int keycode, U32 modifiers, Window window = THIS->vt, \ |
|
|
1037 | int owner_events = 1, int pointer_mode = GrabModeAsync, int keyboard_mode = GrabModeAsync) |
|
|
1038 | CODE: |
|
|
1039 | XGrabKey (THIS->dpy, keycode, modifiers, window, owner_events, pointer_mode, keyboard_mode); |
|
|
1040 | |
|
|
1041 | void |
|
|
1042 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
|
|
1043 | CODE: |
|
|
1044 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
|
|
1045 | |
|
|
1046 | void |
|
|
1047 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
1048 | CODE: |
|
|
1049 | XUngrabKeyboard (THIS->dpy, eventtime); |
1019 | |
1050 | |
1020 | bool |
1051 | bool |
1021 | rxvt_term::grab (Time eventtime, int sync = 0) |
1052 | rxvt_term::grab (Time eventtime, int sync = 0) |
1022 | CODE: |
1053 | CODE: |
1023 | { |
1054 | { |
1024 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1055 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1025 | |
1056 | |
1026 | THIS->perl.grabtime = 0; |
1057 | THIS->perl.grabtime = 0; |
1027 | |
1058 | |
1028 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
1059 | if (!XGrabPointer (THIS->dpy, THIS->vt, 0, |
1029 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1060 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1030 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1061 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1031 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
1062 | if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime)) |
1032 | THIS->perl.grabtime = eventtime; |
1063 | THIS->perl.grabtime = eventtime; |
1033 | else |
1064 | else |
1034 | XUngrabPointer (THIS->display->display, eventtime); |
1065 | XUngrabPointer (THIS->dpy, eventtime); |
1035 | |
1066 | |
1036 | RETVAL = !!THIS->perl.grabtime; |
1067 | RETVAL = !!THIS->perl.grabtime; |
1037 | } |
1068 | } |
1038 | OUTPUT: |
1069 | OUTPUT: |
1039 | RETVAL |
1070 | RETVAL |
1040 | |
1071 | |
1041 | void |
1072 | void |
1042 | rxvt_term::allow_events_async () |
1073 | rxvt_term::allow_events_async () |
1043 | CODE: |
1074 | CODE: |
1044 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
1075 | XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime); |
1045 | |
1076 | |
1046 | void |
1077 | void |
1047 | rxvt_term::allow_events_sync () |
1078 | rxvt_term::allow_events_sync () |
1048 | CODE: |
1079 | CODE: |
1049 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
1080 | XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime); |
1050 | |
1081 | |
1051 | void |
1082 | void |
1052 | rxvt_term::allow_events_replay () |
1083 | rxvt_term::allow_events_replay () |
1053 | CODE: |
1084 | CODE: |
1054 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
1085 | XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime); |
1055 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
1086 | XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime); |
1056 | |
1087 | |
1057 | void |
1088 | void |
1058 | rxvt_term::ungrab () |
1089 | rxvt_term::ungrab () |
1059 | CODE: |
1090 | CODE: |
1060 | ungrab (THIS); |
1091 | ungrab (THIS); |
|
|
1092 | |
|
|
1093 | int |
|
|
1094 | rxvt_term::XStringToKeysym (char *string) |
|
|
1095 | CODE: |
|
|
1096 | RETVAL = XStringToKeysym (string); |
|
|
1097 | OUTPUT: RETVAL |
|
|
1098 | |
|
|
1099 | char * |
|
|
1100 | rxvt_term::XKeysymToString (int sym) |
|
|
1101 | CODE: |
|
|
1102 | RETVAL = XKeysymToString (sym); |
|
|
1103 | OUTPUT: RETVAL |
|
|
1104 | |
|
|
1105 | int |
|
|
1106 | rxvt_term::XKeysymToKeycode (int sym) |
|
|
1107 | CODE: |
|
|
1108 | RETVAL = XKeysymToKeycode (THIS->dpy, sym); |
|
|
1109 | OUTPUT: RETVAL |
|
|
1110 | |
|
|
1111 | int |
|
|
1112 | rxvt_term::XKeycodeToKeysym (int code, int index) |
|
|
1113 | CODE: |
|
|
1114 | RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); |
|
|
1115 | OUTPUT: RETVAL |
1061 | |
1116 | |
1062 | int |
1117 | int |
1063 | rxvt_term::strwidth (SV *str) |
1118 | rxvt_term::strwidth (SV *str) |
1064 | CODE: |
1119 | CODE: |
1065 | { |
1120 | { |
… | |
… | |
1183 | } |
1238 | } |
1184 | OUTPUT: |
1239 | OUTPUT: |
1185 | RETVAL |
1240 | RETVAL |
1186 | |
1241 | |
1187 | SV * |
1242 | SV * |
1188 | rxvt_term::_env () |
1243 | rxvt_term::envv () |
|
|
1244 | ALIAS: |
|
|
1245 | argv = 1 |
1189 | CODE: |
1246 | PPCODE: |
1190 | { |
1247 | { |
1191 | if (THIS->envv) |
1248 | stringvec *vec = ix ? THIS->argv : THIS->envv; |
1192 | { |
|
|
1193 | AV *av = newAV (); |
|
|
1194 | |
1249 | |
|
|
1250 | EXTEND (SP, vec->size ()); |
|
|
1251 | |
1195 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
1252 | for (char **i = vec->begin (); i != vec->end (); ++i) |
1196 | if (*i) |
1253 | if (*i) |
1197 | av_push (av, newSVpv (*i, 0)); |
1254 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1198 | |
|
|
1199 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1200 | } |
|
|
1201 | else |
|
|
1202 | RETVAL = &PL_sv_undef; |
|
|
1203 | } |
1255 | } |
1204 | OUTPUT: |
|
|
1205 | RETVAL |
|
|
1206 | |
1256 | |
1207 | int |
1257 | int |
1208 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1258 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1209 | CODE: |
1259 | CODE: |
1210 | RETVAL = THIS->pty_ev.events; |
1260 | RETVAL = THIS->pty_ev.events; |
… | |
… | |
1264 | void |
1314 | void |
1265 | rxvt_term::focus_in () |
1315 | rxvt_term::focus_in () |
1266 | |
1316 | |
1267 | void |
1317 | void |
1268 | rxvt_term::focus_out () |
1318 | rxvt_term::focus_out () |
|
|
1319 | |
|
|
1320 | void |
|
|
1321 | rxvt_term::key_press (unsigned int state, unsigned int keycode, Time time = CurrentTime) |
|
|
1322 | ALIAS: |
|
|
1323 | key_release = 1 |
|
|
1324 | CODE: |
|
|
1325 | { |
|
|
1326 | XKeyEvent xkey; |
|
|
1327 | |
|
|
1328 | memset (&xkey, 0, sizeof (xkey)); |
|
|
1329 | |
|
|
1330 | xkey.time = time; |
|
|
1331 | xkey.state = state; |
|
|
1332 | xkey.keycode = keycode; |
|
|
1333 | |
|
|
1334 | xkey.type = ix ? KeyRelease : KeyPress; |
|
|
1335 | xkey.display = THIS->dpy; |
|
|
1336 | xkey.window = THIS->vt; |
|
|
1337 | xkey.root = THIS->display->root; |
|
|
1338 | xkey.subwindow = THIS->vt; |
|
|
1339 | |
|
|
1340 | if (ix) |
|
|
1341 | THIS->key_release (xkey); |
|
|
1342 | else |
|
|
1343 | THIS->key_press (xkey); |
|
|
1344 | } |
1269 | |
1345 | |
1270 | void |
1346 | void |
1271 | rxvt_term::want_refresh () |
1347 | rxvt_term::want_refresh () |
1272 | CODE: |
1348 | CODE: |
1273 | THIS->want_refresh = 1; |
1349 | THIS->want_refresh = 1; |
… | |
… | |
1466 | |
1542 | |
1467 | void |
1543 | void |
1468 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1544 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1469 | PPCODE: |
1545 | PPCODE: |
1470 | { |
1546 | { |
1471 | struct resval { const char *name; int value; } rslist [] = { |
1547 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1472 | # define def(name) { # name, Rs_ ## name }, |
1548 | # define def(name) { # name, Rs_ ## name }, |
1473 | # define reserve(name,count) |
1549 | # define reserve(name,count) |
1474 | # include "rsinc.h" |
1550 | # include "rsinc.h" |
1475 | # undef def |
1551 | # undef def |
1476 | # undef reserve |
1552 | # undef reserve |
1477 | }; |
1553 | }; |
1478 | |
1554 | |
1479 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1555 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1480 | |
1556 | |
1481 | do { |
1557 | do { |
1482 | if (rs-- == rslist) |
1558 | if (rs-- == rslist) |
1483 | croak ("no such resource '%s', requested", name); |
1559 | croak ("no such resource '%s', requested", name); |
1484 | } while (strcmp (name, rs->name)); |
1560 | } while (strcmp (name, rs->name)); |
… | |
… | |
1608 | CODE: |
1684 | CODE: |
1609 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1685 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1610 | OUTPUT: |
1686 | OUTPUT: |
1611 | RETVAL |
1687 | RETVAL |
1612 | |
1688 | |
1613 | #void |
1689 | void |
1614 | #rxvt_term::selection_clear () |
1690 | rxvt_term::selection_clear () |
1615 | |
1691 | |
1616 | void |
1692 | void |
1617 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1693 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1618 | CODE: |
1694 | CODE: |
1619 | THIS->selection.op = SELECTION_CONT; |
1695 | THIS->selection.op = SELECTION_CONT; |
… | |
… | |
1709 | void |
1785 | void |
1710 | rxvt_term::XListProperties (Window window) |
1786 | rxvt_term::XListProperties (Window window) |
1711 | PPCODE: |
1787 | PPCODE: |
1712 | { |
1788 | { |
1713 | int count; |
1789 | int count; |
1714 | Atom *props = XListProperties (THIS->display->display, window, &count); |
1790 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1715 | |
1791 | |
1716 | EXTEND (SP, count); |
1792 | EXTEND (SP, count); |
1717 | while (count--) |
1793 | while (count--) |
1718 | PUSHs (newSVuv ((U32)props [count])); |
1794 | PUSHs (newSVuv ((U32)props [count])); |
1719 | |
1795 | |
… | |
… | |
1728 | int format; |
1804 | int format; |
1729 | unsigned long nitems; |
1805 | unsigned long nitems; |
1730 | unsigned long bytes_after; |
1806 | unsigned long bytes_after; |
1731 | unsigned char *prop; |
1807 | unsigned char *prop; |
1732 | |
1808 | |
1733 | XGetWindowProperty (THIS->display->display, window, property, |
1809 | XGetWindowProperty (THIS->dpy, window, property, |
1734 | 0, 1<<24, 0, AnyPropertyType, |
1810 | 0, 1<<24, 0, AnyPropertyType, |
1735 | &type, &format, &nitems, &bytes_after, &prop); |
1811 | &type, &format, &nitems, &bytes_after, &prop); |
1736 | |
1812 | |
1737 | if (type != None) |
1813 | if (type != None) |
1738 | { |
1814 | { |
… | |
… | |
1757 | |
1833 | |
1758 | int elemsize = format == 16 ? sizeof (short) |
1834 | int elemsize = format == 16 ? sizeof (short) |
1759 | : format == 32 ? sizeof (long) |
1835 | : format == 32 ? sizeof (long) |
1760 | : 1; |
1836 | : 1; |
1761 | |
1837 | |
1762 | XChangeProperty (THIS->display->display, window, property, |
1838 | XChangeProperty (THIS->dpy, window, property, |
1763 | type, format, PropModeReplace, |
1839 | type, format, PropModeReplace, |
1764 | (unsigned char *)data_, len / elemsize); |
1840 | (unsigned char *)data_, len / elemsize); |
1765 | XSync (THIS->display->display, 0); |
|
|
1766 | } |
1841 | } |
1767 | |
1842 | |
1768 | Atom |
1843 | Atom |
1769 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1844 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1770 | C_ARGS: term->display->display, atom_name, only_if_exists |
1845 | C_ARGS: term->dpy, atom_name, only_if_exists |
1771 | |
1846 | |
1772 | char * |
1847 | char * |
1773 | XGetAtomName (rxvt_term *term, Atom atom) |
1848 | XGetAtomName (rxvt_term *term, Atom atom) |
1774 | C_ARGS: term->display->display, atom |
1849 | C_ARGS: term->dpy, atom |
1775 | CLEANUP: |
1850 | CLEANUP: |
1776 | XFree (RETVAL); |
1851 | XFree (RETVAL); |
1777 | |
1852 | |
1778 | void |
1853 | void |
1779 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1854 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1780 | C_ARGS: term->display->display, window, property |
1855 | C_ARGS: term->dpy, window, property |
1781 | |
1856 | |
1782 | Window |
1857 | Window |
1783 | rxvt_term::DefaultRootWindow () |
1858 | rxvt_term::DefaultRootWindow () |
1784 | CODE: |
1859 | CODE: |
1785 | RETVAL = THIS->display->root; |
1860 | RETVAL = THIS->display->root; |
… | |
… | |
1788 | |
1863 | |
1789 | #if 0 |
1864 | #if 0 |
1790 | |
1865 | |
1791 | Window |
1866 | Window |
1792 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1867 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1793 | C_ARGS: term->display->display, (Window)parent, |
1868 | C_ARGS: term->dpy, (Window)parent, |
1794 | x, y, width, height, 0, |
1869 | x, y, width, height, 0, |
1795 | term->pix_colors_focused[Color_border], |
1870 | term->pix_colors_focused[Color_border], |
1796 | term->pix_colors_focused[Color_border] |
1871 | term->pix_colors_focused[Color_border] |
1797 | |
1872 | |
1798 | #endif |
1873 | #endif |
1799 | |
1874 | |
1800 | void |
1875 | void |
1801 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1876 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1802 | C_ARGS: term->display->display, window, parent, x, y |
1877 | C_ARGS: term->dpy, window, parent, x, y |
1803 | |
1878 | |
1804 | void |
1879 | void |
1805 | XMapWindow (rxvt_term *term, Window window) |
1880 | XMapWindow (rxvt_term *term, Window window) |
1806 | C_ARGS: term->display->display, window |
1881 | C_ARGS: term->dpy, window |
1807 | |
1882 | |
1808 | void |
1883 | void |
1809 | XUnmapWindow (rxvt_term *term, Window window) |
1884 | XUnmapWindow (rxvt_term *term, Window window) |
1810 | C_ARGS: term->display->display, window |
1885 | C_ARGS: term->dpy, window |
1811 | |
1886 | |
1812 | void |
1887 | void |
1813 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1888 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1814 | C_ARGS: term->display->display, window, x, y, width, height |
1889 | C_ARGS: term->dpy, window, x, y, width, height |
1815 | |
1890 | |
1816 | void |
1891 | void |
1817 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1892 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1818 | CODE: |
1893 | CODE: |
1819 | { |
1894 | { |
1820 | XWindowAttributes attr; |
1895 | XWindowAttributes attr; |
1821 | XGetWindowAttributes (THIS->display->display, window, &attr); |
1896 | XGetWindowAttributes (THIS->dpy, window, &attr); |
1822 | XSelectInput (THIS->display->display, window, attr.your_event_mask | add_events & ~del_events); |
1897 | XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events); |
1823 | } |
1898 | } |
1824 | |
1899 | |
1825 | void |
1900 | void |
1826 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1901 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1827 | PPCODE: |
1902 | PPCODE: |
1828 | { |
1903 | { |
1829 | int dx, dy; |
1904 | int dx, dy; |
1830 | Window child; |
1905 | Window child; |
1831 | |
1906 | |
1832 | if (XTranslateCoordinates (THIS->display->display, src, dst, x, y, &dx, &dy, &child)) |
1907 | if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child)) |
1833 | { |
1908 | { |
1834 | EXTEND (SP, 3); |
1909 | EXTEND (SP, 3); |
1835 | PUSHs (newSViv (dx)); |
1910 | PUSHs (newSViv (dx)); |
1836 | PUSHs (newSViv (dy)); |
1911 | PUSHs (newSViv (dy)); |
1837 | PUSHs (newSVuv (child)); |
1912 | PUSHs (newSVuv (child)); |