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-2008 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 "ev_cpp.h" |
37 | #include "ev_cpp.h" |
37 | #include "rxvt.h" |
38 | #include "rxvt.h" |
… | |
… | |
45 | |
46 | |
46 | #undef LINENO |
47 | #undef LINENO |
47 | #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) |
48 | #undef ROW |
49 | #undef ROW |
49 | #define ROW(n) THIS->row_buf [LINENO (n)] |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
51 | |
|
|
52 | ///////////////////////////////////////////////////////////////////////////// |
|
|
53 | |
|
|
54 | typedef char * octet_string; |
|
|
55 | typedef char * utf8_string; |
|
|
56 | |
|
|
57 | typedef int render_repeat_mode; |
|
|
58 | |
|
|
59 | #if HAVE_PIXBUF |
|
|
60 | typedef GdkPixbuf * urxvt__pixbuf; |
|
|
61 | #endif |
|
|
62 | typedef rxvt_img * urxvt__img; |
|
|
63 | |
|
|
64 | ///////////////////////////////////////////////////////////////////////////// |
|
|
65 | |
|
|
66 | static void |
|
|
67 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
|
|
68 | { |
|
|
69 | //TODO: support component stuff, 0..1 |
|
|
70 | c.set (s, SvPVbyte_nolen (sv)); |
|
|
71 | } |
50 | |
72 | |
51 | ///////////////////////////////////////////////////////////////////////////// |
73 | ///////////////////////////////////////////////////////////////////////////// |
52 | |
74 | |
53 | static wchar_t * |
75 | static wchar_t * |
54 | sv2wcs (SV *sv) |
76 | sv2wcs (SV *sv) |
… | |
… | |
302 | THIS->refresh_check (); |
324 | THIS->refresh_check (); |
303 | } |
325 | } |
304 | |
326 | |
305 | ///////////////////////////////////////////////////////////////////////////// |
327 | ///////////////////////////////////////////////////////////////////////////// |
306 | |
328 | |
307 | #define IOM_CLASS "urxvt" |
|
|
308 | #define IOM_WARN rxvt_warn |
|
|
309 | #include "iom_perl.h" |
329 | #include "iom_perl.h" |
310 | |
330 | |
311 | ///////////////////////////////////////////////////////////////////////////// |
331 | ///////////////////////////////////////////////////////////////////////////// |
312 | |
332 | |
313 | struct rxvt_perl_interp rxvt_perl; |
333 | struct rxvt_perl_interp rxvt_perl; |
… | |
… | |
323 | PERL_SYS_TERM (); |
343 | PERL_SYS_TERM (); |
324 | } |
344 | } |
325 | } |
345 | } |
326 | |
346 | |
327 | void |
347 | void |
328 | rxvt_perl_interp::init (rxvt_term *term) |
348 | rxvt_perl_interp::init () |
329 | { |
349 | { |
330 | if (!perl) |
350 | if (!perl) |
331 | { |
351 | { |
332 | rxvt_push_locale (""); // perl init destroys current locale |
352 | rxvt_push_locale (""); // perl init destroys current locale |
333 | |
353 | |
|
|
354 | { |
334 | perl_environ = rxvt_environ; |
355 | perl_environ = rxvt_environ; |
335 | swap (perl_environ, environ); |
356 | localise_env set_environ (perl_environ); |
336 | |
357 | |
337 | char *args[] = { |
358 | char *args[] = { |
338 | "", |
359 | "", |
339 | "-e" |
360 | "-e" |
340 | "BEGIN {" |
361 | "BEGIN {" |
341 | " urxvt->bootstrap;" |
362 | " urxvt->bootstrap;" |
342 | " unshift @INC, '" LIBDIR "';" |
363 | " unshift @INC, '" LIBDIR "';" |
343 | "}" |
364 | "}" |
344 | "" |
365 | "" |
345 | "use urxvt;" |
366 | "use urxvt;" |
346 | }; |
367 | }; |
347 | int argc = sizeof (args) / sizeof (args[0]); |
368 | int argc = ecb_array_length (args); |
348 | char **argv = args; |
369 | char **argv = args; |
349 | |
370 | |
350 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
371 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
351 | perl = perl_alloc (); |
372 | perl = perl_alloc (); |
352 | perl_construct (perl); |
373 | perl_construct (perl); |
353 | |
374 | |
354 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
375 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
355 | || perl_run (perl)) |
376 | || perl_run (perl)) |
356 | { |
377 | { |
357 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
378 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
358 | |
379 | |
359 | perl_destruct (perl); |
380 | perl_destruct (perl); |
360 | perl_free (perl); |
381 | perl_free (perl); |
361 | perl = 0; |
382 | perl = 0; |
362 | } |
383 | } |
363 | |
384 | } |
364 | swap (perl_environ, environ); |
|
|
365 | |
385 | |
366 | rxvt_pop_locale (); |
386 | rxvt_pop_locale (); |
367 | } |
387 | } |
|
|
388 | } |
368 | |
389 | |
369 | if (perl) |
390 | void |
|
|
391 | rxvt_perl_interp::init (rxvt_term *term) |
|
|
392 | { |
|
|
393 | init (); |
|
|
394 | |
|
|
395 | if (perl && !term->perl.self) |
370 | { |
396 | { |
371 | // runs outside of perls ENV |
397 | // runs outside of perls ENV |
372 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
398 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
373 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
399 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
400 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
374 | } |
401 | } |
|
|
402 | } |
|
|
403 | |
|
|
404 | void |
|
|
405 | rxvt_perl_interp::eval (const char *str) |
|
|
406 | { |
|
|
407 | eval_pv (str, 1); |
|
|
408 | } |
|
|
409 | |
|
|
410 | void |
|
|
411 | rxvt_perl_interp::usage (rxvt_term *term, int type) |
|
|
412 | { |
|
|
413 | localise_env set_environ (perl_environ); |
|
|
414 | |
|
|
415 | ENTER; |
|
|
416 | SAVETMPS; |
|
|
417 | |
|
|
418 | dSP; |
|
|
419 | PUSHMARK (SP); |
|
|
420 | EXTEND (SP, 2); |
|
|
421 | PUSHs (sv_2mortal (newSVterm (term))); |
|
|
422 | PUSHs (sv_2mortal (newSViv (type))); |
|
|
423 | PUTBACK; |
|
|
424 | call_pv ("urxvt::usage", G_VOID | G_DISCARD); |
|
|
425 | |
|
|
426 | FREETMPS; |
|
|
427 | LEAVE; |
|
|
428 | } |
|
|
429 | |
|
|
430 | uint8_t |
|
|
431 | rxvt_perl_interp::parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
|
|
432 | { |
|
|
433 | localise_env set_environ (perl_environ); |
|
|
434 | |
|
|
435 | ENTER; |
|
|
436 | SAVETMPS; |
|
|
437 | |
|
|
438 | dSP; |
|
|
439 | PUSHMARK (SP); |
|
|
440 | EXTEND (SP, 6); |
|
|
441 | PUSHs (sv_2mortal (newSVterm (term))); |
|
|
442 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
|
|
443 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
|
|
444 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
|
|
445 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
|
|
446 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
|
|
447 | PUTBACK; |
|
|
448 | call_pv ("urxvt::parse_resource", G_SCALAR); |
|
|
449 | SPAGAIN; |
|
|
450 | |
|
|
451 | uint8_t ret = POPi; |
|
|
452 | |
|
|
453 | FREETMPS; |
|
|
454 | LEAVE; |
|
|
455 | |
|
|
456 | return ret; |
375 | } |
457 | } |
376 | |
458 | |
377 | static void |
459 | static void |
378 | ungrab (rxvt_term *THIS) |
460 | ungrab (rxvt_term *THIS) |
379 | { |
461 | { |
… | |
… | |
389 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
471 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
390 | { |
472 | { |
391 | if (!perl || !term->perl.self) |
473 | if (!perl || !term->perl.self) |
392 | return false; |
474 | return false; |
393 | |
475 | |
|
|
476 | localise_env set_environ (perl_environ); |
|
|
477 | |
394 | // pre-handling of some events |
478 | // pre-handling of some events |
395 | if (htype == HOOK_REFRESH_END) |
479 | if (htype == HOOK_REFRESH_END) |
396 | { |
480 | { |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
481 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | |
482 | |
399 | for (int i = 0; i <= AvFILL (av); i++) |
483 | for (int i = 0; i <= AvFILL (av); i++) |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
484 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
401 | } |
485 | } |
|
|
486 | else if (htype == HOOK_DESTROY) |
|
|
487 | { |
|
|
488 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
402 | |
489 | |
403 | swap (perl_environ, environ); |
490 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
491 | { |
|
|
492 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
493 | delete req; |
|
|
494 | } |
|
|
495 | } |
404 | |
496 | |
405 | bool event_consumed; |
497 | bool event_consumed; |
406 | |
498 | |
407 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
|
|
408 | || term->perl.should_invoke [htype]) |
499 | if (term->perl.should_invoke [htype]) |
409 | try |
|
|
410 | { |
500 | { |
411 | dSP; |
501 | dSP; |
412 | va_list ap; |
502 | va_list ap; |
413 | |
503 | |
414 | va_start (ap, htype); |
504 | va_start (ap, htype); |
415 | |
505 | |
416 | ENTER; |
506 | ENTER; |
417 | SAVETMPS; |
507 | SAVETMPS; |
418 | |
508 | |
419 | PUSHMARK (SP); |
509 | PUSHMARK (SP); |
420 | |
510 | |
|
|
511 | EXTEND (SP, 2); |
421 | XPUSHs (sv_2mortal (newSVterm (term))); |
512 | PUSHs (sv_2mortal (newSVterm (term))); |
422 | XPUSHs (sv_2mortal (newSViv (htype))); |
513 | PUSHs (sv_2mortal (newSViv (htype))); |
423 | |
514 | |
424 | for (;;) { |
515 | for (;;) { |
425 | data_type dt = (data_type)va_arg (ap, int); |
516 | data_type dt = (data_type)va_arg (ap, int); |
426 | |
517 | |
427 | switch (dt) |
518 | switch (dt) |
428 | { |
519 | { |
429 | case DT_INT: |
520 | case DT_INT: |
430 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
521 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
431 | break; |
522 | break; |
432 | |
523 | |
433 | case DT_LONG: |
524 | case DT_LONG: |
434 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
525 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
435 | break; |
526 | break; |
436 | |
527 | |
437 | case DT_STR: |
528 | case DT_STR: |
438 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
529 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
439 | break; |
530 | break; |
440 | |
531 | |
441 | case DT_STR_LEN: |
532 | case DT_STR_LEN: |
442 | { |
533 | { |
443 | char *str = va_arg (ap, char *); |
534 | char *str = va_arg (ap, char *); |
444 | int len = va_arg (ap, int); |
535 | int len = va_arg (ap, int); |
445 | |
536 | |
446 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
537 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
447 | } |
538 | } |
448 | break; |
539 | break; |
449 | |
540 | |
450 | case DT_WCS_LEN: |
541 | case DT_WCS_LEN: |
451 | { |
542 | { |
452 | wchar_t *wstr = va_arg (ap, wchar_t *); |
543 | wchar_t *wstr = va_arg (ap, wchar_t *); |
453 | int wlen = va_arg (ap, int); |
544 | int wlen = va_arg (ap, int); |
454 | |
545 | |
455 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
546 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
456 | } |
547 | } |
457 | break; |
548 | break; |
458 | |
549 | |
459 | case DT_LCS_LEN: |
550 | case DT_LCS_LEN: |
460 | { |
551 | { |
461 | long *lstr = va_arg (ap, long *); |
552 | long *lstr = va_arg (ap, long *); |
462 | int llen = va_arg (ap, int); |
553 | int llen = va_arg (ap, int); |
463 | |
554 | |
464 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
555 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
465 | } |
556 | } |
466 | break; |
557 | break; |
467 | |
558 | |
468 | case DT_XEVENT: |
559 | case DT_XEVENT: |
469 | { |
560 | { |
470 | XEvent *xe = va_arg (ap, XEvent *); |
561 | XEvent *xe = va_arg (ap, XEvent *); |
471 | HV *hv = newHV (); |
562 | HV *hv = newHV (); |
472 | |
563 | |
473 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
564 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
474 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
565 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
475 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
566 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
476 | # undef set |
567 | # undef set |
477 | |
568 | |
478 | setiv (type, xe->type); |
569 | setiv (type, xe->type); |
479 | setiv (send_event, xe->xany.send_event); |
570 | setiv (send_event, xe->xany.send_event); |
480 | setiv (serial, xe->xany.serial); |
571 | setiv (serial, xe->xany.serial); |
481 | |
572 | |
482 | switch (xe->type) |
573 | switch (xe->type) |
483 | { |
574 | { |
484 | case KeyPress: |
575 | case KeyPress: |
485 | case KeyRelease: |
576 | case KeyRelease: |
486 | case ButtonPress: |
577 | case ButtonPress: |
487 | case ButtonRelease: |
578 | case ButtonRelease: |
488 | case MotionNotify: |
579 | case MotionNotify: |
489 | setuv (window, xe->xmotion.window); |
580 | setuv (window, xe->xmotion.window); |
490 | setuv (root, xe->xmotion.root); |
581 | setuv (root, xe->xmotion.root); |
491 | setuv (subwindow, xe->xmotion.subwindow); |
582 | setuv (subwindow, xe->xmotion.subwindow); |
492 | setuv (time, xe->xmotion.time); |
583 | setuv (time, xe->xmotion.time); |
493 | setiv (x, xe->xmotion.x); |
584 | setiv (x, xe->xmotion.x); |
494 | setiv (y, xe->xmotion.y); |
585 | setiv (y, xe->xmotion.y); |
495 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
586 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
496 | setiv (col, xe->xmotion.x / term->fwidth); |
587 | setiv (col, xe->xmotion.x / term->fwidth); |
497 | setiv (x_root, xe->xmotion.x_root); |
588 | setiv (x_root, xe->xmotion.x_root); |
498 | setiv (y_root, xe->xmotion.y_root); |
589 | setiv (y_root, xe->xmotion.y_root); |
499 | setuv (state, xe->xmotion.state); |
590 | setuv (state, xe->xmotion.state); |
500 | |
591 | |
501 | switch (xe->type) |
592 | switch (xe->type) |
502 | { |
593 | { |
503 | case KeyPress: |
594 | case KeyPress: |
504 | case KeyRelease: |
595 | case KeyRelease: |
505 | setuv (keycode, xe->xkey.keycode); |
596 | setuv (keycode, xe->xkey.keycode); |
506 | break; |
597 | break; |
507 | |
598 | |
508 | case ButtonPress: |
599 | case ButtonPress: |
509 | case ButtonRelease: |
600 | case ButtonRelease: |
510 | setuv (button, xe->xbutton.button); |
601 | setuv (button, xe->xbutton.button); |
511 | break; |
602 | break; |
512 | |
603 | |
513 | case MotionNotify: |
604 | case MotionNotify: |
514 | setiv (is_hint, xe->xmotion.is_hint); |
605 | setiv (is_hint, xe->xmotion.is_hint); |
515 | break; |
606 | break; |
516 | } |
607 | } |
517 | |
608 | |
518 | break; |
609 | break; |
519 | |
610 | |
520 | case MapNotify: |
611 | case MapNotify: |
521 | case UnmapNotify: |
612 | case UnmapNotify: |
522 | case ConfigureNotify: |
613 | case ConfigureNotify: |
523 | setuv (event, xe->xconfigure.event); |
614 | setuv (event, xe->xconfigure.event); |
524 | setuv (window, xe->xconfigure.window); |
615 | setuv (window, xe->xconfigure.window); |
525 | |
616 | |
526 | switch (xe->type) |
617 | switch (xe->type) |
527 | { |
618 | { |
528 | case ConfigureNotify: |
619 | case ConfigureNotify: |
529 | setiv (x, xe->xconfigure.x); |
620 | setiv (x, xe->xconfigure.x); |
530 | setiv (y, xe->xconfigure.y); |
621 | setiv (y, xe->xconfigure.y); |
531 | setiv (width, xe->xconfigure.width); |
622 | setiv (width, xe->xconfigure.width); |
532 | setiv (height, xe->xconfigure.height); |
623 | setiv (height, xe->xconfigure.height); |
533 | setuv (above, xe->xconfigure.above); |
624 | setuv (above, xe->xconfigure.above); |
534 | break; |
625 | break; |
535 | } |
626 | } |
536 | |
627 | |
537 | break; |
628 | break; |
538 | |
629 | |
539 | case PropertyNotify: |
630 | case PropertyNotify: |
540 | setuv (window, xe->xproperty.window); |
631 | setuv (window, xe->xproperty.window); |
541 | setuv (atom, xe->xproperty.atom); |
632 | setuv (atom, xe->xproperty.atom); |
542 | setuv (time, xe->xproperty.time); |
633 | setuv (time, xe->xproperty.time); |
543 | setiv (state, xe->xproperty.state); |
634 | setiv (state, xe->xproperty.state); |
544 | break; |
635 | break; |
545 | |
636 | |
546 | case ClientMessage: |
637 | case ClientMessage: |
547 | setuv (window, xe->xclient.window); |
638 | setuv (window, xe->xclient.window); |
548 | setuv (message_type, xe->xclient.message_type); |
639 | setuv (message_type, xe->xclient.message_type); |
549 | setuv (format, xe->xclient.format); |
640 | setuv (format, xe->xclient.format); |
550 | setuv (l0, xe->xclient.data.l[0]); |
641 | setuv (l0, xe->xclient.data.l[0]); |
551 | setuv (l1, xe->xclient.data.l[1]); |
642 | setuv (l1, xe->xclient.data.l[1]); |
552 | setuv (l2, xe->xclient.data.l[2]); |
643 | setuv (l2, xe->xclient.data.l[2]); |
553 | setuv (l3, xe->xclient.data.l[3]); |
644 | setuv (l3, xe->xclient.data.l[3]); |
554 | setuv (l4, xe->xclient.data.l[4]); |
645 | setuv (l4, xe->xclient.data.l[4]); |
555 | break; |
646 | break; |
556 | } |
647 | } |
557 | |
648 | |
558 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
649 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
559 | } |
650 | } |
560 | break; |
651 | break; |
561 | |
652 | |
562 | case DT_END: |
653 | case DT_END: |
563 | goto call; |
654 | goto call; |
564 | |
655 | |
565 | default: |
656 | default: |
566 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
657 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
567 | } |
658 | } |
|
|
659 | } |
|
|
660 | |
|
|
661 | call: |
|
|
662 | va_end (ap); |
|
|
663 | |
|
|
664 | PUTBACK; |
|
|
665 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
666 | SPAGAIN; |
|
|
667 | |
|
|
668 | if (count) |
|
|
669 | { |
|
|
670 | SV *status = POPs; |
|
|
671 | count = SvTRUE (status); |
568 | } |
672 | } |
569 | |
673 | |
570 | call: |
|
|
571 | va_end (ap); |
|
|
572 | |
|
|
573 | PUTBACK; |
674 | PUTBACK; |
574 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
575 | SPAGAIN; |
|
|
576 | |
|
|
577 | if (count) |
|
|
578 | { |
|
|
579 | SV *status = POPs; |
|
|
580 | count = SvTRUE (status); |
|
|
581 | } |
|
|
582 | |
|
|
583 | PUTBACK; |
|
|
584 | FREETMPS; |
675 | FREETMPS; |
585 | LEAVE; |
676 | LEAVE; |
586 | |
677 | |
587 | if (SvTRUE (ERRSV)) |
678 | if (SvTRUE (ERRSV)) |
588 | { |
679 | { |
589 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
680 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
590 | ungrab (term); // better lose the grab than the session |
681 | ungrab (term); // better lose the grab than the session |
591 | } |
682 | } |
592 | |
683 | |
593 | event_consumed = !!count; |
684 | event_consumed = !!count; |
594 | } |
685 | } |
595 | catch (...) |
|
|
596 | { |
|
|
597 | swap (perl_environ, environ); |
|
|
598 | throw; |
|
|
599 | } |
|
|
600 | else |
686 | else |
601 | event_consumed = false; |
687 | event_consumed = false; |
602 | |
688 | |
603 | // post-handling of some events |
689 | // post-handling of some events |
604 | if (htype == HOOK_REFRESH_BEGIN) |
690 | if (htype == HOOK_REFRESH_BEGIN) |
… | |
… | |
615 | |
701 | |
616 | // don't allow further calls |
702 | // don't allow further calls |
617 | term->perl.self = 0; |
703 | term->perl.self = 0; |
618 | } |
704 | } |
619 | |
705 | |
620 | swap (perl_environ, environ); |
|
|
621 | |
|
|
622 | return event_consumed; |
706 | return event_consumed; |
|
|
707 | } |
|
|
708 | |
|
|
709 | void |
|
|
710 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
711 | { |
|
|
712 | localise_env set_environ (perl_environ); |
|
|
713 | |
|
|
714 | ENTER; |
|
|
715 | SAVETMPS; |
|
|
716 | |
|
|
717 | dSP; |
|
|
718 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
719 | PUTBACK; |
|
|
720 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
721 | |
|
|
722 | if (SvTRUE (ERRSV)) |
|
|
723 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
724 | |
|
|
725 | FREETMPS; |
|
|
726 | LEAVE; |
623 | } |
727 | } |
624 | |
728 | |
625 | ///////////////////////////////////////////////////////////////////////////// |
729 | ///////////////////////////////////////////////////////////////////////////// |
626 | |
730 | |
627 | MODULE = urxvt PACKAGE = urxvt |
731 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
761 | const_iv (XIMSecondary), |
865 | const_iv (XIMSecondary), |
762 | const_iv (XIMTertiary), |
866 | const_iv (XIMTertiary), |
763 | const_iv (XIMVisibleToForward), |
867 | const_iv (XIMVisibleToForward), |
764 | const_iv (XIMVisibleToBackword), |
868 | const_iv (XIMVisibleToBackword), |
765 | const_iv (XIMVisibleToCenter), |
869 | const_iv (XIMVisibleToCenter), |
|
|
870 | #if XRENDER |
|
|
871 | const_iv (PictStandardARGB32), |
|
|
872 | const_iv (PictStandardRGB24), |
|
|
873 | const_iv (PictStandardA8), |
|
|
874 | const_iv (PictStandardA4), |
|
|
875 | const_iv (PictStandardA1), |
|
|
876 | const_iv (RepeatNone), |
|
|
877 | const_iv (RepeatNormal), |
|
|
878 | const_iv (RepeatPad), |
|
|
879 | const_iv (RepeatReflect), |
|
|
880 | #endif |
766 | # if 0 |
881 | # if 0 |
767 | const_iv (XIMForwardChar), |
882 | const_iv (XIMForwardChar), |
768 | const_iv (XIMBackwardChar), |
883 | const_iv (XIMBackwardChar), |
769 | const_iv (XIMForwardWord), |
884 | const_iv (XIMForwardWord), |
770 | const_iv (XIMBackwardWord), |
885 | const_iv (XIMBackwardWord), |
… | |
… | |
778 | const_iv (XIMDontChange), |
893 | const_iv (XIMDontChange), |
779 | # endif |
894 | # endif |
780 | # endif |
895 | # endif |
781 | }; |
896 | }; |
782 | |
897 | |
783 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
898 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
784 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
899 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
785 | } |
900 | } |
|
|
901 | |
|
|
902 | void |
|
|
903 | log (const char *msg) |
|
|
904 | CODE: |
|
|
905 | rxvt_log ("%s", msg); |
786 | |
906 | |
787 | void |
907 | void |
788 | warn (const char *msg) |
908 | warn (const char *msg) |
789 | CODE: |
909 | CODE: |
790 | rxvt_warn ("%s", msg); |
910 | rxvt_warn ("%s", msg); |
… | |
… | |
794 | CODE: |
914 | CODE: |
795 | rxvt_fatal ("%s", msg); |
915 | rxvt_fatal ("%s", msg); |
796 | |
916 | |
797 | void |
917 | void |
798 | _exit (int status) |
918 | _exit (int status) |
|
|
919 | |
|
|
920 | void |
|
|
921 | catch_fatal (SV *block) |
|
|
922 | PROTOTYPE: & |
|
|
923 | CODE: |
|
|
924 | try |
|
|
925 | { |
|
|
926 | PUSHMARK (SP); |
|
|
927 | PUTBACK; |
|
|
928 | call_sv (block, G_VOID | G_DISCARD); |
|
|
929 | SPAGAIN; |
|
|
930 | } |
|
|
931 | catch (const rxvt_failure_exception &e) |
|
|
932 | { |
|
|
933 | croak ("rxvt_fatal exception caught, trying to continue."); |
|
|
934 | } |
799 | |
935 | |
800 | NV |
936 | NV |
801 | NOW () |
937 | NOW () |
802 | CODE: |
938 | CODE: |
803 | RETVAL = ev::now (); |
939 | RETVAL = ev::now (); |
… | |
… | |
861 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
997 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
862 | if ((*t)->perl.self) |
998 | if ((*t)->perl.self) |
863 | PUSHs (sv_2mortal (newSVterm (*t))); |
999 | PUSHs (sv_2mortal (newSVterm (*t))); |
864 | } |
1000 | } |
865 | |
1001 | |
|
|
1002 | IV |
|
|
1003 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
1004 | CODE: |
|
|
1005 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
1006 | req->cb_sv = newSVsv (cb); |
|
|
1007 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
1008 | av_push (av, newSViv ((IV)req)); |
|
|
1009 | RETVAL = (IV)req; |
|
|
1010 | OUTPUT: |
|
|
1011 | RETVAL |
|
|
1012 | |
|
|
1013 | void |
|
|
1014 | _delete_selection_request (IV req_) |
|
|
1015 | CODE: |
|
|
1016 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
1017 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
1018 | int i; |
|
|
1019 | |
|
|
1020 | for (i = AvFILL (av); i >= 0; i--) |
|
|
1021 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
1022 | break; |
|
|
1023 | |
|
|
1024 | for (; i < AvFILL (av); i++) |
|
|
1025 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
1026 | |
|
|
1027 | av_pop (av); |
|
|
1028 | |
|
|
1029 | delete req; |
|
|
1030 | |
866 | MODULE = urxvt PACKAGE = urxvt::term |
1031 | MODULE = urxvt PACKAGE = urxvt::term |
867 | |
1032 | |
868 | SV * |
1033 | SV * |
869 | _new (AV *env, AV *arg) |
1034 | _new (AV *env, AV *arg) |
870 | CODE: |
1035 | CODE: |
871 | { |
1036 | { |
872 | rxvt_term *term = new rxvt_term; |
1037 | rxvt_term *term = new rxvt_term; |
873 | |
1038 | |
874 | stringvec *argv = new stringvec; |
1039 | stringvec *argv = new stringvec; |
875 | stringvec *envv = new stringvec; |
|
|
876 | |
|
|
877 | for (int i = 0; i <= AvFILL (arg); i++) |
1040 | for (int i = 0; i <= AvFILL (arg); i++) |
878 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
1041 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
879 | |
1042 | |
|
|
1043 | stringvec *envv = new stringvec; |
880 | for (int i = AvFILL (env) + 1; i--; ) |
1044 | for (int i = AvFILL (env) + 1; i--; ) |
881 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
1045 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
882 | |
1046 | |
883 | envv->push_back (0); |
|
|
884 | |
|
|
885 | try |
1047 | try |
886 | { |
1048 | { |
887 | term->init (argv, envv); |
1049 | term->init (argv, envv); |
888 | } |
1050 | } |
889 | catch (const class rxvt_failure_exception &e) |
1051 | catch (const class rxvt_failure_exception &e) |
… | |
… | |
902 | rxvt_term::destroy () |
1064 | rxvt_term::destroy () |
903 | |
1065 | |
904 | void |
1066 | void |
905 | rxvt_term::set_should_invoke (int htype, int inc) |
1067 | rxvt_term::set_should_invoke (int htype, int inc) |
906 | CODE: |
1068 | CODE: |
907 | THIS->perl.should_invoke [htype] += inc; |
1069 | uint8_t &count = THIS->perl.should_invoke [htype]; |
|
|
1070 | uint8_t prev = count; |
|
|
1071 | count += inc; |
|
|
1072 | if (!prev != !count) |
|
|
1073 | { |
|
|
1074 | // hook status changed, react |
|
|
1075 | switch (htype) |
|
|
1076 | { |
|
|
1077 | case HOOK_POSITION_CHANGE: |
|
|
1078 | if (count) |
|
|
1079 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
|
|
1080 | } |
|
|
1081 | } |
|
|
1082 | |
|
|
1083 | void |
|
|
1084 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
|
|
1085 | CODE: |
|
|
1086 | XrmPutStringResource (&THIS->option_db, specifier, value); |
908 | |
1087 | |
909 | int |
1088 | int |
910 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1089 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
911 | CODE: |
1090 | CODE: |
912 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1091 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
… | |
… | |
928 | |
1107 | |
929 | void |
1108 | void |
930 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
1109 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
931 | CODE: |
1110 | CODE: |
932 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
1111 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
933 | |
|
|
934 | void |
|
|
935 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
936 | CODE: |
|
|
937 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
938 | |
1112 | |
939 | bool |
1113 | bool |
940 | rxvt_term::grab (Time eventtime, int sync = 0) |
1114 | rxvt_term::grab (Time eventtime, int sync = 0) |
941 | CODE: |
1115 | CODE: |
942 | { |
1116 | { |
… | |
… | |
1054 | rxvt_pop_locale (); |
1228 | rxvt_pop_locale (); |
1055 | |
1229 | |
1056 | RETVAL = wcs2sv (wstr); |
1230 | RETVAL = wcs2sv (wstr); |
1057 | free (wstr); |
1231 | free (wstr); |
1058 | } |
1232 | } |
1059 | OUTPUT: |
|
|
1060 | RETVAL |
|
|
1061 | |
|
|
1062 | char * |
|
|
1063 | rxvt_term::locale () |
|
|
1064 | CODE: |
|
|
1065 | RETVAL = THIS->locale; |
|
|
1066 | OUTPUT: |
1233 | OUTPUT: |
1067 | RETVAL |
1234 | RETVAL |
1068 | |
1235 | |
1069 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1236 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1070 | |
1237 | |
… | |
… | |
1177 | RETVAL |
1344 | RETVAL |
1178 | |
1345 | |
1179 | Window |
1346 | Window |
1180 | rxvt_term::parent () |
1347 | rxvt_term::parent () |
1181 | CODE: |
1348 | CODE: |
1182 | RETVAL = THIS->parent [0]; |
1349 | RETVAL = THIS->parent; |
1183 | OUTPUT: |
1350 | OUTPUT: |
1184 | RETVAL |
1351 | RETVAL |
1185 | |
1352 | |
1186 | Window |
1353 | int |
1187 | rxvt_term::vt () |
1354 | rxvt_term::parent_x () |
1188 | CODE: |
1355 | CODE: |
1189 | RETVAL = THIS->vt; |
1356 | RETVAL = THIS->parent_x; |
|
|
1357 | OUTPUT: |
|
|
1358 | RETVAL |
|
|
1359 | |
|
|
1360 | int |
|
|
1361 | rxvt_term::parent_y () |
|
|
1362 | CODE: |
|
|
1363 | RETVAL = THIS->parent_y; |
1190 | OUTPUT: |
1364 | OUTPUT: |
1191 | RETVAL |
1365 | RETVAL |
1192 | |
1366 | |
1193 | void |
1367 | void |
1194 | rxvt_term::vt_emask_add (U32 emask) |
1368 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1214 | if (newval <= 0) |
1388 | if (newval <= 0) |
1215 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1389 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1216 | } |
1390 | } |
1217 | OUTPUT: |
1391 | OUTPUT: |
1218 | RETVAL |
1392 | RETVAL |
|
|
1393 | |
|
|
1394 | void |
|
|
1395 | rxvt_term::set_urgency (bool enable) |
1219 | |
1396 | |
1220 | void |
1397 | void |
1221 | rxvt_term::focus_in () |
1398 | rxvt_term::focus_in () |
1222 | |
1399 | |
1223 | void |
1400 | void |
… | |
… | |
1456 | # include "rsinc.h" |
1633 | # include "rsinc.h" |
1457 | # undef def |
1634 | # undef def |
1458 | # undef reserve |
1635 | # undef reserve |
1459 | }; |
1636 | }; |
1460 | |
1637 | |
1461 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1638 | rs = rslist + ecb_array_length (rslist); |
1462 | |
1639 | |
1463 | if (*name) |
1640 | if (*name) |
1464 | { |
1641 | { |
1465 | do { |
1642 | do { |
1466 | if (rs-- == rslist) |
1643 | if (rs-- == rslist) |
… | |
… | |
1505 | |
1682 | |
1506 | if (set >= 0) |
1683 | if (set >= 0) |
1507 | { |
1684 | { |
1508 | THIS->set_option (optval, set); |
1685 | THIS->set_option (optval, set); |
1509 | |
1686 | |
1510 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1687 | if (THIS->init_done) // avoid doing this before START |
1511 | switch (optval) |
1688 | switch (optval) |
1512 | { |
1689 | { |
1513 | case Opt_skipBuiltinGlyphs: |
1690 | case Opt_skipBuiltinGlyphs: |
1514 | THIS->set_fonts (); |
1691 | THIS->set_fonts (); |
1515 | THIS->scr_remap_chars (); |
1692 | THIS->scr_remap_chars (); |
1516 | THIS->scr_touch (true); |
1693 | THIS->scr_touch (true); |
1517 | THIS->want_refresh = 1; |
1694 | THIS->want_refresh = 1; |
1518 | THIS->refresh_check (); |
1695 | THIS->refresh_check (); |
1519 | break; |
1696 | break; |
|
|
1697 | #ifdef CURSOR_BLINK |
|
|
1698 | case Opt_cursorBlink: |
|
|
1699 | THIS->cursor_blink_reset (); |
|
|
1700 | break; |
|
|
1701 | #endif |
1520 | |
1702 | |
1521 | case Opt_cursorUnderline: |
1703 | case Opt_cursorUnderline: |
1522 | THIS->want_refresh = 1; |
1704 | THIS->want_refresh = 1; |
1523 | THIS->refresh_check (); |
1705 | THIS->refresh_check (); |
1524 | break; |
1706 | break; |
… | |
… | |
1538 | CODE: |
1720 | CODE: |
1539 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1721 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1540 | THIS->keyboard->register_done (); |
1722 | THIS->keyboard->register_done (); |
1541 | OUTPUT: |
1723 | OUTPUT: |
1542 | RETVAL |
1724 | RETVAL |
|
|
1725 | |
|
|
1726 | void |
|
|
1727 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1728 | CODE: |
|
|
1729 | wchar_t *wstr = sv2wcs (str); |
|
|
1730 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1731 | free (wstr); |
1543 | |
1732 | |
1544 | void |
1733 | void |
1545 | rxvt_term::screen_cur (...) |
1734 | rxvt_term::screen_cur (...) |
1546 | PROTOTYPE: $;$$ |
1735 | PROTOTYPE: $;$$ |
1547 | ALIAS: |
1736 | ALIAS: |
… | |
… | |
1655 | |
1844 | |
1656 | void |
1845 | void |
1657 | rxvt_term::scr_bell () |
1846 | rxvt_term::scr_bell () |
1658 | |
1847 | |
1659 | void |
1848 | void |
|
|
1849 | rxvt_term::scr_recolour (bool refresh = true); |
|
|
1850 | |
|
|
1851 | void |
1660 | rxvt_term::scr_change_screen (int screen) |
1852 | rxvt_term::scr_change_screen (int screen) |
1661 | |
1853 | |
1662 | void |
1854 | void |
1663 | rxvt_term::scr_add_lines (SV *string) |
1855 | rxvt_term::scr_add_lines (SV *string) |
1664 | CODE: |
1856 | CODE: |
… | |
… | |
1777 | type, format, PropModeReplace, |
1969 | type, format, PropModeReplace, |
1778 | (unsigned char *)data_, len / elemsize); |
1970 | (unsigned char *)data_, len / elemsize); |
1779 | } |
1971 | } |
1780 | |
1972 | |
1781 | Atom |
1973 | Atom |
1782 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1974 | XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE) |
1783 | C_ARGS: term->dpy, atom_name, only_if_exists |
1975 | C_ARGS: term->dpy, atom_name, only_if_exists |
1784 | |
1976 | |
1785 | char * |
1977 | char * |
1786 | XGetAtomName (rxvt_term *term, Atom atom) |
1978 | XGetAtomName (rxvt_term *term, Atom atom) |
1787 | C_ARGS: term->dpy, atom |
1979 | C_ARGS: term->dpy, atom |
1788 | CLEANUP: |
1980 | CLEANUP: |
1789 | XFree (RETVAL); |
1981 | XFree (RETVAL); |
1790 | |
1982 | |
1791 | void |
1983 | void |
1792 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1984 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1793 | C_ARGS: term->dpy, window, property |
1985 | C_ARGS: term->dpy, window, property |
1794 | |
1986 | |
1795 | Window |
1987 | Window |
1796 | rxvt_term::DefaultRootWindow () |
1988 | rxvt_term::DefaultRootWindow () |
1797 | CODE: |
1989 | CODE: |
1798 | RETVAL = THIS->display->root; |
1990 | RETVAL = THIS->display->root; |
… | |
… | |
1850 | PUSHs (newSVuv (child)); |
2042 | PUSHs (newSVuv (child)); |
1851 | } |
2043 | } |
1852 | } |
2044 | } |
1853 | |
2045 | |
1854 | ############################################################################# |
2046 | ############################################################################# |
|
|
2047 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
|
|
2048 | |
|
|
2049 | bool |
|
|
2050 | rxvt_term::has_render () |
|
|
2051 | CODE: |
|
|
2052 | RETVAL = THIS->display->flags & DISPLAY_HAS_RENDER; |
|
|
2053 | OUTPUT: |
|
|
2054 | RETVAL |
|
|
2055 | |
|
|
2056 | void |
|
|
2057 | rxvt_term::background_geometry (bool border = false) |
|
|
2058 | PPCODE: |
|
|
2059 | EXTEND (SP, 4); |
|
|
2060 | PUSHs (sv_2mortal (newSViv (THIS->parent_x + (border ? THIS->window_vt_x : 0)))); |
|
|
2061 | PUSHs (sv_2mortal (newSViv (THIS->parent_y + (border ? THIS->window_vt_y : 0)))); |
|
|
2062 | PUSHs (sv_2mortal (newSViv (border ? THIS->vt_width : THIS->szHint.width ))); |
|
|
2063 | PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height))); |
|
|
2064 | |
|
|
2065 | #if HAVE_IMG |
|
|
2066 | |
|
|
2067 | rxvt_img * |
|
|
2068 | rxvt_term::new_img (SV *format, int width = 1, int height = 1) |
|
|
2069 | CODE: |
|
|
2070 | XRenderPictFormat *f = SvOK (format) |
|
|
2071 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
|
|
2072 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
|
|
2073 | RETVAL = new rxvt_img (THIS, f, 0, 0, width, height); |
|
|
2074 | RETVAL->alloc (); |
|
|
2075 | OUTPUT: |
|
|
2076 | RETVAL |
|
|
2077 | |
|
|
2078 | #if ENABLE_TRANSPARENCY |
|
|
2079 | |
|
|
2080 | rxvt_img * |
|
|
2081 | rxvt_term::new_img_from_root () |
|
|
2082 | CODE: |
|
|
2083 | RETVAL = rxvt_img::new_from_root (THIS); |
|
|
2084 | OUTPUT: |
|
|
2085 | RETVAL |
|
|
2086 | |
|
|
2087 | #endif |
|
|
2088 | |
|
|
2089 | #if HAVE_PIXBUF |
|
|
2090 | |
|
|
2091 | rxvt_img * |
|
|
2092 | rxvt_term::new_img_from_file (octet_string filename) |
|
|
2093 | CODE: |
|
|
2094 | try |
|
|
2095 | { |
|
|
2096 | RETVAL = rxvt_img::new_from_file (THIS, filename); |
|
|
2097 | } |
|
|
2098 | catch (const class rxvt_failure_exception &e) |
|
|
2099 | { |
|
|
2100 | croak ("new_img_from_file failed"); |
|
|
2101 | } |
|
|
2102 | OUTPUT: |
|
|
2103 | RETVAL |
|
|
2104 | |
|
|
2105 | #endif |
|
|
2106 | |
|
|
2107 | #if HAVE_BG_PIXMAP |
|
|
2108 | |
|
|
2109 | void |
|
|
2110 | rxvt_term::set_background (rxvt_img *img, bool border = false) |
|
|
2111 | CODE: |
|
|
2112 | THIS->bg_destroy (); |
|
|
2113 | THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT); |
|
|
2114 | |
|
|
2115 | if (img) // TODO: cannot be false |
|
|
2116 | { |
|
|
2117 | img = img->clone (); // own the img |
|
|
2118 | |
|
|
2119 | if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap |
|
|
2120 | img->sub_rect (0, 0, |
|
|
2121 | border ? THIS->vt_width : THIS->szHint.width, |
|
|
2122 | border ? THIS->vt_height : THIS->szHint.height) |
|
|
2123 | ->replace (img); |
|
|
2124 | |
|
|
2125 | // just in case, should usually be a nop |
|
|
2126 | img->reify () |
|
|
2127 | ->replace (img); |
|
|
2128 | |
|
|
2129 | img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]) |
|
|
2130 | ->replace (img); |
|
|
2131 | |
|
|
2132 | THIS->bg_img = img; |
|
|
2133 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; |
|
|
2134 | |
|
|
2135 | if (!border) |
|
|
2136 | THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; |
|
|
2137 | } |
|
|
2138 | |
|
|
2139 | #endif |
|
|
2140 | |
|
|
2141 | #endif |
|
|
2142 | |
|
|
2143 | ############################################################################# |
1855 | # urxvt::overlay |
2144 | # urxvt::overlay |
1856 | ############################################################################# |
2145 | ############################################################################# |
1857 | |
2146 | |
1858 | MODULE = urxvt PACKAGE = urxvt::overlay |
2147 | MODULE = urxvt PACKAGE = urxvt::overlay |
1859 | |
2148 | |
… | |
… | |
1869 | void |
2158 | void |
1870 | overlay::DESTROY () |
2159 | overlay::DESTROY () |
1871 | |
2160 | |
1872 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
2161 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1873 | |
2162 | |
|
|
2163 | MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_ |
|
|
2164 | |
|
|
2165 | #if HAVE_PIXBUF |
|
|
2166 | |
|
|
2167 | urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename) |
|
|
2168 | C_ARGS: filename, 0 |
|
|
2169 | |
|
|
2170 | void |
|
|
2171 | DESTROY (urxvt::pixbuf self) |
|
|
2172 | CODE: |
|
|
2173 | gdk_pixbuf_unref (self); |
|
|
2174 | |
|
|
2175 | #endif |
|
|
2176 | |
|
|
2177 | MODULE = urxvt PACKAGE = urxvt::img |
|
|
2178 | |
|
|
2179 | #if HAVE_IMG |
|
|
2180 | |
|
|
2181 | # rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
|
|
2182 | # rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
|
|
2183 | |
|
|
2184 | int |
|
|
2185 | rxvt_img::w () |
|
|
2186 | CODE: |
|
|
2187 | RETVAL = THIS->w; |
|
|
2188 | OUTPUT: |
|
|
2189 | RETVAL |
|
|
2190 | |
|
|
2191 | int |
|
|
2192 | rxvt_img::h () |
|
|
2193 | CODE: |
|
|
2194 | RETVAL = THIS->h; |
|
|
2195 | OUTPUT: |
|
|
2196 | RETVAL |
|
|
2197 | |
|
|
2198 | Pixmap |
|
|
2199 | rxvt_img::pm () |
|
|
2200 | CODE: |
|
|
2201 | RETVAL = THIS->pm; |
|
|
2202 | OUTPUT: |
|
|
2203 | RETVAL |
|
|
2204 | |
|
|
2205 | void |
|
|
2206 | rxvt_img::fill (SV *c) |
|
|
2207 | INIT: |
|
|
2208 | rxvt_color rc; |
|
|
2209 | parse_color (THIS->s, rc, c); |
|
|
2210 | C_ARGS: rc |
|
|
2211 | |
|
|
2212 | void |
|
|
2213 | rxvt_img::DESTROY () |
|
|
2214 | CODE: |
|
|
2215 | delete THIS; |
|
|
2216 | |
|
|
2217 | void |
|
|
2218 | rxvt_img::unshare () |
|
|
2219 | |
|
|
2220 | int |
|
|
2221 | rxvt_img::repeat_mode (render_repeat_mode repeat = 0) |
|
|
2222 | CODE: |
|
|
2223 | if (items >= 2) |
|
|
2224 | THIS->repeat_mode (repeat); |
|
|
2225 | if (GIMME_V != G_VOID) |
|
|
2226 | XPUSHs (sv_2mortal (newSViv (THIS->repeat))); |
|
|
2227 | |
|
|
2228 | void |
|
|
2229 | rxvt_img::move (int dx, int dy) |
|
|
2230 | |
|
|
2231 | void |
|
|
2232 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2233 | |
|
|
2234 | void |
|
|
2235 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2236 | |
|
|
2237 | rxvt_img * |
|
|
2238 | rxvt_img::clone () |
|
|
2239 | |
|
|
2240 | rxvt_img * |
|
|
2241 | rxvt_img::reify () |
|
|
2242 | |
|
|
2243 | rxvt_img * |
|
|
2244 | rxvt_img::sub_rect (int x, int y, int width, int height) |
|
|
2245 | |
|
|
2246 | rxvt_img * |
|
|
2247 | rxvt_img::blur (int rh, int rv) |
|
|
2248 | |
|
|
2249 | rxvt_img * |
|
|
2250 | rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) |
|
|
2251 | INIT: |
|
|
2252 | double matrix[3][3] = { |
|
|
2253 | { p11, p12, p13 }, |
|
|
2254 | { p21, p22, p23 }, |
|
|
2255 | { p31, p32, p33 } |
|
|
2256 | }; |
|
|
2257 | C_ARGS: matrix |
|
|
2258 | |
|
|
2259 | rxvt_img * |
|
|
2260 | rxvt_img::scale (int new_width, int new_height) |
|
|
2261 | |
|
|
2262 | rxvt_img * |
|
|
2263 | rxvt_img::rotate (int x, int y, NV phi) |
|
|
2264 | |
|
|
2265 | #endif |
|
|
2266 | |