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. |
… | |
… | |
31 | #include <cstddef> |
31 | #include <cstddef> |
32 | #include <cstdarg> |
32 | #include <cstdarg> |
33 | |
33 | |
34 | #include "unistd.h" |
34 | #include "unistd.h" |
35 | |
35 | |
36 | #include "iom.h" |
36 | #include "ev_cpp.h" |
37 | #include "rxvt.h" |
37 | #include "rxvt.h" |
38 | #include "keyboard.h" |
38 | #include "keyboard.h" |
39 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
40 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
41 | |
41 | |
42 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
43 | |
43 | |
44 | #ifdef HAVE_SCROLLBARS |
|
|
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
44 | #define GRAB_CURSOR THIS->scrollBar.leftptr_cursor |
46 | #else |
|
|
47 | # define GRAB_CURSOR None |
|
|
48 | #endif |
|
|
49 | |
45 | |
50 | #undef LINENO |
46 | #undef LINENO |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
47 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
52 | #undef ROW |
48 | #undef ROW |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
49 | #define ROW(n) THIS->row_buf [LINENO (n)] |
… | |
… | |
73 | |
69 | |
74 | return sv; |
70 | return sv; |
75 | } |
71 | } |
76 | |
72 | |
77 | static SV * |
73 | 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) |
74 | newSVptr (void *ptr, const char *klass) |
85 | { |
75 | { |
86 | HV *hv = newHV (); |
76 | HV *hv = newHV (); |
87 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
77 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
88 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
78 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
… | |
… | |
117 | |
107 | |
118 | ///////////////////////////////////////////////////////////////////////////// |
108 | ///////////////////////////////////////////////////////////////////////////// |
119 | |
109 | |
120 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
110 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
121 | |
111 | |
122 | class overlay { |
112 | class overlay : overlay_base |
|
|
113 | { |
123 | rxvt_term *THIS; |
114 | rxvt_term *THIS; |
124 | AV *overlay_av; |
115 | AV *overlay_av; |
125 | int x, y, w, h; |
|
|
126 | int border; |
116 | int border; |
127 | text_t **text; |
|
|
128 | rend_t **rend; |
|
|
129 | |
117 | |
130 | public: |
118 | public: |
131 | HV *self; |
119 | HV *self; |
132 | |
120 | |
133 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
121 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
… | |
… | |
140 | |
128 | |
141 | void set (int x, int y, SV *str, SV *rend); |
129 | void set (int x, int y, SV *str, SV *rend); |
142 | }; |
130 | }; |
143 | |
131 | |
144 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
132 | 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) |
133 | : THIS(THIS), border(border == 2), overlay_av (0) |
146 | { |
134 | { |
|
|
135 | x = x_; |
|
|
136 | y = y_; |
|
|
137 | w = w_; |
|
|
138 | h = h_; |
|
|
139 | |
147 | if (w < 0) w = 0; |
140 | if (w < 0) w = 0; |
148 | if (h < 0) h = 0; |
141 | if (h < 0) h = 0; |
149 | |
142 | |
150 | if (border == 2) |
143 | if (border == 2) |
151 | { |
144 | { |
… | |
… | |
220 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
213 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
221 | )); |
214 | )); |
222 | av_push (overlay_av, newSViv ((long)this)); |
215 | av_push (overlay_av, newSViv ((long)this)); |
223 | |
216 | |
224 | THIS->want_refresh = 1; |
217 | THIS->want_refresh = 1; |
|
|
218 | THIS->refresh_check (); |
225 | } |
219 | } |
226 | |
220 | |
227 | void |
221 | void |
228 | overlay::hide () |
222 | overlay::hide () |
229 | { |
223 | { |
… | |
… | |
243 | |
237 | |
244 | SvREFCNT_dec (overlay_av); |
238 | SvREFCNT_dec (overlay_av); |
245 | overlay_av = 0; |
239 | overlay_av = 0; |
246 | |
240 | |
247 | THIS->want_refresh = 1; |
241 | THIS->want_refresh = 1; |
|
|
242 | THIS->refresh_check (); |
248 | } |
243 | } |
249 | |
244 | |
250 | void overlay::swap () |
245 | void overlay::swap () |
251 | { |
246 | { |
252 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
247 | 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)); |
248 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
254 | |
249 | |
255 | int ov_w = min (w, THIS->ncol - ov_x); |
250 | int ov_w = min (w, THIS->ncol - ov_x); |
256 | int ov_h = min (h, THIS->nrow - ov_y); |
251 | int ov_h = min (h, THIS->nrow - ov_y); |
|
|
252 | |
|
|
253 | // hide cursor if it is within the overlay area |
|
|
254 | if (IN_RANGE_EXC (THIS->screen.cur.col - ov_x, 0, ov_w) |
|
|
255 | && IN_RANGE_EXC (THIS->screen.cur.row - ov_y, 0, ov_h)) |
|
|
256 | THIS->screen.flags &= ~Screen_VisibleCursor; |
257 | |
257 | |
258 | for (int y = ov_h; y--; ) |
258 | for (int y = ov_h; y--; ) |
259 | { |
259 | { |
260 | text_t *t1 = text [y]; |
260 | text_t *t1 = text [y]; |
261 | rend_t *r1 = rend [y]; |
261 | rend_t *r1 = rend [y]; |
… | |
… | |
297 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
297 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
298 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
298 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
299 | } |
299 | } |
300 | |
300 | |
301 | THIS->want_refresh = 1; |
301 | THIS->want_refresh = 1; |
|
|
302 | THIS->refresh_check (); |
302 | } |
303 | } |
303 | |
304 | |
304 | ///////////////////////////////////////////////////////////////////////////// |
305 | ///////////////////////////////////////////////////////////////////////////// |
305 | |
306 | |
306 | #define IOM_CLASS "urxvt" |
|
|
307 | #include <iom_perl.h> |
307 | #include "iom_perl.h" |
308 | |
308 | |
309 | ///////////////////////////////////////////////////////////////////////////// |
309 | ///////////////////////////////////////////////////////////////////////////// |
310 | |
310 | |
311 | struct rxvt_perl_interp rxvt_perl; |
311 | struct rxvt_perl_interp rxvt_perl; |
312 | |
312 | |
… | |
… | |
316 | { |
316 | { |
317 | if (perl) |
317 | if (perl) |
318 | { |
318 | { |
319 | perl_destruct (perl); |
319 | perl_destruct (perl); |
320 | perl_free (perl); |
320 | perl_free (perl); |
|
|
321 | PERL_SYS_TERM (); |
321 | } |
322 | } |
322 | } |
323 | } |
323 | |
324 | |
324 | void |
325 | void |
325 | rxvt_perl_interp::init (rxvt_term *term) |
326 | rxvt_perl_interp::init (rxvt_term *term) |
326 | { |
327 | { |
327 | if (!perl) |
328 | if (!perl) |
328 | { |
329 | { |
329 | rxvt_push_locale (""); // perl init destroys current locale |
330 | rxvt_push_locale (""); // perl init destroys current locale |
330 | |
331 | |
|
|
332 | { |
331 | perl_environ = rxvt_environ; |
333 | perl_environ = rxvt_environ; |
332 | swap (perl_environ, environ); |
334 | localise_env set_environ (perl_environ); |
333 | |
335 | |
334 | char *argv[] = { |
336 | char *args[] = { |
335 | "", |
337 | "", |
336 | "-e" |
338 | "-e" |
337 | "BEGIN {" |
339 | "BEGIN {" |
338 | " urxvt->bootstrap;" |
340 | " urxvt->bootstrap;" |
339 | " unshift @INC, '" LIBDIR "';" |
341 | " unshift @INC, '" LIBDIR "';" |
340 | "}" |
342 | "}" |
341 | "" |
343 | "" |
342 | "use urxvt;" |
344 | "use urxvt;" |
343 | }; |
345 | }; |
|
|
346 | int argc = ARRAY_LENGTH(args); |
|
|
347 | char **argv = args; |
344 | |
348 | |
|
|
349 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
345 | perl = perl_alloc (); |
350 | perl = perl_alloc (); |
346 | perl_construct (perl); |
351 | perl_construct (perl); |
347 | |
352 | |
348 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
353 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
349 | || perl_run (perl)) |
354 | || perl_run (perl)) |
350 | { |
355 | { |
351 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
356 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
352 | |
357 | |
353 | perl_destruct (perl); |
358 | perl_destruct (perl); |
354 | perl_free (perl); |
359 | perl_free (perl); |
355 | perl = 0; |
360 | perl = 0; |
356 | } |
361 | } |
357 | |
362 | } |
358 | swap (perl_environ, environ); |
|
|
359 | |
363 | |
360 | rxvt_pop_locale (); |
364 | rxvt_pop_locale (); |
361 | } |
365 | } |
362 | |
366 | |
363 | if (perl) |
367 | if (perl) |
… | |
… | |
383 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
387 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
384 | { |
388 | { |
385 | if (!perl || !term->perl.self) |
389 | if (!perl || !term->perl.self) |
386 | return false; |
390 | return false; |
387 | |
391 | |
|
|
392 | localise_env set_environ (perl_environ); |
|
|
393 | |
388 | // pre-handling of some events |
394 | // pre-handling of some events |
389 | if (htype == HOOK_REFRESH_END) |
395 | if (htype == HOOK_REFRESH_END) |
390 | { |
396 | { |
391 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
392 | |
398 | |
393 | for (int i = 0; i <= AvFILL (av); i++) |
399 | for (int i = 0; i <= AvFILL (av); i++) |
394 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
395 | } |
401 | } |
396 | |
402 | |
397 | swap (perl_environ, environ); |
|
|
398 | |
|
|
399 | bool event_consumed; |
403 | bool event_consumed; |
400 | |
404 | |
401 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
405 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
402 | || term->perl.should_invoke [htype]) |
406 | || term->perl.should_invoke [htype]) |
403 | try |
|
|
404 | { |
407 | { |
405 | dSP; |
408 | dSP; |
406 | va_list ap; |
409 | va_list ap; |
407 | |
410 | |
408 | va_start (ap, htype); |
411 | va_start (ap, htype); |
409 | |
412 | |
410 | ENTER; |
413 | ENTER; |
411 | SAVETMPS; |
414 | SAVETMPS; |
412 | |
415 | |
413 | PUSHMARK (SP); |
416 | PUSHMARK (SP); |
414 | |
417 | |
|
|
418 | EXTEND (SP, 2); |
415 | XPUSHs (sv_2mortal (newSVterm (term))); |
419 | PUSHs (sv_2mortal (newSVterm (term))); |
416 | XPUSHs (sv_2mortal (newSViv (htype))); |
420 | PUSHs (sv_2mortal (newSViv (htype))); |
417 | |
421 | |
418 | for (;;) { |
422 | for (;;) { |
419 | data_type dt = (data_type)va_arg (ap, int); |
423 | data_type dt = (data_type)va_arg (ap, int); |
420 | |
424 | |
421 | switch (dt) |
425 | switch (dt) |
422 | { |
426 | { |
423 | case DT_INT: |
427 | case DT_INT: |
424 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
428 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
425 | break; |
429 | break; |
426 | |
430 | |
427 | case DT_LONG: |
431 | case DT_LONG: |
428 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
432 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
429 | break; |
433 | break; |
430 | |
434 | |
431 | case DT_STR: |
435 | case DT_STR: |
432 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
436 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
433 | break; |
437 | break; |
434 | |
438 | |
435 | case DT_STR_LEN: |
439 | case DT_STR_LEN: |
436 | { |
440 | { |
437 | char *str = va_arg (ap, char *); |
441 | char *str = va_arg (ap, char *); |
438 | int len = va_arg (ap, int); |
442 | int len = va_arg (ap, int); |
439 | |
443 | |
440 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
444 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
441 | } |
445 | } |
442 | break; |
446 | break; |
443 | |
447 | |
444 | case DT_WCS_LEN: |
448 | case DT_WCS_LEN: |
445 | { |
449 | { |
446 | wchar_t *wstr = va_arg (ap, wchar_t *); |
450 | wchar_t *wstr = va_arg (ap, wchar_t *); |
447 | int wlen = va_arg (ap, int); |
451 | int wlen = va_arg (ap, int); |
448 | |
452 | |
449 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
453 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
450 | } |
454 | } |
451 | break; |
455 | break; |
452 | |
456 | |
453 | case DT_LCS_LEN: |
457 | case DT_LCS_LEN: |
454 | { |
458 | { |
455 | long *lstr = va_arg (ap, long *); |
459 | long *lstr = va_arg (ap, long *); |
456 | int llen = va_arg (ap, int); |
460 | int llen = va_arg (ap, int); |
457 | |
461 | |
458 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
462 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
459 | } |
463 | } |
460 | break; |
464 | break; |
461 | |
465 | |
462 | case DT_XEVENT: |
466 | case DT_XEVENT: |
463 | { |
467 | { |
464 | XEvent *xe = va_arg (ap, XEvent *); |
468 | XEvent *xe = va_arg (ap, XEvent *); |
465 | HV *hv = newHV (); |
469 | HV *hv = newHV (); |
466 | |
470 | |
467 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
471 | # 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) |
472 | # 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) |
473 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
470 | # undef set |
474 | # undef set |
471 | |
475 | |
472 | setiv (type, xe->type); |
476 | setiv (type, xe->type); |
473 | setiv (send_event, xe->xany.send_event); |
477 | setiv (send_event, xe->xany.send_event); |
474 | setiv (serial, xe->xany.serial); |
478 | setiv (serial, xe->xany.serial); |
475 | |
479 | |
476 | switch (xe->type) |
480 | switch (xe->type) |
477 | { |
481 | { |
478 | case KeyPress: |
482 | case KeyPress: |
479 | case KeyRelease: |
483 | case KeyRelease: |
480 | case ButtonPress: |
484 | case ButtonPress: |
481 | case ButtonRelease: |
485 | case ButtonRelease: |
482 | case MotionNotify: |
486 | case MotionNotify: |
483 | setuv (window, xe->xmotion.window); |
487 | setuv (window, xe->xmotion.window); |
484 | setuv (root, xe->xmotion.root); |
488 | setuv (root, xe->xmotion.root); |
485 | setuv (subwindow, xe->xmotion.subwindow); |
489 | setuv (subwindow, xe->xmotion.subwindow); |
486 | setuv (time, xe->xmotion.time); |
490 | setuv (time, xe->xmotion.time); |
487 | setiv (x, xe->xmotion.x); |
491 | setiv (x, xe->xmotion.x); |
488 | setiv (y, xe->xmotion.y); |
492 | setiv (y, xe->xmotion.y); |
489 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
493 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
490 | setiv (col, xe->xmotion.x / term->fwidth); |
494 | setiv (col, xe->xmotion.x / term->fwidth); |
491 | setiv (x_root, xe->xmotion.x_root); |
495 | setiv (x_root, xe->xmotion.x_root); |
492 | setiv (y_root, xe->xmotion.y_root); |
496 | setiv (y_root, xe->xmotion.y_root); |
493 | setuv (state, xe->xmotion.state); |
497 | setuv (state, xe->xmotion.state); |
494 | |
498 | |
495 | switch (xe->type) |
499 | switch (xe->type) |
496 | { |
500 | { |
497 | case KeyPress: |
501 | case KeyPress: |
498 | case KeyRelease: |
502 | case KeyRelease: |
499 | setuv (keycode, xe->xkey.keycode); |
503 | setuv (keycode, xe->xkey.keycode); |
500 | break; |
504 | break; |
501 | |
505 | |
502 | case ButtonPress: |
506 | case ButtonPress: |
503 | case ButtonRelease: |
507 | case ButtonRelease: |
504 | setuv (button, xe->xbutton.button); |
508 | setuv (button, xe->xbutton.button); |
505 | break; |
509 | break; |
506 | |
510 | |
507 | case MotionNotify: |
511 | case MotionNotify: |
508 | setiv (is_hint, xe->xmotion.is_hint); |
512 | setiv (is_hint, xe->xmotion.is_hint); |
509 | break; |
513 | break; |
510 | } |
514 | } |
511 | |
515 | |
512 | break; |
516 | break; |
513 | |
517 | |
514 | case MapNotify: |
518 | case MapNotify: |
515 | case UnmapNotify: |
519 | case UnmapNotify: |
516 | case ConfigureNotify: |
520 | case ConfigureNotify: |
517 | setuv (event, xe->xconfigure.event); |
521 | setuv (event, xe->xconfigure.event); |
518 | setuv (window, xe->xconfigure.window); |
522 | setuv (window, xe->xconfigure.window); |
519 | |
523 | |
520 | switch (xe->type) |
524 | switch (xe->type) |
521 | { |
525 | { |
522 | case ConfigureNotify: |
526 | case ConfigureNotify: |
523 | setiv (x, xe->xconfigure.x); |
527 | setiv (x, xe->xconfigure.x); |
524 | setiv (y, xe->xconfigure.y); |
528 | setiv (y, xe->xconfigure.y); |
525 | setiv (width, xe->xconfigure.width); |
529 | setiv (width, xe->xconfigure.width); |
526 | setiv (height, xe->xconfigure.height); |
530 | setiv (height, xe->xconfigure.height); |
527 | setuv (above, xe->xconfigure.above); |
531 | setuv (above, xe->xconfigure.above); |
528 | break; |
532 | break; |
529 | } |
533 | } |
530 | |
534 | |
531 | break; |
535 | break; |
532 | |
536 | |
533 | case PropertyNotify: |
537 | case PropertyNotify: |
534 | setuv (window, xe->xproperty.window); |
538 | setuv (window, xe->xproperty.window); |
535 | setuv (atom, xe->xproperty.atom); |
539 | setuv (atom, xe->xproperty.atom); |
536 | setuv (time, xe->xproperty.time); |
540 | setuv (time, xe->xproperty.time); |
537 | setiv (state, xe->xproperty.state); |
541 | setiv (state, xe->xproperty.state); |
538 | break; |
542 | break; |
539 | |
543 | |
540 | case ClientMessage: |
544 | case ClientMessage: |
541 | setuv (window, xe->xclient.window); |
545 | setuv (window, xe->xclient.window); |
542 | setuv (message_type, xe->xclient.message_type); |
546 | setuv (message_type, xe->xclient.message_type); |
543 | setuv (format, xe->xclient.format); |
547 | setuv (format, xe->xclient.format); |
544 | setuv (l0, xe->xclient.data.l[0]); |
548 | setuv (l0, xe->xclient.data.l[0]); |
545 | setuv (l1, xe->xclient.data.l[1]); |
549 | setuv (l1, xe->xclient.data.l[1]); |
546 | setuv (l2, xe->xclient.data.l[2]); |
550 | setuv (l2, xe->xclient.data.l[2]); |
547 | setuv (l3, xe->xclient.data.l[3]); |
551 | setuv (l3, xe->xclient.data.l[3]); |
548 | setuv (l4, xe->xclient.data.l[4]); |
552 | setuv (l4, xe->xclient.data.l[4]); |
549 | break; |
553 | break; |
550 | } |
554 | } |
551 | |
555 | |
552 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
556 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
553 | } |
557 | } |
554 | break; |
558 | break; |
555 | |
559 | |
556 | case DT_END: |
560 | case DT_END: |
557 | goto call; |
561 | goto call; |
558 | |
562 | |
559 | default: |
563 | default: |
560 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
564 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
561 | } |
565 | } |
|
|
566 | } |
|
|
567 | |
|
|
568 | call: |
|
|
569 | va_end (ap); |
|
|
570 | |
|
|
571 | PUTBACK; |
|
|
572 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
573 | SPAGAIN; |
|
|
574 | |
|
|
575 | if (count) |
|
|
576 | { |
|
|
577 | SV *status = POPs; |
|
|
578 | count = SvTRUE (status); |
562 | } |
579 | } |
563 | |
580 | |
564 | call: |
|
|
565 | va_end (ap); |
|
|
566 | |
|
|
567 | PUTBACK; |
581 | 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; |
582 | FREETMPS; |
579 | LEAVE; |
583 | LEAVE; |
580 | |
584 | |
581 | if (SvTRUE (ERRSV)) |
585 | if (SvTRUE (ERRSV)) |
582 | { |
586 | { |
583 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
587 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
584 | ungrab (term); // better lose the grab than the session |
588 | ungrab (term); // better lose the grab than the session |
585 | } |
589 | } |
586 | |
590 | |
587 | event_consumed = !!count; |
591 | event_consumed = !!count; |
588 | } |
592 | } |
589 | catch (...) |
|
|
590 | { |
|
|
591 | swap (perl_environ, environ); |
|
|
592 | throw; |
|
|
593 | } |
|
|
594 | else |
593 | else |
595 | event_consumed = false; |
594 | event_consumed = false; |
596 | |
595 | |
597 | // post-handling of some events |
596 | // post-handling of some events |
598 | if (htype == HOOK_REFRESH_BEGIN) |
597 | if (htype == HOOK_REFRESH_BEGIN) |
599 | { |
598 | { |
600 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
599 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
601 | |
600 | |
602 | for (int i = AvFILL (av); i >= 0; i--) |
601 | for (int i = AvFILL (av); i >= 0; i--) |
603 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
602 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
604 | } |
603 | } |
605 | else if (htype == HOOK_DESTROY) |
604 | else if (htype == HOOK_DESTROY) |
606 | { |
605 | { |
607 | clearSVptr ((SV *)term->perl.self); |
606 | clearSVptr ((SV *)term->perl.self); |
608 | SvREFCNT_dec ((SV *)term->perl.self); |
607 | SvREFCNT_dec ((SV *)term->perl.self); |
609 | |
608 | |
610 | // don't allow further calls |
609 | // don't allow further calls |
611 | term->perl.self = 0; |
610 | term->perl.self = 0; |
612 | } |
611 | } |
613 | |
612 | |
614 | swap (perl_environ, environ); |
|
|
615 | |
|
|
616 | return event_consumed; |
613 | return event_consumed; |
|
|
614 | } |
|
|
615 | |
|
|
616 | void |
|
|
617 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
618 | { |
|
|
619 | localise_env set_environ (perl_environ); |
|
|
620 | |
|
|
621 | ENTER; |
|
|
622 | SAVETMPS; |
|
|
623 | |
|
|
624 | dSP; |
|
|
625 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
626 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
627 | |
|
|
628 | if (SvTRUE (ERRSV)) |
|
|
629 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
630 | |
|
|
631 | FREETMPS; |
|
|
632 | LEAVE; |
617 | } |
633 | } |
618 | |
634 | |
619 | ///////////////////////////////////////////////////////////////////////////// |
635 | ///////////////////////////////////////////////////////////////////////////// |
620 | |
636 | |
621 | MODULE = urxvt PACKAGE = urxvt |
637 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
633 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
649 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
634 | # include "hookinc.h" |
650 | # include "hookinc.h" |
635 | # undef def |
651 | # undef def |
636 | |
652 | |
637 | HV *option = get_hv ("urxvt::OPTION", 1); |
653 | HV *option = get_hv ("urxvt::OPTION", 1); |
638 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
654 | # define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
639 | # define nodef(name) |
655 | # define nodef(name) |
640 | # include "optinc.h" |
656 | # include "optinc.h" |
641 | # undef nodef |
657 | # undef nodef |
642 | # undef def |
658 | # undef def |
643 | |
659 | |
… | |
… | |
645 | static const struct { |
661 | static const struct { |
646 | const char *name; |
662 | const char *name; |
647 | IV iv; |
663 | IV iv; |
648 | } *civ, const_iv[] = { |
664 | } *civ, const_iv[] = { |
649 | # define const_iv(name) { # name, (IV)name } |
665 | # define const_iv(name) { # name, (IV)name } |
|
|
666 | const_iv (NUM_RESOURCES), |
650 | const_iv (DEFAULT_RSTYLE), |
667 | const_iv (DEFAULT_RSTYLE), |
651 | const_iv (OVERLAY_RSTYLE), |
668 | const_iv (OVERLAY_RSTYLE), |
|
|
669 | const_iv (Color_Bits), |
|
|
670 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
|
|
671 | const_iv (RS_fgShift), const_iv (RS_fgMask), |
|
|
672 | const_iv (RS_Careful), |
|
|
673 | const_iv (RS_fontCount), |
|
|
674 | const_iv (RS_fontShift), |
|
|
675 | const_iv (RS_fontMask), |
|
|
676 | const_iv (RS_baseattrMask), |
|
|
677 | const_iv (RS_attrMask), |
|
|
678 | const_iv (RS_redraw), |
|
|
679 | const_iv (RS_Sel), |
652 | const_iv (RS_Bold), |
680 | const_iv (RS_Bold), |
653 | const_iv (RS_Italic), |
681 | const_iv (RS_Italic), |
654 | const_iv (RS_Blink), |
682 | const_iv (RS_Blink), |
655 | const_iv (RS_RVid), |
683 | const_iv (RS_RVid), |
656 | const_iv (RS_Uline), |
684 | const_iv (RS_Uline), |
… | |
… | |
760 | const_iv (XIMDontChange), |
788 | const_iv (XIMDontChange), |
761 | # endif |
789 | # endif |
762 | # endif |
790 | # endif |
763 | }; |
791 | }; |
764 | |
792 | |
765 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
793 | for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) |
766 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
794 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
767 | } |
795 | } |
768 | |
796 | |
769 | void |
797 | void |
770 | warn (const char *msg) |
798 | warn (const char *msg) |
… | |
… | |
780 | _exit (int status) |
808 | _exit (int status) |
781 | |
809 | |
782 | NV |
810 | NV |
783 | NOW () |
811 | NOW () |
784 | CODE: |
812 | CODE: |
785 | RETVAL = NOW; |
813 | RETVAL = ev::now (); |
786 | OUTPUT: |
814 | OUTPUT: |
787 | RETVAL |
815 | RETVAL |
788 | |
816 | |
789 | int |
817 | int |
790 | GET_BASEFG (int rend) |
818 | GET_BASEFG (int rend) |
… | |
… | |
843 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
871 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
844 | if ((*t)->perl.self) |
872 | if ((*t)->perl.self) |
845 | PUSHs (sv_2mortal (newSVterm (*t))); |
873 | PUSHs (sv_2mortal (newSVterm (*t))); |
846 | } |
874 | } |
847 | |
875 | |
|
|
876 | IV |
|
|
877 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
878 | CODE: |
|
|
879 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
880 | req->cb_sv = newSVsv (cb); |
|
|
881 | RETVAL = (IV)req; |
|
|
882 | OUTPUT: |
|
|
883 | RETVAL |
|
|
884 | |
|
|
885 | void |
|
|
886 | _delete_selection_request (IV req_) |
|
|
887 | CODE: |
|
|
888 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
889 | delete req; |
|
|
890 | |
848 | MODULE = urxvt PACKAGE = urxvt::term |
891 | MODULE = urxvt PACKAGE = urxvt::term |
849 | |
892 | |
850 | SV * |
893 | SV * |
851 | _new (AV *env, AV *arg) |
894 | _new (AV *env, AV *arg) |
852 | CODE: |
895 | CODE: |
… | |
… | |
862 | for (int i = AvFILL (env) + 1; i--; ) |
905 | for (int i = AvFILL (env) + 1; i--; ) |
863 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
906 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
864 | |
907 | |
865 | envv->push_back (0); |
908 | envv->push_back (0); |
866 | |
909 | |
867 | bool success; |
|
|
868 | |
|
|
869 | try |
910 | try |
870 | { |
911 | { |
871 | success = term->init (argv, envv); |
912 | term->init (argv, envv); |
872 | } |
913 | } |
873 | catch (const class rxvt_failure_exception &e) |
914 | catch (const class rxvt_failure_exception &e) |
874 | { |
|
|
875 | success = false; |
|
|
876 | } |
|
|
877 | |
|
|
878 | if (!success) |
|
|
879 | { |
915 | { |
880 | term->destroy (); |
916 | term->destroy (); |
881 | croak ("error while initializing new terminal instance"); |
917 | croak ("error while initializing new terminal instance"); |
882 | } |
918 | } |
883 | |
919 | |
… | |
… | |
1055 | OUTPUT: |
1091 | OUTPUT: |
1056 | RETVAL |
1092 | RETVAL |
1057 | |
1093 | |
1058 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1094 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1059 | |
1095 | |
1060 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1096 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1061 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1097 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1062 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1098 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1063 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1099 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1064 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1100 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1065 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1101 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1066 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1102 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1067 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1103 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1068 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1104 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1069 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1105 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1070 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1106 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1071 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
1107 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
|
|
1108 | #define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace) |
1072 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1109 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1073 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1110 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1074 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1111 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1075 | |
1112 | |
1076 | int |
1113 | int |
1077 | rxvt_term::width () |
1114 | rxvt_term::width () |
1078 | ALIAS: |
1115 | ALIAS: |
1079 | width = TERM_OFFSET_width |
1116 | width = TERM_OFFSET_width |
1080 | height = TERM_OFFSET_height |
1117 | height = TERM_OFFSET_height |
1081 | fwidth = TERM_OFFSET_fwidth |
1118 | fwidth = TERM_OFFSET_fwidth |
1082 | fheight = TERM_OFFSET_fheight |
1119 | fheight = TERM_OFFSET_fheight |
1083 | fbase = TERM_OFFSET_fbase |
1120 | fbase = TERM_OFFSET_fbase |
1084 | nrow = TERM_OFFSET_nrow |
1121 | nrow = TERM_OFFSET_nrow |
1085 | ncol = TERM_OFFSET_ncol |
1122 | ncol = TERM_OFFSET_ncol |
1086 | focus = TERM_OFFSET_focus |
1123 | focus = TERM_OFFSET_focus |
1087 | mapped = TERM_OFFSET_mapped |
1124 | mapped = TERM_OFFSET_mapped |
1088 | int_bwidth = TERM_OFFSET_int_bwidth |
1125 | int_bwidth = TERM_OFFSET_int_bwidth |
1089 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1126 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1090 | lineSpace = TERM_OFFSET_lineSpace |
1127 | lineSpace = TERM_OFFSET_lineSpace |
|
|
1128 | letterSpace = TERM_OFFSET_letterSpace |
1091 | saveLines = TERM_OFFSET_saveLines |
1129 | saveLines = TERM_OFFSET_saveLines |
1092 | total_rows = TERM_OFFSET_total_rows |
1130 | total_rows = TERM_OFFSET_total_rows |
1093 | top_row = TERM_OFFSET_top_row |
1131 | top_row = TERM_OFFSET_top_row |
1094 | CODE: |
1132 | CODE: |
1095 | RETVAL = *(int *)((char *)THIS + ix); |
1133 | RETVAL = *(int *)((char *)THIS + ix); |
1096 | OUTPUT: |
1134 | OUTPUT: |
1097 | RETVAL |
1135 | RETVAL |
1098 | |
1136 | |
… | |
… | |
1109 | { |
1147 | { |
1110 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1148 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1111 | case 1: RETVAL = THIS->ModMetaMask; break; |
1149 | case 1: RETVAL = THIS->ModMetaMask; break; |
1112 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1150 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1113 | case 3: RETVAL = THIS->current_screen; break; |
1151 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1152 | #ifdef CURSOR_BLINK |
1114 | case 4: RETVAL = THIS->hidden_cursor; break; |
1153 | case 4: RETVAL = THIS->hidden_cursor; break; |
|
|
1154 | #endif |
1115 | } |
1155 | } |
1116 | OUTPUT: |
1156 | OUTPUT: |
1117 | RETVAL |
1157 | RETVAL |
1118 | |
1158 | |
1119 | char * |
1159 | char * |
… | |
… | |
1144 | if (*i) |
1184 | if (*i) |
1145 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1185 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1146 | } |
1186 | } |
1147 | |
1187 | |
1148 | int |
1188 | int |
1149 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1189 | rxvt_term::pty_ev_events (int events = ev::UNDEF) |
1150 | CODE: |
1190 | CODE: |
1151 | RETVAL = THIS->pty_ev.events; |
1191 | RETVAL = THIS->pty_ev.events; |
1152 | if (events != EVENT_UNDEF) |
1192 | if (events != ev::UNDEF) |
1153 | THIS->pty_ev.set (events); |
1193 | THIS->pty_ev.set (events); |
1154 | OUTPUT: |
1194 | OUTPUT: |
1155 | RETVAL |
1195 | RETVAL |
1156 | |
1196 | |
1157 | int |
1197 | int |
… | |
… | |
1236 | |
1276 | |
1237 | void |
1277 | void |
1238 | rxvt_term::want_refresh () |
1278 | rxvt_term::want_refresh () |
1239 | CODE: |
1279 | CODE: |
1240 | THIS->want_refresh = 1; |
1280 | THIS->want_refresh = 1; |
|
|
1281 | THIS->refresh_check (); |
1241 | |
1282 | |
1242 | void |
1283 | 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) |
1284 | 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: |
1285 | PPCODE: |
1245 | { |
1286 | { |
… | |
… | |
1400 | SV * |
1441 | SV * |
1401 | rxvt_term::special_decode (SV *text) |
1442 | rxvt_term::special_decode (SV *text) |
1402 | CODE: |
1443 | CODE: |
1403 | { |
1444 | { |
1404 | wchar_t *wstr = sv2wcs (text); |
1445 | wchar_t *wstr = sv2wcs (text); |
1405 | int wlen = wcslen (wstr); |
|
|
1406 | int dlen = 0; |
1446 | int dlen = 0; |
1407 | |
1447 | |
1408 | // find length |
1448 | // find length |
1409 | for (wchar_t *s = wstr; *s; s++) |
1449 | for (wchar_t *s = wstr; *s; s++) |
1410 | if (*s == NOCHAR) |
1450 | if (*s == NOCHAR) |
… | |
… | |
1441 | # include "rsinc.h" |
1481 | # include "rsinc.h" |
1442 | # undef def |
1482 | # undef def |
1443 | # undef reserve |
1483 | # undef reserve |
1444 | }; |
1484 | }; |
1445 | |
1485 | |
1446 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1486 | rs = rslist + ARRAY_LENGTH(rslist); |
1447 | |
1487 | |
|
|
1488 | if (*name) |
1448 | do { |
1489 | { |
|
|
1490 | do { |
1449 | if (rs-- == rslist) |
1491 | if (rs-- == rslist) |
1450 | croak ("no such resource '%s', requested", name); |
1492 | croak ("no such resource '%s', requested", name); |
1451 | } while (strcmp (name, rs->name)); |
1493 | } while (strcmp (name, rs->name)); |
1452 | |
1494 | |
1453 | index += rs->value; |
1495 | index += rs->value; |
|
|
1496 | } |
|
|
1497 | else |
|
|
1498 | { |
|
|
1499 | --rs; |
|
|
1500 | name = ""; |
|
|
1501 | } |
1454 | |
1502 | |
1455 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1503 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1456 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1504 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1457 | |
1505 | |
1458 | if (GIMME_V != G_VOID) |
1506 | if (GIMME_V != G_VOID) |
… | |
… | |
1473 | |
1521 | |
1474 | const char * |
1522 | const char * |
1475 | rxvt_term::x_resource (const char *name) |
1523 | rxvt_term::x_resource (const char *name) |
1476 | |
1524 | |
1477 | bool |
1525 | bool |
1478 | rxvt_term::option (U32 optval, int set = -1) |
1526 | rxvt_term::option (U8 optval, int set = -1) |
1479 | CODE: |
1527 | CODE: |
1480 | { |
1528 | { |
1481 | RETVAL = THIS->options & optval; |
1529 | RETVAL = THIS->option (optval); |
1482 | |
1530 | |
1483 | if (set >= 0) |
1531 | if (set >= 0) |
1484 | { |
1532 | { |
1485 | if (set) |
|
|
1486 | THIS->options |= optval; |
1533 | THIS->set_option (optval, set); |
1487 | else |
|
|
1488 | THIS->options &= ~optval; |
|
|
1489 | |
1534 | |
1490 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1535 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1491 | switch (optval) |
1536 | switch (optval) |
1492 | { |
1537 | { |
1493 | case Opt_skipBuiltinGlyphs: |
1538 | case Opt_skipBuiltinGlyphs: |
1494 | THIS->set_fonts (); |
1539 | THIS->set_fonts (); |
1495 | THIS->scr_remap_chars (); |
1540 | THIS->scr_remap_chars (); |
1496 | THIS->scr_touch (true); |
1541 | THIS->scr_touch (true); |
1497 | THIS->want_refresh = 1; |
1542 | THIS->want_refresh = 1; |
|
|
1543 | THIS->refresh_check (); |
1498 | break; |
1544 | break; |
1499 | |
1545 | |
1500 | case Opt_cursorUnderline: |
1546 | case Opt_cursorUnderline: |
1501 | THIS->want_refresh = 1; |
1547 | THIS->want_refresh = 1; |
|
|
1548 | THIS->refresh_check (); |
1502 | break; |
1549 | break; |
1503 | |
1550 | |
1504 | # case Opt_scrollBar_floating: |
1551 | # case Opt_scrollBar_floating: |
1505 | # case Opt_scrollBar_right: |
1552 | # case Opt_scrollBar_right: |
1506 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1553 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
… | |
… | |
1539 | EXTEND (SP, 2); |
1586 | EXTEND (SP, 2); |
1540 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1587 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1541 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1588 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1542 | } |
1589 | } |
1543 | |
1590 | |
1544 | if (items == 3) |
1591 | if (items >= 3) |
1545 | { |
1592 | { |
1546 | rc.row = SvIV (ST (1)); |
1593 | rc.row = SvIV (ST (1)); |
1547 | rc.col = SvIV (ST (2)); |
1594 | rc.col = SvIV (ST (2)); |
1548 | |
1595 | |
1549 | if (ix == 2) |
1596 | if (ix == 2) |
… | |
… | |
1564 | |
1611 | |
1565 | clamp_it (rc.col, 0, THIS->ncol); |
1612 | clamp_it (rc.col, 0, THIS->ncol); |
1566 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1613 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1567 | |
1614 | |
1568 | if (ix) |
1615 | if (ix) |
|
|
1616 | { |
|
|
1617 | THIS->selection.screen = THIS->current_screen; |
|
|
1618 | |
1569 | THIS->want_refresh = 1; |
1619 | THIS->want_refresh = 1; |
|
|
1620 | THIS->refresh_check (); |
1570 | } |
1621 | } |
|
|
1622 | } |
1571 | } |
1623 | } |
1572 | |
1624 | |
1573 | char |
1625 | int |
1574 | rxvt_term::cur_charset () |
1626 | rxvt_term::selection_screen (int screen = -1) |
1575 | CODE: |
1627 | CODE: |
1576 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1628 | RETVAL = THIS->selection.screen; |
1577 | OUTPUT: |
1629 | if (screen >= 0) |
|
|
1630 | THIS->selection.screen = screen; |
|
|
1631 | OUTPUT: |
1578 | RETVAL |
1632 | RETVAL |
1579 | |
1633 | |
1580 | void |
1634 | void |
1581 | rxvt_term::selection_clear () |
1635 | rxvt_term::selection_clear (bool clipboard = false) |
1582 | |
1636 | |
1583 | void |
1637 | void |
1584 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1638 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1585 | CODE: |
1639 | CODE: |
1586 | THIS->selection.op = SELECTION_CONT; |
1640 | THIS->selection.op = SELECTION_CONT; |
1587 | THIS->selection.rect = rect; |
1641 | THIS->selection.rect = rect; |
1588 | THIS->selection_make (eventtime); |
1642 | THIS->selection_make (eventtime); |
1589 | |
1643 | |
1590 | int |
1644 | int |
1591 | rxvt_term::selection_grab (Time eventtime) |
1645 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1592 | |
1646 | |
1593 | void |
1647 | void |
1594 | rxvt_term::selection (SV *newtext = 0) |
1648 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1595 | PPCODE: |
1649 | PPCODE: |
1596 | { |
1650 | { |
|
|
1651 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1652 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1653 | |
1597 | if (GIMME_V != G_VOID) |
1654 | if (GIMME_V != G_VOID) |
1598 | XPUSHs (THIS->selection.text |
1655 | XPUSHs (text |
1599 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1656 | ? sv_2mortal (wcs2sv (text, len)) |
1600 | : &PL_sv_undef); |
1657 | : &PL_sv_undef); |
1601 | |
1658 | |
1602 | if (newtext) |
1659 | if (newtext) |
1603 | { |
1660 | { |
1604 | free (THIS->selection.text); |
1661 | free (text); |
1605 | |
1662 | |
1606 | THIS->selection.text = sv2wcs (newtext); |
1663 | text = sv2wcs (newtext); |
1607 | THIS->selection.len = wcslen (THIS->selection.text); |
1664 | len = wcslen (text); |
1608 | } |
1665 | } |
1609 | } |
1666 | } |
|
|
1667 | |
|
|
1668 | char |
|
|
1669 | rxvt_term::cur_charset () |
|
|
1670 | CODE: |
|
|
1671 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1672 | OUTPUT: |
|
|
1673 | RETVAL |
1610 | |
1674 | |
1611 | void |
1675 | 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) |
1676 | 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 | |
1677 | |
1614 | void |
1678 | void |
… | |
… | |
1636 | char *str = SvPVbyte (octets, len); |
1700 | char *str = SvPVbyte (octets, len); |
1637 | C_ARGS: |
1701 | C_ARGS: |
1638 | str, len |
1702 | str, len |
1639 | |
1703 | |
1640 | void |
1704 | void |
|
|
1705 | rxvt_term::tt_paste (SV *octets) |
|
|
1706 | INIT: |
|
|
1707 | STRLEN len; |
|
|
1708 | char *str = SvPVbyte (octets, len); |
|
|
1709 | C_ARGS: |
|
|
1710 | str, len |
|
|
1711 | |
|
|
1712 | void |
1641 | rxvt_term::cmd_parse (SV *octets) |
1713 | rxvt_term::cmd_parse (SV *octets) |
1642 | CODE: |
1714 | CODE: |
1643 | { |
1715 | { |
1644 | STRLEN len; |
1716 | STRLEN len; |
1645 | char *str = SvPVbyte (octets, len); |
1717 | char *str = SvPVbyte (octets, len); |
… | |
… | |
1681 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1753 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1682 | |
1754 | |
1683 | EXTEND (SP, count); |
1755 | EXTEND (SP, count); |
1684 | while (count--) |
1756 | while (count--) |
1685 | PUSHs (newSVuv ((U32)props [count])); |
1757 | PUSHs (newSVuv ((U32)props [count])); |
1686 | |
1758 | |
1687 | XFree (props); |
1759 | XFree (props); |
1688 | } |
1760 | } |
1689 | |
1761 | |
1690 | void |
1762 | void |
1691 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
1763 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
… | |
… | |
1714 | XFree (prop); |
1786 | XFree (prop); |
1715 | } |
1787 | } |
1716 | } |
1788 | } |
1717 | |
1789 | |
1718 | void |
1790 | void |
1719 | rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) |
1791 | rxvt_term::XChangeProperty (Window window, Atom property, Atom type, int format, SV *data) |
1720 | CODE: |
1792 | CODE: |
1721 | { |
1793 | { |
1722 | STRLEN len; |
1794 | STRLEN len; |
1723 | char *data_ = SvPVbyte (data, len); |
1795 | char *data_ = SvPVbyte (data, len); |
1724 | |
1796 | |