1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtperl.xs |
2 | * File: rxvtperl.xs |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008,2011 Marc Lehmann <schmorp@schmorp.de> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
23 | #define line_t perl_line_t |
23 | #define line_t perl_line_t |
24 | #include <EXTERN.h> |
24 | #include <EXTERN.h> |
25 | #include <perl.h> |
25 | #include <perl.h> |
26 | #include <XSUB.h> |
26 | #include <XSUB.h> |
27 | #undef line_t |
27 | #undef line_t |
|
|
28 | #undef bool // perl defines it's own bool type, except with g++... what a trap |
28 | |
29 | |
29 | #include "../config.h" |
30 | #include "../config.h" |
30 | |
31 | |
31 | #include <cstddef> |
32 | #include <stddef.h> |
32 | #include <cstdarg> |
33 | #include <stdarg.h> |
33 | |
34 | |
34 | #include "unistd.h" |
35 | #include "unistd.h" |
35 | |
36 | |
36 | #include "iom.h" |
37 | #include "ev_cpp.h" |
37 | #include "rxvt.h" |
38 | #include "rxvt.h" |
38 | #include "keyboard.h" |
39 | #include "keyboard.h" |
39 | #include "rxvtutil.h" |
40 | #include "rxvtutil.h" |
40 | #include "rxvtperl.h" |
41 | #include "rxvtperl.h" |
41 | |
42 | |
42 | #include "perlxsi.c" |
43 | #include "perlxsi.c" |
43 | |
44 | |
44 | #ifdef HAVE_SCROLLBARS |
|
|
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
45 | #define GRAB_CURSOR THIS->scrollBar.leftptr_cursor |
46 | #else |
|
|
47 | # define GRAB_CURSOR None |
|
|
48 | #endif |
|
|
49 | |
46 | |
50 | #undef LINENO |
47 | #undef LINENO |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
48 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
52 | #undef ROW |
49 | #undef ROW |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
54 | |
51 | |
55 | ///////////////////////////////////////////////////////////////////////////// |
52 | ///////////////////////////////////////////////////////////////////////////// |
56 | |
53 | |
|
|
54 | typedef char * octet_string; |
|
|
55 | typedef char * utf8_string; |
|
|
56 | |
|
|
57 | typedef GdkPixbuf * urxvt__pixbuf; |
|
|
58 | typedef rxvt_img * urxvt__img; |
|
|
59 | |
|
|
60 | ///////////////////////////////////////////////////////////////////////////// |
|
|
61 | |
|
|
62 | static void |
|
|
63 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
|
|
64 | { |
|
|
65 | //TODO: support component stuff |
|
|
66 | c.set (s, SvPVbyte_nolen (sv)); |
|
|
67 | } |
|
|
68 | |
|
|
69 | ///////////////////////////////////////////////////////////////////////////// |
|
|
70 | |
57 | static wchar_t * |
71 | static wchar_t * |
58 | sv2wcs (SV *sv) |
72 | sv2wcs (SV *sv) |
59 | { |
73 | { |
60 | STRLEN len; |
74 | STRLEN len; |
61 | char *str = SvPVutf8 (sv, len); |
75 | char *str = SvPVutf8 (sv, len); |
… | |
… | |
73 | |
87 | |
74 | return sv; |
88 | return sv; |
75 | } |
89 | } |
76 | |
90 | |
77 | static SV * |
91 | static SV * |
78 | new_ref (HV *hv, const char *klass) |
|
|
79 | { |
|
|
80 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
81 | } |
|
|
82 | |
|
|
83 | static SV * |
|
|
84 | newSVptr (void *ptr, const char *klass) |
92 | newSVptr (void *ptr, const char *klass) |
85 | { |
93 | { |
86 | HV *hv = newHV (); |
94 | HV *hv = newHV (); |
87 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
95 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
88 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
96 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
… | |
… | |
117 | |
125 | |
118 | ///////////////////////////////////////////////////////////////////////////// |
126 | ///////////////////////////////////////////////////////////////////////////// |
119 | |
127 | |
120 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
128 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
121 | |
129 | |
122 | class overlay { |
130 | class overlay : overlay_base |
|
|
131 | { |
123 | rxvt_term *THIS; |
132 | rxvt_term *THIS; |
124 | AV *overlay_av; |
133 | AV *overlay_av; |
125 | int x, y, w, h; |
|
|
126 | int border; |
134 | int border; |
127 | text_t **text; |
|
|
128 | rend_t **rend; |
|
|
129 | |
135 | |
130 | public: |
136 | public: |
131 | HV *self; |
137 | HV *self; |
132 | |
138 | |
133 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
139 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
… | |
… | |
140 | |
146 | |
141 | void set (int x, int y, SV *str, SV *rend); |
147 | void set (int x, int y, SV *str, SV *rend); |
142 | }; |
148 | }; |
143 | |
149 | |
144 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
150 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
145 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) |
151 | : THIS(THIS), border(border == 2), overlay_av (0) |
146 | { |
152 | { |
|
|
153 | x = x_; |
|
|
154 | y = y_; |
|
|
155 | w = w_; |
|
|
156 | h = h_; |
|
|
157 | |
147 | if (w < 0) w = 0; |
158 | if (w < 0) w = 0; |
148 | if (h < 0) h = 0; |
159 | if (h < 0) h = 0; |
149 | |
160 | |
150 | if (border == 2) |
161 | if (border == 2) |
151 | { |
162 | { |
… | |
… | |
220 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
231 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
221 | )); |
232 | )); |
222 | av_push (overlay_av, newSViv ((long)this)); |
233 | av_push (overlay_av, newSViv ((long)this)); |
223 | |
234 | |
224 | THIS->want_refresh = 1; |
235 | THIS->want_refresh = 1; |
|
|
236 | THIS->refresh_check (); |
225 | } |
237 | } |
226 | |
238 | |
227 | void |
239 | void |
228 | overlay::hide () |
240 | overlay::hide () |
229 | { |
241 | { |
… | |
… | |
243 | |
255 | |
244 | SvREFCNT_dec (overlay_av); |
256 | SvREFCNT_dec (overlay_av); |
245 | overlay_av = 0; |
257 | overlay_av = 0; |
246 | |
258 | |
247 | THIS->want_refresh = 1; |
259 | THIS->want_refresh = 1; |
|
|
260 | THIS->refresh_check (); |
248 | } |
261 | } |
249 | |
262 | |
250 | void overlay::swap () |
263 | void overlay::swap () |
251 | { |
264 | { |
252 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
265 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
253 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
266 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
254 | |
267 | |
255 | int ov_w = min (w, THIS->ncol - ov_x); |
268 | int ov_w = min (w, THIS->ncol - ov_x); |
256 | int ov_h = min (h, THIS->nrow - ov_y); |
269 | int ov_h = min (h, THIS->nrow - ov_y); |
|
|
270 | |
|
|
271 | // hide cursor if it is within the overlay area |
|
|
272 | if (IN_RANGE_EXC (THIS->screen.cur.col - ov_x, 0, ov_w) |
|
|
273 | && IN_RANGE_EXC (THIS->screen.cur.row - ov_y, 0, ov_h)) |
|
|
274 | THIS->screen.flags &= ~Screen_VisibleCursor; |
257 | |
275 | |
258 | for (int y = ov_h; y--; ) |
276 | for (int y = ov_h; y--; ) |
259 | { |
277 | { |
260 | text_t *t1 = text [y]; |
278 | text_t *t1 = text [y]; |
261 | rend_t *r1 = rend [y]; |
279 | rend_t *r1 = rend [y]; |
… | |
… | |
297 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
315 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
298 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
316 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
299 | } |
317 | } |
300 | |
318 | |
301 | THIS->want_refresh = 1; |
319 | THIS->want_refresh = 1; |
|
|
320 | THIS->refresh_check (); |
302 | } |
321 | } |
303 | |
322 | |
304 | ///////////////////////////////////////////////////////////////////////////// |
323 | ///////////////////////////////////////////////////////////////////////////// |
305 | |
324 | |
306 | #define IOM_CLASS "urxvt" |
|
|
307 | #include <iom_perl.h> |
325 | #include "iom_perl.h" |
308 | |
326 | |
309 | ///////////////////////////////////////////////////////////////////////////// |
327 | ///////////////////////////////////////////////////////////////////////////// |
310 | |
328 | |
311 | struct rxvt_perl_interp rxvt_perl; |
329 | struct rxvt_perl_interp rxvt_perl; |
312 | |
330 | |
… | |
… | |
316 | { |
334 | { |
317 | if (perl) |
335 | if (perl) |
318 | { |
336 | { |
319 | perl_destruct (perl); |
337 | perl_destruct (perl); |
320 | perl_free (perl); |
338 | perl_free (perl); |
|
|
339 | PERL_SYS_TERM (); |
321 | } |
340 | } |
322 | } |
341 | } |
323 | |
342 | |
324 | void |
343 | void |
325 | rxvt_perl_interp::init (rxvt_term *term) |
344 | rxvt_perl_interp::init (rxvt_term *term) |
326 | { |
345 | { |
327 | if (!perl) |
346 | if (!perl) |
328 | { |
347 | { |
329 | rxvt_push_locale (""); // perl init destroys current locale |
348 | rxvt_push_locale (""); // perl init destroys current locale |
330 | |
349 | |
|
|
350 | { |
331 | perl_environ = rxvt_environ; |
351 | perl_environ = rxvt_environ; |
332 | swap (perl_environ, environ); |
352 | localise_env set_environ (perl_environ); |
333 | |
353 | |
334 | char *argv[] = { |
354 | char *args[] = { |
335 | "", |
355 | "", |
336 | "-e" |
356 | "-e" |
337 | "BEGIN {" |
357 | "BEGIN {" |
338 | " urxvt->bootstrap;" |
358 | " urxvt->bootstrap;" |
339 | " unshift @INC, '" LIBDIR "';" |
359 | " unshift @INC, '" LIBDIR "';" |
340 | "}" |
360 | "}" |
341 | "" |
361 | "" |
342 | "use urxvt;" |
362 | "use urxvt;" |
343 | }; |
363 | }; |
|
|
364 | int argc = ecb_array_length (args); |
|
|
365 | char **argv = args; |
344 | |
366 | |
|
|
367 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
345 | perl = perl_alloc (); |
368 | perl = perl_alloc (); |
346 | perl_construct (perl); |
369 | perl_construct (perl); |
347 | |
370 | |
348 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
371 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
349 | || perl_run (perl)) |
372 | || perl_run (perl)) |
350 | { |
373 | { |
351 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
374 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
352 | |
375 | |
353 | perl_destruct (perl); |
376 | perl_destruct (perl); |
354 | perl_free (perl); |
377 | perl_free (perl); |
355 | perl = 0; |
378 | perl = 0; |
356 | } |
379 | } |
357 | |
380 | } |
358 | swap (perl_environ, environ); |
|
|
359 | |
381 | |
360 | rxvt_pop_locale (); |
382 | rxvt_pop_locale (); |
361 | } |
383 | } |
362 | |
384 | |
363 | if (perl) |
385 | if (perl) |
364 | { |
386 | { |
365 | // runs outside of perls ENV |
387 | // runs outside of perls ENV |
366 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
388 | 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); |
389 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
390 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
368 | } |
391 | } |
369 | } |
392 | } |
370 | |
393 | |
371 | static void |
394 | static void |
372 | ungrab (rxvt_term *THIS) |
395 | ungrab (rxvt_term *THIS) |
… | |
… | |
383 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
406 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
384 | { |
407 | { |
385 | if (!perl || !term->perl.self) |
408 | if (!perl || !term->perl.self) |
386 | return false; |
409 | return false; |
387 | |
410 | |
|
|
411 | localise_env set_environ (perl_environ); |
|
|
412 | |
388 | // pre-handling of some events |
413 | // pre-handling of some events |
389 | if (htype == HOOK_REFRESH_END) |
414 | if (htype == HOOK_REFRESH_END) |
390 | { |
415 | { |
391 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
416 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
392 | |
417 | |
393 | for (int i = 0; i <= AvFILL (av); i++) |
418 | for (int i = 0; i <= AvFILL (av); i++) |
394 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
419 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
395 | } |
420 | } |
|
|
421 | else if (htype == HOOK_DESTROY) |
|
|
422 | { |
|
|
423 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
396 | |
424 | |
397 | swap (perl_environ, environ); |
425 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
426 | { |
|
|
427 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
428 | delete req; |
|
|
429 | } |
|
|
430 | } |
398 | |
431 | |
399 | bool event_consumed; |
432 | bool event_consumed; |
400 | |
433 | |
401 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
434 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
402 | || term->perl.should_invoke [htype]) |
435 | || term->perl.should_invoke [htype]) |
403 | try |
|
|
404 | { |
436 | { |
405 | dSP; |
437 | dSP; |
406 | va_list ap; |
438 | va_list ap; |
407 | |
439 | |
408 | va_start (ap, htype); |
440 | va_start (ap, htype); |
409 | |
441 | |
410 | ENTER; |
442 | ENTER; |
411 | SAVETMPS; |
443 | SAVETMPS; |
412 | |
444 | |
413 | PUSHMARK (SP); |
445 | PUSHMARK (SP); |
414 | |
446 | |
|
|
447 | EXTEND (SP, 2); |
415 | XPUSHs (sv_2mortal (newSVterm (term))); |
448 | PUSHs (sv_2mortal (newSVterm (term))); |
416 | XPUSHs (sv_2mortal (newSViv (htype))); |
449 | PUSHs (sv_2mortal (newSViv (htype))); |
417 | |
450 | |
418 | for (;;) { |
451 | for (;;) { |
419 | data_type dt = (data_type)va_arg (ap, int); |
452 | data_type dt = (data_type)va_arg (ap, int); |
420 | |
453 | |
421 | switch (dt) |
454 | switch (dt) |
422 | { |
455 | { |
423 | case DT_INT: |
456 | case DT_INT: |
424 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
457 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
425 | break; |
458 | break; |
426 | |
459 | |
427 | case DT_LONG: |
460 | case DT_LONG: |
428 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
461 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
429 | break; |
462 | break; |
430 | |
463 | |
431 | case DT_STR: |
464 | case DT_STR: |
432 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
465 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
433 | break; |
466 | break; |
434 | |
467 | |
435 | case DT_STR_LEN: |
468 | case DT_STR_LEN: |
436 | { |
469 | { |
437 | char *str = va_arg (ap, char *); |
470 | char *str = va_arg (ap, char *); |
438 | int len = va_arg (ap, int); |
471 | int len = va_arg (ap, int); |
439 | |
472 | |
440 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
473 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
441 | } |
474 | } |
442 | break; |
475 | break; |
443 | |
476 | |
444 | case DT_WCS_LEN: |
477 | case DT_WCS_LEN: |
445 | { |
478 | { |
446 | wchar_t *wstr = va_arg (ap, wchar_t *); |
479 | wchar_t *wstr = va_arg (ap, wchar_t *); |
447 | int wlen = va_arg (ap, int); |
480 | int wlen = va_arg (ap, int); |
448 | |
481 | |
449 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
482 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
450 | } |
483 | } |
451 | break; |
484 | break; |
452 | |
485 | |
453 | case DT_LCS_LEN: |
486 | case DT_LCS_LEN: |
454 | { |
487 | { |
455 | long *lstr = va_arg (ap, long *); |
488 | long *lstr = va_arg (ap, long *); |
456 | int llen = va_arg (ap, int); |
489 | int llen = va_arg (ap, int); |
457 | |
490 | |
458 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
491 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
459 | } |
492 | } |
460 | break; |
493 | break; |
461 | |
494 | |
462 | case DT_XEVENT: |
495 | case DT_XEVENT: |
463 | { |
496 | { |
464 | XEvent *xe = va_arg (ap, XEvent *); |
497 | XEvent *xe = va_arg (ap, XEvent *); |
465 | HV *hv = newHV (); |
498 | HV *hv = newHV (); |
466 | |
499 | |
467 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
500 | # 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) |
501 | # 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) |
502 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
470 | # undef set |
503 | # undef set |
471 | |
504 | |
472 | setiv (type, xe->type); |
505 | setiv (type, xe->type); |
473 | setiv (send_event, xe->xany.send_event); |
506 | setiv (send_event, xe->xany.send_event); |
474 | setiv (serial, xe->xany.serial); |
507 | setiv (serial, xe->xany.serial); |
475 | |
508 | |
476 | switch (xe->type) |
509 | switch (xe->type) |
477 | { |
510 | { |
478 | case KeyPress: |
511 | case KeyPress: |
479 | case KeyRelease: |
512 | case KeyRelease: |
480 | case ButtonPress: |
513 | case ButtonPress: |
481 | case ButtonRelease: |
514 | case ButtonRelease: |
482 | case MotionNotify: |
515 | case MotionNotify: |
483 | setuv (window, xe->xmotion.window); |
516 | setuv (window, xe->xmotion.window); |
484 | setuv (root, xe->xmotion.root); |
517 | setuv (root, xe->xmotion.root); |
485 | setuv (subwindow, xe->xmotion.subwindow); |
518 | setuv (subwindow, xe->xmotion.subwindow); |
486 | setuv (time, xe->xmotion.time); |
519 | setuv (time, xe->xmotion.time); |
487 | setiv (x, xe->xmotion.x); |
520 | setiv (x, xe->xmotion.x); |
488 | setiv (y, xe->xmotion.y); |
521 | setiv (y, xe->xmotion.y); |
489 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
522 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
490 | setiv (col, xe->xmotion.x / term->fwidth); |
523 | setiv (col, xe->xmotion.x / term->fwidth); |
491 | setiv (x_root, xe->xmotion.x_root); |
524 | setiv (x_root, xe->xmotion.x_root); |
492 | setiv (y_root, xe->xmotion.y_root); |
525 | setiv (y_root, xe->xmotion.y_root); |
493 | setuv (state, xe->xmotion.state); |
526 | setuv (state, xe->xmotion.state); |
494 | |
527 | |
495 | switch (xe->type) |
528 | switch (xe->type) |
496 | { |
529 | { |
497 | case KeyPress: |
530 | case KeyPress: |
498 | case KeyRelease: |
531 | case KeyRelease: |
499 | setuv (keycode, xe->xkey.keycode); |
532 | setuv (keycode, xe->xkey.keycode); |
500 | break; |
533 | break; |
501 | |
534 | |
502 | case ButtonPress: |
535 | case ButtonPress: |
503 | case ButtonRelease: |
536 | case ButtonRelease: |
504 | setuv (button, xe->xbutton.button); |
537 | setuv (button, xe->xbutton.button); |
505 | break; |
538 | break; |
506 | |
539 | |
507 | case MotionNotify: |
540 | case MotionNotify: |
508 | setiv (is_hint, xe->xmotion.is_hint); |
541 | setiv (is_hint, xe->xmotion.is_hint); |
509 | break; |
542 | break; |
510 | } |
543 | } |
511 | |
544 | |
512 | break; |
545 | break; |
513 | |
546 | |
514 | case MapNotify: |
547 | case MapNotify: |
515 | case UnmapNotify: |
548 | case UnmapNotify: |
516 | case ConfigureNotify: |
549 | case ConfigureNotify: |
517 | setuv (event, xe->xconfigure.event); |
550 | setuv (event, xe->xconfigure.event); |
518 | setuv (window, xe->xconfigure.window); |
551 | setuv (window, xe->xconfigure.window); |
519 | |
552 | |
520 | switch (xe->type) |
553 | switch (xe->type) |
521 | { |
554 | { |
522 | case ConfigureNotify: |
555 | case ConfigureNotify: |
523 | setiv (x, xe->xconfigure.x); |
556 | setiv (x, xe->xconfigure.x); |
524 | setiv (y, xe->xconfigure.y); |
557 | setiv (y, xe->xconfigure.y); |
525 | setiv (width, xe->xconfigure.width); |
558 | setiv (width, xe->xconfigure.width); |
526 | setiv (height, xe->xconfigure.height); |
559 | setiv (height, xe->xconfigure.height); |
527 | setuv (above, xe->xconfigure.above); |
560 | setuv (above, xe->xconfigure.above); |
528 | break; |
561 | break; |
529 | } |
562 | } |
530 | |
563 | |
531 | break; |
564 | break; |
532 | |
565 | |
533 | case PropertyNotify: |
566 | case PropertyNotify: |
534 | setuv (window, xe->xproperty.window); |
567 | setuv (window, xe->xproperty.window); |
535 | setuv (atom, xe->xproperty.atom); |
568 | setuv (atom, xe->xproperty.atom); |
536 | setuv (time, xe->xproperty.time); |
569 | setuv (time, xe->xproperty.time); |
537 | setiv (state, xe->xproperty.state); |
570 | setiv (state, xe->xproperty.state); |
538 | break; |
571 | break; |
539 | |
572 | |
540 | case ClientMessage: |
573 | case ClientMessage: |
541 | setuv (window, xe->xclient.window); |
574 | setuv (window, xe->xclient.window); |
542 | setuv (message_type, xe->xclient.message_type); |
575 | setuv (message_type, xe->xclient.message_type); |
543 | setuv (format, xe->xclient.format); |
576 | setuv (format, xe->xclient.format); |
544 | setuv (l0, xe->xclient.data.l[0]); |
577 | setuv (l0, xe->xclient.data.l[0]); |
545 | setuv (l1, xe->xclient.data.l[1]); |
578 | setuv (l1, xe->xclient.data.l[1]); |
546 | setuv (l2, xe->xclient.data.l[2]); |
579 | setuv (l2, xe->xclient.data.l[2]); |
547 | setuv (l3, xe->xclient.data.l[3]); |
580 | setuv (l3, xe->xclient.data.l[3]); |
548 | setuv (l4, xe->xclient.data.l[4]); |
581 | setuv (l4, xe->xclient.data.l[4]); |
549 | break; |
582 | break; |
550 | } |
583 | } |
551 | |
584 | |
552 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
585 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
553 | } |
586 | } |
554 | break; |
587 | break; |
555 | |
588 | |
556 | case DT_END: |
589 | case DT_END: |
557 | goto call; |
590 | goto call; |
558 | |
591 | |
559 | default: |
592 | default: |
560 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
593 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
561 | } |
594 | } |
|
|
595 | } |
|
|
596 | |
|
|
597 | call: |
|
|
598 | va_end (ap); |
|
|
599 | |
|
|
600 | PUTBACK; |
|
|
601 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
602 | SPAGAIN; |
|
|
603 | |
|
|
604 | if (count) |
|
|
605 | { |
|
|
606 | SV *status = POPs; |
|
|
607 | count = SvTRUE (status); |
562 | } |
608 | } |
563 | |
609 | |
564 | call: |
|
|
565 | va_end (ap); |
|
|
566 | |
|
|
567 | PUTBACK; |
610 | 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; |
611 | FREETMPS; |
579 | LEAVE; |
612 | LEAVE; |
580 | |
613 | |
581 | if (SvTRUE (ERRSV)) |
614 | if (SvTRUE (ERRSV)) |
582 | { |
615 | { |
583 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
616 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
584 | ungrab (term); // better lose the grab than the session |
617 | ungrab (term); // better lose the grab than the session |
585 | } |
618 | } |
586 | |
619 | |
587 | event_consumed = !!count; |
620 | event_consumed = !!count; |
588 | } |
621 | } |
589 | catch (...) |
|
|
590 | { |
|
|
591 | swap (perl_environ, environ); |
|
|
592 | throw; |
|
|
593 | } |
|
|
594 | else |
622 | else |
595 | event_consumed = false; |
623 | event_consumed = false; |
596 | |
624 | |
597 | // post-handling of some events |
625 | // post-handling of some events |
598 | if (htype == HOOK_REFRESH_BEGIN) |
626 | if (htype == HOOK_REFRESH_BEGIN) |
599 | { |
627 | { |
600 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
628 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
601 | |
629 | |
602 | for (int i = AvFILL (av); i >= 0; i--) |
630 | for (int i = AvFILL (av); i >= 0; i--) |
603 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
631 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
604 | } |
632 | } |
605 | else if (htype == HOOK_DESTROY) |
633 | else if (htype == HOOK_DESTROY) |
606 | { |
634 | { |
607 | clearSVptr ((SV *)term->perl.self); |
635 | clearSVptr ((SV *)term->perl.self); |
608 | SvREFCNT_dec ((SV *)term->perl.self); |
636 | SvREFCNT_dec ((SV *)term->perl.self); |
609 | |
637 | |
610 | // don't allow further calls |
638 | // don't allow further calls |
611 | term->perl.self = 0; |
639 | term->perl.self = 0; |
612 | } |
640 | } |
613 | |
641 | |
614 | swap (perl_environ, environ); |
|
|
615 | |
|
|
616 | return event_consumed; |
642 | return event_consumed; |
|
|
643 | } |
|
|
644 | |
|
|
645 | void |
|
|
646 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
647 | { |
|
|
648 | localise_env set_environ (perl_environ); |
|
|
649 | |
|
|
650 | ENTER; |
|
|
651 | SAVETMPS; |
|
|
652 | |
|
|
653 | dSP; |
|
|
654 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
655 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
656 | |
|
|
657 | if (SvTRUE (ERRSV)) |
|
|
658 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
659 | |
|
|
660 | FREETMPS; |
|
|
661 | LEAVE; |
617 | } |
662 | } |
618 | |
663 | |
619 | ///////////////////////////////////////////////////////////////////////////// |
664 | ///////////////////////////////////////////////////////////////////////////// |
620 | |
665 | |
621 | MODULE = urxvt PACKAGE = urxvt |
666 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
633 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
678 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
634 | # include "hookinc.h" |
679 | # include "hookinc.h" |
635 | # undef def |
680 | # undef def |
636 | |
681 | |
637 | HV *option = get_hv ("urxvt::OPTION", 1); |
682 | HV *option = get_hv ("urxvt::OPTION", 1); |
638 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
683 | # define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
639 | # define nodef(name) |
684 | # define nodef(name) |
640 | # include "optinc.h" |
685 | # include "optinc.h" |
641 | # undef nodef |
686 | # undef nodef |
642 | # undef def |
687 | # undef def |
643 | |
688 | |
… | |
… | |
645 | static const struct { |
690 | static const struct { |
646 | const char *name; |
691 | const char *name; |
647 | IV iv; |
692 | IV iv; |
648 | } *civ, const_iv[] = { |
693 | } *civ, const_iv[] = { |
649 | # define const_iv(name) { # name, (IV)name } |
694 | # define const_iv(name) { # name, (IV)name } |
|
|
695 | const_iv (NUM_RESOURCES), |
650 | const_iv (DEFAULT_RSTYLE), |
696 | const_iv (DEFAULT_RSTYLE), |
651 | const_iv (OVERLAY_RSTYLE), |
697 | const_iv (OVERLAY_RSTYLE), |
|
|
698 | const_iv (Color_Bits), |
|
|
699 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
|
|
700 | const_iv (RS_fgShift), const_iv (RS_fgMask), |
|
|
701 | const_iv (RS_Careful), |
|
|
702 | const_iv (RS_fontCount), |
|
|
703 | const_iv (RS_fontShift), |
|
|
704 | const_iv (RS_fontMask), |
|
|
705 | const_iv (RS_baseattrMask), |
|
|
706 | const_iv (RS_attrMask), |
|
|
707 | const_iv (RS_redraw), |
|
|
708 | const_iv (RS_Sel), |
652 | const_iv (RS_Bold), |
709 | const_iv (RS_Bold), |
653 | const_iv (RS_Italic), |
710 | const_iv (RS_Italic), |
654 | const_iv (RS_Blink), |
711 | const_iv (RS_Blink), |
655 | const_iv (RS_RVid), |
712 | const_iv (RS_RVid), |
656 | const_iv (RS_Uline), |
713 | const_iv (RS_Uline), |
… | |
… | |
743 | const_iv (XIMSecondary), |
800 | const_iv (XIMSecondary), |
744 | const_iv (XIMTertiary), |
801 | const_iv (XIMTertiary), |
745 | const_iv (XIMVisibleToForward), |
802 | const_iv (XIMVisibleToForward), |
746 | const_iv (XIMVisibleToBackword), |
803 | const_iv (XIMVisibleToBackword), |
747 | const_iv (XIMVisibleToCenter), |
804 | const_iv (XIMVisibleToCenter), |
|
|
805 | #if XRENDER |
|
|
806 | const_iv (PictStandardARGB32), |
|
|
807 | const_iv (PictStandardRGB24), |
|
|
808 | const_iv (PictStandardA8), |
|
|
809 | const_iv (PictStandardA4), |
|
|
810 | const_iv (PictStandardA1), |
|
|
811 | const_iv (RepeatNone), |
|
|
812 | const_iv (RepeatNormal), |
|
|
813 | const_iv (RepeatPad), |
|
|
814 | const_iv (RepeatReflect), |
|
|
815 | #endif |
748 | # if 0 |
816 | # if 0 |
749 | const_iv (XIMForwardChar), |
817 | const_iv (XIMForwardChar), |
750 | const_iv (XIMBackwardChar), |
818 | const_iv (XIMBackwardChar), |
751 | const_iv (XIMForwardWord), |
819 | const_iv (XIMForwardWord), |
752 | const_iv (XIMBackwardWord), |
820 | const_iv (XIMBackwardWord), |
… | |
… | |
760 | const_iv (XIMDontChange), |
828 | const_iv (XIMDontChange), |
761 | # endif |
829 | # endif |
762 | # endif |
830 | # endif |
763 | }; |
831 | }; |
764 | |
832 | |
765 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
833 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
766 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
834 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
767 | } |
835 | } |
768 | |
836 | |
769 | void |
837 | void |
770 | warn (const char *msg) |
838 | warn (const char *msg) |
771 | CODE: |
839 | CODE: |
… | |
… | |
780 | _exit (int status) |
848 | _exit (int status) |
781 | |
849 | |
782 | NV |
850 | NV |
783 | NOW () |
851 | NOW () |
784 | CODE: |
852 | CODE: |
785 | RETVAL = NOW; |
853 | RETVAL = ev::now (); |
786 | OUTPUT: |
854 | OUTPUT: |
787 | RETVAL |
855 | RETVAL |
788 | |
856 | |
789 | int |
857 | int |
790 | GET_BASEFG (int rend) |
858 | GET_BASEFG (int rend) |
… | |
… | |
843 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
911 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
844 | if ((*t)->perl.self) |
912 | if ((*t)->perl.self) |
845 | PUSHs (sv_2mortal (newSVterm (*t))); |
913 | PUSHs (sv_2mortal (newSVterm (*t))); |
846 | } |
914 | } |
847 | |
915 | |
|
|
916 | IV |
|
|
917 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
918 | CODE: |
|
|
919 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
920 | req->cb_sv = newSVsv (cb); |
|
|
921 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
922 | av_push (av, newSViv ((IV)req)); |
|
|
923 | RETVAL = (IV)req; |
|
|
924 | OUTPUT: |
|
|
925 | RETVAL |
|
|
926 | |
|
|
927 | void |
|
|
928 | _delete_selection_request (IV req_) |
|
|
929 | CODE: |
|
|
930 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
931 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
932 | int i; |
|
|
933 | |
|
|
934 | for (i = AvFILL (av); i >= 0; i--) |
|
|
935 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
936 | break; |
|
|
937 | |
|
|
938 | for (; i < AvFILL (av); i++) |
|
|
939 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
940 | |
|
|
941 | av_pop (av); |
|
|
942 | |
|
|
943 | delete req; |
|
|
944 | |
848 | MODULE = urxvt PACKAGE = urxvt::term |
945 | MODULE = urxvt PACKAGE = urxvt::term |
849 | |
946 | |
850 | SV * |
947 | SV * |
851 | _new (AV *env, AV *arg) |
948 | _new (AV *env, AV *arg) |
852 | CODE: |
949 | CODE: |
853 | { |
950 | { |
854 | rxvt_term *term = new rxvt_term; |
951 | rxvt_term *term = new rxvt_term; |
855 | |
952 | |
856 | stringvec *argv = new stringvec; |
953 | stringvec *argv = new stringvec; |
857 | stringvec *envv = new stringvec; |
|
|
858 | |
|
|
859 | for (int i = 0; i <= AvFILL (arg); i++) |
954 | for (int i = 0; i <= AvFILL (arg); i++) |
860 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
955 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
861 | |
956 | |
|
|
957 | stringvec *envv = new stringvec; |
862 | for (int i = AvFILL (env) + 1; i--; ) |
958 | for (int i = AvFILL (env) + 1; i--; ) |
863 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
959 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
864 | |
960 | |
865 | envv->push_back (0); |
|
|
866 | |
|
|
867 | bool success; |
|
|
868 | |
|
|
869 | try |
961 | try |
870 | { |
962 | { |
871 | success = term->init (argv, envv); |
963 | term->init (argv, envv); |
872 | } |
964 | } |
873 | catch (const class rxvt_failure_exception &e) |
965 | catch (const class rxvt_failure_exception &e) |
874 | { |
|
|
875 | success = false; |
|
|
876 | } |
|
|
877 | |
|
|
878 | if (!success) |
|
|
879 | { |
966 | { |
880 | term->destroy (); |
967 | term->destroy (); |
881 | croak ("error while initializing new terminal instance"); |
968 | croak ("error while initializing new terminal instance"); |
882 | } |
969 | } |
883 | |
970 | |
… | |
… | |
891 | rxvt_term::destroy () |
978 | rxvt_term::destroy () |
892 | |
979 | |
893 | void |
980 | void |
894 | rxvt_term::set_should_invoke (int htype, int inc) |
981 | rxvt_term::set_should_invoke (int htype, int inc) |
895 | CODE: |
982 | CODE: |
896 | THIS->perl.should_invoke [htype] += inc; |
983 | uint8_t &count = THIS->perl.should_invoke [htype]; |
|
|
984 | uint8_t prev = count; |
|
|
985 | count += inc; |
|
|
986 | if (!prev != !count) |
|
|
987 | { |
|
|
988 | // hook status changed, react |
|
|
989 | switch (htype) |
|
|
990 | { |
|
|
991 | case HOOK_POSITION_CHANGE: |
|
|
992 | if (count) |
|
|
993 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
|
|
994 | } |
|
|
995 | } |
897 | |
996 | |
898 | int |
997 | int |
899 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
998 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
900 | CODE: |
999 | CODE: |
901 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1000 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
… | |
… | |
917 | |
1016 | |
918 | void |
1017 | void |
919 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
1018 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
920 | CODE: |
1019 | CODE: |
921 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
1020 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
922 | |
|
|
923 | void |
|
|
924 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
925 | CODE: |
|
|
926 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
927 | |
1021 | |
928 | bool |
1022 | bool |
929 | rxvt_term::grab (Time eventtime, int sync = 0) |
1023 | rxvt_term::grab (Time eventtime, int sync = 0) |
930 | CODE: |
1024 | CODE: |
931 | { |
1025 | { |
… | |
… | |
1046 | free (wstr); |
1140 | free (wstr); |
1047 | } |
1141 | } |
1048 | OUTPUT: |
1142 | OUTPUT: |
1049 | RETVAL |
1143 | RETVAL |
1050 | |
1144 | |
1051 | char * |
|
|
1052 | rxvt_term::locale () |
|
|
1053 | CODE: |
|
|
1054 | RETVAL = THIS->locale; |
|
|
1055 | OUTPUT: |
|
|
1056 | RETVAL |
|
|
1057 | |
|
|
1058 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1145 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1059 | |
1146 | |
1060 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1147 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1061 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1148 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1062 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1149 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1063 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1150 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1064 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1151 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1065 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1152 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1066 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1153 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1067 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1154 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1068 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1155 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1069 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1156 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1070 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1157 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1071 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
1158 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
|
|
1159 | #define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace) |
1072 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1160 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1073 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1161 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1074 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1162 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1075 | |
1163 | |
1076 | int |
1164 | int |
1077 | rxvt_term::width () |
1165 | rxvt_term::width () |
1078 | ALIAS: |
1166 | ALIAS: |
1079 | width = TERM_OFFSET_width |
1167 | width = TERM_OFFSET_width |
1080 | height = TERM_OFFSET_height |
1168 | height = TERM_OFFSET_height |
1081 | fwidth = TERM_OFFSET_fwidth |
1169 | fwidth = TERM_OFFSET_fwidth |
1082 | fheight = TERM_OFFSET_fheight |
1170 | fheight = TERM_OFFSET_fheight |
1083 | fbase = TERM_OFFSET_fbase |
1171 | fbase = TERM_OFFSET_fbase |
1084 | nrow = TERM_OFFSET_nrow |
1172 | nrow = TERM_OFFSET_nrow |
1085 | ncol = TERM_OFFSET_ncol |
1173 | ncol = TERM_OFFSET_ncol |
1086 | focus = TERM_OFFSET_focus |
1174 | focus = TERM_OFFSET_focus |
1087 | mapped = TERM_OFFSET_mapped |
1175 | mapped = TERM_OFFSET_mapped |
1088 | int_bwidth = TERM_OFFSET_int_bwidth |
1176 | int_bwidth = TERM_OFFSET_int_bwidth |
1089 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1177 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1090 | lineSpace = TERM_OFFSET_lineSpace |
1178 | lineSpace = TERM_OFFSET_lineSpace |
|
|
1179 | letterSpace = TERM_OFFSET_letterSpace |
1091 | saveLines = TERM_OFFSET_saveLines |
1180 | saveLines = TERM_OFFSET_saveLines |
1092 | total_rows = TERM_OFFSET_total_rows |
1181 | total_rows = TERM_OFFSET_total_rows |
1093 | top_row = TERM_OFFSET_top_row |
1182 | top_row = TERM_OFFSET_top_row |
1094 | CODE: |
1183 | CODE: |
1095 | RETVAL = *(int *)((char *)THIS + ix); |
1184 | RETVAL = *(int *)((char *)THIS + ix); |
1096 | OUTPUT: |
1185 | OUTPUT: |
1097 | RETVAL |
1186 | RETVAL |
1098 | |
1187 | |
… | |
… | |
1109 | { |
1198 | { |
1110 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1199 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1111 | case 1: RETVAL = THIS->ModMetaMask; break; |
1200 | case 1: RETVAL = THIS->ModMetaMask; break; |
1112 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1201 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1113 | case 3: RETVAL = THIS->current_screen; break; |
1202 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1203 | #ifdef CURSOR_BLINK |
1114 | case 4: RETVAL = THIS->hidden_cursor; break; |
1204 | case 4: RETVAL = THIS->hidden_cursor; break; |
|
|
1205 | #endif |
1115 | } |
1206 | } |
1116 | OUTPUT: |
1207 | OUTPUT: |
1117 | RETVAL |
1208 | RETVAL |
1118 | |
1209 | |
1119 | char * |
1210 | char * |
… | |
… | |
1144 | if (*i) |
1235 | if (*i) |
1145 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1236 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1146 | } |
1237 | } |
1147 | |
1238 | |
1148 | int |
1239 | int |
1149 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1240 | rxvt_term::pty_ev_events (int events = ev::UNDEF) |
1150 | CODE: |
1241 | CODE: |
1151 | RETVAL = THIS->pty_ev.events; |
1242 | RETVAL = THIS->pty_ev.events; |
1152 | if (events != EVENT_UNDEF) |
1243 | if (events != ev::UNDEF) |
1153 | THIS->pty_ev.set (events); |
1244 | THIS->pty_ev.set (events); |
1154 | OUTPUT: |
1245 | OUTPUT: |
1155 | RETVAL |
1246 | RETVAL |
1156 | |
1247 | |
1157 | int |
1248 | int |
… | |
… | |
1162 | RETVAL |
1253 | RETVAL |
1163 | |
1254 | |
1164 | Window |
1255 | Window |
1165 | rxvt_term::parent () |
1256 | rxvt_term::parent () |
1166 | CODE: |
1257 | CODE: |
1167 | RETVAL = THIS->parent [0]; |
1258 | RETVAL = THIS->parent; |
1168 | OUTPUT: |
1259 | OUTPUT: |
1169 | RETVAL |
1260 | RETVAL |
1170 | |
1261 | |
1171 | Window |
1262 | int |
1172 | rxvt_term::vt () |
1263 | rxvt_term::parent_x () |
1173 | CODE: |
1264 | CODE: |
1174 | RETVAL = THIS->vt; |
1265 | RETVAL = THIS->parent_x; |
|
|
1266 | OUTPUT: |
|
|
1267 | RETVAL |
|
|
1268 | |
|
|
1269 | int |
|
|
1270 | rxvt_term::parent_y () |
|
|
1271 | CODE: |
|
|
1272 | RETVAL = THIS->parent_y; |
1175 | OUTPUT: |
1273 | OUTPUT: |
1176 | RETVAL |
1274 | RETVAL |
1177 | |
1275 | |
1178 | void |
1276 | void |
1179 | rxvt_term::vt_emask_add (U32 emask) |
1277 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1199 | if (newval <= 0) |
1297 | if (newval <= 0) |
1200 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1298 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1201 | } |
1299 | } |
1202 | OUTPUT: |
1300 | OUTPUT: |
1203 | RETVAL |
1301 | RETVAL |
|
|
1302 | |
|
|
1303 | void |
|
|
1304 | rxvt_term::set_urgency (bool enable) |
1204 | |
1305 | |
1205 | void |
1306 | void |
1206 | rxvt_term::focus_in () |
1307 | rxvt_term::focus_in () |
1207 | |
1308 | |
1208 | void |
1309 | void |
… | |
… | |
1236 | |
1337 | |
1237 | void |
1338 | void |
1238 | rxvt_term::want_refresh () |
1339 | rxvt_term::want_refresh () |
1239 | CODE: |
1340 | CODE: |
1240 | THIS->want_refresh = 1; |
1341 | THIS->want_refresh = 1; |
|
|
1342 | THIS->refresh_check (); |
1241 | |
1343 | |
1242 | void |
1344 | void |
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) |
1345 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1244 | PPCODE: |
1346 | PPCODE: |
1245 | { |
1347 | { |
… | |
… | |
1400 | SV * |
1502 | SV * |
1401 | rxvt_term::special_decode (SV *text) |
1503 | rxvt_term::special_decode (SV *text) |
1402 | CODE: |
1504 | CODE: |
1403 | { |
1505 | { |
1404 | wchar_t *wstr = sv2wcs (text); |
1506 | wchar_t *wstr = sv2wcs (text); |
1405 | int wlen = wcslen (wstr); |
|
|
1406 | int dlen = 0; |
1507 | int dlen = 0; |
1407 | |
1508 | |
1408 | // find length |
1509 | // find length |
1409 | for (wchar_t *s = wstr; *s; s++) |
1510 | for (wchar_t *s = wstr; *s; s++) |
1410 | if (*s == NOCHAR) |
1511 | if (*s == NOCHAR) |
… | |
… | |
1441 | # include "rsinc.h" |
1542 | # include "rsinc.h" |
1442 | # undef def |
1543 | # undef def |
1443 | # undef reserve |
1544 | # undef reserve |
1444 | }; |
1545 | }; |
1445 | |
1546 | |
1446 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1547 | rs = rslist + ecb_array_length (rslist); |
1447 | |
1548 | |
|
|
1549 | if (*name) |
1448 | do { |
1550 | { |
|
|
1551 | do { |
1449 | if (rs-- == rslist) |
1552 | if (rs-- == rslist) |
1450 | croak ("no such resource '%s', requested", name); |
1553 | croak ("no such resource '%s', requested", name); |
1451 | } while (strcmp (name, rs->name)); |
1554 | } while (strcmp (name, rs->name)); |
1452 | |
1555 | |
1453 | index += rs->value; |
1556 | index += rs->value; |
|
|
1557 | } |
|
|
1558 | else |
|
|
1559 | { |
|
|
1560 | --rs; |
|
|
1561 | name = ""; |
|
|
1562 | } |
1454 | |
1563 | |
1455 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1564 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1456 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1565 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1457 | |
1566 | |
1458 | if (GIMME_V != G_VOID) |
1567 | if (GIMME_V != G_VOID) |
… | |
… | |
1473 | |
1582 | |
1474 | const char * |
1583 | const char * |
1475 | rxvt_term::x_resource (const char *name) |
1584 | rxvt_term::x_resource (const char *name) |
1476 | |
1585 | |
1477 | bool |
1586 | bool |
1478 | rxvt_term::option (U32 optval, int set = -1) |
1587 | rxvt_term::option (U8 optval, int set = -1) |
1479 | CODE: |
1588 | CODE: |
1480 | { |
1589 | { |
1481 | RETVAL = THIS->options & optval; |
1590 | RETVAL = THIS->option (optval); |
1482 | |
1591 | |
1483 | if (set >= 0) |
1592 | if (set >= 0) |
1484 | { |
1593 | { |
1485 | if (set) |
|
|
1486 | THIS->options |= optval; |
1594 | THIS->set_option (optval, set); |
1487 | else |
|
|
1488 | THIS->options &= ~optval; |
|
|
1489 | |
1595 | |
1490 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1596 | if (THIS->init_done) // avoid doing this before START |
1491 | switch (optval) |
1597 | switch (optval) |
1492 | { |
1598 | { |
1493 | case Opt_skipBuiltinGlyphs: |
1599 | case Opt_skipBuiltinGlyphs: |
1494 | THIS->set_fonts (); |
1600 | THIS->set_fonts (); |
1495 | THIS->scr_remap_chars (); |
1601 | THIS->scr_remap_chars (); |
1496 | THIS->scr_touch (true); |
1602 | THIS->scr_touch (true); |
1497 | THIS->want_refresh = 1; |
1603 | THIS->want_refresh = 1; |
|
|
1604 | THIS->refresh_check (); |
1498 | break; |
1605 | break; |
|
|
1606 | #ifdef CURSOR_BLINK |
|
|
1607 | case Opt_cursorBlink: |
|
|
1608 | THIS->cursor_blink_reset (); |
|
|
1609 | break; |
|
|
1610 | #endif |
1499 | |
1611 | |
1500 | case Opt_cursorUnderline: |
1612 | case Opt_cursorUnderline: |
1501 | THIS->want_refresh = 1; |
1613 | THIS->want_refresh = 1; |
|
|
1614 | THIS->refresh_check (); |
1502 | break; |
1615 | break; |
1503 | |
1616 | |
1504 | # case Opt_scrollBar_floating: |
1617 | # case Opt_scrollBar_floating: |
1505 | # case Opt_scrollBar_right: |
1618 | # case Opt_scrollBar_right: |
1506 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1619 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
… | |
… | |
1516 | CODE: |
1629 | CODE: |
1517 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1630 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1518 | THIS->keyboard->register_done (); |
1631 | THIS->keyboard->register_done (); |
1519 | OUTPUT: |
1632 | OUTPUT: |
1520 | RETVAL |
1633 | RETVAL |
|
|
1634 | |
|
|
1635 | void |
|
|
1636 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1637 | CODE: |
|
|
1638 | wchar_t *wstr = sv2wcs (str); |
|
|
1639 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1640 | free (wstr); |
1521 | |
1641 | |
1522 | void |
1642 | void |
1523 | rxvt_term::screen_cur (...) |
1643 | rxvt_term::screen_cur (...) |
1524 | PROTOTYPE: $;$$ |
1644 | PROTOTYPE: $;$$ |
1525 | ALIAS: |
1645 | ALIAS: |
… | |
… | |
1539 | EXTEND (SP, 2); |
1659 | EXTEND (SP, 2); |
1540 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1660 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1541 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1661 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1542 | } |
1662 | } |
1543 | |
1663 | |
1544 | if (items == 3) |
1664 | if (items >= 3) |
1545 | { |
1665 | { |
1546 | rc.row = SvIV (ST (1)); |
1666 | rc.row = SvIV (ST (1)); |
1547 | rc.col = SvIV (ST (2)); |
1667 | rc.col = SvIV (ST (2)); |
1548 | |
1668 | |
1549 | if (ix == 2) |
1669 | if (ix == 2) |
… | |
… | |
1564 | |
1684 | |
1565 | clamp_it (rc.col, 0, THIS->ncol); |
1685 | clamp_it (rc.col, 0, THIS->ncol); |
1566 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1686 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1567 | |
1687 | |
1568 | if (ix) |
1688 | if (ix) |
|
|
1689 | { |
|
|
1690 | THIS->selection.screen = THIS->current_screen; |
|
|
1691 | |
1569 | THIS->want_refresh = 1; |
1692 | THIS->want_refresh = 1; |
|
|
1693 | THIS->refresh_check (); |
1570 | } |
1694 | } |
|
|
1695 | } |
1571 | } |
1696 | } |
1572 | |
1697 | |
1573 | char |
1698 | int |
1574 | rxvt_term::cur_charset () |
1699 | rxvt_term::selection_screen (int screen = -1) |
1575 | CODE: |
1700 | CODE: |
1576 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1701 | RETVAL = THIS->selection.screen; |
1577 | OUTPUT: |
1702 | if (screen >= 0) |
|
|
1703 | THIS->selection.screen = screen; |
|
|
1704 | OUTPUT: |
1578 | RETVAL |
1705 | RETVAL |
1579 | |
1706 | |
1580 | void |
1707 | void |
1581 | rxvt_term::selection_clear () |
1708 | rxvt_term::selection_clear (bool clipboard = false) |
1582 | |
1709 | |
1583 | void |
1710 | void |
1584 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1711 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1585 | CODE: |
1712 | CODE: |
1586 | THIS->selection.op = SELECTION_CONT; |
1713 | THIS->selection.op = SELECTION_CONT; |
1587 | THIS->selection.rect = rect; |
1714 | THIS->selection.rect = rect; |
1588 | THIS->selection_make (eventtime); |
1715 | THIS->selection_make (eventtime); |
1589 | |
1716 | |
1590 | int |
1717 | int |
1591 | rxvt_term::selection_grab (Time eventtime) |
1718 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1592 | |
1719 | |
1593 | void |
1720 | void |
1594 | rxvt_term::selection (SV *newtext = 0) |
1721 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1595 | PPCODE: |
1722 | PPCODE: |
1596 | { |
1723 | { |
|
|
1724 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1725 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1726 | |
1597 | if (GIMME_V != G_VOID) |
1727 | if (GIMME_V != G_VOID) |
1598 | XPUSHs (THIS->selection.text |
1728 | XPUSHs (text |
1599 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1729 | ? sv_2mortal (wcs2sv (text, len)) |
1600 | : &PL_sv_undef); |
1730 | : &PL_sv_undef); |
1601 | |
1731 | |
1602 | if (newtext) |
1732 | if (newtext) |
1603 | { |
1733 | { |
1604 | free (THIS->selection.text); |
1734 | free (text); |
1605 | |
1735 | |
1606 | THIS->selection.text = sv2wcs (newtext); |
1736 | text = sv2wcs (newtext); |
1607 | THIS->selection.len = wcslen (THIS->selection.text); |
1737 | len = wcslen (text); |
1608 | } |
1738 | } |
1609 | } |
1739 | } |
|
|
1740 | |
|
|
1741 | char |
|
|
1742 | rxvt_term::cur_charset () |
|
|
1743 | CODE: |
|
|
1744 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1745 | OUTPUT: |
|
|
1746 | RETVAL |
1610 | |
1747 | |
1611 | void |
1748 | void |
1612 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline) |
1749 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline) |
1613 | |
1750 | |
1614 | void |
1751 | void |
1615 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1752 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1616 | |
1753 | |
1617 | void |
1754 | void |
1618 | rxvt_term::scr_bell () |
1755 | rxvt_term::scr_bell () |
|
|
1756 | |
|
|
1757 | void |
|
|
1758 | rxvt_term::scr_recolour (bool refresh = true); |
1619 | |
1759 | |
1620 | void |
1760 | void |
1621 | rxvt_term::scr_change_screen (int screen) |
1761 | rxvt_term::scr_change_screen (int screen) |
1622 | |
1762 | |
1623 | void |
1763 | void |
… | |
… | |
1636 | char *str = SvPVbyte (octets, len); |
1776 | char *str = SvPVbyte (octets, len); |
1637 | C_ARGS: |
1777 | C_ARGS: |
1638 | str, len |
1778 | str, len |
1639 | |
1779 | |
1640 | void |
1780 | void |
|
|
1781 | rxvt_term::tt_paste (SV *octets) |
|
|
1782 | INIT: |
|
|
1783 | STRLEN len; |
|
|
1784 | char *str = SvPVbyte (octets, len); |
|
|
1785 | C_ARGS: |
|
|
1786 | str, len |
|
|
1787 | |
|
|
1788 | void |
1641 | rxvt_term::cmd_parse (SV *octets) |
1789 | rxvt_term::cmd_parse (SV *octets) |
1642 | CODE: |
1790 | CODE: |
1643 | { |
1791 | { |
1644 | STRLEN len; |
1792 | STRLEN len; |
1645 | char *str = SvPVbyte (octets, len); |
1793 | char *str = SvPVbyte (octets, len); |
… | |
… | |
1681 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1829 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1682 | |
1830 | |
1683 | EXTEND (SP, count); |
1831 | EXTEND (SP, count); |
1684 | while (count--) |
1832 | while (count--) |
1685 | PUSHs (newSVuv ((U32)props [count])); |
1833 | PUSHs (newSVuv ((U32)props [count])); |
1686 | |
1834 | |
1687 | XFree (props); |
1835 | XFree (props); |
1688 | } |
1836 | } |
1689 | |
1837 | |
1690 | void |
1838 | void |
1691 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
1839 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
… | |
… | |
1714 | XFree (prop); |
1862 | XFree (prop); |
1715 | } |
1863 | } |
1716 | } |
1864 | } |
1717 | |
1865 | |
1718 | void |
1866 | void |
1719 | rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) |
1867 | rxvt_term::XChangeProperty (Window window, Atom property, Atom type, int format, SV *data) |
1720 | CODE: |
1868 | CODE: |
1721 | { |
1869 | { |
1722 | STRLEN len; |
1870 | STRLEN len; |
1723 | char *data_ = SvPVbyte (data, len); |
1871 | char *data_ = SvPVbyte (data, len); |
1724 | |
1872 | |
… | |
… | |
1730 | type, format, PropModeReplace, |
1878 | type, format, PropModeReplace, |
1731 | (unsigned char *)data_, len / elemsize); |
1879 | (unsigned char *)data_, len / elemsize); |
1732 | } |
1880 | } |
1733 | |
1881 | |
1734 | Atom |
1882 | Atom |
1735 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1883 | XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE) |
1736 | C_ARGS: term->dpy, atom_name, only_if_exists |
1884 | C_ARGS: term->dpy, atom_name, only_if_exists |
1737 | |
1885 | |
1738 | char * |
1886 | char * |
1739 | XGetAtomName (rxvt_term *term, Atom atom) |
1887 | XGetAtomName (rxvt_term *term, Atom atom) |
1740 | C_ARGS: term->dpy, atom |
1888 | C_ARGS: term->dpy, atom |
1741 | CLEANUP: |
1889 | CLEANUP: |
1742 | XFree (RETVAL); |
1890 | XFree (RETVAL); |
1743 | |
1891 | |
1744 | void |
1892 | void |
1745 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1893 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1746 | C_ARGS: term->dpy, window, property |
1894 | C_ARGS: term->dpy, window, property |
1747 | |
1895 | |
1748 | Window |
1896 | Window |
1749 | rxvt_term::DefaultRootWindow () |
1897 | rxvt_term::DefaultRootWindow () |
1750 | CODE: |
1898 | CODE: |
1751 | RETVAL = THIS->display->root; |
1899 | RETVAL = THIS->display->root; |
… | |
… | |
1803 | PUSHs (newSVuv (child)); |
1951 | PUSHs (newSVuv (child)); |
1804 | } |
1952 | } |
1805 | } |
1953 | } |
1806 | |
1954 | |
1807 | ############################################################################# |
1955 | ############################################################################# |
|
|
1956 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
|
|
1957 | |
|
|
1958 | # TODO: ugly |
|
|
1959 | void |
|
|
1960 | rxvt_term::get_geometry () |
|
|
1961 | PPCODE: |
|
|
1962 | EXTEND (SP, 4); |
|
|
1963 | PUSHs (sv_2mortal (newSViv (THIS->parent_x))); |
|
|
1964 | PUSHs (sv_2mortal (newSViv (THIS->parent_y))); |
|
|
1965 | PUSHs (sv_2mortal (newSViv (THIS->szHint.width))); |
|
|
1966 | PUSHs (sv_2mortal (newSViv (THIS->szHint.height))); |
|
|
1967 | |
|
|
1968 | #if HAVE_IMG |
|
|
1969 | |
|
|
1970 | rxvt_img * |
|
|
1971 | rxvt_term::new_img (SV *format, int width, int height) |
|
|
1972 | CODE: |
|
|
1973 | XRenderPictFormat *f = SvOK (format) |
|
|
1974 | ? XRenderFindVisualFormat (THIS->dpy, THIS->visual) |
|
|
1975 | : XRenderFindStandardFormat (THIS->dpy, SvIV (format)); |
|
|
1976 | RETVAL = new rxvt_img (THIS, f, width, height); |
|
|
1977 | OUTPUT: |
|
|
1978 | RETVAL |
|
|
1979 | |
|
|
1980 | #if ENABLE_TRANSPARENCY |
|
|
1981 | |
|
|
1982 | #if 0 |
|
|
1983 | |
|
|
1984 | rxvt_img * |
|
|
1985 | rxvt_term::new_img_from_root () |
|
|
1986 | CODE: |
|
|
1987 | RETVAL = rxvt_img::new_from_root (THIS); |
|
|
1988 | OUTPUT: |
|
|
1989 | RETVAL |
|
|
1990 | |
|
|
1991 | #endif |
|
|
1992 | |
|
|
1993 | #endif |
|
|
1994 | |
|
|
1995 | #if HAVE_PIXBUF |
|
|
1996 | |
|
|
1997 | rxvt_img * |
|
|
1998 | rxvt_term::new_img_from_file (octet_string filename) |
|
|
1999 | CODE: |
|
|
2000 | try |
|
|
2001 | { |
|
|
2002 | RETVAL = rxvt_img::new_from_file (THIS, filename); |
|
|
2003 | } |
|
|
2004 | catch (const class rxvt_failure_exception &e) |
|
|
2005 | { |
|
|
2006 | croak ("new_img_from_file failed"); |
|
|
2007 | } |
|
|
2008 | OUTPUT: |
|
|
2009 | RETVAL |
|
|
2010 | |
|
|
2011 | #endif |
|
|
2012 | |
|
|
2013 | #if HAVE_BG_PIXMAP |
|
|
2014 | |
|
|
2015 | void |
|
|
2016 | rxvt_term::set_background (rxvt_img *img) |
|
|
2017 | CODE: |
|
|
2018 | THIS->bg_destroy (); |
|
|
2019 | THIS->bg_pixmap = None; |
|
|
2020 | THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH; |
|
|
2021 | |
|
|
2022 | if (img) // TODO: cannot be false |
|
|
2023 | { |
|
|
2024 | img->unshare (); |
|
|
2025 | THIS->bg_pixmap = img->steal (); |
|
|
2026 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; |
|
|
2027 | THIS->bg_valid_since = ev::now (); // TODO: extra bloat |
|
|
2028 | } |
|
|
2029 | |
|
|
2030 | #endif |
|
|
2031 | |
|
|
2032 | #endif |
|
|
2033 | |
|
|
2034 | ############################################################################# |
1808 | # urxvt::overlay |
2035 | # urxvt::overlay |
1809 | ############################################################################# |
2036 | ############################################################################# |
1810 | |
2037 | |
1811 | MODULE = urxvt PACKAGE = urxvt::overlay |
2038 | MODULE = urxvt PACKAGE = urxvt::overlay |
1812 | |
2039 | |
… | |
… | |
1822 | void |
2049 | void |
1823 | overlay::DESTROY () |
2050 | overlay::DESTROY () |
1824 | |
2051 | |
1825 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
2052 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1826 | |
2053 | |
|
|
2054 | MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_ |
|
|
2055 | |
|
|
2056 | #if HAVE_PIXBUF |
|
|
2057 | |
|
|
2058 | urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename) |
|
|
2059 | C_ARGS: filename, 0 |
|
|
2060 | |
|
|
2061 | void |
|
|
2062 | DESTROY (urxvt::pixbuf self) |
|
|
2063 | CODE: |
|
|
2064 | gdk_pixbuf_unref (self); |
|
|
2065 | |
|
|
2066 | #endif |
|
|
2067 | |
|
|
2068 | MODULE = urxvt PACKAGE = urxvt::img |
|
|
2069 | |
|
|
2070 | #if HAVE_IMG |
|
|
2071 | |
|
|
2072 | # rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
|
|
2073 | # rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
|
|
2074 | |
|
|
2075 | int |
|
|
2076 | rxvt_img::w () |
|
|
2077 | CODE: |
|
|
2078 | RETVAL = THIS->w; |
|
|
2079 | OUTPUT: |
|
|
2080 | RETVAL |
|
|
2081 | |
|
|
2082 | int |
|
|
2083 | rxvt_img::h () |
|
|
2084 | CODE: |
|
|
2085 | RETVAL = THIS->h; |
|
|
2086 | OUTPUT: |
|
|
2087 | RETVAL |
|
|
2088 | |
|
|
2089 | bool |
|
|
2090 | rxvt_img::shared () |
|
|
2091 | CODE: |
|
|
2092 | RETVAL = THIS->shared; |
|
|
2093 | OUTPUT: |
|
|
2094 | RETVAL |
|
|
2095 | |
|
|
2096 | Pixmap |
|
|
2097 | rxvt_img::pm () |
|
|
2098 | CODE: |
|
|
2099 | RETVAL = THIS->pm; |
|
|
2100 | OUTPUT: |
|
|
2101 | RETVAL |
|
|
2102 | |
|
|
2103 | void |
|
|
2104 | rxvt_img::fill (SV *c) |
|
|
2105 | INIT: |
|
|
2106 | rxvt_color rc; |
|
|
2107 | parse_color (THIS->s, rc, c); |
|
|
2108 | C_ARGS: rc |
|
|
2109 | |
|
|
2110 | void |
|
|
2111 | rxvt_img::DESTROY () |
|
|
2112 | CODE: |
|
|
2113 | delete THIS; |
|
|
2114 | |
|
|
2115 | void |
|
|
2116 | rxvt_img::blur (int rh, int rv) |
|
|
2117 | |
|
|
2118 | void |
|
|
2119 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2120 | |
|
|
2121 | void |
|
|
2122 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2123 | |
|
|
2124 | void |
|
|
2125 | rxvt_img::unshare () |
|
|
2126 | |
|
|
2127 | rxvt_img * |
|
|
2128 | rxvt_img::clone () |
|
|
2129 | |
|
|
2130 | rxvt_img * |
|
|
2131 | rxvt_img::transform (int new_width, int new_height, int repeat, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) |
|
|
2132 | INIT: |
|
|
2133 | double matrix[9] = { |
|
|
2134 | p11, p12, p13, |
|
|
2135 | p21, p22, p23, |
|
|
2136 | p31, p32, p33 |
|
|
2137 | }; |
|
|
2138 | C_ARGS: new_width, new_height, repeat, matrix |
|
|
2139 | |
|
|
2140 | rxvt_img * |
|
|
2141 | rxvt_img::scale (int new_width, int new_height) |
|
|
2142 | |
|
|
2143 | rxvt_img * |
|
|
2144 | rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, NV phi) |
|
|
2145 | |
|
|
2146 | #endif |
|
|
2147 | |