ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtperl.xs
(Generate patch)

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.94 by root, Thu Jan 26 00:09:47 2006 UTC vs.
Revision 1.95 by root, Sun Jan 29 20:51:28 2006 UTC

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
179struct timer : perl_watcher, time_watcher 179struct 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
200struct iow : perl_watcher, io_watcher 200struct 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
216struct iw : perl_watcher, idle_watcher 216struct 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
232struct pw : perl_watcher, child_watcher 232struct pw : perl_watcher, child_watcher
233{ 233{
234 pw () 234 pw ()
235 : child_watcher (this, &pw::execute) 235 : child_watcher (this, &pw::execute)
494static void 494static void
495ungrab (rxvt_term *THIS) 495ungrab (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
505bool 505bool
956 | ((new_value << RS_customShift) & RS_customMask); 956 | ((new_value << RS_customShift) & RS_customMask);
957} 957}
958 OUTPUT: 958 OUTPUT:
959 RETVAL 959 RETVAL
960 960
961void
962termlist ()
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
961MODULE = urxvt PACKAGE = urxvt::term 972MODULE = urxvt PACKAGE = urxvt::term
962 973
963SV * 974SV *
964_new (...) 975_new (AV *env, AV *arg)
965 CODE: 976 CODE:
966{ 977{
967 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
968 croak ("first argument to urxvt::term->_new must be arrayref");
969
970 rxvt_term *term = new rxvt_term; 978 rxvt_term *term = new rxvt_term;
971 979
972 stringvec *argv = new stringvec; 980 stringvec *argv = new stringvec;
973 stringvec *envv = new stringvec; 981 stringvec *envv = new stringvec;
974 982
975 for (int i = 1; i < items; i++) 983 for (int i = 0; i <= AvFILL (arg); i++)
976 argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); 984 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
977 985
978 AV *env = (AV *)SvRV (ST (0));
979 for (int i = AvFILL (env) + 1; i--; ) 986 for (int i = AvFILL (env) + 1; i--; )
980 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 987 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
981 988
982 envv->push_back (0); 989 envv->push_back (0);
983 990
1011rxvt_term::set_should_invoke (int htype, int inc) 1018rxvt_term::set_should_invoke (int htype, int inc)
1012 CODE: 1019 CODE:
1013 THIS->perl.should_invoke [htype] += inc; 1020 THIS->perl.should_invoke [htype] += inc;
1014 1021
1015void 1022void
1016rxvt_term::grab_button (int button, U32 modifiers) 1023rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
1017 CODE: 1024 CODE:
1018 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, 1025 XGrabButton (THIS->xdisp, button, modifiers, window, 1,
1019 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 1026 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1020 GrabModeSync, GrabModeSync, None, GRAB_CURSOR); 1027 GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
1021 1028
1029void
1030rxvt_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
1036void
1037XGrabKey (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
1042void
1043XUngrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt)
1044 C_ARGS: THIS->xdisp, keycode, modifiers, window
1045
1046#endif
1047
1022bool 1048bool
1023rxvt_term::grab (Time eventtime, int sync = 0) 1049rxvt_term::grab (Time eventtime, int sync = 0)
1024 CODE: 1050 CODE:
1025{ 1051{
1026 int mode = sync ? GrabModeSync : GrabModeAsync; 1052 int mode = sync ? GrabModeSync : GrabModeAsync;
1027 1053
1028 THIS->perl.grabtime = 0; 1054 THIS->perl.grabtime = 0;
1029 1055
1030 if (!XGrabPointer (THIS->display->display, THIS->vt, 0, 1056 if (!XGrabPointer (THIS->xdisp, THIS->vt, 0,
1031 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 1057 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1032 mode, mode, None, GRAB_CURSOR, eventtime)) 1058 mode, mode, None, GRAB_CURSOR, eventtime))
1033 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) 1059 if (!XGrabKeyboard (THIS->xdisp, THIS->vt, 0, mode, mode, eventtime))
1034 THIS->perl.grabtime = eventtime; 1060 THIS->perl.grabtime = eventtime;
1035 else 1061 else
1036 XUngrabPointer (THIS->display->display, eventtime); 1062 XUngrabPointer (THIS->xdisp, eventtime);
1037 1063
1038 RETVAL = !!THIS->perl.grabtime; 1064 RETVAL = !!THIS->perl.grabtime;
1039} 1065}
1040 OUTPUT: 1066 OUTPUT:
1041 RETVAL 1067 RETVAL
1042 1068
1043void 1069void
1044rxvt_term::allow_events_async () 1070rxvt_term::allow_events_async ()
1045 CODE: 1071 CODE:
1046 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); 1072 XAllowEvents (THIS->xdisp, AsyncBoth, THIS->perl.grabtime);
1047 1073
1048void 1074void
1049rxvt_term::allow_events_sync () 1075rxvt_term::allow_events_sync ()
1050 CODE: 1076 CODE:
1051 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); 1077 XAllowEvents (THIS->xdisp, SyncBoth, THIS->perl.grabtime);
1052 1078
1053void 1079void
1054rxvt_term::allow_events_replay () 1080rxvt_term::allow_events_replay ()
1055 CODE: 1081 CODE:
1056 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); 1082 XAllowEvents (THIS->xdisp, ReplayPointer, THIS->perl.grabtime);
1057 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); 1083 XAllowEvents (THIS->xdisp, ReplayKeyboard, THIS->perl.grabtime);
1058 1084
1059void 1085void
1060rxvt_term::ungrab () 1086rxvt_term::ungrab ()
1061 CODE: 1087 CODE:
1062 ungrab (THIS); 1088 ungrab (THIS);
1711void 1737void
1712rxvt_term::XListProperties (Window window) 1738rxvt_term::XListProperties (Window window)
1713 PPCODE: 1739 PPCODE:
1714{ 1740{
1715 int count; 1741 int count;
1716 Atom *props = XListProperties (THIS->display->display, window, &count); 1742 Atom *props = XListProperties (THIS->xdisp, window, &count);
1717 1743
1718 EXTEND (SP, count); 1744 EXTEND (SP, count);
1719 while (count--) 1745 while (count--)
1720 PUSHs (newSVuv ((U32)props [count])); 1746 PUSHs (newSVuv ((U32)props [count]));
1721 1747
1730 int format; 1756 int format;
1731 unsigned long nitems; 1757 unsigned long nitems;
1732 unsigned long bytes_after; 1758 unsigned long bytes_after;
1733 unsigned char *prop; 1759 unsigned char *prop;
1734 1760
1735 XGetWindowProperty (THIS->display->display, window, property, 1761 XGetWindowProperty (THIS->xdisp, window, property,
1736 0, 1<<24, 0, AnyPropertyType, 1762 0, 1<<24, 0, AnyPropertyType,
1737 &type, &format, &nitems, &bytes_after, &prop); 1763 &type, &format, &nitems, &bytes_after, &prop);
1738 1764
1739 if (type != None) 1765 if (type != None)
1740 { 1766 {
1759 1785
1760 int elemsize = format == 16 ? sizeof (short) 1786 int elemsize = format == 16 ? sizeof (short)
1761 : format == 32 ? sizeof (long) 1787 : format == 32 ? sizeof (long)
1762 : 1; 1788 : 1;
1763 1789
1764 XChangeProperty (THIS->display->display, window, property, 1790 XChangeProperty (THIS->xdisp, window, property,
1765 type, format, PropModeReplace, 1791 type, format, PropModeReplace,
1766 (unsigned char *)data_, len / elemsize); 1792 (unsigned char *)data_, len / elemsize);
1767 XSync (THIS->display->display, 0); 1793 XSync (THIS->xdisp, 0);
1768} 1794}
1769 1795
1770Atom 1796Atom
1771XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) 1797XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE)
1772 C_ARGS: term->display->display, atom_name, only_if_exists 1798 C_ARGS: term->xdisp, atom_name, only_if_exists
1773 1799
1774char * 1800char *
1775XGetAtomName (rxvt_term *term, Atom atom) 1801XGetAtomName (rxvt_term *term, Atom atom)
1776 C_ARGS: term->display->display, atom 1802 C_ARGS: term->xdisp, atom
1777 CLEANUP: 1803 CLEANUP:
1778 XFree (RETVAL); 1804 XFree (RETVAL);
1779 1805
1780void 1806void
1781XDeleteProperty (rxvt_term *term, Window window, Atom property) 1807XDeleteProperty (rxvt_term *term, Window window, Atom property)
1782 C_ARGS: term->display->display, window, property 1808 C_ARGS: term->xdisp, window, property
1783 1809
1784Window 1810Window
1785rxvt_term::DefaultRootWindow () 1811rxvt_term::DefaultRootWindow ()
1786 CODE: 1812 CODE:
1787 RETVAL = THIS->display->root; 1813 RETVAL = THIS->display->root;
1790 1816
1791#if 0 1817#if 0
1792 1818
1793Window 1819Window
1794XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) 1820XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height)
1795 C_ARGS: term->display->display, (Window)parent, 1821 C_ARGS: term->xdisp, (Window)parent,
1796 x, y, width, height, 0, 1822 x, y, width, height, 0,
1797 term->pix_colors_focused[Color_border], 1823 term->pix_colors_focused[Color_border],
1798 term->pix_colors_focused[Color_border] 1824 term->pix_colors_focused[Color_border]
1799 1825
1800#endif 1826#endif
1801 1827
1802void 1828void
1803XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) 1829XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0)
1804 C_ARGS: term->display->display, window, parent, x, y 1830 C_ARGS: term->xdisp, window, parent, x, y
1805 1831
1806void 1832void
1807XMapWindow (rxvt_term *term, Window window) 1833XMapWindow (rxvt_term *term, Window window)
1808 C_ARGS: term->display->display, window 1834 C_ARGS: term->xdisp, window
1809 1835
1810void 1836void
1811XUnmapWindow (rxvt_term *term, Window window) 1837XUnmapWindow (rxvt_term *term, Window window)
1812 C_ARGS: term->display->display, window 1838 C_ARGS: term->xdisp, window
1813 1839
1814void 1840void
1815XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) 1841XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height)
1816 C_ARGS: term->display->display, window, x, y, width, height 1842 C_ARGS: term->xdisp, window, x, y, width, height
1817 1843
1818void 1844void
1819rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) 1845rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0)
1820 CODE: 1846 CODE:
1821{ 1847{
1822 XWindowAttributes attr; 1848 XWindowAttributes attr;
1823 XGetWindowAttributes (THIS->display->display, window, &attr); 1849 XGetWindowAttributes (THIS->xdisp, window, &attr);
1824 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);
1825} 1851}
1826 1852
1827void 1853void
1828rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) 1854rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y)
1829 PPCODE: 1855 PPCODE:
1830{ 1856{
1831 int dx, dy; 1857 int dx, dy;
1832 Window child; 1858 Window child;
1833 1859
1834 if (XTranslateCoordinates (THIS->display->display, src, dst, x, y, &dx, &dy, &child)) 1860 if (XTranslateCoordinates (THIS->xdisp, src, dst, x, y, &dx, &dy, &child))
1835 { 1861 {
1836 EXTEND (SP, 3); 1862 EXTEND (SP, 3);
1837 PUSHs (newSViv (dx)); 1863 PUSHs (newSViv (dx));
1838 PUSHs (newSViv (dy)); 1864 PUSHs (newSViv (dy));
1839 PUSHs (newSVuv (child)); 1865 PUSHs (newSVuv (child));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines