… | |
… | |
50 | #undef LINENO |
50 | #undef LINENO |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
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 | #define ENABLE_PERL_FRILLS 1 |
55 | typedef int CHAINED UNUSED; |
56 | |
56 | |
57 | ///////////////////////////////////////////////////////////////////////////// |
57 | ///////////////////////////////////////////////////////////////////////////// |
58 | |
58 | |
59 | static wchar_t * |
59 | static wchar_t * |
60 | sv2wcs (SV *sv) |
60 | sv2wcs (SV *sv) |
… | |
… | |
80 | new_ref (HV *hv, const char *klass) |
80 | new_ref (HV *hv, const char *klass) |
81 | { |
81 | { |
82 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
82 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
83 | } |
83 | } |
84 | |
84 | |
85 | //TODO: use magic |
|
|
86 | static SV * |
85 | static SV * |
87 | newSVptr (void *ptr, const char *klass) |
86 | newSVptr (void *ptr, const char *klass) |
88 | { |
87 | { |
89 | HV *hv = newHV (); |
88 | HV *hv = newHV (); |
90 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
89 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
… | |
… | |
113 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
112 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
114 | |
113 | |
115 | return (long)mg->mg_ptr; |
114 | return (long)mg->mg_ptr; |
116 | } |
115 | } |
117 | |
116 | |
118 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
117 | #define newSVterm(term) SvREFCNT_inc ((SV *)(term)->perl.self) |
119 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
118 | #define SvTERM(sv) (rxvt_term *)SvPTR ((sv), "urxvt::term") |
120 | |
119 | |
121 | ///////////////////////////////////////////////////////////////////////////// |
120 | ///////////////////////////////////////////////////////////////////////////// |
122 | |
121 | |
123 | struct perl_watcher |
|
|
124 | { |
|
|
125 | SV *cbsv; |
|
|
126 | HV *self; |
|
|
127 | |
|
|
128 | perl_watcher () |
|
|
129 | : cbsv (newSV (0)) |
|
|
130 | { |
|
|
131 | } |
|
|
132 | |
|
|
133 | ~perl_watcher () |
|
|
134 | { |
|
|
135 | SvREFCNT_dec (cbsv); |
|
|
136 | } |
|
|
137 | |
|
|
138 | void cb (SV *cb) |
|
|
139 | { |
|
|
140 | sv_setsv (cbsv, cb); |
|
|
141 | } |
|
|
142 | |
|
|
143 | void invoke (const char *type, SV *self, int arg = -1); |
|
|
144 | }; |
|
|
145 | |
|
|
146 | void |
|
|
147 | perl_watcher::invoke (const char *type, SV *self, int arg) |
|
|
148 | { |
|
|
149 | dSP; |
|
|
150 | |
|
|
151 | ENTER; |
|
|
152 | SAVETMPS; |
|
|
153 | |
|
|
154 | PUSHMARK (SP); |
|
|
155 | |
|
|
156 | XPUSHs (sv_2mortal (self)); |
|
|
157 | |
|
|
158 | if (arg >= 0) |
|
|
159 | XPUSHs (sv_2mortal (newSViv (arg))); |
|
|
160 | |
|
|
161 | PUTBACK; |
|
|
162 | call_sv (cbsv, G_VOID | G_EVAL | G_DISCARD); |
|
|
163 | SPAGAIN; |
|
|
164 | |
|
|
165 | PUTBACK; |
|
|
166 | FREETMPS; |
|
|
167 | LEAVE; |
|
|
168 | |
|
|
169 | if (SvTRUE (ERRSV)) |
|
|
170 | rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); |
|
|
171 | } |
|
|
172 | |
|
|
173 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
|
|
174 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
|
|
175 | |
|
|
176 | struct timer : time_watcher, perl_watcher |
|
|
177 | { |
|
|
178 | tstamp interval; |
|
|
179 | |
|
|
180 | timer () |
|
|
181 | : time_watcher (this, &timer::execute) |
|
|
182 | { |
|
|
183 | } |
|
|
184 | |
|
|
185 | void execute (time_watcher &w) |
|
|
186 | { |
|
|
187 | if (interval) |
|
|
188 | start (at + interval); |
|
|
189 | |
|
|
190 | invoke ("urxvt::timer", newSVtimer (this)); |
|
|
191 | } |
|
|
192 | }; |
|
|
193 | |
|
|
194 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
|
|
195 | #define SvIOW(sv) (iow *)SvPTR (sv, "urxvt::iow") |
|
|
196 | |
|
|
197 | struct iow : io_watcher, perl_watcher |
|
|
198 | { |
|
|
199 | iow () |
|
|
200 | : io_watcher (this, &iow::execute) |
|
|
201 | { |
|
|
202 | } |
|
|
203 | |
|
|
204 | void execute (io_watcher &w, short revents) |
|
|
205 | { |
|
|
206 | invoke ("urxvt::iow", newSViow (this), revents); |
|
|
207 | } |
|
|
208 | }; |
|
|
209 | |
|
|
210 | ///////////////////////////////////////////////////////////////////////////// |
|
|
211 | |
|
|
212 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
122 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
213 | |
123 | |
214 | struct overlay { |
124 | class overlay { |
215 | HV *self; |
|
|
216 | rxvt_term *THIS; |
125 | rxvt_term *THIS; |
|
|
126 | AV *overlay_av; |
217 | int x, y, w, h; |
127 | int x, y, w, h; |
218 | int border; |
128 | int border; |
219 | text_t **text; |
129 | text_t **text; |
220 | rend_t **rend; |
130 | rend_t **rend; |
221 | |
131 | |
|
|
132 | public: |
|
|
133 | HV *self; |
|
|
134 | |
222 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
135 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
223 | ~overlay (); |
136 | ~overlay (); |
224 | |
137 | |
225 | void show (); |
138 | void show (); |
226 | void hide (); |
139 | void hide (); |
… | |
… | |
229 | |
142 | |
230 | void set (int x, int y, SV *str, SV *rend); |
143 | void set (int x, int y, SV *str, SV *rend); |
231 | }; |
144 | }; |
232 | |
145 | |
233 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
146 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
234 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) |
147 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) |
235 | { |
148 | { |
|
|
149 | if (w < 0) w = 0; |
|
|
150 | if (h < 0) h = 0; |
|
|
151 | |
236 | if (border == 2) |
152 | if (border == 2) |
237 | { |
153 | { |
238 | w += 2; |
154 | w += 2; |
239 | h += 2; |
155 | h += 2; |
240 | } |
156 | } |
… | |
… | |
278 | *rp++ = r; |
194 | *rp++ = r; |
279 | } |
195 | } |
280 | } |
196 | } |
281 | |
197 | |
282 | show (); |
198 | show (); |
283 | THIS->want_refresh = 1; |
|
|
284 | } |
199 | } |
285 | |
200 | |
286 | overlay::~overlay () |
201 | overlay::~overlay () |
287 | { |
202 | { |
288 | hide (); |
203 | hide (); |
… | |
… | |
293 | delete [] rend[y]; |
208 | delete [] rend[y]; |
294 | } |
209 | } |
295 | |
210 | |
296 | delete [] text; |
211 | delete [] text; |
297 | delete [] rend; |
212 | delete [] rend; |
|
|
213 | } |
|
|
214 | |
|
|
215 | void |
|
|
216 | overlay::show () |
|
|
217 | { |
|
|
218 | if (overlay_av) |
|
|
219 | return; |
|
|
220 | |
|
|
221 | overlay_av = (AV *)SvREFCNT_inc (SvRV ( |
|
|
222 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
|
|
223 | )); |
|
|
224 | av_push (overlay_av, newSViv ((long)this)); |
298 | |
225 | |
299 | THIS->want_refresh = 1; |
226 | THIS->want_refresh = 1; |
300 | } |
227 | } |
301 | |
228 | |
302 | void |
229 | void |
303 | overlay::show () |
|
|
304 | { |
|
|
305 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
306 | |
|
|
307 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
|
|
308 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
|
|
309 | } |
|
|
310 | |
|
|
311 | void |
|
|
312 | overlay::hide () |
230 | overlay::hide () |
313 | { |
231 | { |
314 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
232 | if (!overlay_av) |
|
|
233 | return; |
315 | |
234 | |
316 | if (ovs) |
235 | int i; |
317 | { |
|
|
318 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
319 | |
236 | |
320 | HV *hv = (HV *)SvRV (*ovs); |
237 | for (i = AvFILL (overlay_av); i >= 0; i--) |
321 | hv_delete (hv, key, 32, G_DISCARD); |
238 | if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this) |
322 | } |
239 | break; |
|
|
240 | |
|
|
241 | for (; i < AvFILL (overlay_av); i++) |
|
|
242 | av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0))); |
|
|
243 | |
|
|
244 | av_pop (overlay_av); |
|
|
245 | |
|
|
246 | SvREFCNT_dec (overlay_av); |
|
|
247 | overlay_av = 0; |
|
|
248 | |
|
|
249 | THIS->want_refresh = 1; |
323 | } |
250 | } |
324 | |
251 | |
325 | void overlay::swap () |
252 | void overlay::swap () |
326 | { |
253 | { |
327 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
254 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
… | |
… | |
367 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
294 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
368 | croak ("rend must be arrayref"); |
295 | croak ("rend must be arrayref"); |
369 | |
296 | |
370 | AV *av = (AV *)SvRV (rend); |
297 | AV *av = (AV *)SvRV (rend); |
371 | |
298 | |
372 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
299 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
373 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
300 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
374 | } |
301 | } |
375 | |
302 | |
376 | THIS->want_refresh = 1; |
303 | THIS->want_refresh = 1; |
377 | } |
304 | } |
378 | |
305 | |
|
|
306 | ///////////////////////////////////////////////////////////////////////////// |
|
|
307 | |
|
|
308 | #define IOM_CLASS "urxvt" |
|
|
309 | #include <iom_perl.h> |
379 | |
310 | |
380 | ///////////////////////////////////////////////////////////////////////////// |
311 | ///////////////////////////////////////////////////////////////////////////// |
381 | |
312 | |
382 | struct rxvt_perl_interp rxvt_perl; |
313 | struct rxvt_perl_interp rxvt_perl; |
383 | |
314 | |
… | |
… | |
433 | |
364 | |
434 | if (perl) |
365 | if (perl) |
435 | { |
366 | { |
436 | // runs outside of perls ENV |
367 | // runs outside of perls ENV |
437 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
368 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
438 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
369 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
439 | } |
370 | } |
440 | } |
371 | } |
441 | |
372 | |
442 | static void |
373 | static void |
443 | ungrab (rxvt_term *THIS) |
374 | ungrab (rxvt_term *THIS) |
444 | { |
375 | { |
445 | if (THIS->perl.grabtime) |
376 | if (THIS->perl.grabtime) |
446 | { |
377 | { |
447 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
378 | XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime); |
448 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
379 | XUngrabPointer (THIS->dpy, THIS->perl.grabtime); |
449 | THIS->perl.grabtime = 0; |
380 | THIS->perl.grabtime = 0; |
450 | } |
381 | } |
451 | } |
382 | } |
452 | |
383 | |
453 | static void |
|
|
454 | swap_overlays (rxvt_term *term) |
|
|
455 | { |
|
|
456 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
457 | |
|
|
458 | if (HvKEYS (hv)) |
|
|
459 | { |
|
|
460 | hv_iterinit (hv); |
|
|
461 | |
|
|
462 | while (HE *he = hv_iternext (hv)) |
|
|
463 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
464 | } |
|
|
465 | } |
|
|
466 | |
|
|
467 | bool |
384 | bool |
468 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
385 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
469 | { |
386 | { |
470 | if (!perl || !term->perl.self) |
387 | if (!perl || !term->perl.self) |
471 | return false; |
388 | return false; |
472 | |
389 | |
473 | // pre-handling of some events |
390 | // pre-handling of some events |
474 | if (htype == HOOK_REFRESH_END) |
391 | if (htype == HOOK_REFRESH_END) |
475 | swap_overlays (term); |
392 | { |
|
|
393 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
394 | |
|
|
395 | for (int i = 0; i <= AvFILL (av); i++) |
|
|
396 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
|
|
397 | } |
476 | |
398 | |
477 | swap (perl_environ, environ); |
399 | swap (perl_environ, environ); |
478 | |
400 | |
479 | bool event_consumed; |
401 | bool event_consumed; |
480 | |
402 | |
… | |
… | |
513 | break; |
435 | break; |
514 | |
436 | |
515 | case DT_STR_LEN: |
437 | case DT_STR_LEN: |
516 | { |
438 | { |
517 | char *str = va_arg (ap, char *); |
439 | char *str = va_arg (ap, char *); |
518 | int len = va_arg (ap, int); |
440 | int len = va_arg (ap, int); |
519 | |
441 | |
520 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
442 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
521 | } |
443 | } |
522 | break; |
444 | break; |
523 | |
445 | |
524 | case DT_WCS_LEN: |
446 | case DT_WCS_LEN: |
525 | { |
447 | { |
526 | wchar_t *wstr = va_arg (ap, wchar_t *); |
448 | wchar_t *wstr = va_arg (ap, wchar_t *); |
527 | int wlen = va_arg (ap, int); |
449 | int wlen = va_arg (ap, int); |
528 | |
450 | |
529 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
451 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
452 | } |
|
|
453 | break; |
|
|
454 | |
|
|
455 | case DT_LCS_LEN: |
|
|
456 | { |
|
|
457 | long *lstr = va_arg (ap, long *); |
|
|
458 | int llen = va_arg (ap, int); |
|
|
459 | |
|
|
460 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
530 | } |
461 | } |
531 | break; |
462 | break; |
532 | |
463 | |
533 | case DT_XEVENT: |
464 | case DT_XEVENT: |
534 | { |
465 | { |
535 | XEvent *xe = va_arg (ap, XEvent *); |
466 | XEvent *xe = va_arg (ap, XEvent *); |
536 | HV *hv = newHV (); |
467 | HV *hv = newHV (); |
537 | |
468 | |
538 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
469 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
539 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
470 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
540 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
471 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
541 | # undef set |
472 | # undef set |
542 | |
473 | |
543 | setiv (type, xe->type); |
474 | setiv (type, xe->type); |
544 | setiv (send_event, xe->xany.send_event); |
475 | setiv (send_event, xe->xany.send_event); |
545 | setiv (serial, xe->xany.serial); |
476 | setiv (serial, xe->xany.serial); |
546 | |
477 | |
… | |
… | |
555 | setuv (root, xe->xmotion.root); |
486 | setuv (root, xe->xmotion.root); |
556 | setuv (subwindow, xe->xmotion.subwindow); |
487 | setuv (subwindow, xe->xmotion.subwindow); |
557 | setuv (time, xe->xmotion.time); |
488 | setuv (time, xe->xmotion.time); |
558 | setiv (x, xe->xmotion.x); |
489 | setiv (x, xe->xmotion.x); |
559 | setiv (y, xe->xmotion.y); |
490 | setiv (y, xe->xmotion.y); |
560 | setiv (row, xe->xmotion.y / term->fheight); |
491 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
561 | setiv (col, xe->xmotion.x / term->fwidth); |
492 | setiv (col, xe->xmotion.x / term->fwidth); |
562 | setiv (x_root, xe->xmotion.x_root); |
493 | setiv (x_root, xe->xmotion.x_root); |
563 | setiv (y_root, xe->xmotion.y_root); |
494 | setiv (y_root, xe->xmotion.y_root); |
564 | setuv (state, xe->xmotion.state); |
495 | setuv (state, xe->xmotion.state); |
565 | |
496 | |
… | |
… | |
598 | setuv (above, xe->xconfigure.above); |
529 | setuv (above, xe->xconfigure.above); |
599 | break; |
530 | break; |
600 | } |
531 | } |
601 | |
532 | |
602 | break; |
533 | break; |
|
|
534 | |
|
|
535 | case PropertyNotify: |
|
|
536 | setuv (window, xe->xproperty.window); |
|
|
537 | setuv (atom, xe->xproperty.atom); |
|
|
538 | setuv (time, xe->xproperty.time); |
|
|
539 | setiv (state, xe->xproperty.state); |
|
|
540 | break; |
|
|
541 | |
|
|
542 | case ClientMessage: |
|
|
543 | setuv (window, xe->xclient.window); |
|
|
544 | setuv (message_type, xe->xclient.message_type); |
|
|
545 | setuv (format, xe->xclient.format); |
|
|
546 | setuv (l0, xe->xclient.data.l[0]); |
|
|
547 | setuv (l1, xe->xclient.data.l[1]); |
|
|
548 | setuv (l2, xe->xclient.data.l[2]); |
|
|
549 | setuv (l3, xe->xclient.data.l[3]); |
|
|
550 | setuv (l4, xe->xclient.data.l[4]); |
|
|
551 | break; |
603 | } |
552 | } |
604 | |
553 | |
605 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
554 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
606 | } |
555 | } |
607 | break; |
556 | break; |
… | |
… | |
647 | else |
596 | else |
648 | event_consumed = false; |
597 | event_consumed = false; |
649 | |
598 | |
650 | // post-handling of some events |
599 | // post-handling of some events |
651 | if (htype == HOOK_REFRESH_BEGIN) |
600 | if (htype == HOOK_REFRESH_BEGIN) |
652 | swap_overlays (term); |
601 | { |
|
|
602 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
603 | |
|
|
604 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
605 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
|
|
606 | } |
653 | else if (htype == HOOK_DESTROY) |
607 | else if (htype == HOOK_DESTROY) |
654 | { |
608 | { |
655 | clearSVptr ((SV *)term->perl.self); |
609 | clearSVptr ((SV *)term->perl.self); |
656 | SvREFCNT_dec ((SV *)term->perl.self); |
610 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
611 | |
|
|
612 | // don't allow further calls |
|
|
613 | term->perl.self = 0; |
657 | } |
614 | } |
658 | |
615 | |
659 | swap (perl_environ, environ); |
616 | swap (perl_environ, environ); |
660 | |
617 | |
661 | return event_consumed; |
618 | return event_consumed; |
… | |
… | |
685 | # include "optinc.h" |
642 | # include "optinc.h" |
686 | # undef nodef |
643 | # undef nodef |
687 | # undef def |
644 | # undef def |
688 | |
645 | |
689 | HV *stash = gv_stashpv ("urxvt", 1); |
646 | HV *stash = gv_stashpv ("urxvt", 1); |
690 | struct { |
647 | static const struct { |
691 | const char *name; |
648 | const char *name; |
692 | IV iv; |
649 | IV iv; |
693 | } *civ, const_iv[] = { |
650 | } *civ, const_iv[] = { |
694 | # define const_iv(name) { # name, (IV)name } |
651 | # define const_iv(name) { # name, (IV)name } |
695 | const_iv (DEFAULT_RSTYLE), |
652 | const_iv (DEFAULT_RSTYLE), |
… | |
… | |
714 | const_iv (Button3Mask), |
671 | const_iv (Button3Mask), |
715 | const_iv (Button4Mask), |
672 | const_iv (Button4Mask), |
716 | const_iv (Button5Mask), |
673 | const_iv (Button5Mask), |
717 | const_iv (AnyModifier), |
674 | const_iv (AnyModifier), |
718 | |
675 | |
719 | const_iv (EVENT_NONE), |
676 | const_iv (NoSymbol), |
720 | const_iv (EVENT_READ), |
677 | const_iv (GrabModeSync), |
721 | const_iv (EVENT_WRITE), |
678 | const_iv (GrabModeAsync), |
722 | |
679 | |
723 | const_iv (NoEventMask), |
680 | const_iv (NoEventMask), |
724 | const_iv (KeyPressMask), |
681 | const_iv (KeyPressMask), |
725 | const_iv (KeyReleaseMask), |
682 | const_iv (KeyReleaseMask), |
726 | const_iv (ButtonPressMask), |
683 | const_iv (ButtonPressMask), |
… | |
… | |
778 | const_iv (SelectionRequest), |
735 | const_iv (SelectionRequest), |
779 | const_iv (SelectionNotify), |
736 | const_iv (SelectionNotify), |
780 | const_iv (ColormapNotify), |
737 | const_iv (ColormapNotify), |
781 | const_iv (ClientMessage), |
738 | const_iv (ClientMessage), |
782 | const_iv (MappingNotify), |
739 | const_iv (MappingNotify), |
|
|
740 | # if ENABLE_XIM_ONTHESPOT |
|
|
741 | const_iv (XIMReverse), |
|
|
742 | const_iv (XIMUnderline), |
|
|
743 | const_iv (XIMHighlight), |
|
|
744 | const_iv (XIMPrimary), |
|
|
745 | const_iv (XIMSecondary), |
|
|
746 | const_iv (XIMTertiary), |
|
|
747 | const_iv (XIMVisibleToForward), |
|
|
748 | const_iv (XIMVisibleToBackword), |
|
|
749 | const_iv (XIMVisibleToCenter), |
|
|
750 | # if 0 |
|
|
751 | const_iv (XIMForwardChar), |
|
|
752 | const_iv (XIMBackwardChar), |
|
|
753 | const_iv (XIMForwardWord), |
|
|
754 | const_iv (XIMBackwardWord), |
|
|
755 | const_iv (XIMCaretUp), |
|
|
756 | const_iv (XIMCaretDown), |
|
|
757 | const_iv (XIMNextLine), |
|
|
758 | const_iv (XIMPreviousLine), |
|
|
759 | const_iv (XIMLineStart), |
|
|
760 | const_iv (XIMLineEnd), |
|
|
761 | const_iv (XIMAbsolutePosition), |
|
|
762 | const_iv (XIMDontChange), |
|
|
763 | # endif |
|
|
764 | # endif |
783 | }; |
765 | }; |
784 | |
766 | |
785 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
767 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
786 | civ-- > const_iv; ) |
|
|
787 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
768 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
788 | } |
769 | } |
789 | |
770 | |
790 | void |
771 | void |
791 | warn (const char *msg) |
772 | warn (const char *msg) |
… | |
… | |
822 | RETVAL |
803 | RETVAL |
823 | |
804 | |
824 | int |
805 | int |
825 | SET_FGCOLOR (int rend, int new_color) |
806 | SET_FGCOLOR (int rend, int new_color) |
826 | CODE: |
807 | CODE: |
827 | RETVAL = SET_FGCOLOR (rend, new_color); |
808 | RETVAL = SET_FGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
828 | OUTPUT: |
809 | OUTPUT: |
829 | RETVAL |
810 | RETVAL |
830 | |
811 | |
831 | int |
812 | int |
832 | SET_BGCOLOR (int rend, int new_color) |
813 | SET_BGCOLOR (int rend, int new_color) |
833 | CODE: |
814 | CODE: |
834 | RETVAL = SET_BGCOLOR (rend, new_color); |
815 | RETVAL = SET_BGCOLOR (rend, clamp (new_color, 0, TOTAL_COLORS - 1)); |
835 | OUTPUT: |
816 | OUTPUT: |
836 | RETVAL |
817 | RETVAL |
837 | |
818 | |
838 | int |
819 | int |
839 | GET_CUSTOM (int rend) |
820 | GET_CUSTOM (int rend) |
840 | CODE: |
821 | CODE: |
841 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
822 | RETVAL = (rend & RS_customMask) >> RS_customShift; |
842 | OUTPUT: |
823 | OUTPUT: |
843 | RETVAL |
824 | RETVAL |
844 | |
825 | |
845 | int |
826 | int |
846 | SET_CUSTOM (int rend, int new_value) |
827 | SET_CUSTOM (int rend, int new_value) |
… | |
… | |
853 | | ((new_value << RS_customShift) & RS_customMask); |
834 | | ((new_value << RS_customShift) & RS_customMask); |
854 | } |
835 | } |
855 | OUTPUT: |
836 | OUTPUT: |
856 | RETVAL |
837 | RETVAL |
857 | |
838 | |
|
|
839 | void |
|
|
840 | termlist () |
|
|
841 | PPCODE: |
|
|
842 | { |
|
|
843 | EXTEND (SP, rxvt_term::termlist.size ()); |
|
|
844 | |
|
|
845 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
846 | if ((*t)->perl.self) |
|
|
847 | PUSHs (sv_2mortal (newSVterm (*t))); |
|
|
848 | } |
|
|
849 | |
858 | MODULE = urxvt PACKAGE = urxvt::term |
850 | MODULE = urxvt PACKAGE = urxvt::term |
859 | |
851 | |
860 | SV * |
852 | SV * |
861 | _new (...) |
853 | _new (AV *env, AV *arg) |
862 | CODE: |
854 | CODE: |
863 | { |
855 | { |
864 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
865 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
866 | |
|
|
867 | rxvt_term *term = new rxvt_term; |
856 | rxvt_term *term = new rxvt_term; |
868 | |
857 | |
869 | term->argv = new stringvec; |
858 | stringvec *argv = new stringvec; |
870 | term->envv = new stringvec; |
859 | stringvec *envv = new stringvec; |
871 | |
860 | |
872 | for (int i = 1; i < items; i++) |
861 | for (int i = 0; i <= AvFILL (arg); i++) |
873 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
862 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
874 | |
863 | |
875 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
876 | for (int i = av_len (envv) + 1; i--; ) |
864 | for (int i = AvFILL (env) + 1; i--; ) |
877 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
865 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
878 | |
866 | |
879 | term->envv->push_back (0); |
867 | envv->push_back (0); |
880 | |
868 | |
881 | bool success; |
869 | bool success; |
882 | |
870 | |
883 | try |
871 | try |
884 | { |
872 | { |
885 | success = term->init (term->argv->size (), term->argv->begin ()); |
873 | success = term->init (argv, envv); |
886 | } |
874 | } |
887 | catch (const class rxvt_failure_exception &e) |
875 | catch (const class rxvt_failure_exception &e) |
888 | { |
876 | { |
889 | success = false; |
877 | success = false; |
890 | } |
878 | } |
… | |
… | |
902 | RETVAL |
890 | RETVAL |
903 | |
891 | |
904 | void |
892 | void |
905 | rxvt_term::destroy () |
893 | rxvt_term::destroy () |
906 | |
894 | |
907 | #if ENABLE_PERL_FRILLS |
|
|
908 | |
|
|
909 | void |
|
|
910 | rxvt_term::XListProperties (U32 window) |
|
|
911 | PPCODE: |
|
|
912 | { |
|
|
913 | int count; |
|
|
914 | Atom *props = XListProperties (THIS->display->display, (Window)window, &count); |
|
|
915 | |
|
|
916 | EXTEND (SP, count); |
|
|
917 | while (count--) |
|
|
918 | PUSHs (newSVuv ((U32)props [count])); |
|
|
919 | |
|
|
920 | XFree (props); |
|
|
921 | } |
|
|
922 | |
|
|
923 | void |
|
|
924 | rxvt_term::XGetWindowProperty (U32 window, U32 property) |
|
|
925 | PPCODE: |
|
|
926 | { |
|
|
927 | Atom type; |
|
|
928 | int format; |
|
|
929 | unsigned long nitems; |
|
|
930 | unsigned long bytes_after; |
|
|
931 | unsigned char *prop; |
|
|
932 | XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
933 | 0, 1<<30, 0, AnyPropertyType, |
|
|
934 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
935 | if (type != None) |
|
|
936 | { |
|
|
937 | EXTEND (SP, 3); |
|
|
938 | PUSHs (newSVuv ((U32)type)); |
|
|
939 | PUSHs (newSViv (format)); |
|
|
940 | PUSHs (newSVpvn ((char *)prop, nitems * format / 8)); |
|
|
941 | XFree (prop); |
|
|
942 | } |
|
|
943 | } |
|
|
944 | |
|
|
945 | void |
|
|
946 | rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data) |
|
|
947 | CODE: |
|
|
948 | { |
|
|
949 | STRLEN len; |
|
|
950 | char *data_ = SvPVbyte (data, len); |
|
|
951 | |
|
|
952 | XChangeProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
953 | type, format, PropModeReplace, |
|
|
954 | (unsigned char *)data, len * 8 / format); |
|
|
955 | } |
|
|
956 | |
|
|
957 | void |
|
|
958 | rxvt_term::XDeleteProperty (U32 window, U32 property) |
|
|
959 | CODE: |
|
|
960 | XDeleteProperty (THIS->display->display, (Window)window, (Atom)property); |
|
|
961 | |
|
|
962 | U32 |
|
|
963 | rxvt_term::DefaultRootWindow () |
|
|
964 | CODE: |
|
|
965 | RETVAL = (U32)THIS->display->root; |
|
|
966 | OUTPUT: |
|
|
967 | RETVAL |
|
|
968 | |
|
|
969 | U32 |
|
|
970 | rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height) |
|
|
971 | CODE: |
|
|
972 | RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent, |
|
|
973 | x, y, width, height, 0, |
|
|
974 | THIS->pix_colors_focused[Color_border], |
|
|
975 | THIS->pix_colors_focused[Color_border]); |
|
|
976 | OUTPUT: |
|
|
977 | RETVAL |
|
|
978 | |
|
|
979 | void |
|
|
980 | rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0) |
|
|
981 | CODE: |
|
|
982 | XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y); |
|
|
983 | |
|
|
984 | void |
|
|
985 | rxvt_term::XMapWindow (U32 window) |
|
|
986 | CODE: |
|
|
987 | XMapWindow (THIS->display->display, (Window)window); |
|
|
988 | |
|
|
989 | void |
|
|
990 | rxvt_term::XUnmapWindow (U32 window) |
|
|
991 | CODE: |
|
|
992 | XUnmapWindow (THIS->display->display, (Window)window); |
|
|
993 | |
|
|
994 | #endif |
|
|
995 | |
|
|
996 | void |
895 | void |
997 | rxvt_term::set_should_invoke (int htype, int inc) |
896 | rxvt_term::set_should_invoke (int htype, int inc) |
998 | CODE: |
897 | CODE: |
999 | THIS->perl.should_invoke [htype] += inc; |
898 | THIS->perl.should_invoke [htype] += inc; |
1000 | |
899 | |
1001 | void |
900 | int |
1002 | rxvt_term::grab_button (int button, U32 modifiers) |
901 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1003 | CODE: |
902 | CODE: |
1004 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
903 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1005 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
904 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1006 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
905 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
906 | OUTPUT: RETVAL |
|
|
907 | |
|
|
908 | int |
|
|
909 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
|
|
910 | CODE: |
|
|
911 | RETVAL = XUngrabButton (THIS->dpy, button, modifiers, window); |
|
|
912 | OUTPUT: RETVAL |
|
|
913 | |
|
|
914 | void |
|
|
915 | rxvt_term::XGrabKey (int keycode, U32 modifiers, Window window = THIS->vt, \ |
|
|
916 | int owner_events = 1, int pointer_mode = GrabModeAsync, int keyboard_mode = GrabModeAsync) |
|
|
917 | CODE: |
|
|
918 | XGrabKey (THIS->dpy, keycode, modifiers, window, owner_events, pointer_mode, keyboard_mode); |
|
|
919 | |
|
|
920 | void |
|
|
921 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
|
|
922 | CODE: |
|
|
923 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
|
|
924 | |
|
|
925 | void |
|
|
926 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
927 | CODE: |
|
|
928 | XUngrabKeyboard (THIS->dpy, eventtime); |
1007 | |
929 | |
1008 | bool |
930 | bool |
1009 | rxvt_term::grab (U32 eventtime, int sync = 0) |
931 | rxvt_term::grab (Time eventtime, int sync = 0) |
1010 | CODE: |
932 | CODE: |
1011 | { |
933 | { |
1012 | int mode = sync ? GrabModeSync : GrabModeAsync; |
934 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1013 | |
935 | |
1014 | THIS->perl.grabtime = 0; |
936 | THIS->perl.grabtime = 0; |
1015 | |
937 | |
1016 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
938 | if (!XGrabPointer (THIS->dpy, THIS->vt, 0, |
1017 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
939 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1018 | mode, mode, None, GRAB_CURSOR, eventtime)) |
940 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1019 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
941 | if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime)) |
1020 | THIS->perl.grabtime = eventtime; |
942 | THIS->perl.grabtime = eventtime; |
1021 | else |
943 | else |
1022 | XUngrabPointer (THIS->display->display, eventtime); |
944 | XUngrabPointer (THIS->dpy, eventtime); |
1023 | |
945 | |
1024 | RETVAL = !!THIS->perl.grabtime; |
946 | RETVAL = !!THIS->perl.grabtime; |
1025 | } |
947 | } |
1026 | OUTPUT: |
948 | OUTPUT: |
1027 | RETVAL |
949 | RETVAL |
1028 | |
950 | |
1029 | void |
951 | void |
1030 | rxvt_term::allow_events_async () |
952 | rxvt_term::allow_events_async () |
1031 | CODE: |
953 | CODE: |
1032 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
954 | XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime); |
1033 | |
955 | |
1034 | void |
956 | void |
1035 | rxvt_term::allow_events_sync () |
957 | rxvt_term::allow_events_sync () |
1036 | CODE: |
958 | CODE: |
1037 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
959 | XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime); |
1038 | |
960 | |
1039 | void |
961 | void |
1040 | rxvt_term::allow_events_replay () |
962 | rxvt_term::allow_events_replay () |
1041 | CODE: |
963 | CODE: |
1042 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
964 | XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime); |
1043 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
965 | XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime); |
1044 | |
966 | |
1045 | void |
967 | void |
1046 | rxvt_term::ungrab () |
968 | rxvt_term::ungrab () |
1047 | CODE: |
969 | CODE: |
1048 | ungrab (THIS); |
970 | ungrab (THIS); |
|
|
971 | |
|
|
972 | int |
|
|
973 | rxvt_term::XStringToKeysym (char *string) |
|
|
974 | CODE: |
|
|
975 | RETVAL = XStringToKeysym (string); |
|
|
976 | OUTPUT: RETVAL |
|
|
977 | |
|
|
978 | char * |
|
|
979 | rxvt_term::XKeysymToString (int sym) |
|
|
980 | CODE: |
|
|
981 | RETVAL = XKeysymToString (sym); |
|
|
982 | OUTPUT: RETVAL |
|
|
983 | |
|
|
984 | int |
|
|
985 | rxvt_term::XKeysymToKeycode (int sym) |
|
|
986 | CODE: |
|
|
987 | RETVAL = XKeysymToKeycode (THIS->dpy, sym); |
|
|
988 | OUTPUT: RETVAL |
|
|
989 | |
|
|
990 | int |
|
|
991 | rxvt_term::XKeycodeToKeysym (int code, int index) |
|
|
992 | CODE: |
|
|
993 | RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); |
|
|
994 | OUTPUT: RETVAL |
1049 | |
995 | |
1050 | int |
996 | int |
1051 | rxvt_term::strwidth (SV *str) |
997 | rxvt_term::strwidth (SV *str) |
1052 | CODE: |
998 | CODE: |
1053 | { |
999 | { |
1054 | wchar_t *wstr = sv2wcs (str); |
1000 | wchar_t *wstr = sv2wcs (str); |
1055 | |
1001 | |
1056 | rxvt_push_locale (THIS->locale); |
1002 | rxvt_push_locale (THIS->locale); |
1057 | RETVAL = wcswidth (wstr, wcslen (wstr)); |
1003 | RETVAL = 0; |
|
|
1004 | for (wchar_t *wc = wstr; *wc; wc++) |
|
|
1005 | { |
|
|
1006 | int w = WCWIDTH (*wc); |
|
|
1007 | |
|
|
1008 | if (w) |
|
|
1009 | RETVAL += max (w, 1); |
|
|
1010 | } |
1058 | rxvt_pop_locale (); |
1011 | rxvt_pop_locale (); |
1059 | |
1012 | |
1060 | free (wstr); |
1013 | free (wstr); |
1061 | } |
1014 | } |
1062 | OUTPUT: |
1015 | OUTPUT: |
… | |
… | |
1092 | rxvt_pop_locale (); |
1045 | rxvt_pop_locale (); |
1093 | |
1046 | |
1094 | RETVAL = wcs2sv (wstr); |
1047 | RETVAL = wcs2sv (wstr); |
1095 | free (wstr); |
1048 | free (wstr); |
1096 | } |
1049 | } |
|
|
1050 | OUTPUT: |
|
|
1051 | RETVAL |
|
|
1052 | |
|
|
1053 | char * |
|
|
1054 | rxvt_term::locale () |
|
|
1055 | CODE: |
|
|
1056 | RETVAL = THIS->locale; |
1097 | OUTPUT: |
1057 | OUTPUT: |
1098 | RETVAL |
1058 | RETVAL |
1099 | |
1059 | |
1100 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1060 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1101 | |
1061 | |
… | |
… | |
1106 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1066 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1107 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1067 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1108 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1068 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1109 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1069 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1110 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1070 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
1071 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
|
|
1072 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
|
|
1073 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
1111 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1074 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1112 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1075 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1113 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1076 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1114 | |
1077 | |
1115 | int |
1078 | int |
… | |
… | |
1122 | fbase = TERM_OFFSET_fbase |
1085 | fbase = TERM_OFFSET_fbase |
1123 | nrow = TERM_OFFSET_nrow |
1086 | nrow = TERM_OFFSET_nrow |
1124 | ncol = TERM_OFFSET_ncol |
1087 | ncol = TERM_OFFSET_ncol |
1125 | focus = TERM_OFFSET_focus |
1088 | focus = TERM_OFFSET_focus |
1126 | mapped = TERM_OFFSET_mapped |
1089 | mapped = TERM_OFFSET_mapped |
|
|
1090 | int_bwidth = TERM_OFFSET_int_bwidth |
|
|
1091 | ext_bwidth = TERM_OFFSET_ext_bwidth |
|
|
1092 | lineSpace = TERM_OFFSET_lineSpace |
1127 | saveLines = TERM_OFFSET_saveLines |
1093 | saveLines = TERM_OFFSET_saveLines |
1128 | total_rows = TERM_OFFSET_total_rows |
1094 | total_rows = TERM_OFFSET_total_rows |
1129 | top_row = TERM_OFFSET_top_row |
1095 | top_row = TERM_OFFSET_top_row |
1130 | CODE: |
1096 | CODE: |
1131 | RETVAL = *(int *)((char *)THIS + ix); |
1097 | RETVAL = *(int *)((char *)THIS + ix); |
… | |
… | |
1136 | rxvt_term::ModLevel3Mask () |
1102 | rxvt_term::ModLevel3Mask () |
1137 | ALIAS: |
1103 | ALIAS: |
1138 | ModLevel3Mask = 0 |
1104 | ModLevel3Mask = 0 |
1139 | ModMetaMask = 1 |
1105 | ModMetaMask = 1 |
1140 | ModNumLockMask = 2 |
1106 | ModNumLockMask = 2 |
|
|
1107 | current_screen = 3 |
|
|
1108 | hidden_cursor = 4 |
1141 | CODE: |
1109 | CODE: |
1142 | switch (ix) |
1110 | switch (ix) |
1143 | { |
1111 | { |
1144 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1112 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1145 | case 1: RETVAL = THIS->ModMetaMask; break; |
1113 | case 1: RETVAL = THIS->ModMetaMask; break; |
1146 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1114 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
1115 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1116 | case 4: RETVAL = THIS->hidden_cursor; break; |
1147 | } |
1117 | } |
1148 | OUTPUT: |
1118 | OUTPUT: |
1149 | RETVAL |
1119 | RETVAL |
1150 | |
1120 | |
1151 | char * |
1121 | char * |
… | |
… | |
1161 | } |
1131 | } |
1162 | OUTPUT: |
1132 | OUTPUT: |
1163 | RETVAL |
1133 | RETVAL |
1164 | |
1134 | |
1165 | SV * |
1135 | SV * |
1166 | rxvt_term::_env () |
1136 | rxvt_term::envv () |
|
|
1137 | ALIAS: |
|
|
1138 | argv = 1 |
1167 | CODE: |
1139 | PPCODE: |
1168 | { |
1140 | { |
1169 | if (THIS->envv) |
1141 | stringvec *vec = ix ? THIS->argv : THIS->envv; |
1170 | { |
|
|
1171 | AV *av = newAV (); |
|
|
1172 | |
1142 | |
|
|
1143 | EXTEND (SP, vec->size ()); |
|
|
1144 | |
1173 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
1145 | for (char **i = vec->begin (); i != vec->end (); ++i) |
1174 | if (*i) |
1146 | if (*i) |
1175 | av_push (av, newSVpv (*i, 0)); |
1147 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1176 | |
|
|
1177 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1178 | } |
|
|
1179 | else |
|
|
1180 | RETVAL = &PL_sv_undef; |
|
|
1181 | } |
1148 | } |
1182 | OUTPUT: |
|
|
1183 | RETVAL |
|
|
1184 | |
1149 | |
1185 | int |
1150 | int |
1186 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1151 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1187 | CODE: |
1152 | CODE: |
1188 | RETVAL = THIS->pty_ev.events; |
1153 | RETVAL = THIS->pty_ev.events; |
1189 | if (events != EVENT_UNDEF) |
1154 | if (events != EVENT_UNDEF) |
1190 | THIS->pty_ev.set (events); |
1155 | THIS->pty_ev.set (events); |
1191 | OUTPUT: |
1156 | OUTPUT: |
1192 | RETVAL |
1157 | RETVAL |
1193 | |
1158 | |
1194 | U32 |
1159 | int |
|
|
1160 | rxvt_term::pty_fd () |
|
|
1161 | CODE: |
|
|
1162 | RETVAL = THIS->pty->pty; |
|
|
1163 | OUTPUT: |
|
|
1164 | RETVAL |
|
|
1165 | |
|
|
1166 | Window |
1195 | rxvt_term::parent () |
1167 | rxvt_term::parent () |
1196 | CODE: |
1168 | CODE: |
1197 | RETVAL = (U32)THIS->parent [0]; |
1169 | RETVAL = THIS->parent [0]; |
1198 | OUTPUT: |
1170 | OUTPUT: |
1199 | RETVAL |
1171 | RETVAL |
1200 | |
1172 | |
1201 | U32 |
1173 | Window |
1202 | rxvt_term::vt () |
1174 | rxvt_term::vt () |
1203 | CODE: |
1175 | CODE: |
1204 | RETVAL = (U32)THIS->vt; |
1176 | RETVAL = THIS->vt; |
1205 | OUTPUT: |
1177 | OUTPUT: |
1206 | RETVAL |
1178 | RETVAL |
1207 | |
1179 | |
1208 | void |
1180 | void |
1209 | rxvt_term::vt_emask_add (U32 emask) |
1181 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1231 | } |
1203 | } |
1232 | OUTPUT: |
1204 | OUTPUT: |
1233 | RETVAL |
1205 | RETVAL |
1234 | |
1206 | |
1235 | void |
1207 | void |
|
|
1208 | rxvt_term::focus_in () |
|
|
1209 | |
|
|
1210 | void |
|
|
1211 | rxvt_term::focus_out () |
|
|
1212 | |
|
|
1213 | void |
|
|
1214 | rxvt_term::key_press (unsigned int state, unsigned int keycode, Time time = CurrentTime) |
|
|
1215 | ALIAS: |
|
|
1216 | key_release = 1 |
|
|
1217 | CODE: |
|
|
1218 | { |
|
|
1219 | XKeyEvent xkey; |
|
|
1220 | |
|
|
1221 | memset (&xkey, 0, sizeof (xkey)); |
|
|
1222 | |
|
|
1223 | xkey.time = time; |
|
|
1224 | xkey.state = state; |
|
|
1225 | xkey.keycode = keycode; |
|
|
1226 | |
|
|
1227 | xkey.type = ix ? KeyRelease : KeyPress; |
|
|
1228 | xkey.display = THIS->dpy; |
|
|
1229 | xkey.window = THIS->vt; |
|
|
1230 | xkey.root = THIS->display->root; |
|
|
1231 | xkey.subwindow = THIS->vt; |
|
|
1232 | |
|
|
1233 | if (ix) |
|
|
1234 | THIS->key_release (xkey); |
|
|
1235 | else |
|
|
1236 | THIS->key_press (xkey); |
|
|
1237 | } |
|
|
1238 | |
|
|
1239 | void |
1236 | rxvt_term::want_refresh () |
1240 | rxvt_term::want_refresh () |
1237 | CODE: |
1241 | CODE: |
1238 | THIS->want_refresh = 1; |
1242 | THIS->want_refresh = 1; |
1239 | |
1243 | |
1240 | void |
1244 | void |
… | |
… | |
1246 | |
1250 | |
1247 | line_t &l = ROW(row_number); |
1251 | line_t &l = ROW(row_number); |
1248 | |
1252 | |
1249 | if (GIMME_V != G_VOID) |
1253 | if (GIMME_V != G_VOID) |
1250 | { |
1254 | { |
1251 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
1255 | wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol); |
1252 | |
1256 | |
1253 | for (int col = 0; col < THIS->ncol; col++) |
1257 | for (int col = 0; col < THIS->ncol; col++) |
1254 | wstr [col] = l.t [col]; |
1258 | wstr [col] = l.t [col]; |
1255 | |
1259 | |
1256 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1260 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1257 | |
|
|
1258 | delete [] wstr; |
|
|
1259 | } |
1261 | } |
1260 | |
1262 | |
1261 | if (new_text) |
1263 | if (new_text) |
1262 | { |
1264 | { |
1263 | wchar_t *wstr = sv2wcs (new_text); |
1265 | wchar_t *wstr = sv2wcs (new_text); |
1264 | |
1266 | |
1265 | int len = min (wcslen (wstr) - start_ofs, max_len); |
1267 | int len = min (wcslen (wstr) - start_ofs, max_len); |
1266 | |
1268 | |
1267 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1269 | if (start_col < 0 || start_col + len > THIS->ncol) |
1268 | { |
1270 | { |
1269 | free (wstr); |
1271 | free (wstr); |
1270 | croak ("new_text extends beyond horizontal margins"); |
1272 | croak ("new_text extends beyond horizontal margins"); |
1271 | } |
1273 | } |
1272 | |
1274 | |
… | |
… | |
1304 | { |
1306 | { |
1305 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1307 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1306 | croak ("new_rend must be arrayref"); |
1308 | croak ("new_rend must be arrayref"); |
1307 | |
1309 | |
1308 | AV *av = (AV *)SvRV (new_rend); |
1310 | AV *av = (AV *)SvRV (new_rend); |
1309 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
1311 | int len = min (AvFILL (av) + 1 - start_ofs, max_len); |
1310 | |
1312 | |
1311 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1313 | if (start_col < 0 || start_col + len > THIS->ncol) |
1312 | croak ("new_rend array extends beyond horizontal margins"); |
1314 | croak ("new_rend array extends beyond horizontal margins"); |
1313 | |
1315 | |
1314 | for (int col = start_col; col < start_col + len; col++) |
1316 | for (int col = start_col; col < start_col + len; col++) |
1315 | { |
1317 | { |
1316 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
1318 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
… | |
… | |
1356 | rxvt_term::special_encode (SV *string) |
1358 | rxvt_term::special_encode (SV *string) |
1357 | CODE: |
1359 | CODE: |
1358 | { |
1360 | { |
1359 | wchar_t *wstr = sv2wcs (string); |
1361 | wchar_t *wstr = sv2wcs (string); |
1360 | int wlen = wcslen (wstr); |
1362 | int wlen = wcslen (wstr); |
1361 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
1363 | wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer |
1362 | |
1364 | |
1363 | rxvt_push_locale (THIS->locale); |
1365 | rxvt_push_locale (THIS->locale); |
1364 | |
1366 | |
1365 | wchar_t *r = rstr; |
1367 | wchar_t *r = rstr; |
1366 | for (wchar_t *s = wstr; *s; s++) |
1368 | for (wchar_t *s = wstr; *s; s++) |
|
|
1369 | { |
|
|
1370 | int w = WCWIDTH (*s); |
|
|
1371 | |
1367 | if (wcwidth (*s) == 0) |
1372 | if (w == 0) |
1368 | { |
1373 | { |
1369 | if (r == rstr) |
1374 | if (r == rstr) |
1370 | croak ("leading combining character unencodable"); |
1375 | croak ("leading combining character unencodable"); |
1371 | |
1376 | |
1372 | unicode_t n = rxvt_compose (r[-1], *s); |
1377 | unicode_t n = rxvt_compose (r[-1], *s); |
1373 | if (n == NOCHAR) |
1378 | if (n == NOCHAR) |
1374 | n = rxvt_composite.compose (r[-1], *s); |
1379 | n = rxvt_composite.compose (r[-1], *s); |
1375 | |
1380 | |
1376 | r[-1] = n; |
1381 | r[-1] = n; |
1377 | } |
1382 | } |
1378 | #if !UNICODE_3 |
1383 | #if !UNICODE_3 |
1379 | else if (*s >= 0x10000) |
1384 | else if (*s >= 0x10000) |
1380 | *r++ = rxvt_composite.compose (*s); |
1385 | *r++ = rxvt_composite.compose (*s); |
1381 | #endif |
1386 | #endif |
1382 | else |
1387 | else |
1383 | *r++ = *s; |
1388 | *r++ = *s; |
|
|
1389 | |
|
|
1390 | // the *2 above only allows wcwidth <= 2 |
|
|
1391 | if (w > 1) |
|
|
1392 | *r++ = NOCHAR; |
|
|
1393 | } |
1384 | |
1394 | |
1385 | rxvt_pop_locale (); |
1395 | rxvt_pop_locale (); |
1386 | |
1396 | |
1387 | RETVAL = wcs2sv (rstr, r - rstr); |
1397 | RETVAL = wcs2sv (rstr, r - rstr); |
1388 | |
|
|
1389 | delete [] rstr; |
|
|
1390 | } |
1398 | } |
1391 | OUTPUT: |
1399 | OUTPUT: |
1392 | RETVAL |
1400 | RETVAL |
1393 | |
1401 | |
1394 | SV * |
1402 | SV * |
… | |
… | |
1406 | else if (IS_COMPOSE (*s)) |
1414 | else if (IS_COMPOSE (*s)) |
1407 | dlen += rxvt_composite.expand (*s, 0); |
1415 | dlen += rxvt_composite.expand (*s, 0); |
1408 | else |
1416 | else |
1409 | dlen++; |
1417 | dlen++; |
1410 | |
1418 | |
1411 | wchar_t *rstr = new wchar_t [dlen]; |
1419 | wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen); |
1412 | |
1420 | |
1413 | // decode |
1421 | // decode |
1414 | wchar_t *r = rstr; |
1422 | wchar_t *r = rstr; |
1415 | for (wchar_t *s = wstr; *s; s++) |
1423 | for (wchar_t *s = wstr; *s; s++) |
1416 | if (*s == NOCHAR) |
1424 | if (*s == NOCHAR) |
… | |
… | |
1419 | r += rxvt_composite.expand (*s, r); |
1427 | r += rxvt_composite.expand (*s, r); |
1420 | else |
1428 | else |
1421 | *r++ = *s; |
1429 | *r++ = *s; |
1422 | |
1430 | |
1423 | RETVAL = wcs2sv (rstr, r - rstr); |
1431 | RETVAL = wcs2sv (rstr, r - rstr); |
1424 | |
|
|
1425 | delete [] rstr; |
|
|
1426 | } |
1432 | } |
1427 | OUTPUT: |
1433 | OUTPUT: |
1428 | RETVAL |
1434 | RETVAL |
1429 | |
1435 | |
1430 | void |
1436 | void |
1431 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1437 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1432 | PPCODE: |
1438 | PPCODE: |
1433 | { |
1439 | { |
1434 | struct resval { const char *name; int value; } rslist [] = { |
1440 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1435 | # define def(name) { # name, Rs_ ## name }, |
1441 | # define def(name) { # name, Rs_ ## name }, |
1436 | # define reserve(name,count) |
1442 | # define reserve(name,count) |
1437 | # include "rsinc.h" |
1443 | # include "rsinc.h" |
1438 | # undef def |
1444 | # undef def |
1439 | # undef reserve |
1445 | # undef reserve |
1440 | }; |
1446 | }; |
1441 | |
1447 | |
1442 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1448 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1443 | |
1449 | |
1444 | do { |
1450 | do { |
1445 | if (rs-- == rslist) |
1451 | if (rs-- == rslist) |
1446 | croak ("no such resource '%s', requested", name); |
1452 | croak ("no such resource '%s', requested", name); |
1447 | } while (strcmp (name, rs->name)); |
1453 | } while (strcmp (name, rs->name)); |
… | |
… | |
1481 | if (set) |
1487 | if (set) |
1482 | THIS->options |= optval; |
1488 | THIS->options |= optval; |
1483 | else |
1489 | else |
1484 | THIS->options &= ~optval; |
1490 | THIS->options &= ~optval; |
1485 | |
1491 | |
|
|
1492 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1486 | switch (optval) |
1493 | switch (optval) |
1487 | { |
1494 | { |
1488 | case Opt_skipBuiltinGlyphs: |
1495 | case Opt_skipBuiltinGlyphs: |
1489 | THIS->set_fonts (); |
1496 | THIS->set_fonts (); |
1490 | THIS->scr_remap_chars (); |
1497 | THIS->scr_remap_chars (); |
1491 | THIS->scr_touch (true); |
1498 | THIS->scr_touch (true); |
1492 | THIS->want_refresh = 1; |
1499 | THIS->want_refresh = 1; |
1493 | break; |
1500 | break; |
1494 | |
1501 | |
1495 | case Opt_cursorUnderline: |
1502 | case Opt_cursorUnderline: |
1496 | THIS->want_refresh = 1; |
1503 | THIS->want_refresh = 1; |
1497 | break; |
1504 | break; |
1498 | |
1505 | |
1499 | # case Opt_scrollBar_floating: |
1506 | # case Opt_scrollBar_floating: |
1500 | # case Opt_scrollBar_right: |
1507 | # case Opt_scrollBar_right: |
1501 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1508 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1502 | # break; |
1509 | # break; |
1503 | } |
1510 | } |
1504 | } |
1511 | } |
1505 | } |
1512 | } |
1506 | OUTPUT: |
1513 | OUTPUT: |
1507 | RETVAL |
1514 | RETVAL |
1508 | |
1515 | |
… | |
… | |
1539 | if (items == 3) |
1546 | if (items == 3) |
1540 | { |
1547 | { |
1541 | rc.row = SvIV (ST (1)); |
1548 | rc.row = SvIV (ST (1)); |
1542 | rc.col = SvIV (ST (2)); |
1549 | rc.col = SvIV (ST (2)); |
1543 | |
1550 | |
1544 | if (ix == 2 && rc.col == 0) |
1551 | if (ix == 2) |
1545 | { |
1552 | { |
|
|
1553 | if (rc.col == 0) |
|
|
1554 | { |
|
|
1555 | // col == 0 means end of previous line |
1546 | rc.row--; |
1556 | rc.row--; |
1547 | rc.col = THIS->ncol; |
1557 | rc.col = THIS->ncol; |
|
|
1558 | } |
|
|
1559 | else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow) |
|
|
1560 | && rc.col > ROW(rc.row).l) |
|
|
1561 | { |
|
|
1562 | // col >= length means while line and add newline |
|
|
1563 | rc.col = THIS->ncol; |
|
|
1564 | } |
1548 | } |
1565 | } |
1549 | |
1566 | |
1550 | clamp_it (rc.col, 0, THIS->ncol); |
1567 | clamp_it (rc.col, 0, THIS->ncol); |
1551 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1568 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1552 | |
1569 | |
… | |
… | |
1560 | CODE: |
1577 | CODE: |
1561 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1578 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1562 | OUTPUT: |
1579 | OUTPUT: |
1563 | RETVAL |
1580 | RETVAL |
1564 | |
1581 | |
1565 | #void |
1582 | void |
1566 | #rxvt_term::selection_clear () |
1583 | rxvt_term::selection_clear () |
1567 | |
1584 | |
1568 | void |
1585 | void |
1569 | rxvt_term::selection_make (U32 eventtime, bool rect = false) |
1586 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1570 | CODE: |
1587 | CODE: |
1571 | THIS->selection.op = SELECTION_CONT; |
1588 | THIS->selection.op = SELECTION_CONT; |
1572 | THIS->selection.rect = rect; |
1589 | THIS->selection.rect = rect; |
1573 | THIS->selection_make (eventtime); |
1590 | THIS->selection_make (eventtime); |
1574 | |
1591 | |
1575 | int |
1592 | int |
1576 | rxvt_term::selection_grab (U32 eventtime) |
1593 | rxvt_term::selection_grab (Time eventtime) |
1577 | |
1594 | |
1578 | void |
1595 | void |
1579 | rxvt_term::selection (SV *newtext = 0) |
1596 | rxvt_term::selection (SV *newtext = 0) |
1580 | PPCODE: |
1597 | PPCODE: |
1581 | { |
1598 | { |
… | |
… | |
1599 | void |
1616 | void |
1600 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1617 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1601 | |
1618 | |
1602 | void |
1619 | void |
1603 | rxvt_term::scr_bell () |
1620 | rxvt_term::scr_bell () |
|
|
1621 | |
|
|
1622 | void |
|
|
1623 | rxvt_term::scr_change_screen (int screen) |
1604 | |
1624 | |
1605 | void |
1625 | void |
1606 | rxvt_term::scr_add_lines (SV *string) |
1626 | rxvt_term::scr_add_lines (SV *string) |
1607 | CODE: |
1627 | CODE: |
1608 | { |
1628 | { |
… | |
… | |
1649 | o->self = (HV *)SvRV (RETVAL); |
1669 | o->self = (HV *)SvRV (RETVAL); |
1650 | } |
1670 | } |
1651 | OUTPUT: |
1671 | OUTPUT: |
1652 | RETVAL |
1672 | RETVAL |
1653 | |
1673 | |
|
|
1674 | ############################################################################# |
|
|
1675 | # Various X Utility Functions |
|
|
1676 | ############################################################################# |
|
|
1677 | |
|
|
1678 | void |
|
|
1679 | rxvt_term::XListProperties (Window window) |
|
|
1680 | PPCODE: |
|
|
1681 | { |
|
|
1682 | int count; |
|
|
1683 | Atom *props = XListProperties (THIS->dpy, window, &count); |
|
|
1684 | |
|
|
1685 | EXTEND (SP, count); |
|
|
1686 | while (count--) |
|
|
1687 | PUSHs (newSVuv ((U32)props [count])); |
|
|
1688 | |
|
|
1689 | XFree (props); |
|
|
1690 | } |
|
|
1691 | |
|
|
1692 | void |
|
|
1693 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
|
|
1694 | PPCODE: |
|
|
1695 | { |
|
|
1696 | Atom type; |
|
|
1697 | int format; |
|
|
1698 | unsigned long nitems; |
|
|
1699 | unsigned long bytes_after; |
|
|
1700 | unsigned char *prop; |
|
|
1701 | |
|
|
1702 | XGetWindowProperty (THIS->dpy, window, property, |
|
|
1703 | 0, 1<<24, 0, AnyPropertyType, |
|
|
1704 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
1705 | |
|
|
1706 | if (type != None) |
|
|
1707 | { |
|
|
1708 | int elemsize = format == 16 ? sizeof (short) |
|
|
1709 | : format == 32 ? sizeof (long) |
|
|
1710 | : 1; |
|
|
1711 | |
|
|
1712 | EXTEND (SP, 3); |
|
|
1713 | PUSHs (newSVuv ((U32)type)); |
|
|
1714 | PUSHs (newSViv (format)); |
|
|
1715 | PUSHs (newSVpvn ((char *)prop, nitems * elemsize)); |
|
|
1716 | XFree (prop); |
|
|
1717 | } |
|
|
1718 | } |
|
|
1719 | |
|
|
1720 | void |
|
|
1721 | rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) |
|
|
1722 | CODE: |
|
|
1723 | { |
|
|
1724 | STRLEN len; |
|
|
1725 | char *data_ = SvPVbyte (data, len); |
|
|
1726 | |
|
|
1727 | int elemsize = format == 16 ? sizeof (short) |
|
|
1728 | : format == 32 ? sizeof (long) |
|
|
1729 | : 1; |
|
|
1730 | |
|
|
1731 | XChangeProperty (THIS->dpy, window, property, |
|
|
1732 | type, format, PropModeReplace, |
|
|
1733 | (unsigned char *)data_, len / elemsize); |
|
|
1734 | } |
|
|
1735 | |
|
|
1736 | Atom |
|
|
1737 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
|
|
1738 | C_ARGS: term->dpy, atom_name, only_if_exists |
|
|
1739 | |
|
|
1740 | char * |
|
|
1741 | XGetAtomName (rxvt_term *term, Atom atom) |
|
|
1742 | C_ARGS: term->dpy, atom |
|
|
1743 | CLEANUP: |
|
|
1744 | XFree (RETVAL); |
|
|
1745 | |
|
|
1746 | void |
|
|
1747 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
|
|
1748 | C_ARGS: term->dpy, window, property |
|
|
1749 | |
|
|
1750 | Window |
|
|
1751 | rxvt_term::DefaultRootWindow () |
|
|
1752 | CODE: |
|
|
1753 | RETVAL = THIS->display->root; |
|
|
1754 | OUTPUT: |
|
|
1755 | RETVAL |
|
|
1756 | |
|
|
1757 | #if 0 |
|
|
1758 | |
|
|
1759 | Window |
|
|
1760 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
|
|
1761 | C_ARGS: term->dpy, (Window)parent, |
|
|
1762 | x, y, width, height, 0, |
|
|
1763 | term->pix_colors_focused[Color_border], |
|
|
1764 | term->pix_colors_focused[Color_border] |
|
|
1765 | |
|
|
1766 | #endif |
|
|
1767 | |
|
|
1768 | void |
|
|
1769 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
|
|
1770 | C_ARGS: term->dpy, window, parent, x, y |
|
|
1771 | |
|
|
1772 | void |
|
|
1773 | XMapWindow (rxvt_term *term, Window window) |
|
|
1774 | C_ARGS: term->dpy, window |
|
|
1775 | |
|
|
1776 | void |
|
|
1777 | XUnmapWindow (rxvt_term *term, Window window) |
|
|
1778 | C_ARGS: term->dpy, window |
|
|
1779 | |
|
|
1780 | void |
|
|
1781 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
|
|
1782 | C_ARGS: term->dpy, window, x, y, width, height |
|
|
1783 | |
|
|
1784 | void |
|
|
1785 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
|
|
1786 | CODE: |
|
|
1787 | { |
|
|
1788 | XWindowAttributes attr; |
|
|
1789 | XGetWindowAttributes (THIS->dpy, window, &attr); |
|
|
1790 | XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events); |
|
|
1791 | } |
|
|
1792 | |
|
|
1793 | void |
|
|
1794 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
|
|
1795 | PPCODE: |
|
|
1796 | { |
|
|
1797 | int dx, dy; |
|
|
1798 | Window child; |
|
|
1799 | |
|
|
1800 | if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child)) |
|
|
1801 | { |
|
|
1802 | EXTEND (SP, 3); |
|
|
1803 | PUSHs (newSViv (dx)); |
|
|
1804 | PUSHs (newSViv (dy)); |
|
|
1805 | PUSHs (newSVuv (child)); |
|
|
1806 | } |
|
|
1807 | } |
|
|
1808 | |
|
|
1809 | ############################################################################# |
|
|
1810 | # urxvt::overlay |
|
|
1811 | ############################################################################# |
|
|
1812 | |
1654 | MODULE = urxvt PACKAGE = urxvt::overlay |
1813 | MODULE = urxvt PACKAGE = urxvt::overlay |
1655 | |
1814 | |
1656 | void |
1815 | void |
1657 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
1816 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
1658 | |
1817 | |
… | |
… | |
1663 | overlay::hide () |
1822 | overlay::hide () |
1664 | |
1823 | |
1665 | void |
1824 | void |
1666 | overlay::DESTROY () |
1825 | overlay::DESTROY () |
1667 | |
1826 | |
1668 | MODULE = urxvt PACKAGE = urxvt::timer |
1827 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1669 | |
1828 | |
1670 | SV * |
|
|
1671 | timer::new () |
|
|
1672 | CODE: |
|
|
1673 | timer *w = new timer; |
|
|
1674 | w->start (NOW); |
|
|
1675 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
|
|
1676 | w->self = (HV *)SvRV (RETVAL); |
|
|
1677 | OUTPUT: |
|
|
1678 | RETVAL |
|
|
1679 | |
|
|
1680 | timer * |
|
|
1681 | timer::cb (SV *cb) |
|
|
1682 | CODE: |
|
|
1683 | THIS->cb (cb); |
|
|
1684 | RETVAL = THIS; |
|
|
1685 | OUTPUT: |
|
|
1686 | RETVAL |
|
|
1687 | |
|
|
1688 | NV |
|
|
1689 | timer::at () |
|
|
1690 | CODE: |
|
|
1691 | RETVAL = THIS->at; |
|
|
1692 | OUTPUT: |
|
|
1693 | RETVAL |
|
|
1694 | |
|
|
1695 | timer * |
|
|
1696 | timer::interval (NV interval) |
|
|
1697 | CODE: |
|
|
1698 | THIS->interval = interval; |
|
|
1699 | RETVAL = THIS; |
|
|
1700 | OUTPUT: |
|
|
1701 | RETVAL |
|
|
1702 | |
|
|
1703 | timer * |
|
|
1704 | timer::set (NV tstamp) |
|
|
1705 | CODE: |
|
|
1706 | THIS->set (tstamp); |
|
|
1707 | RETVAL = THIS; |
|
|
1708 | OUTPUT: |
|
|
1709 | RETVAL |
|
|
1710 | |
|
|
1711 | timer * |
|
|
1712 | timer::start (NV tstamp = THIS->at) |
|
|
1713 | CODE: |
|
|
1714 | THIS->start (tstamp); |
|
|
1715 | RETVAL = THIS; |
|
|
1716 | OUTPUT: |
|
|
1717 | RETVAL |
|
|
1718 | |
|
|
1719 | timer * |
|
|
1720 | timer::stop () |
|
|
1721 | CODE: |
|
|
1722 | THIS->stop (); |
|
|
1723 | RETVAL = THIS; |
|
|
1724 | OUTPUT: |
|
|
1725 | RETVAL |
|
|
1726 | |
|
|
1727 | void |
|
|
1728 | timer::DESTROY () |
|
|
1729 | |
|
|
1730 | MODULE = urxvt PACKAGE = urxvt::iow |
|
|
1731 | |
|
|
1732 | SV * |
|
|
1733 | iow::new () |
|
|
1734 | CODE: |
|
|
1735 | iow *w = new iow; |
|
|
1736 | RETVAL = newSVptr ((void *)w, "urxvt::iow"); |
|
|
1737 | w->self = (HV *)SvRV (RETVAL); |
|
|
1738 | OUTPUT: |
|
|
1739 | RETVAL |
|
|
1740 | |
|
|
1741 | iow * |
|
|
1742 | iow::cb (SV *cb) |
|
|
1743 | CODE: |
|
|
1744 | THIS->cb (cb); |
|
|
1745 | RETVAL = THIS; |
|
|
1746 | OUTPUT: |
|
|
1747 | RETVAL |
|
|
1748 | |
|
|
1749 | iow * |
|
|
1750 | iow::fd (int fd) |
|
|
1751 | CODE: |
|
|
1752 | THIS->fd = fd; |
|
|
1753 | RETVAL = THIS; |
|
|
1754 | OUTPUT: |
|
|
1755 | RETVAL |
|
|
1756 | |
|
|
1757 | iow * |
|
|
1758 | iow::events (short events) |
|
|
1759 | CODE: |
|
|
1760 | THIS->events = events; |
|
|
1761 | RETVAL = THIS; |
|
|
1762 | OUTPUT: |
|
|
1763 | RETVAL |
|
|
1764 | |
|
|
1765 | iow * |
|
|
1766 | iow::start () |
|
|
1767 | CODE: |
|
|
1768 | THIS->start (); |
|
|
1769 | RETVAL = THIS; |
|
|
1770 | OUTPUT: |
|
|
1771 | RETVAL |
|
|
1772 | |
|
|
1773 | iow * |
|
|
1774 | iow::stop () |
|
|
1775 | CODE: |
|
|
1776 | THIS->stop (); |
|
|
1777 | RETVAL = THIS; |
|
|
1778 | OUTPUT: |
|
|
1779 | RETVAL |
|
|
1780 | |
|
|
1781 | void |
|
|
1782 | iow::DESTROY () |
|
|
1783 | |
|
|
1784 | |
|
|