… | |
… | |
113 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
113 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
114 | |
114 | |
115 | return (long)mg->mg_ptr; |
115 | return (long)mg->mg_ptr; |
116 | } |
116 | } |
117 | |
117 | |
118 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
118 | #define newSVterm(term) SvREFCNT_inc ((SV *)(term)->perl.self) |
119 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
119 | #define SvTERM(sv) (rxvt_term *)SvPTR ((sv), "urxvt::term") |
120 | |
120 | |
121 | ///////////////////////////////////////////////////////////////////////////// |
121 | ///////////////////////////////////////////////////////////////////////////// |
122 | |
122 | |
123 | #define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, "urxvt::watcher") |
123 | #define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, "urxvt::watcher") |
124 | |
124 | |
… | |
… | |
171 | |
171 | |
172 | if (SvTRUE (ERRSV)) |
172 | if (SvTRUE (ERRSV)) |
173 | rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); |
173 | rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); |
174 | } |
174 | } |
175 | |
175 | |
176 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
176 | #define newSVtimer(timer) new_ref ((timer)->self, "urxvt::timer") |
177 | #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR (sv, "urxvt::timer") |
177 | #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), "urxvt::timer") |
178 | |
178 | |
179 | struct timer : perl_watcher, time_watcher |
179 | struct timer : perl_watcher, time_watcher |
180 | { |
180 | { |
181 | tstamp interval; |
181 | tstamp interval; |
182 | |
182 | |
… | |
… | |
192 | |
192 | |
193 | invoke ("urxvt::timer", newSVtimer (this)); |
193 | invoke ("urxvt::timer", newSVtimer (this)); |
194 | } |
194 | } |
195 | }; |
195 | }; |
196 | |
196 | |
197 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
197 | #define newSViow(iow) new_ref ((iow)->self, "urxvt::iow") |
198 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR (sv, "urxvt::iow") |
198 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), "urxvt::iow") |
199 | |
199 | |
200 | struct iow : perl_watcher, io_watcher |
200 | struct iow : perl_watcher, io_watcher |
201 | { |
201 | { |
202 | iow () |
202 | iow () |
203 | : io_watcher (this, &iow::execute) |
203 | : io_watcher (this, &iow::execute) |
… | |
… | |
208 | { |
208 | { |
209 | invoke ("urxvt::iow", newSViow (this), revents); |
209 | invoke ("urxvt::iow", newSViow (this), revents); |
210 | } |
210 | } |
211 | }; |
211 | }; |
212 | |
212 | |
213 | #define newSViw(iw) new_ref (iw->self, "urxvt::iw") |
213 | #define newSViw(iw) new_ref ((iw)->self, "urxvt::iw") |
214 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR (sv, "urxvt::iw") |
214 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), "urxvt::iw") |
215 | |
215 | |
216 | struct iw : perl_watcher, idle_watcher |
216 | struct iw : perl_watcher, idle_watcher |
217 | { |
217 | { |
218 | iw () |
218 | iw () |
219 | : idle_watcher (this, &iw::execute) |
219 | : idle_watcher (this, &iw::execute) |
… | |
… | |
224 | { |
224 | { |
225 | invoke ("urxvt::iw", newSViw (this)); |
225 | invoke ("urxvt::iw", newSViw (this)); |
226 | } |
226 | } |
227 | }; |
227 | }; |
228 | |
228 | |
229 | #define newSVpw(pw) new_ref (pw->self, "urxvt::pw") |
229 | #define newSVpw(pw) new_ref ((pw)->self, "urxvt::pw") |
230 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR (sv, "urxvt::pw") |
230 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), "urxvt::pw") |
231 | |
231 | |
232 | struct pw : perl_watcher, child_watcher |
232 | struct pw : perl_watcher, child_watcher |
233 | { |
233 | { |
234 | pw () |
234 | pw () |
235 | : child_watcher (this, &pw::execute) |
235 | : child_watcher (this, &pw::execute) |
… | |
… | |
494 | static void |
494 | static void |
495 | ungrab (rxvt_term *THIS) |
495 | ungrab (rxvt_term *THIS) |
496 | { |
496 | { |
497 | if (THIS->perl.grabtime) |
497 | if (THIS->perl.grabtime) |
498 | { |
498 | { |
499 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
499 | XUngrabKeyboard (THIS->xdisp, THIS->perl.grabtime); |
500 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
500 | XUngrabPointer (THIS->xdisp, THIS->perl.grabtime); |
501 | THIS->perl.grabtime = 0; |
501 | THIS->perl.grabtime = 0; |
502 | } |
502 | } |
503 | } |
503 | } |
504 | |
504 | |
505 | bool |
505 | bool |
… | |
… | |
558 | case DT_STR_LEN: |
558 | case DT_STR_LEN: |
559 | { |
559 | { |
560 | char *str = va_arg (ap, char *); |
560 | char *str = va_arg (ap, char *); |
561 | int len = va_arg (ap, int); |
561 | int len = va_arg (ap, int); |
562 | |
562 | |
563 | printf ("pushing str %p:%d\n", str,len);//D |
|
|
564 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
563 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
565 | } |
564 | } |
566 | break; |
565 | break; |
567 | |
566 | |
568 | case DT_WCS_LEN: |
567 | case DT_WCS_LEN: |
… | |
… | |
957 | | ((new_value << RS_customShift) & RS_customMask); |
956 | | ((new_value << RS_customShift) & RS_customMask); |
958 | } |
957 | } |
959 | OUTPUT: |
958 | OUTPUT: |
960 | RETVAL |
959 | RETVAL |
961 | |
960 | |
|
|
961 | void |
|
|
962 | termlist () |
|
|
963 | PPCODE: |
|
|
964 | { |
|
|
965 | EXTEND (SP, rxvt_term::termlist.size ()); |
|
|
966 | |
|
|
967 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
968 | if ((*t)->perl.self) |
|
|
969 | PUSHs (sv_2mortal (newSVterm (*t))); |
|
|
970 | } |
|
|
971 | |
962 | MODULE = urxvt PACKAGE = urxvt::term |
972 | MODULE = urxvt PACKAGE = urxvt::term |
963 | |
973 | |
964 | SV * |
974 | SV * |
965 | _new (...) |
975 | _new (AV *env, AV *arg) |
966 | CODE: |
976 | CODE: |
967 | { |
977 | { |
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; |
978 | rxvt_term *term = new rxvt_term; |
972 | |
979 | |
973 | stringvec *argv = new stringvec; |
980 | stringvec *argv = new stringvec; |
974 | stringvec *envv = new stringvec; |
981 | stringvec *envv = new stringvec; |
975 | |
982 | |
976 | for (int i = 1; i < items; i++) |
983 | for (int i = 0; i <= AvFILL (arg); i++) |
977 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
984 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
978 | |
985 | |
979 | AV *env = (AV *)SvRV (ST (0)); |
|
|
980 | for (int i = AvFILL (env) + 1; i--; ) |
986 | for (int i = AvFILL (env) + 1; i--; ) |
981 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
987 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
982 | |
988 | |
983 | envv->push_back (0); |
989 | envv->push_back (0); |
984 | |
990 | |
… | |
… | |
1012 | rxvt_term::set_should_invoke (int htype, int inc) |
1018 | rxvt_term::set_should_invoke (int htype, int inc) |
1013 | CODE: |
1019 | CODE: |
1014 | THIS->perl.should_invoke [htype] += inc; |
1020 | THIS->perl.should_invoke [htype] += inc; |
1015 | |
1021 | |
1016 | void |
1022 | void |
1017 | rxvt_term::grab_button (int button, U32 modifiers) |
1023 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1018 | CODE: |
1024 | CODE: |
1019 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1025 | XGrabButton (THIS->xdisp, button, modifiers, window, 1, |
1020 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1026 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1021 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
1027 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
1022 | |
1028 | |
|
|
1029 | void |
|
|
1030 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
|
|
1031 | CODE: |
|
|
1032 | XUngrabButton (THIS->xdisp, button, modifiers, window); |
|
|
1033 | |
|
|
1034 | #if 0 |
|
|
1035 | |
|
|
1036 | void |
|
|
1037 | XGrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) |
|
|
1038 | C_ARGS: |
|
|
1039 | THIS->xdisp, keycode, modifiers, window, 1, |
|
|
1040 | GrabModeSync, GrabModeSync |
|
|
1041 | |
|
|
1042 | void |
|
|
1043 | XUngrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) |
|
|
1044 | C_ARGS: THIS->xdisp, keycode, modifiers, window |
|
|
1045 | |
|
|
1046 | #endif |
|
|
1047 | |
1023 | bool |
1048 | bool |
1024 | rxvt_term::grab (Time eventtime, int sync = 0) |
1049 | rxvt_term::grab (Time eventtime, int sync = 0) |
1025 | CODE: |
1050 | CODE: |
1026 | { |
1051 | { |
1027 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1052 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1028 | |
1053 | |
1029 | THIS->perl.grabtime = 0; |
1054 | THIS->perl.grabtime = 0; |
1030 | |
1055 | |
1031 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
1056 | if (!XGrabPointer (THIS->xdisp, THIS->vt, 0, |
1032 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1057 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1033 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1058 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1034 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
1059 | if (!XGrabKeyboard (THIS->xdisp, THIS->vt, 0, mode, mode, eventtime)) |
1035 | THIS->perl.grabtime = eventtime; |
1060 | THIS->perl.grabtime = eventtime; |
1036 | else |
1061 | else |
1037 | XUngrabPointer (THIS->display->display, eventtime); |
1062 | XUngrabPointer (THIS->xdisp, eventtime); |
1038 | |
1063 | |
1039 | RETVAL = !!THIS->perl.grabtime; |
1064 | RETVAL = !!THIS->perl.grabtime; |
1040 | } |
1065 | } |
1041 | OUTPUT: |
1066 | OUTPUT: |
1042 | RETVAL |
1067 | RETVAL |
1043 | |
1068 | |
1044 | void |
1069 | void |
1045 | rxvt_term::allow_events_async () |
1070 | rxvt_term::allow_events_async () |
1046 | CODE: |
1071 | CODE: |
1047 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
1072 | XAllowEvents (THIS->xdisp, AsyncBoth, THIS->perl.grabtime); |
1048 | |
1073 | |
1049 | void |
1074 | void |
1050 | rxvt_term::allow_events_sync () |
1075 | rxvt_term::allow_events_sync () |
1051 | CODE: |
1076 | CODE: |
1052 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
1077 | XAllowEvents (THIS->xdisp, SyncBoth, THIS->perl.grabtime); |
1053 | |
1078 | |
1054 | void |
1079 | void |
1055 | rxvt_term::allow_events_replay () |
1080 | rxvt_term::allow_events_replay () |
1056 | CODE: |
1081 | CODE: |
1057 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
1082 | XAllowEvents (THIS->xdisp, ReplayPointer, THIS->perl.grabtime); |
1058 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
1083 | XAllowEvents (THIS->xdisp, ReplayKeyboard, THIS->perl.grabtime); |
1059 | |
1084 | |
1060 | void |
1085 | void |
1061 | rxvt_term::ungrab () |
1086 | rxvt_term::ungrab () |
1062 | CODE: |
1087 | CODE: |
1063 | ungrab (THIS); |
1088 | ungrab (THIS); |
… | |
… | |
1712 | void |
1737 | void |
1713 | rxvt_term::XListProperties (Window window) |
1738 | rxvt_term::XListProperties (Window window) |
1714 | PPCODE: |
1739 | PPCODE: |
1715 | { |
1740 | { |
1716 | int count; |
1741 | int count; |
1717 | Atom *props = XListProperties (THIS->display->display, window, &count); |
1742 | Atom *props = XListProperties (THIS->xdisp, window, &count); |
1718 | |
1743 | |
1719 | EXTEND (SP, count); |
1744 | EXTEND (SP, count); |
1720 | while (count--) |
1745 | while (count--) |
1721 | PUSHs (newSVuv ((U32)props [count])); |
1746 | PUSHs (newSVuv ((U32)props [count])); |
1722 | |
1747 | |
… | |
… | |
1731 | int format; |
1756 | int format; |
1732 | unsigned long nitems; |
1757 | unsigned long nitems; |
1733 | unsigned long bytes_after; |
1758 | unsigned long bytes_after; |
1734 | unsigned char *prop; |
1759 | unsigned char *prop; |
1735 | |
1760 | |
1736 | XGetWindowProperty (THIS->display->display, window, property, |
1761 | XGetWindowProperty (THIS->xdisp, window, property, |
1737 | 0, 1<<24, 0, AnyPropertyType, |
1762 | 0, 1<<24, 0, AnyPropertyType, |
1738 | &type, &format, &nitems, &bytes_after, &prop); |
1763 | &type, &format, &nitems, &bytes_after, &prop); |
1739 | |
1764 | |
1740 | if (type != None) |
1765 | if (type != None) |
1741 | { |
1766 | { |
… | |
… | |
1760 | |
1785 | |
1761 | int elemsize = format == 16 ? sizeof (short) |
1786 | int elemsize = format == 16 ? sizeof (short) |
1762 | : format == 32 ? sizeof (long) |
1787 | : format == 32 ? sizeof (long) |
1763 | : 1; |
1788 | : 1; |
1764 | |
1789 | |
1765 | XChangeProperty (THIS->display->display, window, property, |
1790 | XChangeProperty (THIS->xdisp, window, property, |
1766 | type, format, PropModeReplace, |
1791 | type, format, PropModeReplace, |
1767 | (unsigned char *)data_, len / elemsize); |
1792 | (unsigned char *)data_, len / elemsize); |
1768 | XSync (THIS->display->display, 0); |
1793 | XSync (THIS->xdisp, 0); |
1769 | } |
1794 | } |
1770 | |
1795 | |
1771 | Atom |
1796 | Atom |
1772 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1797 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1773 | C_ARGS: term->display->display, atom_name, only_if_exists |
1798 | C_ARGS: term->xdisp, atom_name, only_if_exists |
1774 | |
1799 | |
1775 | char * |
1800 | char * |
1776 | XGetAtomName (rxvt_term *term, Atom atom) |
1801 | XGetAtomName (rxvt_term *term, Atom atom) |
1777 | C_ARGS: term->display->display, atom |
1802 | C_ARGS: term->xdisp, atom |
1778 | CLEANUP: |
1803 | CLEANUP: |
1779 | XFree (RETVAL); |
1804 | XFree (RETVAL); |
1780 | |
1805 | |
1781 | void |
1806 | void |
1782 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1807 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1783 | C_ARGS: term->display->display, window, property |
1808 | C_ARGS: term->xdisp, window, property |
1784 | |
1809 | |
1785 | Window |
1810 | Window |
1786 | rxvt_term::DefaultRootWindow () |
1811 | rxvt_term::DefaultRootWindow () |
1787 | CODE: |
1812 | CODE: |
1788 | RETVAL = THIS->display->root; |
1813 | RETVAL = THIS->display->root; |
… | |
… | |
1791 | |
1816 | |
1792 | #if 0 |
1817 | #if 0 |
1793 | |
1818 | |
1794 | Window |
1819 | Window |
1795 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1820 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1796 | C_ARGS: term->display->display, (Window)parent, |
1821 | C_ARGS: term->xdisp, (Window)parent, |
1797 | x, y, width, height, 0, |
1822 | x, y, width, height, 0, |
1798 | term->pix_colors_focused[Color_border], |
1823 | term->pix_colors_focused[Color_border], |
1799 | term->pix_colors_focused[Color_border] |
1824 | term->pix_colors_focused[Color_border] |
1800 | |
1825 | |
1801 | #endif |
1826 | #endif |
1802 | |
1827 | |
1803 | void |
1828 | void |
1804 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1829 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1805 | C_ARGS: term->display->display, window, parent, x, y |
1830 | C_ARGS: term->xdisp, window, parent, x, y |
1806 | |
1831 | |
1807 | void |
1832 | void |
1808 | XMapWindow (rxvt_term *term, Window window) |
1833 | XMapWindow (rxvt_term *term, Window window) |
1809 | C_ARGS: term->display->display, window |
1834 | C_ARGS: term->xdisp, window |
1810 | |
1835 | |
1811 | void |
1836 | void |
1812 | XUnmapWindow (rxvt_term *term, Window window) |
1837 | XUnmapWindow (rxvt_term *term, Window window) |
1813 | C_ARGS: term->display->display, window |
1838 | C_ARGS: term->xdisp, window |
1814 | |
1839 | |
1815 | void |
1840 | void |
1816 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1841 | 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 |
1842 | C_ARGS: term->xdisp, window, x, y, width, height |
1818 | |
1843 | |
1819 | void |
1844 | void |
1820 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1845 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1821 | CODE: |
1846 | CODE: |
1822 | { |
1847 | { |
1823 | XWindowAttributes attr; |
1848 | XWindowAttributes attr; |
1824 | XGetWindowAttributes (THIS->display->display, window, &attr); |
1849 | XGetWindowAttributes (THIS->xdisp, window, &attr); |
1825 | XSelectInput (THIS->display->display, window, attr.your_event_mask | add_events & ~del_events); |
1850 | XSelectInput (THIS->xdisp, window, attr.your_event_mask | add_events & ~del_events); |
1826 | } |
1851 | } |
1827 | |
1852 | |
1828 | void |
1853 | void |
1829 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1854 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1830 | PPCODE: |
1855 | PPCODE: |
1831 | { |
1856 | { |
1832 | int dx, dy; |
1857 | int dx, dy; |
1833 | Window child; |
1858 | Window child; |
1834 | |
1859 | |
1835 | if (XTranslateCoordinates (THIS->display->display, src, dst, x, y, &dx, &dy, &child)) |
1860 | if (XTranslateCoordinates (THIS->xdisp, src, dst, x, y, &dx, &dy, &child)) |
1836 | { |
1861 | { |
1837 | EXTEND (SP, 3); |
1862 | EXTEND (SP, 3); |
1838 | PUSHs (newSViv (dx)); |
1863 | PUSHs (newSViv (dx)); |
1839 | PUSHs (newSViv (dy)); |
1864 | PUSHs (newSViv (dy)); |
1840 | PUSHs (newSVuv (child)); |
1865 | PUSHs (newSVuv (child)); |