… | |
… | |
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 | { |
|
|
273 | if (w < 0) w = 0; |
|
|
274 | if (h < 0) h = 0; |
|
|
275 | |
272 | if (border == 2) |
276 | if (border == 2) |
273 | { |
277 | { |
274 | w += 2; |
278 | w += 2; |
275 | h += 2; |
279 | h += 2; |
276 | } |
280 | } |
… | |
… | |
314 | *rp++ = r; |
318 | *rp++ = r; |
315 | } |
319 | } |
316 | } |
320 | } |
317 | |
321 | |
318 | show (); |
322 | show (); |
319 | THIS->want_refresh = 1; |
|
|
320 | } |
323 | } |
321 | |
324 | |
322 | overlay::~overlay () |
325 | overlay::~overlay () |
323 | { |
326 | { |
324 | hide (); |
327 | hide (); |
… | |
… | |
329 | delete [] rend[y]; |
332 | delete [] rend[y]; |
330 | } |
333 | } |
331 | |
334 | |
332 | delete [] text; |
335 | delete [] text; |
333 | delete [] rend; |
336 | delete [] rend; |
|
|
337 | } |
|
|
338 | |
|
|
339 | void |
|
|
340 | overlay::show () |
|
|
341 | { |
|
|
342 | if (overlay_av) |
|
|
343 | return; |
|
|
344 | |
|
|
345 | overlay_av = (AV *)SvREFCNT_inc (SvRV ( |
|
|
346 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
|
|
347 | )); |
|
|
348 | av_push (overlay_av, newSViv ((long)this)); |
334 | |
349 | |
335 | THIS->want_refresh = 1; |
350 | THIS->want_refresh = 1; |
336 | } |
351 | } |
337 | |
352 | |
338 | void |
353 | void |
339 | overlay::show () |
354 | overlay::hide () |
340 | { |
355 | { |
341 | if (visible) |
356 | if (!overlay_av) |
342 | return; |
357 | return; |
343 | |
358 | |
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; |
359 | int i; |
361 | |
360 | |
362 | for (i = AvFILL (av); i >= 0; i--) |
361 | for (i = AvFILL (overlay_av); i >= 0; i--) |
363 | if (SvIV (*av_fetch (av, i, 1)) == (long)this) |
362 | if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this) |
364 | { |
|
|
365 | av_delete (av, i, G_DISCARD); |
|
|
366 | break; |
363 | break; |
367 | } |
|
|
368 | |
364 | |
369 | for (; i < AvFILL (av); i++) |
365 | for (; i < AvFILL (overlay_av); i++) |
370 | 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))); |
371 | |
367 | |
372 | av_pop (av); |
368 | av_pop (overlay_av); |
|
|
369 | |
|
|
370 | SvREFCNT_dec (overlay_av); |
|
|
371 | overlay_av = 0; |
|
|
372 | |
|
|
373 | THIS->want_refresh = 1; |
373 | } |
374 | } |
374 | |
375 | |
375 | void overlay::swap () |
376 | void overlay::swap () |
376 | { |
377 | { |
377 | 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)); |
… | |
… | |
492 | static void |
493 | static void |
493 | ungrab (rxvt_term *THIS) |
494 | ungrab (rxvt_term *THIS) |
494 | { |
495 | { |
495 | if (THIS->perl.grabtime) |
496 | if (THIS->perl.grabtime) |
496 | { |
497 | { |
497 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
498 | XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime); |
498 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
499 | XUngrabPointer (THIS->dpy, THIS->perl.grabtime); |
499 | THIS->perl.grabtime = 0; |
500 | THIS->perl.grabtime = 0; |
500 | } |
501 | } |
501 | } |
502 | } |
502 | |
503 | |
503 | bool |
504 | bool |
… | |
… | |
554 | break; |
555 | break; |
555 | |
556 | |
556 | case DT_STR_LEN: |
557 | case DT_STR_LEN: |
557 | { |
558 | { |
558 | char *str = va_arg (ap, char *); |
559 | char *str = va_arg (ap, char *); |
559 | int len = va_arg (ap, int); |
560 | int len = va_arg (ap, int); |
560 | |
561 | |
561 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
562 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
562 | } |
563 | } |
563 | break; |
564 | break; |
564 | |
565 | |
565 | case DT_WCS_LEN: |
566 | case DT_WCS_LEN: |
566 | { |
567 | { |
567 | wchar_t *wstr = va_arg (ap, wchar_t *); |
568 | wchar_t *wstr = va_arg (ap, wchar_t *); |
568 | int wlen = va_arg (ap, int); |
569 | int wlen = va_arg (ap, int); |
569 | |
570 | |
570 | 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)))); |
571 | } |
581 | } |
572 | break; |
582 | break; |
573 | |
583 | |
574 | case DT_XEVENT: |
584 | case DT_XEVENT: |
575 | { |
585 | { |
576 | XEvent *xe = va_arg (ap, XEvent *); |
586 | XEvent *xe = va_arg (ap, XEvent *); |
577 | HV *hv = newHV (); |
587 | HV *hv = newHV (); |
578 | |
588 | |
579 | # 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) |
580 | # 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) |
581 | # 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) |
582 | # undef set |
592 | # undef set |
583 | |
593 | |
584 | setiv (type, xe->type); |
594 | setiv (type, xe->type); |
585 | setiv (send_event, xe->xany.send_event); |
595 | setiv (send_event, xe->xany.send_event); |
586 | setiv (serial, xe->xany.serial); |
596 | setiv (serial, xe->xany.serial); |
587 | |
597 | |
… | |
… | |
596 | setuv (root, xe->xmotion.root); |
606 | setuv (root, xe->xmotion.root); |
597 | setuv (subwindow, xe->xmotion.subwindow); |
607 | setuv (subwindow, xe->xmotion.subwindow); |
598 | setuv (time, xe->xmotion.time); |
608 | setuv (time, xe->xmotion.time); |
599 | setiv (x, xe->xmotion.x); |
609 | setiv (x, xe->xmotion.x); |
600 | setiv (y, xe->xmotion.y); |
610 | setiv (y, xe->xmotion.y); |
601 | setiv (row, xe->xmotion.y / term->fheight); |
611 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
602 | setiv (col, xe->xmotion.x / term->fwidth); |
612 | setiv (col, xe->xmotion.x / term->fwidth); |
603 | setiv (x_root, xe->xmotion.x_root); |
613 | setiv (x_root, xe->xmotion.x_root); |
604 | setiv (y_root, xe->xmotion.y_root); |
614 | setiv (y_root, xe->xmotion.y_root); |
605 | setuv (state, xe->xmotion.state); |
615 | setuv (state, xe->xmotion.state); |
606 | |
616 | |
… | |
… | |
640 | break; |
650 | break; |
641 | } |
651 | } |
642 | |
652 | |
643 | break; |
653 | break; |
644 | |
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 | |
645 | case ClientMessage: |
662 | case ClientMessage: |
646 | setuv (window, xe->xclient.window); |
663 | setuv (window, xe->xclient.window); |
647 | setuv (message_type, xe->xclient.message_type); |
664 | setuv (message_type, xe->xclient.message_type); |
648 | setuv (format, xe->xclient.format); |
665 | setuv (format, xe->xclient.format); |
649 | setuv (l0, xe->xclient.data.l[0]); |
666 | setuv (l0, xe->xclient.data.l[0]); |
650 | setuv (l1, xe->xclient.data.l[1]); |
667 | setuv (l1, xe->xclient.data.l[1]); |
651 | setuv (l2, xe->xclient.data.l[2]); |
668 | setuv (l2, xe->xclient.data.l[2]); |
652 | setuv (l3, xe->xclient.data.l[3]); |
669 | setuv (l3, xe->xclient.data.l[3]); |
653 | setuv (l4, xe->xclient.data.l[4]); |
670 | setuv (l4, xe->xclient.data.l[4]); |
|
|
671 | break; |
654 | } |
672 | } |
655 | |
673 | |
656 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
674 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
657 | } |
675 | } |
658 | break; |
676 | break; |
… | |
… | |
708 | } |
726 | } |
709 | else if (htype == HOOK_DESTROY) |
727 | else if (htype == HOOK_DESTROY) |
710 | { |
728 | { |
711 | clearSVptr ((SV *)term->perl.self); |
729 | clearSVptr ((SV *)term->perl.self); |
712 | 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; |
713 | } |
734 | } |
714 | |
735 | |
715 | swap (perl_environ, environ); |
736 | swap (perl_environ, environ); |
716 | |
737 | |
717 | return event_consumed; |
738 | return event_consumed; |
… | |
… | |
741 | # include "optinc.h" |
762 | # include "optinc.h" |
742 | # undef nodef |
763 | # undef nodef |
743 | # undef def |
764 | # undef def |
744 | |
765 | |
745 | HV *stash = gv_stashpv ("urxvt", 1); |
766 | HV *stash = gv_stashpv ("urxvt", 1); |
746 | struct { |
767 | static const struct { |
747 | const char *name; |
768 | const char *name; |
748 | IV iv; |
769 | IV iv; |
749 | } *civ, const_iv[] = { |
770 | } *civ, const_iv[] = { |
750 | # define const_iv(name) { # name, (IV)name } |
771 | # define const_iv(name) { # name, (IV)name } |
751 | const_iv (DEFAULT_RSTYLE), |
772 | const_iv (DEFAULT_RSTYLE), |
… | |
… | |
769 | const_iv (Button2Mask), |
790 | const_iv (Button2Mask), |
770 | const_iv (Button3Mask), |
791 | const_iv (Button3Mask), |
771 | const_iv (Button4Mask), |
792 | const_iv (Button4Mask), |
772 | const_iv (Button5Mask), |
793 | const_iv (Button5Mask), |
773 | const_iv (AnyModifier), |
794 | const_iv (AnyModifier), |
|
|
795 | |
|
|
796 | const_iv (NoSymbol), |
|
|
797 | const_iv (GrabModeSync), |
|
|
798 | const_iv (GrabModeAsync), |
774 | |
799 | |
775 | const_iv (EVENT_NONE), |
800 | const_iv (EVENT_NONE), |
776 | const_iv (EVENT_READ), |
801 | const_iv (EVENT_READ), |
777 | const_iv (EVENT_WRITE), |
802 | const_iv (EVENT_WRITE), |
778 | |
803 | |
… | |
… | |
834 | const_iv (SelectionRequest), |
859 | const_iv (SelectionRequest), |
835 | const_iv (SelectionNotify), |
860 | const_iv (SelectionNotify), |
836 | const_iv (ColormapNotify), |
861 | const_iv (ColormapNotify), |
837 | const_iv (ClientMessage), |
862 | const_iv (ClientMessage), |
838 | const_iv (MappingNotify), |
863 | const_iv (MappingNotify), |
|
|
864 | # if ENABLE_XIM_ONTHESPOT |
|
|
865 | const_iv (XIMReverse), |
|
|
866 | const_iv (XIMUnderline), |
|
|
867 | const_iv (XIMHighlight), |
|
|
868 | const_iv (XIMPrimary), |
|
|
869 | const_iv (XIMSecondary), |
|
|
870 | const_iv (XIMTertiary), |
|
|
871 | const_iv (XIMVisibleToForward), |
|
|
872 | const_iv (XIMVisibleToBackword), |
|
|
873 | const_iv (XIMVisibleToCenter), |
|
|
874 | # if 0 |
|
|
875 | const_iv (XIMForwardChar), |
|
|
876 | const_iv (XIMBackwardChar), |
|
|
877 | const_iv (XIMForwardWord), |
|
|
878 | const_iv (XIMBackwardWord), |
|
|
879 | const_iv (XIMCaretUp), |
|
|
880 | const_iv (XIMCaretDown), |
|
|
881 | const_iv (XIMNextLine), |
|
|
882 | const_iv (XIMPreviousLine), |
|
|
883 | const_iv (XIMLineStart), |
|
|
884 | const_iv (XIMLineEnd), |
|
|
885 | const_iv (XIMAbsolutePosition), |
|
|
886 | const_iv (XIMDontChange), |
|
|
887 | # endif |
|
|
888 | # endif |
839 | }; |
889 | }; |
840 | |
890 | |
841 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
891 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
842 | civ-- > const_iv; ) |
|
|
843 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
892 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
844 | } |
893 | } |
845 | |
894 | |
846 | void |
895 | void |
847 | warn (const char *msg) |
896 | warn (const char *msg) |
… | |
… | |
878 | RETVAL |
927 | RETVAL |
879 | |
928 | |
880 | int |
929 | int |
881 | SET_FGCOLOR (int rend, int new_color) |
930 | SET_FGCOLOR (int rend, int new_color) |
882 | CODE: |
931 | CODE: |
883 | RETVAL = SET_FGCOLOR (rend, new_color); |
932 | RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
884 | OUTPUT: |
933 | OUTPUT: |
885 | RETVAL |
934 | RETVAL |
886 | |
935 | |
887 | int |
936 | int |
888 | SET_BGCOLOR (int rend, int new_color) |
937 | SET_BGCOLOR (int rend, int new_color) |
889 | CODE: |
938 | CODE: |
890 | RETVAL = SET_BGCOLOR (rend, new_color); |
939 | RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
891 | OUTPUT: |
940 | OUTPUT: |
892 | RETVAL |
941 | RETVAL |
893 | |
942 | |
894 | int |
943 | int |
895 | GET_CUSTOM (int rend) |
944 | GET_CUSTOM (int rend) |
… | |
… | |
909 | | ((new_value << RS_customShift) & RS_customMask); |
958 | | ((new_value << RS_customShift) & RS_customMask); |
910 | } |
959 | } |
911 | OUTPUT: |
960 | OUTPUT: |
912 | RETVAL |
961 | RETVAL |
913 | |
962 | |
|
|
963 | void |
|
|
964 | termlist () |
|
|
965 | PPCODE: |
|
|
966 | { |
|
|
967 | EXTEND (SP, rxvt_term::termlist.size ()); |
|
|
968 | |
|
|
969 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
970 | if ((*t)->perl.self) |
|
|
971 | PUSHs (sv_2mortal (newSVterm (*t))); |
|
|
972 | } |
|
|
973 | |
914 | MODULE = urxvt PACKAGE = urxvt::term |
974 | MODULE = urxvt PACKAGE = urxvt::term |
915 | |
975 | |
916 | SV * |
976 | SV * |
917 | _new (...) |
977 | _new (AV *env, AV *arg) |
918 | CODE: |
978 | CODE: |
919 | { |
979 | { |
920 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
921 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
922 | |
|
|
923 | rxvt_term *term = new rxvt_term; |
980 | rxvt_term *term = new rxvt_term; |
924 | |
981 | |
925 | term->argv = new stringvec; |
982 | stringvec *argv = new stringvec; |
926 | term->envv = new stringvec; |
983 | stringvec *envv = new stringvec; |
927 | |
984 | |
928 | for (int i = 1; i < items; i++) |
985 | for (int i = 0; i <= AvFILL (arg); i++) |
929 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
986 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
930 | |
987 | |
931 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
932 | for (int i = AvFILL (envv) + 1; i--; ) |
988 | for (int i = AvFILL (env) + 1; i--; ) |
933 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
989 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
934 | |
990 | |
935 | term->envv->push_back (0); |
991 | envv->push_back (0); |
936 | |
992 | |
937 | bool success; |
993 | bool success; |
938 | |
994 | |
939 | try |
995 | try |
940 | { |
996 | { |
941 | success = term->init (term->argv->size (), term->argv->begin ()); |
997 | success = term->init (argv, envv); |
942 | } |
998 | } |
943 | catch (const class rxvt_failure_exception &e) |
999 | catch (const class rxvt_failure_exception &e) |
944 | { |
1000 | { |
945 | success = false; |
1001 | success = false; |
946 | } |
1002 | } |
… | |
… | |
963 | void |
1019 | void |
964 | rxvt_term::set_should_invoke (int htype, int inc) |
1020 | rxvt_term::set_should_invoke (int htype, int inc) |
965 | CODE: |
1021 | CODE: |
966 | THIS->perl.should_invoke [htype] += inc; |
1022 | THIS->perl.should_invoke [htype] += inc; |
967 | |
1023 | |
968 | void |
1024 | int |
969 | rxvt_term::grab_button (int button, U32 modifiers) |
1025 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
970 | CODE: |
1026 | CODE: |
971 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1027 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
972 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1028 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
973 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
1029 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
1030 | OUTPUT: RETVAL |
|
|
1031 | |
|
|
1032 | int |
|
|
1033 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
|
|
1034 | CODE: |
|
|
1035 | RETVAL = XUngrabButton (THIS->dpy, button, modifiers, window); |
|
|
1036 | OUTPUT: RETVAL |
|
|
1037 | |
|
|
1038 | void |
|
|
1039 | rxvt_term::XGrabKey (int keycode, U32 modifiers, Window window = THIS->vt, \ |
|
|
1040 | int owner_events = 1, int pointer_mode = GrabModeAsync, int keyboard_mode = GrabModeAsync) |
|
|
1041 | CODE: |
|
|
1042 | XGrabKey (THIS->dpy, keycode, modifiers, window, owner_events, pointer_mode, keyboard_mode); |
|
|
1043 | |
|
|
1044 | void |
|
|
1045 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
|
|
1046 | CODE: |
|
|
1047 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
|
|
1048 | |
|
|
1049 | void |
|
|
1050 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
1051 | CODE: |
|
|
1052 | XUngrabKeyboard (THIS->dpy, eventtime); |
974 | |
1053 | |
975 | bool |
1054 | bool |
976 | rxvt_term::grab (Time eventtime, int sync = 0) |
1055 | rxvt_term::grab (Time eventtime, int sync = 0) |
977 | CODE: |
1056 | CODE: |
978 | { |
1057 | { |
979 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1058 | int mode = sync ? GrabModeSync : GrabModeAsync; |
980 | |
1059 | |
981 | THIS->perl.grabtime = 0; |
1060 | THIS->perl.grabtime = 0; |
982 | |
1061 | |
983 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
1062 | if (!XGrabPointer (THIS->dpy, THIS->vt, 0, |
984 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1063 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
985 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1064 | mode, mode, None, GRAB_CURSOR, eventtime)) |
986 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
1065 | if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime)) |
987 | THIS->perl.grabtime = eventtime; |
1066 | THIS->perl.grabtime = eventtime; |
988 | else |
1067 | else |
989 | XUngrabPointer (THIS->display->display, eventtime); |
1068 | XUngrabPointer (THIS->dpy, eventtime); |
990 | |
1069 | |
991 | RETVAL = !!THIS->perl.grabtime; |
1070 | RETVAL = !!THIS->perl.grabtime; |
992 | } |
1071 | } |
993 | OUTPUT: |
1072 | OUTPUT: |
994 | RETVAL |
1073 | RETVAL |
995 | |
1074 | |
996 | void |
1075 | void |
997 | rxvt_term::allow_events_async () |
1076 | rxvt_term::allow_events_async () |
998 | CODE: |
1077 | CODE: |
999 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
1078 | XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime); |
1000 | |
1079 | |
1001 | void |
1080 | void |
1002 | rxvt_term::allow_events_sync () |
1081 | rxvt_term::allow_events_sync () |
1003 | CODE: |
1082 | CODE: |
1004 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
1083 | XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime); |
1005 | |
1084 | |
1006 | void |
1085 | void |
1007 | rxvt_term::allow_events_replay () |
1086 | rxvt_term::allow_events_replay () |
1008 | CODE: |
1087 | CODE: |
1009 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
1088 | XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime); |
1010 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
1089 | XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime); |
1011 | |
1090 | |
1012 | void |
1091 | void |
1013 | rxvt_term::ungrab () |
1092 | rxvt_term::ungrab () |
1014 | CODE: |
1093 | CODE: |
1015 | ungrab (THIS); |
1094 | ungrab (THIS); |
|
|
1095 | |
|
|
1096 | int |
|
|
1097 | rxvt_term::XStringToKeysym (char *string) |
|
|
1098 | CODE: |
|
|
1099 | RETVAL = XStringToKeysym (string); |
|
|
1100 | OUTPUT: RETVAL |
|
|
1101 | |
|
|
1102 | char * |
|
|
1103 | rxvt_term::XKeysymToString (int sym) |
|
|
1104 | CODE: |
|
|
1105 | RETVAL = XKeysymToString (sym); |
|
|
1106 | OUTPUT: RETVAL |
|
|
1107 | |
|
|
1108 | int |
|
|
1109 | rxvt_term::XKeysymToKeycode (int sym) |
|
|
1110 | CODE: |
|
|
1111 | RETVAL = XKeysymToKeycode (THIS->dpy, sym); |
|
|
1112 | OUTPUT: RETVAL |
|
|
1113 | |
|
|
1114 | int |
|
|
1115 | rxvt_term::XKeycodeToKeysym (int code, int index) |
|
|
1116 | CODE: |
|
|
1117 | RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); |
|
|
1118 | OUTPUT: RETVAL |
1016 | |
1119 | |
1017 | int |
1120 | int |
1018 | rxvt_term::strwidth (SV *str) |
1121 | rxvt_term::strwidth (SV *str) |
1019 | CODE: |
1122 | CODE: |
1020 | { |
1123 | { |
… | |
… | |
1109 | rxvt_term::ModLevel3Mask () |
1212 | rxvt_term::ModLevel3Mask () |
1110 | ALIAS: |
1213 | ALIAS: |
1111 | ModLevel3Mask = 0 |
1214 | ModLevel3Mask = 0 |
1112 | ModMetaMask = 1 |
1215 | ModMetaMask = 1 |
1113 | ModNumLockMask = 2 |
1216 | ModNumLockMask = 2 |
|
|
1217 | current_screen = 3 |
|
|
1218 | hidden_cursor = 4 |
1114 | CODE: |
1219 | CODE: |
1115 | switch (ix) |
1220 | switch (ix) |
1116 | { |
1221 | { |
1117 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1222 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1118 | case 1: RETVAL = THIS->ModMetaMask; break; |
1223 | case 1: RETVAL = THIS->ModMetaMask; break; |
1119 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1224 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
1225 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1226 | case 4: RETVAL = THIS->hidden_cursor; break; |
1120 | } |
1227 | } |
1121 | OUTPUT: |
1228 | OUTPUT: |
1122 | RETVAL |
1229 | RETVAL |
1123 | |
1230 | |
1124 | char * |
1231 | char * |
… | |
… | |
1134 | } |
1241 | } |
1135 | OUTPUT: |
1242 | OUTPUT: |
1136 | RETVAL |
1243 | RETVAL |
1137 | |
1244 | |
1138 | SV * |
1245 | SV * |
1139 | rxvt_term::_env () |
1246 | rxvt_term::envv () |
|
|
1247 | ALIAS: |
|
|
1248 | argv = 1 |
1140 | CODE: |
1249 | PPCODE: |
1141 | { |
1250 | { |
1142 | if (THIS->envv) |
1251 | stringvec *vec = ix ? THIS->argv : THIS->envv; |
1143 | { |
|
|
1144 | AV *av = newAV (); |
|
|
1145 | |
1252 | |
|
|
1253 | EXTEND (SP, vec->size ()); |
|
|
1254 | |
1146 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
1255 | for (char **i = vec->begin (); i != vec->end (); ++i) |
1147 | if (*i) |
1256 | if (*i) |
1148 | av_push (av, newSVpv (*i, 0)); |
1257 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1149 | |
|
|
1150 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1151 | } |
|
|
1152 | else |
|
|
1153 | RETVAL = &PL_sv_undef; |
|
|
1154 | } |
1258 | } |
1155 | OUTPUT: |
|
|
1156 | RETVAL |
|
|
1157 | |
1259 | |
1158 | int |
1260 | int |
1159 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1261 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1160 | CODE: |
1262 | CODE: |
1161 | RETVAL = THIS->pty_ev.events; |
1263 | RETVAL = THIS->pty_ev.events; |
1162 | if (events != EVENT_UNDEF) |
1264 | if (events != EVENT_UNDEF) |
1163 | THIS->pty_ev.set (events); |
1265 | THIS->pty_ev.set (events); |
1164 | OUTPUT: |
1266 | OUTPUT: |
1165 | RETVAL |
1267 | RETVAL |
1166 | |
1268 | |
|
|
1269 | int |
|
|
1270 | rxvt_term::pty_fd () |
|
|
1271 | CODE: |
|
|
1272 | RETVAL = THIS->pty->pty; |
|
|
1273 | OUTPUT: |
|
|
1274 | RETVAL |
|
|
1275 | |
1167 | Window |
1276 | Window |
1168 | rxvt_term::parent () |
1277 | rxvt_term::parent () |
1169 | CODE: |
1278 | CODE: |
1170 | RETVAL = THIS->parent [0]; |
1279 | RETVAL = THIS->parent [0]; |
1171 | OUTPUT: |
1280 | OUTPUT: |
… | |
… | |
1204 | } |
1313 | } |
1205 | OUTPUT: |
1314 | OUTPUT: |
1206 | RETVAL |
1315 | RETVAL |
1207 | |
1316 | |
1208 | void |
1317 | void |
|
|
1318 | rxvt_term::focus_in () |
|
|
1319 | |
|
|
1320 | void |
|
|
1321 | rxvt_term::focus_out () |
|
|
1322 | |
|
|
1323 | void |
|
|
1324 | rxvt_term::key_press (unsigned int state, unsigned int keycode, Time time = CurrentTime) |
|
|
1325 | ALIAS: |
|
|
1326 | key_release = 1 |
|
|
1327 | CODE: |
|
|
1328 | { |
|
|
1329 | XKeyEvent xkey; |
|
|
1330 | |
|
|
1331 | memset (&xkey, 0, sizeof (xkey)); |
|
|
1332 | |
|
|
1333 | xkey.time = time; |
|
|
1334 | xkey.state = state; |
|
|
1335 | xkey.keycode = keycode; |
|
|
1336 | |
|
|
1337 | xkey.type = ix ? KeyRelease : KeyPress; |
|
|
1338 | xkey.display = THIS->dpy; |
|
|
1339 | xkey.window = THIS->vt; |
|
|
1340 | xkey.root = THIS->display->root; |
|
|
1341 | xkey.subwindow = THIS->vt; |
|
|
1342 | |
|
|
1343 | if (ix) |
|
|
1344 | THIS->key_release (xkey); |
|
|
1345 | else |
|
|
1346 | THIS->key_press (xkey); |
|
|
1347 | } |
|
|
1348 | |
|
|
1349 | void |
1209 | rxvt_term::want_refresh () |
1350 | rxvt_term::want_refresh () |
1210 | CODE: |
1351 | CODE: |
1211 | THIS->want_refresh = 1; |
1352 | THIS->want_refresh = 1; |
1212 | |
1353 | |
1213 | void |
1354 | void |
… | |
… | |
1219 | |
1360 | |
1220 | line_t &l = ROW(row_number); |
1361 | line_t &l = ROW(row_number); |
1221 | |
1362 | |
1222 | if (GIMME_V != G_VOID) |
1363 | if (GIMME_V != G_VOID) |
1223 | { |
1364 | { |
1224 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
1365 | wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol); |
1225 | |
1366 | |
1226 | for (int col = 0; col < THIS->ncol; col++) |
1367 | for (int col = 0; col < THIS->ncol; col++) |
1227 | wstr [col] = l.t [col]; |
1368 | wstr [col] = l.t [col]; |
1228 | |
1369 | |
1229 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1370 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1230 | |
|
|
1231 | delete [] wstr; |
|
|
1232 | } |
1371 | } |
1233 | |
1372 | |
1234 | if (new_text) |
1373 | if (new_text) |
1235 | { |
1374 | { |
1236 | wchar_t *wstr = sv2wcs (new_text); |
1375 | wchar_t *wstr = sv2wcs (new_text); |
1237 | |
1376 | |
1238 | int len = min (wcslen (wstr) - start_ofs, max_len); |
1377 | int len = min (wcslen (wstr) - start_ofs, max_len); |
1239 | |
1378 | |
1240 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1379 | if (start_col < 0 || start_col + len > THIS->ncol) |
1241 | { |
1380 | { |
1242 | free (wstr); |
1381 | free (wstr); |
1243 | croak ("new_text extends beyond horizontal margins"); |
1382 | croak ("new_text extends beyond horizontal margins"); |
1244 | } |
1383 | } |
1245 | |
1384 | |
… | |
… | |
1279 | croak ("new_rend must be arrayref"); |
1418 | croak ("new_rend must be arrayref"); |
1280 | |
1419 | |
1281 | AV *av = (AV *)SvRV (new_rend); |
1420 | AV *av = (AV *)SvRV (new_rend); |
1282 | int len = min (AvFILL (av) + 1 - start_ofs, max_len); |
1421 | int len = min (AvFILL (av) + 1 - start_ofs, max_len); |
1283 | |
1422 | |
1284 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1423 | if (start_col < 0 || start_col + len > THIS->ncol) |
1285 | croak ("new_rend array extends beyond horizontal margins"); |
1424 | croak ("new_rend array extends beyond horizontal margins"); |
1286 | |
1425 | |
1287 | for (int col = start_col; col < start_col + len; col++) |
1426 | for (int col = start_col; col < start_col + len; col++) |
1288 | { |
1427 | { |
1289 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
1428 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
… | |
… | |
1329 | rxvt_term::special_encode (SV *string) |
1468 | rxvt_term::special_encode (SV *string) |
1330 | CODE: |
1469 | CODE: |
1331 | { |
1470 | { |
1332 | wchar_t *wstr = sv2wcs (string); |
1471 | wchar_t *wstr = sv2wcs (string); |
1333 | int wlen = wcslen (wstr); |
1472 | int wlen = wcslen (wstr); |
1334 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
1473 | wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer |
1335 | |
1474 | |
1336 | rxvt_push_locale (THIS->locale); |
1475 | rxvt_push_locale (THIS->locale); |
1337 | |
1476 | |
1338 | wchar_t *r = rstr; |
1477 | wchar_t *r = rstr; |
1339 | for (wchar_t *s = wstr; *s; s++) |
1478 | for (wchar_t *s = wstr; *s; s++) |
|
|
1479 | { |
|
|
1480 | int w = WCWIDTH (*s); |
|
|
1481 | |
1340 | if (wcwidth (*s) == 0) |
1482 | if (w == 0) |
1341 | { |
1483 | { |
1342 | if (r == rstr) |
1484 | if (r == rstr) |
1343 | croak ("leading combining character unencodable"); |
1485 | croak ("leading combining character unencodable"); |
1344 | |
1486 | |
1345 | unicode_t n = rxvt_compose (r[-1], *s); |
1487 | unicode_t n = rxvt_compose (r[-1], *s); |
1346 | if (n == NOCHAR) |
1488 | if (n == NOCHAR) |
1347 | n = rxvt_composite.compose (r[-1], *s); |
1489 | n = rxvt_composite.compose (r[-1], *s); |
1348 | |
1490 | |
1349 | r[-1] = n; |
1491 | r[-1] = n; |
1350 | } |
1492 | } |
1351 | #if !UNICODE_3 |
1493 | #if !UNICODE_3 |
1352 | else if (*s >= 0x10000) |
1494 | else if (*s >= 0x10000) |
1353 | *r++ = rxvt_composite.compose (*s); |
1495 | *r++ = rxvt_composite.compose (*s); |
1354 | #endif |
1496 | #endif |
1355 | else |
1497 | else |
1356 | *r++ = *s; |
1498 | *r++ = *s; |
|
|
1499 | |
|
|
1500 | // the *2 above only allows wcwidth <= 2 |
|
|
1501 | if (w > 1) |
|
|
1502 | *r++ = NOCHAR; |
|
|
1503 | } |
1357 | |
1504 | |
1358 | rxvt_pop_locale (); |
1505 | rxvt_pop_locale (); |
1359 | |
1506 | |
1360 | RETVAL = wcs2sv (rstr, r - rstr); |
1507 | RETVAL = wcs2sv (rstr, r - rstr); |
1361 | |
|
|
1362 | delete [] rstr; |
|
|
1363 | } |
1508 | } |
1364 | OUTPUT: |
1509 | OUTPUT: |
1365 | RETVAL |
1510 | RETVAL |
1366 | |
1511 | |
1367 | SV * |
1512 | SV * |
… | |
… | |
1379 | else if (IS_COMPOSE (*s)) |
1524 | else if (IS_COMPOSE (*s)) |
1380 | dlen += rxvt_composite.expand (*s, 0); |
1525 | dlen += rxvt_composite.expand (*s, 0); |
1381 | else |
1526 | else |
1382 | dlen++; |
1527 | dlen++; |
1383 | |
1528 | |
1384 | wchar_t *rstr = new wchar_t [dlen]; |
1529 | wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen); |
1385 | |
1530 | |
1386 | // decode |
1531 | // decode |
1387 | wchar_t *r = rstr; |
1532 | wchar_t *r = rstr; |
1388 | for (wchar_t *s = wstr; *s; s++) |
1533 | for (wchar_t *s = wstr; *s; s++) |
1389 | if (*s == NOCHAR) |
1534 | if (*s == NOCHAR) |
… | |
… | |
1392 | r += rxvt_composite.expand (*s, r); |
1537 | r += rxvt_composite.expand (*s, r); |
1393 | else |
1538 | else |
1394 | *r++ = *s; |
1539 | *r++ = *s; |
1395 | |
1540 | |
1396 | RETVAL = wcs2sv (rstr, r - rstr); |
1541 | RETVAL = wcs2sv (rstr, r - rstr); |
1397 | |
|
|
1398 | delete [] rstr; |
|
|
1399 | } |
1542 | } |
1400 | OUTPUT: |
1543 | OUTPUT: |
1401 | RETVAL |
1544 | RETVAL |
1402 | |
1545 | |
1403 | void |
1546 | void |
1404 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1547 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1405 | PPCODE: |
1548 | PPCODE: |
1406 | { |
1549 | { |
1407 | struct resval { const char *name; int value; } rslist [] = { |
1550 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1408 | # define def(name) { # name, Rs_ ## name }, |
1551 | # define def(name) { # name, Rs_ ## name }, |
1409 | # define reserve(name,count) |
1552 | # define reserve(name,count) |
1410 | # include "rsinc.h" |
1553 | # include "rsinc.h" |
1411 | # undef def |
1554 | # undef def |
1412 | # undef reserve |
1555 | # undef reserve |
1413 | }; |
1556 | }; |
1414 | |
1557 | |
1415 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1558 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1416 | |
1559 | |
1417 | do { |
1560 | do { |
1418 | if (rs-- == rslist) |
1561 | if (rs-- == rslist) |
1419 | croak ("no such resource '%s', requested", name); |
1562 | croak ("no such resource '%s', requested", name); |
1420 | } while (strcmp (name, rs->name)); |
1563 | } while (strcmp (name, rs->name)); |
… | |
… | |
1513 | if (items == 3) |
1656 | if (items == 3) |
1514 | { |
1657 | { |
1515 | rc.row = SvIV (ST (1)); |
1658 | rc.row = SvIV (ST (1)); |
1516 | rc.col = SvIV (ST (2)); |
1659 | rc.col = SvIV (ST (2)); |
1517 | |
1660 | |
1518 | if (ix == 2 && rc.col == 0) |
1661 | if (ix == 2) |
1519 | { |
1662 | { |
|
|
1663 | if (rc.col == 0) |
|
|
1664 | { |
|
|
1665 | // col == 0 means end of previous line |
1520 | rc.row--; |
1666 | rc.row--; |
1521 | rc.col = THIS->ncol; |
1667 | rc.col = THIS->ncol; |
|
|
1668 | } |
|
|
1669 | else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow) |
|
|
1670 | && rc.col > ROW(rc.row).l) |
|
|
1671 | { |
|
|
1672 | // col >= length means while line and add newline |
|
|
1673 | rc.col = THIS->ncol; |
|
|
1674 | } |
1522 | } |
1675 | } |
1523 | |
1676 | |
1524 | clamp_it (rc.col, 0, THIS->ncol); |
1677 | clamp_it (rc.col, 0, THIS->ncol); |
1525 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1678 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1526 | |
1679 | |
… | |
… | |
1534 | CODE: |
1687 | CODE: |
1535 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1688 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1536 | OUTPUT: |
1689 | OUTPUT: |
1537 | RETVAL |
1690 | RETVAL |
1538 | |
1691 | |
1539 | #void |
1692 | void |
1540 | #rxvt_term::selection_clear () |
1693 | rxvt_term::selection_clear () |
1541 | |
1694 | |
1542 | void |
1695 | void |
1543 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1696 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1544 | CODE: |
1697 | CODE: |
1545 | THIS->selection.op = SELECTION_CONT; |
1698 | THIS->selection.op = SELECTION_CONT; |
… | |
… | |
1573 | void |
1726 | void |
1574 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1727 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1575 | |
1728 | |
1576 | void |
1729 | void |
1577 | rxvt_term::scr_bell () |
1730 | rxvt_term::scr_bell () |
|
|
1731 | |
|
|
1732 | void |
|
|
1733 | rxvt_term::scr_change_screen (int screen) |
1578 | |
1734 | |
1579 | void |
1735 | void |
1580 | rxvt_term::scr_add_lines (SV *string) |
1736 | rxvt_term::scr_add_lines (SV *string) |
1581 | CODE: |
1737 | CODE: |
1582 | { |
1738 | { |
… | |
… | |
1632 | void |
1788 | void |
1633 | rxvt_term::XListProperties (Window window) |
1789 | rxvt_term::XListProperties (Window window) |
1634 | PPCODE: |
1790 | PPCODE: |
1635 | { |
1791 | { |
1636 | int count; |
1792 | int count; |
1637 | Atom *props = XListProperties (THIS->display->display, window, &count); |
1793 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1638 | |
1794 | |
1639 | EXTEND (SP, count); |
1795 | EXTEND (SP, count); |
1640 | while (count--) |
1796 | while (count--) |
1641 | PUSHs (newSVuv ((U32)props [count])); |
1797 | PUSHs (newSVuv ((U32)props [count])); |
1642 | |
1798 | |
… | |
… | |
1651 | int format; |
1807 | int format; |
1652 | unsigned long nitems; |
1808 | unsigned long nitems; |
1653 | unsigned long bytes_after; |
1809 | unsigned long bytes_after; |
1654 | unsigned char *prop; |
1810 | unsigned char *prop; |
1655 | |
1811 | |
1656 | XGetWindowProperty (THIS->display->display, window, property, |
1812 | XGetWindowProperty (THIS->dpy, window, property, |
1657 | 0, 1<<24, 0, AnyPropertyType, |
1813 | 0, 1<<24, 0, AnyPropertyType, |
1658 | &type, &format, &nitems, &bytes_after, &prop); |
1814 | &type, &format, &nitems, &bytes_after, &prop); |
1659 | |
1815 | |
1660 | if (type != None) |
1816 | if (type != None) |
1661 | { |
1817 | { |
… | |
… | |
1680 | |
1836 | |
1681 | int elemsize = format == 16 ? sizeof (short) |
1837 | int elemsize = format == 16 ? sizeof (short) |
1682 | : format == 32 ? sizeof (long) |
1838 | : format == 32 ? sizeof (long) |
1683 | : 1; |
1839 | : 1; |
1684 | |
1840 | |
1685 | XChangeProperty (THIS->display->display, window, property, |
1841 | XChangeProperty (THIS->dpy, window, property, |
1686 | type, format, PropModeReplace, |
1842 | type, format, PropModeReplace, |
1687 | (unsigned char *)data_, len / elemsize); |
1843 | (unsigned char *)data_, len / elemsize); |
1688 | XSync (THIS->display->display, 0); |
|
|
1689 | } |
1844 | } |
1690 | |
1845 | |
1691 | Atom |
1846 | Atom |
1692 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1847 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1693 | C_ARGS: term->display->display, atom_name, only_if_exists |
1848 | C_ARGS: term->dpy, atom_name, only_if_exists |
1694 | |
1849 | |
1695 | char * |
1850 | char * |
1696 | XGetAtomName (rxvt_term *term, Atom atom) |
1851 | XGetAtomName (rxvt_term *term, Atom atom) |
1697 | C_ARGS: term->display->display, atom |
1852 | C_ARGS: term->dpy, atom |
1698 | CLEANUP: |
1853 | CLEANUP: |
1699 | XFree (RETVAL); |
1854 | XFree (RETVAL); |
1700 | |
1855 | |
1701 | void |
1856 | void |
1702 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1857 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1703 | C_ARGS: term->display->display, window, property |
1858 | C_ARGS: term->dpy, window, property |
1704 | |
1859 | |
1705 | Window |
1860 | Window |
1706 | rxvt_term::DefaultRootWindow () |
1861 | rxvt_term::DefaultRootWindow () |
1707 | CODE: |
1862 | CODE: |
1708 | RETVAL = THIS->display->root; |
1863 | RETVAL = THIS->display->root; |
… | |
… | |
1711 | |
1866 | |
1712 | #if 0 |
1867 | #if 0 |
1713 | |
1868 | |
1714 | Window |
1869 | Window |
1715 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1870 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1716 | C_ARGS: term->display->display, (Window)parent, |
1871 | C_ARGS: term->dpy, (Window)parent, |
1717 | x, y, width, height, 0, |
1872 | x, y, width, height, 0, |
1718 | term->pix_colors_focused[Color_border], |
1873 | term->pix_colors_focused[Color_border], |
1719 | term->pix_colors_focused[Color_border] |
1874 | term->pix_colors_focused[Color_border] |
1720 | |
1875 | |
1721 | #endif |
1876 | #endif |
1722 | |
1877 | |
1723 | void |
1878 | void |
1724 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1879 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1725 | C_ARGS: term->display->display, window, parent, x, y |
1880 | C_ARGS: term->dpy, window, parent, x, y |
1726 | |
1881 | |
1727 | void |
1882 | void |
1728 | XMapWindow (rxvt_term *term, Window window) |
1883 | XMapWindow (rxvt_term *term, Window window) |
1729 | C_ARGS: term->display->display, window |
1884 | C_ARGS: term->dpy, window |
1730 | |
1885 | |
1731 | void |
1886 | void |
1732 | XUnmapWindow (rxvt_term *term, Window window) |
1887 | XUnmapWindow (rxvt_term *term, Window window) |
1733 | C_ARGS: term->display->display, window |
1888 | C_ARGS: term->dpy, window |
1734 | |
1889 | |
1735 | void |
1890 | void |
1736 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1891 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1737 | C_ARGS: term->display->display, (Window)window, x, y, width, height |
1892 | C_ARGS: term->dpy, window, x, y, width, height |
|
|
1893 | |
|
|
1894 | void |
|
|
1895 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
|
|
1896 | CODE: |
|
|
1897 | { |
|
|
1898 | XWindowAttributes attr; |
|
|
1899 | XGetWindowAttributes (THIS->dpy, window, &attr); |
|
|
1900 | XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events); |
|
|
1901 | } |
1738 | |
1902 | |
1739 | void |
1903 | void |
1740 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1904 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1741 | PPCODE: |
1905 | PPCODE: |
1742 | { |
1906 | { |
1743 | int dx, dy; |
1907 | int dx, dy; |
1744 | Window child; |
1908 | Window child; |
1745 | |
1909 | |
1746 | if (XTranslateCoordinates (THIS->display->display, src, dst, x, y, &dx, &dy, &child)) |
1910 | if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child)) |
1747 | { |
1911 | { |
1748 | EXTEND (SP, 3); |
1912 | EXTEND (SP, 3); |
1749 | PUSHs (newSViv (dx)); |
1913 | PUSHs (newSViv (dx)); |
1750 | PUSHs (newSViv (dy)); |
1914 | PUSHs (newSViv (dy)); |
1751 | PUSHs (newSVuv (child)); |
1915 | PUSHs (newSVuv (child)); |