… | |
… | |
39 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
40 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
41 | |
41 | |
42 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
43 | |
43 | |
44 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
44 | #ifdef HAVE_SCROLLBARS |
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
46 | #else |
46 | #else |
47 | # define GRAB_CURSOR None |
47 | # define GRAB_CURSOR None |
48 | #endif |
48 | #endif |
49 | |
49 | |
… | |
… | |
52 | #undef ROW |
52 | #undef ROW |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
54 | |
54 | |
55 | ///////////////////////////////////////////////////////////////////////////// |
55 | ///////////////////////////////////////////////////////////////////////////// |
56 | |
56 | |
57 | static SV * |
|
|
58 | taint (SV *sv) |
|
|
59 | { |
|
|
60 | SvTAINT (sv); |
|
|
61 | return sv; |
|
|
62 | } |
|
|
63 | |
|
|
64 | static SV * |
|
|
65 | taint_if (SV *sv, SV *src) |
|
|
66 | { |
|
|
67 | if (SvTAINTED (src)) |
|
|
68 | SvTAINT (sv); |
|
|
69 | |
|
|
70 | return sv; |
|
|
71 | } |
|
|
72 | |
|
|
73 | static wchar_t * |
57 | static wchar_t * |
74 | sv2wcs (SV *sv) |
58 | sv2wcs (SV *sv) |
75 | { |
59 | { |
76 | STRLEN len; |
60 | STRLEN len; |
77 | char *str = SvPVutf8 (sv, len); |
61 | char *str = SvPVutf8 (sv, len); |
… | |
… | |
94 | new_ref (HV *hv, const char *klass) |
78 | new_ref (HV *hv, const char *klass) |
95 | { |
79 | { |
96 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
80 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
97 | } |
81 | } |
98 | |
82 | |
99 | //TODO: use magic |
|
|
100 | static SV * |
83 | static SV * |
101 | newSVptr (void *ptr, const char *klass) |
84 | newSVptr (void *ptr, const char *klass) |
102 | { |
85 | { |
103 | HV *hv = newHV (); |
86 | HV *hv = newHV (); |
104 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
87 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
… | |
… | |
127 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
110 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
128 | |
111 | |
129 | return (long)mg->mg_ptr; |
112 | return (long)mg->mg_ptr; |
130 | } |
113 | } |
131 | |
114 | |
132 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
115 | #define newSVterm(term) SvREFCNT_inc ((SV *)(term)->perl.self) |
133 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
116 | #define SvTERM(sv) (rxvt_term *)SvPTR ((sv), "urxvt::term") |
134 | |
117 | |
135 | ///////////////////////////////////////////////////////////////////////////// |
118 | ///////////////////////////////////////////////////////////////////////////// |
136 | |
119 | |
137 | struct perl_watcher |
|
|
138 | { |
|
|
139 | SV *cbsv; |
|
|
140 | HV *self; |
|
|
141 | |
|
|
142 | perl_watcher () |
|
|
143 | : cbsv (newSV (0)) |
|
|
144 | { |
|
|
145 | } |
|
|
146 | |
|
|
147 | ~perl_watcher () |
|
|
148 | { |
|
|
149 | SvREFCNT_dec (cbsv); |
|
|
150 | } |
|
|
151 | |
|
|
152 | void cb (SV *cb) |
|
|
153 | { |
|
|
154 | sv_setsv (cbsv, cb); |
|
|
155 | } |
|
|
156 | |
|
|
157 | void invoke (const char *type, SV *self, int arg = -1); |
|
|
158 | }; |
|
|
159 | |
|
|
160 | void |
|
|
161 | perl_watcher::invoke (const char *type, SV *self, int arg) |
|
|
162 | { |
|
|
163 | dSP; |
|
|
164 | |
|
|
165 | ENTER; |
|
|
166 | SAVETMPS; |
|
|
167 | |
|
|
168 | PUSHMARK (SP); |
|
|
169 | |
|
|
170 | XPUSHs (sv_2mortal (self)); |
|
|
171 | |
|
|
172 | if (arg >= 0) |
|
|
173 | XPUSHs (sv_2mortal (newSViv (arg))); |
|
|
174 | |
|
|
175 | PUTBACK; |
|
|
176 | call_sv (cbsv, G_VOID | G_EVAL | G_DISCARD); |
|
|
177 | SPAGAIN; |
|
|
178 | |
|
|
179 | PUTBACK; |
|
|
180 | FREETMPS; |
|
|
181 | LEAVE; |
|
|
182 | |
|
|
183 | if (SvTRUE (ERRSV)) |
|
|
184 | rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); |
|
|
185 | } |
|
|
186 | |
|
|
187 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
|
|
188 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
|
|
189 | |
|
|
190 | struct timer : time_watcher, perl_watcher |
|
|
191 | { |
|
|
192 | tstamp interval; |
|
|
193 | |
|
|
194 | timer () |
|
|
195 | : time_watcher (this, &timer::execute) |
|
|
196 | { |
|
|
197 | } |
|
|
198 | |
|
|
199 | void execute (time_watcher &w) |
|
|
200 | { |
|
|
201 | if (interval) |
|
|
202 | start (at + interval); |
|
|
203 | |
|
|
204 | invoke ("urxvt::timer", newSVtimer (this)); |
|
|
205 | } |
|
|
206 | }; |
|
|
207 | |
|
|
208 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
|
|
209 | #define SvIOW(sv) (iow *)SvPTR (sv, "urxvt::iow") |
|
|
210 | |
|
|
211 | struct iow : io_watcher, perl_watcher |
|
|
212 | { |
|
|
213 | iow () |
|
|
214 | : io_watcher (this, &iow::execute) |
|
|
215 | { |
|
|
216 | } |
|
|
217 | |
|
|
218 | void execute (io_watcher &w, short revents) |
|
|
219 | { |
|
|
220 | invoke ("urxvt::iow", newSViow (this), revents); |
|
|
221 | } |
|
|
222 | }; |
|
|
223 | |
|
|
224 | ///////////////////////////////////////////////////////////////////////////// |
|
|
225 | |
|
|
226 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
120 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
227 | |
121 | |
228 | struct overlay { |
122 | class overlay { |
229 | HV *self; |
|
|
230 | rxvt_term *THIS; |
123 | rxvt_term *THIS; |
|
|
124 | AV *overlay_av; |
231 | int x, y, w, h; |
125 | int x, y, w, h; |
232 | int border; |
126 | int border; |
233 | text_t **text; |
127 | text_t **text; |
234 | rend_t **rend; |
128 | rend_t **rend; |
235 | |
129 | |
|
|
130 | public: |
|
|
131 | HV *self; |
|
|
132 | |
236 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
133 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
237 | ~overlay (); |
134 | ~overlay (); |
238 | |
135 | |
239 | void show (); |
136 | void show (); |
240 | void hide (); |
137 | void hide (); |
… | |
… | |
243 | |
140 | |
244 | void set (int x, int y, SV *str, SV *rend); |
141 | void set (int x, int y, SV *str, SV *rend); |
245 | }; |
142 | }; |
246 | |
143 | |
247 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
144 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
248 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) |
145 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) |
249 | { |
146 | { |
|
|
147 | if (w < 0) w = 0; |
|
|
148 | if (h < 0) h = 0; |
|
|
149 | |
250 | if (border == 2) |
150 | if (border == 2) |
251 | { |
151 | { |
252 | w += 2; |
152 | w += 2; |
253 | h += 2; |
153 | h += 2; |
254 | } |
154 | } |
… | |
… | |
292 | *rp++ = r; |
192 | *rp++ = r; |
293 | } |
193 | } |
294 | } |
194 | } |
295 | |
195 | |
296 | show (); |
196 | show (); |
297 | THIS->want_refresh = 1; |
|
|
298 | } |
197 | } |
299 | |
198 | |
300 | overlay::~overlay () |
199 | overlay::~overlay () |
301 | { |
200 | { |
302 | hide (); |
201 | hide (); |
… | |
… | |
307 | delete [] rend[y]; |
206 | delete [] rend[y]; |
308 | } |
207 | } |
309 | |
208 | |
310 | delete [] text; |
209 | delete [] text; |
311 | delete [] rend; |
210 | delete [] rend; |
|
|
211 | } |
|
|
212 | |
|
|
213 | void |
|
|
214 | overlay::show () |
|
|
215 | { |
|
|
216 | if (overlay_av) |
|
|
217 | return; |
|
|
218 | |
|
|
219 | overlay_av = (AV *)SvREFCNT_inc (SvRV ( |
|
|
220 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
|
|
221 | )); |
|
|
222 | av_push (overlay_av, newSViv ((long)this)); |
312 | |
223 | |
313 | THIS->want_refresh = 1; |
224 | THIS->want_refresh = 1; |
314 | } |
225 | } |
315 | |
226 | |
316 | void |
227 | void |
317 | overlay::show () |
|
|
318 | { |
|
|
319 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
320 | |
|
|
321 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
|
|
322 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
|
|
323 | } |
|
|
324 | |
|
|
325 | void |
|
|
326 | overlay::hide () |
228 | overlay::hide () |
327 | { |
229 | { |
328 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
230 | if (!overlay_av) |
|
|
231 | return; |
329 | |
232 | |
330 | if (ovs) |
233 | int i; |
331 | { |
|
|
332 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
333 | |
234 | |
334 | HV *hv = (HV *)SvRV (*ovs); |
235 | for (i = AvFILL (overlay_av); i >= 0; i--) |
335 | hv_delete (hv, key, 32, G_DISCARD); |
236 | if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this) |
336 | } |
237 | break; |
|
|
238 | |
|
|
239 | for (; i < AvFILL (overlay_av); i++) |
|
|
240 | av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0))); |
|
|
241 | |
|
|
242 | av_pop (overlay_av); |
|
|
243 | |
|
|
244 | SvREFCNT_dec (overlay_av); |
|
|
245 | overlay_av = 0; |
|
|
246 | |
|
|
247 | THIS->want_refresh = 1; |
337 | } |
248 | } |
338 | |
249 | |
339 | void overlay::swap () |
250 | void overlay::swap () |
340 | { |
251 | { |
341 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
252 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
… | |
… | |
347 | for (int y = ov_h; y--; ) |
258 | for (int y = ov_h; y--; ) |
348 | { |
259 | { |
349 | text_t *t1 = text [y]; |
260 | text_t *t1 = text [y]; |
350 | rend_t *r1 = rend [y]; |
261 | rend_t *r1 = rend [y]; |
351 | |
262 | |
352 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
263 | text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x; |
353 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
264 | rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x; |
354 | |
265 | |
355 | for (int x = ov_w; x--; ) |
266 | for (int x = ov_w; x--; ) |
356 | { |
267 | { |
357 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
268 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
358 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
269 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
… | |
… | |
381 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
292 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
382 | croak ("rend must be arrayref"); |
293 | croak ("rend must be arrayref"); |
383 | |
294 | |
384 | AV *av = (AV *)SvRV (rend); |
295 | AV *av = (AV *)SvRV (rend); |
385 | |
296 | |
386 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
297 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
387 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
298 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
388 | } |
299 | } |
389 | |
300 | |
390 | THIS->want_refresh = 1; |
301 | THIS->want_refresh = 1; |
391 | } |
302 | } |
392 | |
303 | |
|
|
304 | ///////////////////////////////////////////////////////////////////////////// |
|
|
305 | |
|
|
306 | #define IOM_CLASS "urxvt" |
|
|
307 | #include <iom_perl.h> |
393 | |
308 | |
394 | ///////////////////////////////////////////////////////////////////////////// |
309 | ///////////////////////////////////////////////////////////////////////////// |
395 | |
310 | |
396 | struct rxvt_perl_interp rxvt_perl; |
311 | struct rxvt_perl_interp rxvt_perl; |
397 | |
312 | |
… | |
… | |
405 | perl_free (perl); |
320 | perl_free (perl); |
406 | } |
321 | } |
407 | } |
322 | } |
408 | |
323 | |
409 | void |
324 | void |
410 | rxvt_perl_interp::init () |
325 | rxvt_perl_interp::init (rxvt_term *term) |
411 | { |
326 | { |
412 | if (!perl) |
327 | if (!perl) |
413 | { |
328 | { |
|
|
329 | rxvt_push_locale (""); // perl init destroys current locale |
|
|
330 | |
414 | perl_environ = rxvt_environ; |
331 | perl_environ = rxvt_environ; |
415 | swap (perl_environ, environ); |
332 | swap (perl_environ, environ); |
416 | |
333 | |
417 | char *argv[] = { |
334 | char *argv[] = { |
418 | "", |
335 | "", |
419 | "-T", |
336 | "-e" |
420 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
337 | "BEGIN {" |
|
|
338 | " urxvt->bootstrap;" |
|
|
339 | " unshift @INC, '" LIBDIR "';" |
|
|
340 | "}" |
|
|
341 | "" |
|
|
342 | "use urxvt;" |
421 | }; |
343 | }; |
422 | |
344 | |
423 | perl = perl_alloc (); |
345 | perl = perl_alloc (); |
424 | perl_construct (perl); |
346 | perl_construct (perl); |
425 | |
347 | |
426 | if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) |
348 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
427 | || perl_run (perl)) |
349 | || perl_run (perl)) |
428 | { |
350 | { |
429 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
351 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
430 | |
352 | |
431 | perl_destruct (perl); |
353 | perl_destruct (perl); |
432 | perl_free (perl); |
354 | perl_free (perl); |
433 | perl = 0; |
355 | perl = 0; |
434 | } |
356 | } |
435 | |
357 | |
436 | swap (perl_environ, environ); |
358 | swap (perl_environ, environ); |
|
|
359 | |
|
|
360 | rxvt_pop_locale (); |
|
|
361 | } |
|
|
362 | |
|
|
363 | if (perl) |
|
|
364 | { |
|
|
365 | // runs outside of perls ENV |
|
|
366 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
367 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
437 | } |
368 | } |
438 | } |
369 | } |
439 | |
370 | |
440 | static void |
371 | static void |
441 | ungrab (rxvt_term *THIS) |
372 | ungrab (rxvt_term *THIS) |
442 | { |
373 | { |
443 | if (THIS->perl.grabtime) |
374 | if (THIS->perl.grabtime) |
444 | { |
375 | { |
445 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
376 | XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime); |
446 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
377 | XUngrabPointer (THIS->dpy, THIS->perl.grabtime); |
447 | THIS->perl.grabtime = 0; |
378 | THIS->perl.grabtime = 0; |
448 | } |
379 | } |
449 | } |
380 | } |
450 | |
381 | |
451 | bool |
382 | bool |
452 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
383 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
453 | { |
384 | { |
454 | if (!perl) |
385 | if (!perl || !term->perl.self) |
455 | return false; |
386 | return false; |
456 | |
387 | |
457 | if (htype == HOOK_INIT) // first hook ever called |
388 | // pre-handling of some events |
|
|
389 | if (htype == HOOK_REFRESH_END) |
458 | { |
390 | { |
459 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
391 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
460 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
392 | |
|
|
393 | for (int i = 0; i <= AvFILL (av); i++) |
|
|
394 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
461 | } |
395 | } |
462 | else if (!term->perl.self) |
396 | |
463 | return false; // perl not initialized for this instance |
397 | swap (perl_environ, environ); |
|
|
398 | |
|
|
399 | bool event_consumed; |
|
|
400 | |
|
|
401 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
|
|
402 | || term->perl.should_invoke [htype]) |
|
|
403 | try |
|
|
404 | { |
|
|
405 | dSP; |
|
|
406 | va_list ap; |
|
|
407 | |
|
|
408 | va_start (ap, htype); |
|
|
409 | |
|
|
410 | ENTER; |
|
|
411 | SAVETMPS; |
|
|
412 | |
|
|
413 | PUSHMARK (SP); |
|
|
414 | |
|
|
415 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
416 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
417 | |
|
|
418 | for (;;) { |
|
|
419 | data_type dt = (data_type)va_arg (ap, int); |
|
|
420 | |
|
|
421 | switch (dt) |
|
|
422 | { |
|
|
423 | case DT_INT: |
|
|
424 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
425 | break; |
|
|
426 | |
|
|
427 | case DT_LONG: |
|
|
428 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
429 | break; |
|
|
430 | |
|
|
431 | case DT_STR: |
|
|
432 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
433 | break; |
|
|
434 | |
|
|
435 | case DT_STR_LEN: |
|
|
436 | { |
|
|
437 | char *str = va_arg (ap, char *); |
|
|
438 | int len = va_arg (ap, int); |
|
|
439 | |
|
|
440 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
441 | } |
|
|
442 | break; |
|
|
443 | |
|
|
444 | case DT_WCS_LEN: |
|
|
445 | { |
|
|
446 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
447 | int wlen = va_arg (ap, int); |
|
|
448 | |
|
|
449 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
450 | } |
|
|
451 | break; |
|
|
452 | |
|
|
453 | case DT_LCS_LEN: |
|
|
454 | { |
|
|
455 | long *lstr = va_arg (ap, long *); |
|
|
456 | int llen = va_arg (ap, int); |
|
|
457 | |
|
|
458 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
|
|
459 | } |
|
|
460 | break; |
|
|
461 | |
|
|
462 | case DT_XEVENT: |
|
|
463 | { |
|
|
464 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
465 | HV *hv = newHV (); |
|
|
466 | |
|
|
467 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
468 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
469 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
|
|
470 | # undef set |
|
|
471 | |
|
|
472 | setiv (type, xe->type); |
|
|
473 | setiv (send_event, xe->xany.send_event); |
|
|
474 | setiv (serial, xe->xany.serial); |
|
|
475 | |
|
|
476 | switch (xe->type) |
|
|
477 | { |
|
|
478 | case KeyPress: |
|
|
479 | case KeyRelease: |
|
|
480 | case ButtonPress: |
|
|
481 | case ButtonRelease: |
|
|
482 | case MotionNotify: |
|
|
483 | setuv (window, xe->xmotion.window); |
|
|
484 | setuv (root, xe->xmotion.root); |
|
|
485 | setuv (subwindow, xe->xmotion.subwindow); |
|
|
486 | setuv (time, xe->xmotion.time); |
|
|
487 | setiv (x, xe->xmotion.x); |
|
|
488 | setiv (y, xe->xmotion.y); |
|
|
489 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
|
|
490 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
491 | setiv (x_root, xe->xmotion.x_root); |
|
|
492 | setiv (y_root, xe->xmotion.y_root); |
|
|
493 | setuv (state, xe->xmotion.state); |
|
|
494 | |
|
|
495 | switch (xe->type) |
|
|
496 | { |
|
|
497 | case KeyPress: |
|
|
498 | case KeyRelease: |
|
|
499 | setuv (keycode, xe->xkey.keycode); |
|
|
500 | break; |
|
|
501 | |
|
|
502 | case ButtonPress: |
|
|
503 | case ButtonRelease: |
|
|
504 | setuv (button, xe->xbutton.button); |
|
|
505 | break; |
|
|
506 | |
|
|
507 | case MotionNotify: |
|
|
508 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
509 | break; |
|
|
510 | } |
|
|
511 | |
|
|
512 | break; |
|
|
513 | |
|
|
514 | case MapNotify: |
|
|
515 | case UnmapNotify: |
|
|
516 | case ConfigureNotify: |
|
|
517 | setuv (event, xe->xconfigure.event); |
|
|
518 | setuv (window, xe->xconfigure.window); |
|
|
519 | |
|
|
520 | switch (xe->type) |
|
|
521 | { |
|
|
522 | case ConfigureNotify: |
|
|
523 | setiv (x, xe->xconfigure.x); |
|
|
524 | setiv (y, xe->xconfigure.y); |
|
|
525 | setiv (width, xe->xconfigure.width); |
|
|
526 | setiv (height, xe->xconfigure.height); |
|
|
527 | setuv (above, xe->xconfigure.above); |
|
|
528 | break; |
|
|
529 | } |
|
|
530 | |
|
|
531 | break; |
|
|
532 | |
|
|
533 | case PropertyNotify: |
|
|
534 | setuv (window, xe->xproperty.window); |
|
|
535 | setuv (atom, xe->xproperty.atom); |
|
|
536 | setuv (time, xe->xproperty.time); |
|
|
537 | setiv (state, xe->xproperty.state); |
|
|
538 | break; |
|
|
539 | |
|
|
540 | case ClientMessage: |
|
|
541 | setuv (window, xe->xclient.window); |
|
|
542 | setuv (message_type, xe->xclient.message_type); |
|
|
543 | setuv (format, xe->xclient.format); |
|
|
544 | setuv (l0, xe->xclient.data.l[0]); |
|
|
545 | setuv (l1, xe->xclient.data.l[1]); |
|
|
546 | setuv (l2, xe->xclient.data.l[2]); |
|
|
547 | setuv (l3, xe->xclient.data.l[3]); |
|
|
548 | setuv (l4, xe->xclient.data.l[4]); |
|
|
549 | break; |
|
|
550 | } |
|
|
551 | |
|
|
552 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
553 | } |
|
|
554 | break; |
|
|
555 | |
|
|
556 | case DT_END: |
|
|
557 | goto call; |
|
|
558 | |
|
|
559 | default: |
|
|
560 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
561 | } |
|
|
562 | } |
|
|
563 | |
|
|
564 | call: |
|
|
565 | va_end (ap); |
|
|
566 | |
|
|
567 | PUTBACK; |
|
|
568 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
569 | SPAGAIN; |
|
|
570 | |
|
|
571 | if (count) |
|
|
572 | { |
|
|
573 | SV *status = POPs; |
|
|
574 | count = SvTRUE (status); |
|
|
575 | } |
|
|
576 | |
|
|
577 | PUTBACK; |
|
|
578 | FREETMPS; |
|
|
579 | LEAVE; |
|
|
580 | |
|
|
581 | if (SvTRUE (ERRSV)) |
|
|
582 | { |
|
|
583 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
584 | ungrab (term); // better lose the grab than the session |
|
|
585 | } |
|
|
586 | |
|
|
587 | event_consumed = !!count; |
|
|
588 | } |
|
|
589 | catch (...) |
|
|
590 | { |
|
|
591 | swap (perl_environ, environ); |
|
|
592 | throw; |
|
|
593 | } |
|
|
594 | else |
|
|
595 | event_consumed = false; |
|
|
596 | |
|
|
597 | // post-handling of some events |
|
|
598 | if (htype == HOOK_REFRESH_BEGIN) |
|
|
599 | { |
|
|
600 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
601 | |
|
|
602 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
603 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
|
|
604 | } |
464 | else if (htype == HOOK_DESTROY) |
605 | else if (htype == HOOK_DESTROY) |
465 | { |
606 | { |
466 | // handled later |
607 | clearSVptr ((SV *)term->perl.self); |
|
|
608 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
609 | |
|
|
610 | // don't allow further calls |
|
|
611 | term->perl.self = 0; |
467 | } |
612 | } |
468 | else |
|
|
469 | { |
|
|
470 | if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
471 | { |
|
|
472 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
473 | |
|
|
474 | if (HvKEYS (hv)) |
|
|
475 | { |
|
|
476 | hv_iterinit (hv); |
|
|
477 | |
|
|
478 | while (HE *he = hv_iternext (hv)) |
|
|
479 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
480 | } |
|
|
481 | |
|
|
482 | } |
|
|
483 | |
|
|
484 | if (!term->perl.should_invoke [htype]) |
|
|
485 | return false; |
|
|
486 | } |
|
|
487 | |
613 | |
488 | swap (perl_environ, environ); |
614 | swap (perl_environ, environ); |
489 | |
615 | |
490 | try |
616 | return event_consumed; |
491 | { |
|
|
492 | dSP; |
|
|
493 | va_list ap; |
|
|
494 | |
|
|
495 | va_start (ap, htype); |
|
|
496 | |
|
|
497 | ENTER; |
|
|
498 | SAVETMPS; |
|
|
499 | |
|
|
500 | PUSHMARK (SP); |
|
|
501 | |
|
|
502 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
503 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
504 | |
|
|
505 | for (;;) { |
|
|
506 | data_type dt = (data_type)va_arg (ap, int); |
|
|
507 | |
|
|
508 | switch (dt) |
|
|
509 | { |
|
|
510 | case DT_INT: |
|
|
511 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
512 | break; |
|
|
513 | |
|
|
514 | case DT_LONG: |
|
|
515 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
516 | break; |
|
|
517 | |
|
|
518 | case DT_STR: |
|
|
519 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
|
|
520 | break; |
|
|
521 | |
|
|
522 | case DT_STR_LEN: |
|
|
523 | { |
|
|
524 | char *str = va_arg (ap, char *); |
|
|
525 | int len = va_arg (ap, int); |
|
|
526 | |
|
|
527 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
|
|
528 | } |
|
|
529 | break; |
|
|
530 | |
|
|
531 | case DT_WCS_LEN: |
|
|
532 | { |
|
|
533 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
534 | int wlen = va_arg (ap, int); |
|
|
535 | |
|
|
536 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
|
|
537 | } |
|
|
538 | break; |
|
|
539 | |
|
|
540 | case DT_XEVENT: |
|
|
541 | { |
|
|
542 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
543 | HV *hv = newHV (); |
|
|
544 | |
|
|
545 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
546 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
547 | # undef set |
|
|
548 | |
|
|
549 | setiv (type, xe->type); |
|
|
550 | setiv (send_event, xe->xany.send_event); |
|
|
551 | setiv (serial, xe->xany.serial); |
|
|
552 | |
|
|
553 | switch (xe->type) |
|
|
554 | { |
|
|
555 | case KeyPress: |
|
|
556 | case KeyRelease: |
|
|
557 | case ButtonPress: |
|
|
558 | case ButtonRelease: |
|
|
559 | case MotionNotify: |
|
|
560 | setiv (time, xe->xmotion.time); |
|
|
561 | setiv (x, xe->xmotion.x); |
|
|
562 | setiv (y, xe->xmotion.y); |
|
|
563 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
564 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
565 | setiv (x_root, xe->xmotion.x_root); |
|
|
566 | setiv (y_root, xe->xmotion.y_root); |
|
|
567 | setiv (state, xe->xmotion.state); |
|
|
568 | break; |
|
|
569 | } |
|
|
570 | |
|
|
571 | switch (xe->type) |
|
|
572 | { |
|
|
573 | case KeyPress: |
|
|
574 | case KeyRelease: |
|
|
575 | setiv (keycode, xe->xkey.keycode); |
|
|
576 | break; |
|
|
577 | |
|
|
578 | case ButtonPress: |
|
|
579 | case ButtonRelease: |
|
|
580 | setiv (button, xe->xbutton.button); |
|
|
581 | break; |
|
|
582 | |
|
|
583 | case MotionNotify: |
|
|
584 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
585 | break; |
|
|
586 | } |
|
|
587 | |
|
|
588 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
589 | } |
|
|
590 | break; |
|
|
591 | |
|
|
592 | case DT_END: |
|
|
593 | { |
|
|
594 | va_end (ap); |
|
|
595 | |
|
|
596 | PUTBACK; |
|
|
597 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
598 | SPAGAIN; |
|
|
599 | |
|
|
600 | if (count) |
|
|
601 | { |
|
|
602 | SV *status = POPs; |
|
|
603 | count = SvTRUE (status); |
|
|
604 | } |
|
|
605 | |
|
|
606 | PUTBACK; |
|
|
607 | FREETMPS; |
|
|
608 | LEAVE; |
|
|
609 | |
|
|
610 | if (SvTRUE (ERRSV)) |
|
|
611 | { |
|
|
612 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
613 | ungrab (term); // better lose the grab than the session |
|
|
614 | } |
|
|
615 | |
|
|
616 | if (htype == HOOK_DESTROY) |
|
|
617 | { |
|
|
618 | clearSVptr ((SV *)term->perl.self); |
|
|
619 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
620 | } |
|
|
621 | |
|
|
622 | swap (perl_environ, environ); |
|
|
623 | return count; |
|
|
624 | } |
|
|
625 | |
|
|
626 | default: |
|
|
627 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
628 | } |
|
|
629 | } |
|
|
630 | } |
|
|
631 | catch (...) |
|
|
632 | { |
|
|
633 | swap (perl_environ, environ); |
|
|
634 | throw; |
|
|
635 | } |
|
|
636 | } |
617 | } |
637 | |
618 | |
638 | ///////////////////////////////////////////////////////////////////////////// |
619 | ///////////////////////////////////////////////////////////////////////////// |
639 | |
620 | |
640 | MODULE = urxvt PACKAGE = urxvt |
621 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
659 | # include "optinc.h" |
640 | # include "optinc.h" |
660 | # undef nodef |
641 | # undef nodef |
661 | # undef def |
642 | # undef def |
662 | |
643 | |
663 | HV *stash = gv_stashpv ("urxvt", 1); |
644 | HV *stash = gv_stashpv ("urxvt", 1); |
664 | struct { |
645 | static const struct { |
665 | const char *name; |
646 | const char *name; |
666 | IV iv; |
647 | IV iv; |
667 | } *civ, const_iv[] = { |
648 | } *civ, const_iv[] = { |
668 | # define const_iv(name) { # name, (IV)name } |
649 | # define const_iv(name) { # name, (IV)name } |
669 | const_iv (DEFAULT_RSTYLE), |
650 | const_iv (DEFAULT_RSTYLE), |
… | |
… | |
688 | const_iv (Button3Mask), |
669 | const_iv (Button3Mask), |
689 | const_iv (Button4Mask), |
670 | const_iv (Button4Mask), |
690 | const_iv (Button5Mask), |
671 | const_iv (Button5Mask), |
691 | const_iv (AnyModifier), |
672 | const_iv (AnyModifier), |
692 | |
673 | |
693 | const_iv (EVENT_NONE), |
674 | const_iv (NoSymbol), |
694 | const_iv (EVENT_READ), |
675 | const_iv (GrabModeSync), |
695 | const_iv (EVENT_WRITE), |
676 | const_iv (GrabModeAsync), |
696 | |
677 | |
697 | const_iv (NoEventMask), |
678 | const_iv (NoEventMask), |
698 | const_iv (KeyPressMask), |
679 | const_iv (KeyPressMask), |
699 | const_iv (KeyReleaseMask), |
680 | const_iv (KeyReleaseMask), |
700 | const_iv (ButtonPressMask), |
681 | const_iv (ButtonPressMask), |
… | |
… | |
752 | const_iv (SelectionRequest), |
733 | const_iv (SelectionRequest), |
753 | const_iv (SelectionNotify), |
734 | const_iv (SelectionNotify), |
754 | const_iv (ColormapNotify), |
735 | const_iv (ColormapNotify), |
755 | const_iv (ClientMessage), |
736 | const_iv (ClientMessage), |
756 | const_iv (MappingNotify), |
737 | const_iv (MappingNotify), |
|
|
738 | # if ENABLE_XIM_ONTHESPOT |
|
|
739 | const_iv (XIMReverse), |
|
|
740 | const_iv (XIMUnderline), |
|
|
741 | const_iv (XIMHighlight), |
|
|
742 | const_iv (XIMPrimary), |
|
|
743 | const_iv (XIMSecondary), |
|
|
744 | const_iv (XIMTertiary), |
|
|
745 | const_iv (XIMVisibleToForward), |
|
|
746 | const_iv (XIMVisibleToBackword), |
|
|
747 | const_iv (XIMVisibleToCenter), |
|
|
748 | # if 0 |
|
|
749 | const_iv (XIMForwardChar), |
|
|
750 | const_iv (XIMBackwardChar), |
|
|
751 | const_iv (XIMForwardWord), |
|
|
752 | const_iv (XIMBackwardWord), |
|
|
753 | const_iv (XIMCaretUp), |
|
|
754 | const_iv (XIMCaretDown), |
|
|
755 | const_iv (XIMNextLine), |
|
|
756 | const_iv (XIMPreviousLine), |
|
|
757 | const_iv (XIMLineStart), |
|
|
758 | const_iv (XIMLineEnd), |
|
|
759 | const_iv (XIMAbsolutePosition), |
|
|
760 | const_iv (XIMDontChange), |
|
|
761 | # endif |
|
|
762 | # endif |
757 | }; |
763 | }; |
758 | |
764 | |
759 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
765 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
760 | civ-- > const_iv; ) |
|
|
761 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
766 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
762 | } |
767 | } |
763 | |
768 | |
764 | void |
769 | void |
765 | warn (const char *msg) |
770 | warn (const char *msg) |
… | |
… | |
769 | void |
774 | void |
770 | fatal (const char *msg) |
775 | fatal (const char *msg) |
771 | CODE: |
776 | CODE: |
772 | rxvt_fatal ("%s", msg); |
777 | rxvt_fatal ("%s", msg); |
773 | |
778 | |
774 | SV * |
|
|
775 | untaint (SV *sv) |
|
|
776 | CODE: |
|
|
777 | RETVAL = newSVsv (sv); |
|
|
778 | SvTAINTED_off (RETVAL); |
|
|
779 | OUTPUT: |
|
|
780 | RETVAL |
|
|
781 | |
|
|
782 | void |
779 | void |
783 | _exit (int status) |
780 | _exit (int status) |
784 | |
|
|
785 | bool |
|
|
786 | safe () |
|
|
787 | CODE: |
|
|
788 | RETVAL = !rxvt_tainted (); |
|
|
789 | OUTPUT: |
|
|
790 | RETVAL |
|
|
791 | |
781 | |
792 | NV |
782 | NV |
793 | NOW () |
783 | NOW () |
794 | CODE: |
784 | CODE: |
795 | RETVAL = NOW; |
785 | RETVAL = NOW; |
… | |
… | |
811 | RETVAL |
801 | RETVAL |
812 | |
802 | |
813 | int |
803 | int |
814 | SET_FGCOLOR (int rend, int new_color) |
804 | SET_FGCOLOR (int rend, int new_color) |
815 | CODE: |
805 | CODE: |
816 | RETVAL = SET_FGCOLOR (rend, new_color); |
806 | RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
817 | OUTPUT: |
807 | OUTPUT: |
818 | RETVAL |
808 | RETVAL |
819 | |
809 | |
820 | int |
810 | int |
821 | SET_BGCOLOR (int rend, int new_color) |
811 | SET_BGCOLOR (int rend, int new_color) |
822 | CODE: |
812 | CODE: |
823 | RETVAL = SET_BGCOLOR (rend, new_color); |
813 | RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
824 | OUTPUT: |
814 | OUTPUT: |
825 | RETVAL |
815 | RETVAL |
826 | |
816 | |
827 | int |
817 | int |
828 | GET_CUSTOM (int rend) |
818 | GET_CUSTOM (int rend) |
829 | CODE: |
819 | CODE: |
830 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
820 | RETVAL = (rend & RS_customMask) >> RS_customShift; |
831 | OUTPUT: |
821 | OUTPUT: |
832 | RETVAL |
822 | RETVAL |
833 | |
823 | |
834 | int |
824 | int |
835 | SET_CUSTOM (int rend, int new_value) |
825 | SET_CUSTOM (int rend, int new_value) |
… | |
… | |
842 | | ((new_value << RS_customShift) & RS_customMask); |
832 | | ((new_value << RS_customShift) & RS_customMask); |
843 | } |
833 | } |
844 | OUTPUT: |
834 | OUTPUT: |
845 | RETVAL |
835 | RETVAL |
846 | |
836 | |
|
|
837 | void |
|
|
838 | termlist () |
|
|
839 | PPCODE: |
|
|
840 | { |
|
|
841 | EXTEND (SP, rxvt_term::termlist.size ()); |
|
|
842 | |
|
|
843 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
844 | if ((*t)->perl.self) |
|
|
845 | PUSHs (sv_2mortal (newSVterm (*t))); |
|
|
846 | } |
|
|
847 | |
847 | MODULE = urxvt PACKAGE = urxvt::term |
848 | MODULE = urxvt PACKAGE = urxvt::term |
848 | |
849 | |
849 | SV * |
850 | SV * |
850 | _new (...) |
851 | _new (AV *env, AV *arg) |
851 | CODE: |
852 | CODE: |
852 | { |
853 | { |
853 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
854 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
855 | |
|
|
856 | rxvt_term *term = new rxvt_term; |
854 | rxvt_term *term = new rxvt_term; |
857 | |
855 | |
858 | term->argv = new stringvec; |
856 | stringvec *argv = new stringvec; |
859 | term->envv = new stringvec; |
857 | stringvec *envv = new stringvec; |
860 | |
858 | |
861 | for (int i = 1; i < items; i++) |
859 | for (int i = 0; i <= AvFILL (arg); i++) |
862 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
860 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
863 | |
861 | |
864 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
865 | for (int i = av_len (envv) + 1; i--; ) |
862 | for (int i = AvFILL (env) + 1; i--; ) |
866 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
863 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
867 | |
864 | |
868 | term->envv->push_back (0); |
865 | envv->push_back (0); |
869 | |
866 | |
870 | bool success; |
867 | bool success; |
871 | |
868 | |
872 | try |
869 | try |
873 | { |
870 | { |
874 | success = term->init (term->argv->size (), term->argv->begin ()); |
871 | success = term->init (argv, envv); |
875 | } |
872 | } |
876 | catch (const class rxvt_failure_exception &e) |
873 | catch (const class rxvt_failure_exception &e) |
877 | { |
874 | { |
878 | success = false; |
875 | success = false; |
879 | } |
876 | } |
… | |
… | |
896 | void |
893 | void |
897 | rxvt_term::set_should_invoke (int htype, int inc) |
894 | rxvt_term::set_should_invoke (int htype, int inc) |
898 | CODE: |
895 | CODE: |
899 | THIS->perl.should_invoke [htype] += inc; |
896 | THIS->perl.should_invoke [htype] += inc; |
900 | |
897 | |
901 | void |
898 | int |
902 | rxvt_term::grab_button (int button, U32 modifiers) |
899 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
903 | CODE: |
900 | CODE: |
904 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
901 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
905 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
902 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
906 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
903 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
904 | OUTPUT: RETVAL |
|
|
905 | |
|
|
906 | int |
|
|
907 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
|
|
908 | CODE: |
|
|
909 | RETVAL = XUngrabButton (THIS->dpy, button, modifiers, window); |
|
|
910 | OUTPUT: RETVAL |
|
|
911 | |
|
|
912 | void |
|
|
913 | rxvt_term::XGrabKey (int keycode, U32 modifiers, Window window = THIS->vt, \ |
|
|
914 | int owner_events = 1, int pointer_mode = GrabModeAsync, int keyboard_mode = GrabModeAsync) |
|
|
915 | CODE: |
|
|
916 | XGrabKey (THIS->dpy, keycode, modifiers, window, owner_events, pointer_mode, keyboard_mode); |
|
|
917 | |
|
|
918 | void |
|
|
919 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
|
|
920 | CODE: |
|
|
921 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
|
|
922 | |
|
|
923 | void |
|
|
924 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
925 | CODE: |
|
|
926 | XUngrabKeyboard (THIS->dpy, eventtime); |
907 | |
927 | |
908 | bool |
928 | bool |
909 | rxvt_term::grab (U32 eventtime, int sync = 0) |
929 | rxvt_term::grab (Time eventtime, int sync = 0) |
910 | CODE: |
930 | CODE: |
911 | { |
931 | { |
912 | int mode = sync ? GrabModeSync : GrabModeAsync; |
932 | int mode = sync ? GrabModeSync : GrabModeAsync; |
913 | |
933 | |
914 | THIS->perl.grabtime = 0; |
934 | THIS->perl.grabtime = 0; |
915 | |
935 | |
916 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
936 | if (!XGrabPointer (THIS->dpy, THIS->vt, 0, |
917 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
937 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
918 | mode, mode, None, GRAB_CURSOR, eventtime)) |
938 | mode, mode, None, GRAB_CURSOR, eventtime)) |
919 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
939 | if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime)) |
920 | THIS->perl.grabtime = eventtime; |
940 | THIS->perl.grabtime = eventtime; |
921 | else |
941 | else |
922 | XUngrabPointer (THIS->display->display, eventtime); |
942 | XUngrabPointer (THIS->dpy, eventtime); |
923 | |
943 | |
924 | RETVAL = !!THIS->perl.grabtime; |
944 | RETVAL = !!THIS->perl.grabtime; |
925 | } |
945 | } |
926 | OUTPUT: |
946 | OUTPUT: |
927 | RETVAL |
947 | RETVAL |
928 | |
948 | |
929 | void |
949 | void |
930 | rxvt_term::allow_events_async () |
950 | rxvt_term::allow_events_async () |
931 | CODE: |
951 | CODE: |
932 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
952 | XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime); |
933 | |
953 | |
934 | void |
954 | void |
935 | rxvt_term::allow_events_sync () |
955 | rxvt_term::allow_events_sync () |
936 | CODE: |
956 | CODE: |
937 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
957 | XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime); |
938 | |
958 | |
939 | void |
959 | void |
940 | rxvt_term::allow_events_replay () |
960 | rxvt_term::allow_events_replay () |
941 | CODE: |
961 | CODE: |
942 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
962 | XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime); |
943 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
963 | XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime); |
944 | |
964 | |
945 | void |
965 | void |
946 | rxvt_term::ungrab () |
966 | rxvt_term::ungrab () |
947 | CODE: |
967 | CODE: |
948 | ungrab (THIS); |
968 | ungrab (THIS); |
|
|
969 | |
|
|
970 | int |
|
|
971 | rxvt_term::XStringToKeysym (char *string) |
|
|
972 | CODE: |
|
|
973 | RETVAL = XStringToKeysym (string); |
|
|
974 | OUTPUT: RETVAL |
|
|
975 | |
|
|
976 | char * |
|
|
977 | rxvt_term::XKeysymToString (int sym) |
|
|
978 | CODE: |
|
|
979 | RETVAL = XKeysymToString (sym); |
|
|
980 | OUTPUT: RETVAL |
|
|
981 | |
|
|
982 | int |
|
|
983 | rxvt_term::XKeysymToKeycode (int sym) |
|
|
984 | CODE: |
|
|
985 | RETVAL = XKeysymToKeycode (THIS->dpy, sym); |
|
|
986 | OUTPUT: RETVAL |
|
|
987 | |
|
|
988 | int |
|
|
989 | rxvt_term::XKeycodeToKeysym (int code, int index) |
|
|
990 | CODE: |
|
|
991 | RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); |
|
|
992 | OUTPUT: RETVAL |
949 | |
993 | |
950 | int |
994 | int |
951 | rxvt_term::strwidth (SV *str) |
995 | rxvt_term::strwidth (SV *str) |
952 | CODE: |
996 | CODE: |
953 | { |
997 | { |
954 | wchar_t *wstr = sv2wcs (str); |
998 | wchar_t *wstr = sv2wcs (str); |
955 | |
999 | |
956 | rxvt_push_locale (THIS->locale); |
1000 | rxvt_push_locale (THIS->locale); |
957 | RETVAL = wcswidth (wstr, wcslen (wstr)); |
1001 | RETVAL = 0; |
|
|
1002 | for (wchar_t *wc = wstr; *wc; wc++) |
|
|
1003 | { |
|
|
1004 | int w = WCWIDTH (*wc); |
|
|
1005 | |
|
|
1006 | if (w) |
|
|
1007 | RETVAL += max (w, 1); |
|
|
1008 | } |
958 | rxvt_pop_locale (); |
1009 | rxvt_pop_locale (); |
959 | |
1010 | |
960 | free (wstr); |
1011 | free (wstr); |
961 | } |
1012 | } |
962 | OUTPUT: |
1013 | OUTPUT: |
… | |
… | |
972 | char *mbstr = rxvt_wcstombs (wstr); |
1023 | char *mbstr = rxvt_wcstombs (wstr); |
973 | rxvt_pop_locale (); |
1024 | rxvt_pop_locale (); |
974 | |
1025 | |
975 | free (wstr); |
1026 | free (wstr); |
976 | |
1027 | |
977 | RETVAL = taint_if (newSVpv (mbstr, 0), str); |
1028 | RETVAL = newSVpv (mbstr, 0); |
978 | free (mbstr); |
1029 | free (mbstr); |
979 | } |
1030 | } |
980 | OUTPUT: |
1031 | OUTPUT: |
981 | RETVAL |
1032 | RETVAL |
982 | |
1033 | |
… | |
… | |
989 | |
1040 | |
990 | rxvt_push_locale (THIS->locale); |
1041 | rxvt_push_locale (THIS->locale); |
991 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
1042 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
992 | rxvt_pop_locale (); |
1043 | rxvt_pop_locale (); |
993 | |
1044 | |
994 | RETVAL = taint_if (wcs2sv (wstr), octets); |
1045 | RETVAL = wcs2sv (wstr); |
995 | free (wstr); |
1046 | free (wstr); |
996 | } |
1047 | } |
|
|
1048 | OUTPUT: |
|
|
1049 | RETVAL |
|
|
1050 | |
|
|
1051 | char * |
|
|
1052 | rxvt_term::locale () |
|
|
1053 | CODE: |
|
|
1054 | RETVAL = THIS->locale; |
997 | OUTPUT: |
1055 | OUTPUT: |
998 | RETVAL |
1056 | RETVAL |
999 | |
1057 | |
1000 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1058 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1001 | |
1059 | |
… | |
… | |
1006 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1064 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1007 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1065 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1008 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1066 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1009 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1067 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1010 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1068 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
1069 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
|
|
1070 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
|
|
1071 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
1011 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1072 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1012 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1073 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1013 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
1074 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1014 | |
1075 | |
1015 | int |
1076 | int |
1016 | rxvt_term::width () |
1077 | rxvt_term::width () |
1017 | ALIAS: |
1078 | ALIAS: |
1018 | width = TERM_OFFSET_width |
1079 | width = TERM_OFFSET_width |
… | |
… | |
1022 | fbase = TERM_OFFSET_fbase |
1083 | fbase = TERM_OFFSET_fbase |
1023 | nrow = TERM_OFFSET_nrow |
1084 | nrow = TERM_OFFSET_nrow |
1024 | ncol = TERM_OFFSET_ncol |
1085 | ncol = TERM_OFFSET_ncol |
1025 | focus = TERM_OFFSET_focus |
1086 | focus = TERM_OFFSET_focus |
1026 | mapped = TERM_OFFSET_mapped |
1087 | mapped = TERM_OFFSET_mapped |
|
|
1088 | int_bwidth = TERM_OFFSET_int_bwidth |
|
|
1089 | ext_bwidth = TERM_OFFSET_ext_bwidth |
|
|
1090 | lineSpace = TERM_OFFSET_lineSpace |
1027 | saveLines = TERM_OFFSET_saveLines |
1091 | saveLines = TERM_OFFSET_saveLines |
1028 | total_rows = TERM_OFFSET_total_rows |
1092 | total_rows = TERM_OFFSET_total_rows |
1029 | nsaved = TERM_OFFSET_nsaved |
1093 | top_row = TERM_OFFSET_top_row |
1030 | CODE: |
1094 | CODE: |
1031 | RETVAL = *(int *)((char *)THIS + ix); |
1095 | RETVAL = *(int *)((char *)THIS + ix); |
1032 | OUTPUT: |
1096 | OUTPUT: |
1033 | RETVAL |
1097 | RETVAL |
1034 | |
1098 | |
… | |
… | |
1036 | rxvt_term::ModLevel3Mask () |
1100 | rxvt_term::ModLevel3Mask () |
1037 | ALIAS: |
1101 | ALIAS: |
1038 | ModLevel3Mask = 0 |
1102 | ModLevel3Mask = 0 |
1039 | ModMetaMask = 1 |
1103 | ModMetaMask = 1 |
1040 | ModNumLockMask = 2 |
1104 | ModNumLockMask = 2 |
|
|
1105 | current_screen = 3 |
|
|
1106 | hidden_cursor = 4 |
1041 | CODE: |
1107 | CODE: |
1042 | switch (ix) |
1108 | switch (ix) |
1043 | { |
1109 | { |
1044 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1110 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1045 | case 1: RETVAL = THIS->ModMetaMask; break; |
1111 | case 1: RETVAL = THIS->ModMetaMask; break; |
1046 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1112 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
1113 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1114 | case 4: RETVAL = THIS->hidden_cursor; break; |
1047 | } |
1115 | } |
1048 | OUTPUT: |
1116 | OUTPUT: |
1049 | RETVAL |
1117 | RETVAL |
1050 | |
1118 | |
1051 | char * |
1119 | char * |
… | |
… | |
1061 | } |
1129 | } |
1062 | OUTPUT: |
1130 | OUTPUT: |
1063 | RETVAL |
1131 | RETVAL |
1064 | |
1132 | |
1065 | SV * |
1133 | SV * |
1066 | rxvt_term::_env () |
1134 | rxvt_term::envv () |
|
|
1135 | ALIAS: |
|
|
1136 | argv = 1 |
1067 | CODE: |
1137 | PPCODE: |
1068 | { |
1138 | { |
1069 | if (THIS->envv) |
1139 | stringvec *vec = ix ? THIS->argv : THIS->envv; |
1070 | { |
|
|
1071 | AV *av = newAV (); |
|
|
1072 | |
1140 | |
|
|
1141 | EXTEND (SP, vec->size ()); |
|
|
1142 | |
1073 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
1143 | for (char **i = vec->begin (); i != vec->end (); ++i) |
1074 | if (*i) |
1144 | if (*i) |
1075 | av_push (av, newSVpv (*i, 0)); |
1145 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1076 | |
|
|
1077 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1078 | } |
|
|
1079 | else |
|
|
1080 | RETVAL = &PL_sv_undef; |
|
|
1081 | } |
1146 | } |
1082 | OUTPUT: |
|
|
1083 | RETVAL |
|
|
1084 | |
1147 | |
1085 | int |
1148 | int |
1086 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1149 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1087 | CODE: |
1150 | CODE: |
1088 | RETVAL = THIS->pty_ev.events; |
1151 | RETVAL = THIS->pty_ev.events; |
1089 | if (events != EVENT_UNDEF) |
1152 | if (events != EVENT_UNDEF) |
1090 | THIS->pty_ev.set (events); |
1153 | THIS->pty_ev.set (events); |
1091 | OUTPUT: |
1154 | OUTPUT: |
1092 | RETVAL |
1155 | RETVAL |
1093 | |
1156 | |
1094 | U32 |
1157 | int |
|
|
1158 | rxvt_term::pty_fd () |
|
|
1159 | CODE: |
|
|
1160 | RETVAL = THIS->pty->pty; |
|
|
1161 | OUTPUT: |
|
|
1162 | RETVAL |
|
|
1163 | |
|
|
1164 | Window |
1095 | rxvt_term::parent () |
1165 | rxvt_term::parent () |
1096 | CODE: |
1166 | CODE: |
1097 | RETVAL = (U32)THIS->parent [0]; |
1167 | RETVAL = THIS->parent [0]; |
1098 | OUTPUT: |
1168 | OUTPUT: |
1099 | RETVAL |
1169 | RETVAL |
1100 | |
1170 | |
1101 | U32 |
1171 | Window |
1102 | rxvt_term::vt () |
1172 | rxvt_term::vt () |
1103 | CODE: |
1173 | CODE: |
1104 | RETVAL = (U32)THIS->vt; |
1174 | RETVAL = THIS->vt; |
1105 | OUTPUT: |
1175 | OUTPUT: |
1106 | RETVAL |
1176 | RETVAL |
1107 | |
1177 | |
1108 | void |
1178 | void |
1109 | rxvt_term::vt_emask_add (U32 emask) |
1179 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1118 | THIS->rstyle = new_rstyle; |
1188 | THIS->rstyle = new_rstyle; |
1119 | OUTPUT: |
1189 | OUTPUT: |
1120 | RETVAL |
1190 | RETVAL |
1121 | |
1191 | |
1122 | int |
1192 | int |
1123 | rxvt_term::view_start (int newval = -1) |
1193 | rxvt_term::view_start (int newval = 1) |
1124 | PROTOTYPE: $;$ |
1194 | PROTOTYPE: $;$ |
1125 | CODE: |
1195 | CODE: |
1126 | { |
1196 | { |
1127 | RETVAL = THIS->view_start; |
1197 | RETVAL = THIS->view_start; |
1128 | |
1198 | |
1129 | if (newval >= 0) |
1199 | if (newval <= 0) |
1130 | { |
1200 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1131 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
1132 | THIS->scr_changeview (RETVAL); |
|
|
1133 | } |
|
|
1134 | } |
1201 | } |
1135 | OUTPUT: |
1202 | OUTPUT: |
1136 | RETVAL |
1203 | RETVAL |
1137 | |
1204 | |
1138 | void |
1205 | void |
|
|
1206 | rxvt_term::focus_in () |
|
|
1207 | |
|
|
1208 | void |
|
|
1209 | rxvt_term::focus_out () |
|
|
1210 | |
|
|
1211 | void |
|
|
1212 | rxvt_term::key_press (unsigned int state, unsigned int keycode, Time time = CurrentTime) |
|
|
1213 | ALIAS: |
|
|
1214 | key_release = 1 |
|
|
1215 | CODE: |
|
|
1216 | { |
|
|
1217 | XKeyEvent xkey; |
|
|
1218 | |
|
|
1219 | memset (&xkey, 0, sizeof (xkey)); |
|
|
1220 | |
|
|
1221 | xkey.time = time; |
|
|
1222 | xkey.state = state; |
|
|
1223 | xkey.keycode = keycode; |
|
|
1224 | |
|
|
1225 | xkey.type = ix ? KeyRelease : KeyPress; |
|
|
1226 | xkey.display = THIS->dpy; |
|
|
1227 | xkey.window = THIS->vt; |
|
|
1228 | xkey.root = THIS->display->root; |
|
|
1229 | xkey.subwindow = THIS->vt; |
|
|
1230 | |
|
|
1231 | if (ix) |
|
|
1232 | THIS->key_release (xkey); |
|
|
1233 | else |
|
|
1234 | THIS->key_press (xkey); |
|
|
1235 | } |
|
|
1236 | |
|
|
1237 | void |
1139 | rxvt_term::want_refresh () |
1238 | rxvt_term::want_refresh () |
1140 | CODE: |
1239 | CODE: |
1141 | THIS->want_refresh = 1; |
1240 | THIS->want_refresh = 1; |
1142 | |
1241 | |
1143 | void |
1242 | void |
1144 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1243 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1145 | PPCODE: |
1244 | PPCODE: |
1146 | { |
1245 | { |
1147 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1246 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1148 | XSRETURN_EMPTY; |
1247 | XSRETURN_EMPTY; |
1149 | |
1248 | |
1150 | line_t &l = ROW(row_number); |
1249 | line_t &l = ROW(row_number); |
1151 | |
1250 | |
1152 | if (GIMME_V != G_VOID) |
1251 | if (GIMME_V != G_VOID) |
1153 | { |
1252 | { |
1154 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
1253 | wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol); |
1155 | |
1254 | |
1156 | for (int col = 0; col < THIS->ncol; col++) |
1255 | for (int col = 0; col < THIS->ncol; col++) |
1157 | wstr [col] = l.t [col]; |
1256 | wstr [col] = l.t [col]; |
1158 | |
1257 | |
1159 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); |
1258 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1160 | |
|
|
1161 | delete [] wstr; |
|
|
1162 | } |
1259 | } |
1163 | |
1260 | |
1164 | if (new_text) |
1261 | if (new_text) |
1165 | { |
1262 | { |
1166 | wchar_t *wstr = sv2wcs (new_text); |
1263 | wchar_t *wstr = sv2wcs (new_text); |
1167 | |
1264 | |
1168 | int len = min (wcslen (wstr) - start_ofs, max_len); |
1265 | int len = min (wcslen (wstr) - start_ofs, max_len); |
1169 | |
1266 | |
1170 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1267 | if (start_col < 0 || start_col + len > THIS->ncol) |
1171 | { |
1268 | { |
1172 | free (wstr); |
1269 | free (wstr); |
1173 | croak ("new_text extends beyond horizontal margins"); |
1270 | croak ("new_text extends beyond horizontal margins"); |
1174 | } |
1271 | } |
1175 | |
1272 | |
… | |
… | |
1185 | |
1282 | |
1186 | void |
1283 | void |
1187 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1284 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1188 | PPCODE: |
1285 | PPCODE: |
1189 | { |
1286 | { |
1190 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1287 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1191 | XSRETURN_EMPTY; |
1288 | XSRETURN_EMPTY; |
1192 | |
1289 | |
1193 | line_t &l = ROW(row_number); |
1290 | line_t &l = ROW(row_number); |
1194 | |
1291 | |
1195 | if (GIMME_V != G_VOID) |
1292 | if (GIMME_V != G_VOID) |
… | |
… | |
1207 | { |
1304 | { |
1208 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1305 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1209 | croak ("new_rend must be arrayref"); |
1306 | croak ("new_rend must be arrayref"); |
1210 | |
1307 | |
1211 | AV *av = (AV *)SvRV (new_rend); |
1308 | AV *av = (AV *)SvRV (new_rend); |
1212 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
1309 | int len = min (AvFILL (av) + 1 - start_ofs, max_len); |
1213 | |
1310 | |
1214 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1311 | if (start_col < 0 || start_col + len > THIS->ncol) |
1215 | croak ("new_rend array extends beyond horizontal margins"); |
1312 | croak ("new_rend array extends beyond horizontal margins"); |
1216 | |
1313 | |
1217 | for (int col = start_col; col < start_col + len; col++) |
1314 | for (int col = start_col; col < start_col + len; col++) |
1218 | { |
1315 | { |
1219 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
1316 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
… | |
… | |
1225 | |
1322 | |
1226 | int |
1323 | int |
1227 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1324 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1228 | CODE: |
1325 | CODE: |
1229 | { |
1326 | { |
1230 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1327 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1231 | XSRETURN_EMPTY; |
1328 | XSRETURN_EMPTY; |
1232 | |
1329 | |
1233 | line_t &l = ROW(row_number); |
1330 | line_t &l = ROW(row_number); |
1234 | RETVAL = l.l; |
1331 | RETVAL = l.l; |
1235 | |
1332 | |
… | |
… | |
1241 | |
1338 | |
1242 | bool |
1339 | bool |
1243 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1340 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1244 | CODE: |
1341 | CODE: |
1245 | { |
1342 | { |
1246 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1343 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1247 | XSRETURN_EMPTY; |
1344 | XSRETURN_EMPTY; |
1248 | |
1345 | |
1249 | line_t &l = ROW(row_number); |
1346 | line_t &l = ROW(row_number); |
1250 | RETVAL = l.is_longer (); |
1347 | RETVAL = l.is_longer (); |
1251 | |
1348 | |
… | |
… | |
1259 | rxvt_term::special_encode (SV *string) |
1356 | rxvt_term::special_encode (SV *string) |
1260 | CODE: |
1357 | CODE: |
1261 | { |
1358 | { |
1262 | wchar_t *wstr = sv2wcs (string); |
1359 | wchar_t *wstr = sv2wcs (string); |
1263 | int wlen = wcslen (wstr); |
1360 | int wlen = wcslen (wstr); |
1264 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
1361 | wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer |
1265 | |
1362 | |
1266 | rxvt_push_locale (THIS->locale); |
1363 | rxvt_push_locale (THIS->locale); |
1267 | |
1364 | |
1268 | wchar_t *r = rstr; |
1365 | wchar_t *r = rstr; |
1269 | for (wchar_t *s = wstr; *s; s++) |
1366 | for (wchar_t *s = wstr; *s; s++) |
|
|
1367 | { |
|
|
1368 | int w = WCWIDTH (*s); |
|
|
1369 | |
1270 | if (wcwidth (*s) == 0) |
1370 | if (w == 0) |
1271 | { |
1371 | { |
1272 | if (r == rstr) |
1372 | if (r == rstr) |
1273 | croak ("leading combining character unencodable"); |
1373 | croak ("leading combining character unencodable"); |
1274 | |
1374 | |
1275 | unicode_t n = rxvt_compose (r[-1], *s); |
1375 | unicode_t n = rxvt_compose (r[-1], *s); |
1276 | if (n == NOCHAR) |
1376 | if (n == NOCHAR) |
1277 | n = rxvt_composite.compose (r[-1], *s); |
1377 | n = rxvt_composite.compose (r[-1], *s); |
1278 | |
1378 | |
1279 | r[-1] = n; |
1379 | r[-1] = n; |
1280 | } |
1380 | } |
1281 | #if !UNICODE_3 |
1381 | #if !UNICODE_3 |
1282 | else if (*s >= 0x10000) |
1382 | else if (*s >= 0x10000) |
1283 | *r++ = rxvt_composite.compose (*s); |
1383 | *r++ = rxvt_composite.compose (*s); |
1284 | #endif |
1384 | #endif |
1285 | else |
1385 | else |
1286 | *r++ = *s; |
1386 | *r++ = *s; |
|
|
1387 | |
|
|
1388 | // the *2 above only allows wcwidth <= 2 |
|
|
1389 | if (w > 1) |
|
|
1390 | *r++ = NOCHAR; |
|
|
1391 | } |
1287 | |
1392 | |
1288 | rxvt_pop_locale (); |
1393 | rxvt_pop_locale (); |
1289 | |
1394 | |
1290 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); |
1395 | RETVAL = wcs2sv (rstr, r - rstr); |
1291 | |
|
|
1292 | delete [] rstr; |
|
|
1293 | } |
1396 | } |
1294 | OUTPUT: |
1397 | OUTPUT: |
1295 | RETVAL |
1398 | RETVAL |
1296 | |
1399 | |
1297 | SV * |
1400 | SV * |
… | |
… | |
1309 | else if (IS_COMPOSE (*s)) |
1412 | else if (IS_COMPOSE (*s)) |
1310 | dlen += rxvt_composite.expand (*s, 0); |
1413 | dlen += rxvt_composite.expand (*s, 0); |
1311 | else |
1414 | else |
1312 | dlen++; |
1415 | dlen++; |
1313 | |
1416 | |
1314 | wchar_t *rstr = new wchar_t [dlen]; |
1417 | wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen); |
1315 | |
1418 | |
1316 | // decode |
1419 | // decode |
1317 | wchar_t *r = rstr; |
1420 | wchar_t *r = rstr; |
1318 | for (wchar_t *s = wstr; *s; s++) |
1421 | for (wchar_t *s = wstr; *s; s++) |
1319 | if (*s == NOCHAR) |
1422 | if (*s == NOCHAR) |
… | |
… | |
1321 | else if (IS_COMPOSE (*s)) |
1424 | else if (IS_COMPOSE (*s)) |
1322 | r += rxvt_composite.expand (*s, r); |
1425 | r += rxvt_composite.expand (*s, r); |
1323 | else |
1426 | else |
1324 | *r++ = *s; |
1427 | *r++ = *s; |
1325 | |
1428 | |
1326 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); |
1429 | RETVAL = wcs2sv (rstr, r - rstr); |
1327 | |
|
|
1328 | delete [] rstr; |
|
|
1329 | } |
1430 | } |
1330 | OUTPUT: |
1431 | OUTPUT: |
1331 | RETVAL |
1432 | RETVAL |
1332 | |
1433 | |
1333 | void |
1434 | void |
1334 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1435 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1335 | PPCODE: |
1436 | PPCODE: |
1336 | { |
1437 | { |
1337 | struct resval { const char *name; int value; } rslist [] = { |
1438 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1338 | # define def(name) { # name, Rs_ ## name }, |
1439 | # define def(name) { # name, Rs_ ## name }, |
1339 | # define reserve(name,count) |
1440 | # define reserve(name,count) |
1340 | # include "rsinc.h" |
1441 | # include "rsinc.h" |
1341 | # undef def |
1442 | # undef def |
1342 | # undef reserve |
1443 | # undef reserve |
1343 | }; |
1444 | }; |
1344 | |
1445 | |
1345 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1446 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1346 | |
1447 | |
1347 | do { |
1448 | do { |
1348 | if (rs-- == rslist) |
1449 | if (rs-- == rslist) |
1349 | croak ("no such resource '%s', requested", name); |
1450 | croak ("no such resource '%s', requested", name); |
1350 | } while (strcmp (name, rs->name)); |
1451 | } while (strcmp (name, rs->name)); |
… | |
… | |
1353 | |
1454 | |
1354 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1455 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1355 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1456 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1356 | |
1457 | |
1357 | if (GIMME_V != G_VOID) |
1458 | if (GIMME_V != G_VOID) |
1358 | XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); |
1459 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
1359 | |
1460 | |
1360 | if (newval) |
1461 | if (newval) |
1361 | { |
1462 | { |
1362 | if (SvOK (newval)) |
1463 | if (SvOK (newval)) |
1363 | { |
1464 | { |
… | |
… | |
1370 | } |
1471 | } |
1371 | } |
1472 | } |
1372 | |
1473 | |
1373 | const char * |
1474 | const char * |
1374 | rxvt_term::x_resource (const char *name) |
1475 | rxvt_term::x_resource (const char *name) |
1375 | CLEANUP: |
|
|
1376 | SvTAINTED_on (ST (0)); |
|
|
1377 | |
1476 | |
1378 | bool |
1477 | bool |
1379 | rxvt_term::option (U32 optval, int set = -1) |
1478 | rxvt_term::option (U32 optval, int set = -1) |
1380 | CODE: |
1479 | CODE: |
1381 | { |
1480 | { |
… | |
… | |
1386 | if (set) |
1485 | if (set) |
1387 | THIS->options |= optval; |
1486 | THIS->options |= optval; |
1388 | else |
1487 | else |
1389 | THIS->options &= ~optval; |
1488 | THIS->options &= ~optval; |
1390 | |
1489 | |
|
|
1490 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1391 | switch (optval) |
1491 | switch (optval) |
1392 | { |
1492 | { |
1393 | case Opt_skipBuiltinGlyphs: |
1493 | case Opt_skipBuiltinGlyphs: |
1394 | THIS->set_fonts (); |
1494 | THIS->set_fonts (); |
1395 | THIS->scr_remap_chars (); |
1495 | THIS->scr_remap_chars (); |
1396 | THIS->scr_touch (true); |
1496 | THIS->scr_touch (true); |
1397 | THIS->want_refresh = 1; |
1497 | THIS->want_refresh = 1; |
1398 | break; |
1498 | break; |
1399 | |
1499 | |
1400 | case Opt_cursorUnderline: |
1500 | case Opt_cursorUnderline: |
1401 | THIS->want_refresh = 1; |
1501 | THIS->want_refresh = 1; |
1402 | break; |
1502 | break; |
1403 | |
1503 | |
1404 | # case Opt_scrollBar_floating: |
1504 | # case Opt_scrollBar_floating: |
1405 | # case Opt_scrollBar_right: |
1505 | # case Opt_scrollBar_right: |
1406 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1506 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1407 | # break; |
1507 | # break; |
1408 | } |
1508 | } |
1409 | } |
1509 | } |
1410 | } |
1510 | } |
1411 | OUTPUT: |
1511 | OUTPUT: |
1412 | RETVAL |
1512 | RETVAL |
1413 | |
1513 | |
… | |
… | |
1441 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1541 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1442 | } |
1542 | } |
1443 | |
1543 | |
1444 | if (items == 3) |
1544 | if (items == 3) |
1445 | { |
1545 | { |
1446 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1546 | rc.row = SvIV (ST (1)); |
1447 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1547 | rc.col = SvIV (ST (2)); |
|
|
1548 | |
|
|
1549 | if (ix == 2) |
|
|
1550 | { |
|
|
1551 | if (rc.col == 0) |
|
|
1552 | { |
|
|
1553 | // col == 0 means end of previous line |
|
|
1554 | rc.row--; |
|
|
1555 | rc.col = THIS->ncol; |
|
|
1556 | } |
|
|
1557 | else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow) |
|
|
1558 | && rc.col > ROW(rc.row).l) |
|
|
1559 | { |
|
|
1560 | // col >= length means while line and add newline |
|
|
1561 | rc.col = THIS->ncol; |
|
|
1562 | } |
|
|
1563 | } |
|
|
1564 | |
|
|
1565 | clamp_it (rc.col, 0, THIS->ncol); |
|
|
1566 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1448 | |
1567 | |
1449 | if (ix) |
1568 | if (ix) |
1450 | THIS->want_refresh = 1; |
1569 | THIS->want_refresh = 1; |
1451 | } |
1570 | } |
1452 | } |
1571 | } |
… | |
… | |
1456 | CODE: |
1575 | CODE: |
1457 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1576 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1458 | OUTPUT: |
1577 | OUTPUT: |
1459 | RETVAL |
1578 | RETVAL |
1460 | |
1579 | |
1461 | #void |
1580 | void |
1462 | #rxvt_term::selection_clear () |
1581 | rxvt_term::selection_clear () |
1463 | |
1582 | |
1464 | void |
1583 | void |
1465 | rxvt_term::selection_make (U32 eventtime, bool rect = false) |
1584 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1466 | CODE: |
1585 | CODE: |
1467 | THIS->selection.op = SELECTION_CONT; |
1586 | THIS->selection.op = SELECTION_CONT; |
1468 | THIS->selection.rect = rect; |
1587 | THIS->selection.rect = rect; |
1469 | THIS->selection_make (eventtime); |
1588 | THIS->selection_make (eventtime); |
1470 | |
1589 | |
1471 | int |
1590 | int |
1472 | rxvt_term::selection_grab (U32 eventtime) |
1591 | rxvt_term::selection_grab (Time eventtime) |
1473 | |
1592 | |
1474 | void |
1593 | void |
1475 | rxvt_term::selection (SV *newtext = 0) |
1594 | rxvt_term::selection (SV *newtext = 0) |
1476 | PPCODE: |
1595 | PPCODE: |
1477 | { |
1596 | { |
1478 | if (GIMME_V != G_VOID) |
1597 | if (GIMME_V != G_VOID) |
1479 | XPUSHs (THIS->selection.text |
1598 | XPUSHs (THIS->selection.text |
1480 | ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) |
1599 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1481 | : &PL_sv_undef); |
1600 | : &PL_sv_undef); |
1482 | |
1601 | |
1483 | if (newtext) |
1602 | if (newtext) |
1484 | { |
1603 | { |
1485 | free (THIS->selection.text); |
1604 | free (THIS->selection.text); |
… | |
… | |
1495 | void |
1614 | void |
1496 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1615 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1497 | |
1616 | |
1498 | void |
1617 | void |
1499 | rxvt_term::scr_bell () |
1618 | rxvt_term::scr_bell () |
|
|
1619 | |
|
|
1620 | void |
|
|
1621 | rxvt_term::scr_change_screen (int screen) |
1500 | |
1622 | |
1501 | void |
1623 | void |
1502 | rxvt_term::scr_add_lines (SV *string) |
1624 | rxvt_term::scr_add_lines (SV *string) |
1503 | CODE: |
1625 | CODE: |
1504 | { |
1626 | { |
… | |
… | |
1545 | o->self = (HV *)SvRV (RETVAL); |
1667 | o->self = (HV *)SvRV (RETVAL); |
1546 | } |
1668 | } |
1547 | OUTPUT: |
1669 | OUTPUT: |
1548 | RETVAL |
1670 | RETVAL |
1549 | |
1671 | |
|
|
1672 | ############################################################################# |
|
|
1673 | # Various X Utility Functions |
|
|
1674 | ############################################################################# |
|
|
1675 | |
|
|
1676 | void |
|
|
1677 | rxvt_term::XListProperties (Window window) |
|
|
1678 | PPCODE: |
|
|
1679 | { |
|
|
1680 | int count; |
|
|
1681 | Atom *props = XListProperties (THIS->dpy, window, &count); |
|
|
1682 | |
|
|
1683 | EXTEND (SP, count); |
|
|
1684 | while (count--) |
|
|
1685 | PUSHs (newSVuv ((U32)props [count])); |
|
|
1686 | |
|
|
1687 | XFree (props); |
|
|
1688 | } |
|
|
1689 | |
|
|
1690 | void |
|
|
1691 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
|
|
1692 | PPCODE: |
|
|
1693 | { |
|
|
1694 | Atom type; |
|
|
1695 | int format; |
|
|
1696 | unsigned long nitems; |
|
|
1697 | unsigned long bytes_after; |
|
|
1698 | unsigned char *prop; |
|
|
1699 | |
|
|
1700 | XGetWindowProperty (THIS->dpy, window, property, |
|
|
1701 | 0, 1<<24, 0, AnyPropertyType, |
|
|
1702 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
1703 | |
|
|
1704 | if (type != None) |
|
|
1705 | { |
|
|
1706 | int elemsize = format == 16 ? sizeof (short) |
|
|
1707 | : format == 32 ? sizeof (long) |
|
|
1708 | : 1; |
|
|
1709 | |
|
|
1710 | EXTEND (SP, 3); |
|
|
1711 | PUSHs (newSVuv ((U32)type)); |
|
|
1712 | PUSHs (newSViv (format)); |
|
|
1713 | PUSHs (newSVpvn ((char *)prop, nitems * elemsize)); |
|
|
1714 | XFree (prop); |
|
|
1715 | } |
|
|
1716 | } |
|
|
1717 | |
|
|
1718 | void |
|
|
1719 | rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) |
|
|
1720 | CODE: |
|
|
1721 | { |
|
|
1722 | STRLEN len; |
|
|
1723 | char *data_ = SvPVbyte (data, len); |
|
|
1724 | |
|
|
1725 | int elemsize = format == 16 ? sizeof (short) |
|
|
1726 | : format == 32 ? sizeof (long) |
|
|
1727 | : 1; |
|
|
1728 | |
|
|
1729 | XChangeProperty (THIS->dpy, window, property, |
|
|
1730 | type, format, PropModeReplace, |
|
|
1731 | (unsigned char *)data_, len / elemsize); |
|
|
1732 | } |
|
|
1733 | |
|
|
1734 | Atom |
|
|
1735 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
|
|
1736 | C_ARGS: term->dpy, atom_name, only_if_exists |
|
|
1737 | |
|
|
1738 | char * |
|
|
1739 | XGetAtomName (rxvt_term *term, Atom atom) |
|
|
1740 | C_ARGS: term->dpy, atom |
|
|
1741 | CLEANUP: |
|
|
1742 | XFree (RETVAL); |
|
|
1743 | |
|
|
1744 | void |
|
|
1745 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
|
|
1746 | C_ARGS: term->dpy, window, property |
|
|
1747 | |
|
|
1748 | Window |
|
|
1749 | rxvt_term::DefaultRootWindow () |
|
|
1750 | CODE: |
|
|
1751 | RETVAL = THIS->display->root; |
|
|
1752 | OUTPUT: |
|
|
1753 | RETVAL |
|
|
1754 | |
|
|
1755 | #if 0 |
|
|
1756 | |
|
|
1757 | Window |
|
|
1758 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
|
|
1759 | C_ARGS: term->dpy, (Window)parent, |
|
|
1760 | x, y, width, height, 0, |
|
|
1761 | term->pix_colors_focused[Color_border], |
|
|
1762 | term->pix_colors_focused[Color_border] |
|
|
1763 | |
|
|
1764 | #endif |
|
|
1765 | |
|
|
1766 | void |
|
|
1767 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
|
|
1768 | C_ARGS: term->dpy, window, parent, x, y |
|
|
1769 | |
|
|
1770 | void |
|
|
1771 | XMapWindow (rxvt_term *term, Window window) |
|
|
1772 | C_ARGS: term->dpy, window |
|
|
1773 | |
|
|
1774 | void |
|
|
1775 | XUnmapWindow (rxvt_term *term, Window window) |
|
|
1776 | C_ARGS: term->dpy, window |
|
|
1777 | |
|
|
1778 | void |
|
|
1779 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
|
|
1780 | C_ARGS: term->dpy, window, x, y, width, height |
|
|
1781 | |
|
|
1782 | void |
|
|
1783 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
|
|
1784 | CODE: |
|
|
1785 | { |
|
|
1786 | XWindowAttributes attr; |
|
|
1787 | XGetWindowAttributes (THIS->dpy, window, &attr); |
|
|
1788 | XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events); |
|
|
1789 | } |
|
|
1790 | |
|
|
1791 | void |
|
|
1792 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
|
|
1793 | PPCODE: |
|
|
1794 | { |
|
|
1795 | int dx, dy; |
|
|
1796 | Window child; |
|
|
1797 | |
|
|
1798 | if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child)) |
|
|
1799 | { |
|
|
1800 | EXTEND (SP, 3); |
|
|
1801 | PUSHs (newSViv (dx)); |
|
|
1802 | PUSHs (newSViv (dy)); |
|
|
1803 | PUSHs (newSVuv (child)); |
|
|
1804 | } |
|
|
1805 | } |
|
|
1806 | |
|
|
1807 | ############################################################################# |
|
|
1808 | # urxvt::overlay |
|
|
1809 | ############################################################################# |
|
|
1810 | |
1550 | MODULE = urxvt PACKAGE = urxvt::overlay |
1811 | MODULE = urxvt PACKAGE = urxvt::overlay |
1551 | |
1812 | |
1552 | void |
1813 | void |
1553 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
1814 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
1554 | |
1815 | |
… | |
… | |
1559 | overlay::hide () |
1820 | overlay::hide () |
1560 | |
1821 | |
1561 | void |
1822 | void |
1562 | overlay::DESTROY () |
1823 | overlay::DESTROY () |
1563 | |
1824 | |
1564 | MODULE = urxvt PACKAGE = urxvt::timer |
1825 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1565 | |
1826 | |
1566 | SV * |
|
|
1567 | timer::new () |
|
|
1568 | CODE: |
|
|
1569 | timer *w = new timer; |
|
|
1570 | w->start (NOW); |
|
|
1571 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
|
|
1572 | w->self = (HV *)SvRV (RETVAL); |
|
|
1573 | OUTPUT: |
|
|
1574 | RETVAL |
|
|
1575 | |
|
|
1576 | timer * |
|
|
1577 | timer::cb (SV *cb) |
|
|
1578 | CODE: |
|
|
1579 | THIS->cb (cb); |
|
|
1580 | RETVAL = THIS; |
|
|
1581 | OUTPUT: |
|
|
1582 | RETVAL |
|
|
1583 | |
|
|
1584 | NV |
|
|
1585 | timer::at () |
|
|
1586 | CODE: |
|
|
1587 | RETVAL = THIS->at; |
|
|
1588 | OUTPUT: |
|
|
1589 | RETVAL |
|
|
1590 | |
|
|
1591 | timer * |
|
|
1592 | timer::interval (NV interval) |
|
|
1593 | CODE: |
|
|
1594 | THIS->interval = interval; |
|
|
1595 | RETVAL = THIS; |
|
|
1596 | OUTPUT: |
|
|
1597 | RETVAL |
|
|
1598 | |
|
|
1599 | timer * |
|
|
1600 | timer::set (NV tstamp) |
|
|
1601 | CODE: |
|
|
1602 | THIS->set (tstamp); |
|
|
1603 | RETVAL = THIS; |
|
|
1604 | OUTPUT: |
|
|
1605 | RETVAL |
|
|
1606 | |
|
|
1607 | timer * |
|
|
1608 | timer::start (NV tstamp = THIS->at) |
|
|
1609 | CODE: |
|
|
1610 | THIS->start (tstamp); |
|
|
1611 | RETVAL = THIS; |
|
|
1612 | OUTPUT: |
|
|
1613 | RETVAL |
|
|
1614 | |
|
|
1615 | timer * |
|
|
1616 | timer::stop () |
|
|
1617 | CODE: |
|
|
1618 | THIS->stop (); |
|
|
1619 | RETVAL = THIS; |
|
|
1620 | OUTPUT: |
|
|
1621 | RETVAL |
|
|
1622 | |
|
|
1623 | void |
|
|
1624 | timer::DESTROY () |
|
|
1625 | |
|
|
1626 | MODULE = urxvt PACKAGE = urxvt::iow |
|
|
1627 | |
|
|
1628 | SV * |
|
|
1629 | iow::new () |
|
|
1630 | CODE: |
|
|
1631 | iow *w = new iow; |
|
|
1632 | RETVAL = newSVptr ((void *)w, "urxvt::iow"); |
|
|
1633 | w->self = (HV *)SvRV (RETVAL); |
|
|
1634 | OUTPUT: |
|
|
1635 | RETVAL |
|
|
1636 | |
|
|
1637 | iow * |
|
|
1638 | iow::cb (SV *cb) |
|
|
1639 | CODE: |
|
|
1640 | THIS->cb (cb); |
|
|
1641 | RETVAL = THIS; |
|
|
1642 | OUTPUT: |
|
|
1643 | RETVAL |
|
|
1644 | |
|
|
1645 | iow * |
|
|
1646 | iow::fd (int fd) |
|
|
1647 | CODE: |
|
|
1648 | THIS->fd = fd; |
|
|
1649 | RETVAL = THIS; |
|
|
1650 | OUTPUT: |
|
|
1651 | RETVAL |
|
|
1652 | |
|
|
1653 | iow * |
|
|
1654 | iow::events (short events) |
|
|
1655 | CODE: |
|
|
1656 | THIS->events = events; |
|
|
1657 | RETVAL = THIS; |
|
|
1658 | OUTPUT: |
|
|
1659 | RETVAL |
|
|
1660 | |
|
|
1661 | iow * |
|
|
1662 | iow::start () |
|
|
1663 | CODE: |
|
|
1664 | THIS->start (); |
|
|
1665 | RETVAL = THIS; |
|
|
1666 | OUTPUT: |
|
|
1667 | RETVAL |
|
|
1668 | |
|
|
1669 | iow * |
|
|
1670 | iow::stop () |
|
|
1671 | CODE: |
|
|
1672 | THIS->stop (); |
|
|
1673 | RETVAL = THIS; |
|
|
1674 | OUTPUT: |
|
|
1675 | RETVAL |
|
|
1676 | |
|
|
1677 | void |
|
|
1678 | iow::DESTROY () |
|
|
1679 | |
|
|
1680 | |
|
|