… | |
… | |
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) |
… | |
… | |
269 | }; |
268 | }; |
270 | |
269 | |
271 | 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) |
272 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) |
271 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) |
273 | { |
272 | { |
|
|
273 | if (w < 0) w = 0; |
|
|
274 | if (h < 0) h = 0; |
|
|
275 | |
274 | if (border == 2) |
276 | if (border == 2) |
275 | { |
277 | { |
276 | w += 2; |
278 | w += 2; |
277 | h += 2; |
279 | h += 2; |
278 | } |
280 | } |
… | |
… | |
356 | |
358 | |
357 | int i; |
359 | int i; |
358 | |
360 | |
359 | for (i = AvFILL (overlay_av); i >= 0; i--) |
361 | for (i = AvFILL (overlay_av); i >= 0; i--) |
360 | if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this) |
362 | if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this) |
361 | { |
|
|
362 | av_delete (overlay_av, i, G_DISCARD); |
|
|
363 | break; |
363 | break; |
364 | } |
|
|
365 | |
364 | |
366 | for (; i < AvFILL (overlay_av); i++) |
365 | for (; i < AvFILL (overlay_av); i++) |
367 | av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0))); |
366 | av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0))); |
368 | |
367 | |
369 | av_pop (overlay_av); |
368 | av_pop (overlay_av); |
… | |
… | |
494 | static void |
493 | static void |
495 | ungrab (rxvt_term *THIS) |
494 | ungrab (rxvt_term *THIS) |
496 | { |
495 | { |
497 | if (THIS->perl.grabtime) |
496 | if (THIS->perl.grabtime) |
498 | { |
497 | { |
499 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
498 | XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime); |
500 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
499 | XUngrabPointer (THIS->dpy, THIS->perl.grabtime); |
501 | THIS->perl.grabtime = 0; |
500 | THIS->perl.grabtime = 0; |
502 | } |
501 | } |
503 | } |
502 | } |
504 | |
503 | |
505 | bool |
504 | bool |
… | |
… | |
558 | case DT_STR_LEN: |
557 | case DT_STR_LEN: |
559 | { |
558 | { |
560 | char *str = va_arg (ap, char *); |
559 | char *str = va_arg (ap, char *); |
561 | int len = va_arg (ap, int); |
560 | int len = va_arg (ap, int); |
562 | |
561 | |
563 | printf ("pushing str %p:%d\n", str,len);//D |
|
|
564 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
562 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
565 | } |
563 | } |
566 | break; |
564 | break; |
567 | |
565 | |
568 | case DT_WCS_LEN: |
566 | case DT_WCS_LEN: |
… | |
… | |
764 | # include "optinc.h" |
762 | # include "optinc.h" |
765 | # undef nodef |
763 | # undef nodef |
766 | # undef def |
764 | # undef def |
767 | |
765 | |
768 | HV *stash = gv_stashpv ("urxvt", 1); |
766 | HV *stash = gv_stashpv ("urxvt", 1); |
769 | struct { |
767 | static const struct { |
770 | const char *name; |
768 | const char *name; |
771 | IV iv; |
769 | IV iv; |
772 | } *civ, const_iv[] = { |
770 | } *civ, const_iv[] = { |
773 | # define const_iv(name) { # name, (IV)name } |
771 | # define const_iv(name) { # name, (IV)name } |
774 | const_iv (DEFAULT_RSTYLE), |
772 | const_iv (DEFAULT_RSTYLE), |
… | |
… | |
792 | const_iv (Button2Mask), |
790 | const_iv (Button2Mask), |
793 | const_iv (Button3Mask), |
791 | const_iv (Button3Mask), |
794 | const_iv (Button4Mask), |
792 | const_iv (Button4Mask), |
795 | const_iv (Button5Mask), |
793 | const_iv (Button5Mask), |
796 | const_iv (AnyModifier), |
794 | const_iv (AnyModifier), |
|
|
795 | |
|
|
796 | const_iv (NoSymbol), |
|
|
797 | const_iv (GrabModeSync), |
|
|
798 | const_iv (GrabModeAsync), |
797 | |
799 | |
798 | const_iv (EVENT_NONE), |
800 | const_iv (EVENT_NONE), |
799 | const_iv (EVENT_READ), |
801 | const_iv (EVENT_READ), |
800 | const_iv (EVENT_WRITE), |
802 | const_iv (EVENT_WRITE), |
801 | |
803 | |
… | |
… | |
884 | const_iv (XIMDontChange), |
886 | const_iv (XIMDontChange), |
885 | # endif |
887 | # endif |
886 | # endif |
888 | # endif |
887 | }; |
889 | }; |
888 | |
890 | |
889 | 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; ) |
890 | civ-- > const_iv; ) |
|
|
891 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
892 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
892 | } |
893 | } |
893 | |
894 | |
894 | void |
895 | void |
895 | warn (const char *msg) |
896 | warn (const char *msg) |
… | |
… | |
926 | RETVAL |
927 | RETVAL |
927 | |
928 | |
928 | int |
929 | int |
929 | SET_FGCOLOR (int rend, int new_color) |
930 | SET_FGCOLOR (int rend, int new_color) |
930 | CODE: |
931 | CODE: |
931 | RETVAL = SET_FGCOLOR (rend, new_color); |
932 | RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
932 | OUTPUT: |
933 | OUTPUT: |
933 | RETVAL |
934 | RETVAL |
934 | |
935 | |
935 | int |
936 | int |
936 | SET_BGCOLOR (int rend, int new_color) |
937 | SET_BGCOLOR (int rend, int new_color) |
937 | CODE: |
938 | CODE: |
938 | RETVAL = SET_BGCOLOR (rend, new_color); |
939 | RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
939 | OUTPUT: |
940 | OUTPUT: |
940 | RETVAL |
941 | RETVAL |
941 | |
942 | |
942 | int |
943 | int |
943 | GET_CUSTOM (int rend) |
944 | GET_CUSTOM (int rend) |
… | |
… | |
957 | | ((new_value << RS_customShift) & RS_customMask); |
958 | | ((new_value << RS_customShift) & RS_customMask); |
958 | } |
959 | } |
959 | OUTPUT: |
960 | OUTPUT: |
960 | RETVAL |
961 | RETVAL |
961 | |
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 | |
962 | MODULE = urxvt PACKAGE = urxvt::term |
974 | MODULE = urxvt PACKAGE = urxvt::term |
963 | |
975 | |
964 | SV * |
976 | SV * |
965 | _new (...) |
977 | _new (AV *env, AV *arg) |
966 | CODE: |
978 | CODE: |
967 | { |
979 | { |
968 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
969 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
970 | |
|
|
971 | rxvt_term *term = new rxvt_term; |
980 | rxvt_term *term = new rxvt_term; |
972 | |
981 | |
973 | stringvec *argv = new stringvec; |
982 | stringvec *argv = new stringvec; |
974 | stringvec *envv = new stringvec; |
983 | stringvec *envv = new stringvec; |
975 | |
984 | |
976 | for (int i = 1; i < items; i++) |
985 | for (int i = 0; i <= AvFILL (arg); i++) |
977 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
986 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
978 | |
987 | |
979 | AV *env = (AV *)SvRV (ST (0)); |
|
|
980 | for (int i = AvFILL (env) + 1; i--; ) |
988 | for (int i = AvFILL (env) + 1; i--; ) |
981 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
989 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
982 | |
990 | |
983 | envv->push_back (0); |
991 | envv->push_back (0); |
984 | |
992 | |
… | |
… | |
1011 | void |
1019 | void |
1012 | rxvt_term::set_should_invoke (int htype, int inc) |
1020 | rxvt_term::set_should_invoke (int htype, int inc) |
1013 | CODE: |
1021 | CODE: |
1014 | THIS->perl.should_invoke [htype] += inc; |
1022 | THIS->perl.should_invoke [htype] += inc; |
1015 | |
1023 | |
1016 | void |
1024 | int |
1017 | rxvt_term::grab_button (int button, U32 modifiers) |
1025 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1018 | CODE: |
1026 | CODE: |
1019 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1027 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1020 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1028 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1021 | 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); |
1022 | |
1053 | |
1023 | bool |
1054 | bool |
1024 | rxvt_term::grab (Time eventtime, int sync = 0) |
1055 | rxvt_term::grab (Time eventtime, int sync = 0) |
1025 | CODE: |
1056 | CODE: |
1026 | { |
1057 | { |
1027 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1058 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1028 | |
1059 | |
1029 | THIS->perl.grabtime = 0; |
1060 | THIS->perl.grabtime = 0; |
1030 | |
1061 | |
1031 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
1062 | if (!XGrabPointer (THIS->dpy, THIS->vt, 0, |
1032 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1063 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1033 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1064 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1034 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
1065 | if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime)) |
1035 | THIS->perl.grabtime = eventtime; |
1066 | THIS->perl.grabtime = eventtime; |
1036 | else |
1067 | else |
1037 | XUngrabPointer (THIS->display->display, eventtime); |
1068 | XUngrabPointer (THIS->dpy, eventtime); |
1038 | |
1069 | |
1039 | RETVAL = !!THIS->perl.grabtime; |
1070 | RETVAL = !!THIS->perl.grabtime; |
1040 | } |
1071 | } |
1041 | OUTPUT: |
1072 | OUTPUT: |
1042 | RETVAL |
1073 | RETVAL |
1043 | |
1074 | |
1044 | void |
1075 | void |
1045 | rxvt_term::allow_events_async () |
1076 | rxvt_term::allow_events_async () |
1046 | CODE: |
1077 | CODE: |
1047 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
1078 | XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime); |
1048 | |
1079 | |
1049 | void |
1080 | void |
1050 | rxvt_term::allow_events_sync () |
1081 | rxvt_term::allow_events_sync () |
1051 | CODE: |
1082 | CODE: |
1052 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
1083 | XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime); |
1053 | |
1084 | |
1054 | void |
1085 | void |
1055 | rxvt_term::allow_events_replay () |
1086 | rxvt_term::allow_events_replay () |
1056 | CODE: |
1087 | CODE: |
1057 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
1088 | XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime); |
1058 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
1089 | XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime); |
1059 | |
1090 | |
1060 | void |
1091 | void |
1061 | rxvt_term::ungrab () |
1092 | rxvt_term::ungrab () |
1062 | CODE: |
1093 | CODE: |
1063 | 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 |
1064 | |
1119 | |
1065 | int |
1120 | int |
1066 | rxvt_term::strwidth (SV *str) |
1121 | rxvt_term::strwidth (SV *str) |
1067 | CODE: |
1122 | CODE: |
1068 | { |
1123 | { |
1069 | wchar_t *wstr = sv2wcs (str); |
1124 | wchar_t *wstr = sv2wcs (str); |
1070 | |
1125 | |
1071 | rxvt_push_locale (THIS->locale); |
1126 | rxvt_push_locale (THIS->locale); |
1072 | RETVAL = wcswidth (wstr, wcslen (wstr)); |
1127 | RETVAL = 0; |
|
|
1128 | for (wchar_t *wc = wstr; *wc; wc++) |
|
|
1129 | { |
|
|
1130 | int w = WCWIDTH (*wc); |
|
|
1131 | |
|
|
1132 | if (w) |
|
|
1133 | RETVAL += min (w, 1); |
|
|
1134 | } |
1073 | rxvt_pop_locale (); |
1135 | rxvt_pop_locale (); |
1074 | |
1136 | |
1075 | free (wstr); |
1137 | free (wstr); |
1076 | } |
1138 | } |
1077 | OUTPUT: |
1139 | OUTPUT: |
… | |
… | |
1107 | rxvt_pop_locale (); |
1169 | rxvt_pop_locale (); |
1108 | |
1170 | |
1109 | RETVAL = wcs2sv (wstr); |
1171 | RETVAL = wcs2sv (wstr); |
1110 | free (wstr); |
1172 | free (wstr); |
1111 | } |
1173 | } |
|
|
1174 | OUTPUT: |
|
|
1175 | RETVAL |
|
|
1176 | |
|
|
1177 | char * |
|
|
1178 | rxvt_term::locale () |
|
|
1179 | CODE: |
|
|
1180 | RETVAL = THIS->locale; |
1112 | OUTPUT: |
1181 | OUTPUT: |
1113 | RETVAL |
1182 | RETVAL |
1114 | |
1183 | |
1115 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1184 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1116 | |
1185 | |
… | |
… | |
1186 | } |
1255 | } |
1187 | OUTPUT: |
1256 | OUTPUT: |
1188 | RETVAL |
1257 | RETVAL |
1189 | |
1258 | |
1190 | SV * |
1259 | SV * |
1191 | rxvt_term::_env () |
1260 | rxvt_term::envv () |
|
|
1261 | ALIAS: |
|
|
1262 | argv = 1 |
1192 | CODE: |
1263 | PPCODE: |
1193 | { |
1264 | { |
1194 | if (THIS->envv) |
1265 | stringvec *vec = ix ? THIS->argv : THIS->envv; |
1195 | { |
|
|
1196 | AV *av = newAV (); |
|
|
1197 | |
1266 | |
|
|
1267 | EXTEND (SP, vec->size ()); |
|
|
1268 | |
1198 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
1269 | for (char **i = vec->begin (); i != vec->end (); ++i) |
1199 | if (*i) |
1270 | if (*i) |
1200 | av_push (av, newSVpv (*i, 0)); |
1271 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1201 | |
|
|
1202 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1203 | } |
|
|
1204 | else |
|
|
1205 | RETVAL = &PL_sv_undef; |
|
|
1206 | } |
1272 | } |
1207 | OUTPUT: |
|
|
1208 | RETVAL |
|
|
1209 | |
1273 | |
1210 | int |
1274 | int |
1211 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1275 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1212 | CODE: |
1276 | CODE: |
1213 | RETVAL = THIS->pty_ev.events; |
1277 | RETVAL = THIS->pty_ev.events; |
… | |
… | |
1267 | void |
1331 | void |
1268 | rxvt_term::focus_in () |
1332 | rxvt_term::focus_in () |
1269 | |
1333 | |
1270 | void |
1334 | void |
1271 | rxvt_term::focus_out () |
1335 | rxvt_term::focus_out () |
|
|
1336 | |
|
|
1337 | void |
|
|
1338 | rxvt_term::key_press (unsigned int state, unsigned int keycode, Time time = CurrentTime) |
|
|
1339 | ALIAS: |
|
|
1340 | key_release = 1 |
|
|
1341 | CODE: |
|
|
1342 | { |
|
|
1343 | XKeyEvent xkey; |
|
|
1344 | |
|
|
1345 | memset (&xkey, 0, sizeof (xkey)); |
|
|
1346 | |
|
|
1347 | xkey.time = time; |
|
|
1348 | xkey.state = state; |
|
|
1349 | xkey.keycode = keycode; |
|
|
1350 | |
|
|
1351 | xkey.type = ix ? KeyRelease : KeyPress; |
|
|
1352 | xkey.display = THIS->dpy; |
|
|
1353 | xkey.window = THIS->vt; |
|
|
1354 | xkey.root = THIS->display->root; |
|
|
1355 | xkey.subwindow = THIS->vt; |
|
|
1356 | |
|
|
1357 | if (ix) |
|
|
1358 | THIS->key_release (xkey); |
|
|
1359 | else |
|
|
1360 | THIS->key_press (xkey); |
|
|
1361 | } |
1272 | |
1362 | |
1273 | void |
1363 | void |
1274 | rxvt_term::want_refresh () |
1364 | rxvt_term::want_refresh () |
1275 | CODE: |
1365 | CODE: |
1276 | THIS->want_refresh = 1; |
1366 | THIS->want_refresh = 1; |
… | |
… | |
1469 | |
1559 | |
1470 | void |
1560 | void |
1471 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1561 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1472 | PPCODE: |
1562 | PPCODE: |
1473 | { |
1563 | { |
1474 | struct resval { const char *name; int value; } rslist [] = { |
1564 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1475 | # define def(name) { # name, Rs_ ## name }, |
1565 | # define def(name) { # name, Rs_ ## name }, |
1476 | # define reserve(name,count) |
1566 | # define reserve(name,count) |
1477 | # include "rsinc.h" |
1567 | # include "rsinc.h" |
1478 | # undef def |
1568 | # undef def |
1479 | # undef reserve |
1569 | # undef reserve |
1480 | }; |
1570 | }; |
1481 | |
1571 | |
1482 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1572 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1483 | |
1573 | |
1484 | do { |
1574 | do { |
1485 | if (rs-- == rslist) |
1575 | if (rs-- == rslist) |
1486 | croak ("no such resource '%s', requested", name); |
1576 | croak ("no such resource '%s', requested", name); |
1487 | } while (strcmp (name, rs->name)); |
1577 | } while (strcmp (name, rs->name)); |
… | |
… | |
1712 | void |
1802 | void |
1713 | rxvt_term::XListProperties (Window window) |
1803 | rxvt_term::XListProperties (Window window) |
1714 | PPCODE: |
1804 | PPCODE: |
1715 | { |
1805 | { |
1716 | int count; |
1806 | int count; |
1717 | Atom *props = XListProperties (THIS->display->display, window, &count); |
1807 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1718 | |
1808 | |
1719 | EXTEND (SP, count); |
1809 | EXTEND (SP, count); |
1720 | while (count--) |
1810 | while (count--) |
1721 | PUSHs (newSVuv ((U32)props [count])); |
1811 | PUSHs (newSVuv ((U32)props [count])); |
1722 | |
1812 | |
… | |
… | |
1731 | int format; |
1821 | int format; |
1732 | unsigned long nitems; |
1822 | unsigned long nitems; |
1733 | unsigned long bytes_after; |
1823 | unsigned long bytes_after; |
1734 | unsigned char *prop; |
1824 | unsigned char *prop; |
1735 | |
1825 | |
1736 | XGetWindowProperty (THIS->display->display, window, property, |
1826 | XGetWindowProperty (THIS->dpy, window, property, |
1737 | 0, 1<<24, 0, AnyPropertyType, |
1827 | 0, 1<<24, 0, AnyPropertyType, |
1738 | &type, &format, &nitems, &bytes_after, &prop); |
1828 | &type, &format, &nitems, &bytes_after, &prop); |
1739 | |
1829 | |
1740 | if (type != None) |
1830 | if (type != None) |
1741 | { |
1831 | { |
… | |
… | |
1760 | |
1850 | |
1761 | int elemsize = format == 16 ? sizeof (short) |
1851 | int elemsize = format == 16 ? sizeof (short) |
1762 | : format == 32 ? sizeof (long) |
1852 | : format == 32 ? sizeof (long) |
1763 | : 1; |
1853 | : 1; |
1764 | |
1854 | |
1765 | XChangeProperty (THIS->display->display, window, property, |
1855 | XChangeProperty (THIS->dpy, window, property, |
1766 | type, format, PropModeReplace, |
1856 | type, format, PropModeReplace, |
1767 | (unsigned char *)data_, len / elemsize); |
1857 | (unsigned char *)data_, len / elemsize); |
1768 | XSync (THIS->display->display, 0); |
|
|
1769 | } |
1858 | } |
1770 | |
1859 | |
1771 | Atom |
1860 | Atom |
1772 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1861 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1773 | C_ARGS: term->display->display, atom_name, only_if_exists |
1862 | C_ARGS: term->dpy, atom_name, only_if_exists |
1774 | |
1863 | |
1775 | char * |
1864 | char * |
1776 | XGetAtomName (rxvt_term *term, Atom atom) |
1865 | XGetAtomName (rxvt_term *term, Atom atom) |
1777 | C_ARGS: term->display->display, atom |
1866 | C_ARGS: term->dpy, atom |
1778 | CLEANUP: |
1867 | CLEANUP: |
1779 | XFree (RETVAL); |
1868 | XFree (RETVAL); |
1780 | |
1869 | |
1781 | void |
1870 | void |
1782 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1871 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1783 | C_ARGS: term->display->display, window, property |
1872 | C_ARGS: term->dpy, window, property |
1784 | |
1873 | |
1785 | Window |
1874 | Window |
1786 | rxvt_term::DefaultRootWindow () |
1875 | rxvt_term::DefaultRootWindow () |
1787 | CODE: |
1876 | CODE: |
1788 | RETVAL = THIS->display->root; |
1877 | RETVAL = THIS->display->root; |
… | |
… | |
1791 | |
1880 | |
1792 | #if 0 |
1881 | #if 0 |
1793 | |
1882 | |
1794 | Window |
1883 | Window |
1795 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1884 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1796 | C_ARGS: term->display->display, (Window)parent, |
1885 | C_ARGS: term->dpy, (Window)parent, |
1797 | x, y, width, height, 0, |
1886 | x, y, width, height, 0, |
1798 | term->pix_colors_focused[Color_border], |
1887 | term->pix_colors_focused[Color_border], |
1799 | term->pix_colors_focused[Color_border] |
1888 | term->pix_colors_focused[Color_border] |
1800 | |
1889 | |
1801 | #endif |
1890 | #endif |
1802 | |
1891 | |
1803 | void |
1892 | void |
1804 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1893 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1805 | C_ARGS: term->display->display, window, parent, x, y |
1894 | C_ARGS: term->dpy, window, parent, x, y |
1806 | |
1895 | |
1807 | void |
1896 | void |
1808 | XMapWindow (rxvt_term *term, Window window) |
1897 | XMapWindow (rxvt_term *term, Window window) |
1809 | C_ARGS: term->display->display, window |
1898 | C_ARGS: term->dpy, window |
1810 | |
1899 | |
1811 | void |
1900 | void |
1812 | XUnmapWindow (rxvt_term *term, Window window) |
1901 | XUnmapWindow (rxvt_term *term, Window window) |
1813 | C_ARGS: term->display->display, window |
1902 | C_ARGS: term->dpy, window |
1814 | |
1903 | |
1815 | void |
1904 | void |
1816 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1905 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1817 | C_ARGS: term->display->display, window, x, y, width, height |
1906 | C_ARGS: term->dpy, window, x, y, width, height |
1818 | |
1907 | |
1819 | void |
1908 | void |
1820 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1909 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1821 | CODE: |
1910 | CODE: |
1822 | { |
1911 | { |
1823 | XWindowAttributes attr; |
1912 | XWindowAttributes attr; |
1824 | XGetWindowAttributes (THIS->display->display, window, &attr); |
1913 | XGetWindowAttributes (THIS->dpy, window, &attr); |
1825 | XSelectInput (THIS->display->display, window, attr.your_event_mask | add_events & ~del_events); |
1914 | XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events); |
1826 | } |
1915 | } |
1827 | |
1916 | |
1828 | void |
1917 | void |
1829 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1918 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1830 | PPCODE: |
1919 | PPCODE: |
1831 | { |
1920 | { |
1832 | int dx, dy; |
1921 | int dx, dy; |
1833 | Window child; |
1922 | Window child; |
1834 | |
1923 | |
1835 | if (XTranslateCoordinates (THIS->display->display, src, dst, x, y, &dx, &dy, &child)) |
1924 | if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child)) |
1836 | { |
1925 | { |
1837 | EXTEND (SP, 3); |
1926 | EXTEND (SP, 3); |
1838 | PUSHs (newSViv (dx)); |
1927 | PUSHs (newSViv (dx)); |
1839 | PUSHs (newSViv (dy)); |
1928 | PUSHs (newSViv (dy)); |
1840 | PUSHs (newSVuv (child)); |
1929 | PUSHs (newSVuv (child)); |