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 |
… | |
… | |
639 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
743 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
640 | # include "hookinc.h" |
744 | # include "hookinc.h" |
641 | # undef def |
745 | # undef def |
642 | |
746 | |
643 | HV *option = get_hv ("urxvt::OPTION", 1); |
747 | HV *option = get_hv ("urxvt::OPTION", 1); |
644 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
748 | # define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
645 | # define nodef(name) |
749 | # define nodef(name) |
646 | # include "optinc.h" |
750 | # include "optinc.h" |
647 | # undef nodef |
751 | # undef nodef |
648 | # undef def |
752 | # undef def |
649 | |
753 | |
… | |
… | |
654 | } *civ, const_iv[] = { |
758 | } *civ, const_iv[] = { |
655 | # define const_iv(name) { # name, (IV)name } |
759 | # define const_iv(name) { # name, (IV)name } |
656 | const_iv (NUM_RESOURCES), |
760 | const_iv (NUM_RESOURCES), |
657 | const_iv (DEFAULT_RSTYLE), |
761 | const_iv (DEFAULT_RSTYLE), |
658 | const_iv (OVERLAY_RSTYLE), |
762 | const_iv (OVERLAY_RSTYLE), |
|
|
763 | const_iv (Color_Bits), |
|
|
764 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
|
|
765 | const_iv (RS_fgShift), const_iv (RS_fgMask), |
|
|
766 | const_iv (RS_Careful), |
|
|
767 | const_iv (RS_fontCount), |
|
|
768 | const_iv (RS_fontShift), |
|
|
769 | const_iv (RS_fontMask), |
|
|
770 | const_iv (RS_baseattrMask), |
|
|
771 | const_iv (RS_attrMask), |
|
|
772 | const_iv (RS_redraw), |
|
|
773 | const_iv (RS_Sel), |
659 | const_iv (RS_Bold), |
774 | const_iv (RS_Bold), |
660 | const_iv (RS_Italic), |
775 | const_iv (RS_Italic), |
661 | const_iv (RS_Blink), |
776 | const_iv (RS_Blink), |
662 | const_iv (RS_RVid), |
777 | const_iv (RS_RVid), |
663 | const_iv (RS_Uline), |
778 | const_iv (RS_Uline), |
… | |
… | |
750 | const_iv (XIMSecondary), |
865 | const_iv (XIMSecondary), |
751 | const_iv (XIMTertiary), |
866 | const_iv (XIMTertiary), |
752 | const_iv (XIMVisibleToForward), |
867 | const_iv (XIMVisibleToForward), |
753 | const_iv (XIMVisibleToBackword), |
868 | const_iv (XIMVisibleToBackword), |
754 | 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 |
755 | # if 0 |
881 | # if 0 |
756 | const_iv (XIMForwardChar), |
882 | const_iv (XIMForwardChar), |
757 | const_iv (XIMBackwardChar), |
883 | const_iv (XIMBackwardChar), |
758 | const_iv (XIMForwardWord), |
884 | const_iv (XIMForwardWord), |
759 | const_iv (XIMBackwardWord), |
885 | const_iv (XIMBackwardWord), |
… | |
… | |
767 | const_iv (XIMDontChange), |
893 | const_iv (XIMDontChange), |
768 | # endif |
894 | # endif |
769 | # endif |
895 | # endif |
770 | }; |
896 | }; |
771 | |
897 | |
772 | 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--) |
773 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
899 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
774 | } |
900 | } |
|
|
901 | |
|
|
902 | void |
|
|
903 | log (const char *msg) |
|
|
904 | CODE: |
|
|
905 | rxvt_log ("%s", msg); |
775 | |
906 | |
776 | void |
907 | void |
777 | warn (const char *msg) |
908 | warn (const char *msg) |
778 | CODE: |
909 | CODE: |
779 | rxvt_warn ("%s", msg); |
910 | rxvt_warn ("%s", msg); |
… | |
… | |
783 | CODE: |
914 | CODE: |
784 | rxvt_fatal ("%s", msg); |
915 | rxvt_fatal ("%s", msg); |
785 | |
916 | |
786 | void |
917 | void |
787 | _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 | } |
788 | |
935 | |
789 | NV |
936 | NV |
790 | NOW () |
937 | NOW () |
791 | CODE: |
938 | CODE: |
792 | RETVAL = ev::now (); |
939 | RETVAL = ev::now (); |
… | |
… | |
850 | 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++) |
851 | if ((*t)->perl.self) |
998 | if ((*t)->perl.self) |
852 | PUSHs (sv_2mortal (newSVterm (*t))); |
999 | PUSHs (sv_2mortal (newSVterm (*t))); |
853 | } |
1000 | } |
854 | |
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 | |
855 | MODULE = urxvt PACKAGE = urxvt::term |
1031 | MODULE = urxvt PACKAGE = urxvt::term |
856 | |
1032 | |
857 | SV * |
1033 | SV * |
858 | _new (AV *env, AV *arg) |
1034 | _new (AV *env, AV *arg) |
859 | CODE: |
1035 | CODE: |
860 | { |
1036 | { |
861 | rxvt_term *term = new rxvt_term; |
1037 | rxvt_term *term = new rxvt_term; |
862 | |
1038 | |
863 | stringvec *argv = new stringvec; |
1039 | stringvec *argv = new stringvec; |
864 | stringvec *envv = new stringvec; |
|
|
865 | |
|
|
866 | for (int i = 0; i <= AvFILL (arg); i++) |
1040 | for (int i = 0; i <= AvFILL (arg); i++) |
867 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
1041 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
868 | |
1042 | |
|
|
1043 | stringvec *envv = new stringvec; |
869 | for (int i = AvFILL (env) + 1; i--; ) |
1044 | for (int i = AvFILL (env) + 1; i--; ) |
870 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
1045 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
871 | |
1046 | |
872 | envv->push_back (0); |
|
|
873 | |
|
|
874 | try |
1047 | try |
875 | { |
1048 | { |
876 | term->init (argv, envv); |
1049 | term->init (argv, envv); |
877 | } |
1050 | } |
878 | catch (const class rxvt_failure_exception &e) |
1051 | catch (const class rxvt_failure_exception &e) |
… | |
… | |
891 | rxvt_term::destroy () |
1064 | rxvt_term::destroy () |
892 | |
1065 | |
893 | void |
1066 | void |
894 | rxvt_term::set_should_invoke (int htype, int inc) |
1067 | rxvt_term::set_should_invoke (int htype, int inc) |
895 | CODE: |
1068 | CODE: |
896 | 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); |
897 | |
1087 | |
898 | int |
1088 | int |
899 | 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) |
900 | CODE: |
1090 | CODE: |
901 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1091 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
… | |
… | |
917 | |
1107 | |
918 | void |
1108 | void |
919 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
1109 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
920 | CODE: |
1110 | CODE: |
921 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
1111 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
922 | |
|
|
923 | void |
|
|
924 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
925 | CODE: |
|
|
926 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
927 | |
1112 | |
928 | bool |
1113 | bool |
929 | rxvt_term::grab (Time eventtime, int sync = 0) |
1114 | rxvt_term::grab (Time eventtime, int sync = 0) |
930 | CODE: |
1115 | CODE: |
931 | { |
1116 | { |
… | |
… | |
1043 | rxvt_pop_locale (); |
1228 | rxvt_pop_locale (); |
1044 | |
1229 | |
1045 | RETVAL = wcs2sv (wstr); |
1230 | RETVAL = wcs2sv (wstr); |
1046 | free (wstr); |
1231 | free (wstr); |
1047 | } |
1232 | } |
1048 | OUTPUT: |
|
|
1049 | RETVAL |
|
|
1050 | |
|
|
1051 | char * |
|
|
1052 | rxvt_term::locale () |
|
|
1053 | CODE: |
|
|
1054 | RETVAL = THIS->locale; |
|
|
1055 | OUTPUT: |
1233 | OUTPUT: |
1056 | RETVAL |
1234 | RETVAL |
1057 | |
1235 | |
1058 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1236 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1059 | |
1237 | |
… | |
… | |
1166 | RETVAL |
1344 | RETVAL |
1167 | |
1345 | |
1168 | Window |
1346 | Window |
1169 | rxvt_term::parent () |
1347 | rxvt_term::parent () |
1170 | CODE: |
1348 | CODE: |
1171 | RETVAL = THIS->parent [0]; |
1349 | RETVAL = THIS->parent; |
1172 | OUTPUT: |
1350 | OUTPUT: |
1173 | RETVAL |
1351 | RETVAL |
1174 | |
1352 | |
1175 | Window |
1353 | int |
1176 | rxvt_term::vt () |
1354 | rxvt_term::parent_x () |
1177 | CODE: |
1355 | CODE: |
1178 | 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; |
1179 | OUTPUT: |
1364 | OUTPUT: |
1180 | RETVAL |
1365 | RETVAL |
1181 | |
1366 | |
1182 | void |
1367 | void |
1183 | rxvt_term::vt_emask_add (U32 emask) |
1368 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1203 | if (newval <= 0) |
1388 | if (newval <= 0) |
1204 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1389 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1205 | } |
1390 | } |
1206 | OUTPUT: |
1391 | OUTPUT: |
1207 | RETVAL |
1392 | RETVAL |
|
|
1393 | |
|
|
1394 | void |
|
|
1395 | rxvt_term::set_urgency (bool enable) |
1208 | |
1396 | |
1209 | void |
1397 | void |
1210 | rxvt_term::focus_in () |
1398 | rxvt_term::focus_in () |
1211 | |
1399 | |
1212 | void |
1400 | void |
… | |
… | |
1445 | # include "rsinc.h" |
1633 | # include "rsinc.h" |
1446 | # undef def |
1634 | # undef def |
1447 | # undef reserve |
1635 | # undef reserve |
1448 | }; |
1636 | }; |
1449 | |
1637 | |
1450 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1638 | rs = rslist + ecb_array_length (rslist); |
1451 | |
1639 | |
1452 | if (*name) |
1640 | if (*name) |
1453 | { |
1641 | { |
1454 | do { |
1642 | do { |
1455 | if (rs-- == rslist) |
1643 | if (rs-- == rslist) |
… | |
… | |
1494 | |
1682 | |
1495 | if (set >= 0) |
1683 | if (set >= 0) |
1496 | { |
1684 | { |
1497 | THIS->set_option (optval, set); |
1685 | THIS->set_option (optval, set); |
1498 | |
1686 | |
1499 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1687 | if (THIS->init_done) // avoid doing this before START |
1500 | switch (optval) |
1688 | switch (optval) |
1501 | { |
1689 | { |
1502 | case Opt_skipBuiltinGlyphs: |
1690 | case Opt_skipBuiltinGlyphs: |
1503 | THIS->set_fonts (); |
1691 | THIS->set_fonts (); |
1504 | THIS->scr_remap_chars (); |
1692 | THIS->scr_remap_chars (); |
1505 | THIS->scr_touch (true); |
1693 | THIS->scr_touch (true); |
1506 | THIS->want_refresh = 1; |
1694 | THIS->want_refresh = 1; |
1507 | THIS->refresh_check (); |
1695 | THIS->refresh_check (); |
1508 | break; |
1696 | break; |
|
|
1697 | #ifdef CURSOR_BLINK |
|
|
1698 | case Opt_cursorBlink: |
|
|
1699 | THIS->cursor_blink_reset (); |
|
|
1700 | break; |
|
|
1701 | #endif |
1509 | |
1702 | |
1510 | case Opt_cursorUnderline: |
1703 | case Opt_cursorUnderline: |
1511 | THIS->want_refresh = 1; |
1704 | THIS->want_refresh = 1; |
1512 | THIS->refresh_check (); |
1705 | THIS->refresh_check (); |
1513 | break; |
1706 | break; |
… | |
… | |
1527 | CODE: |
1720 | CODE: |
1528 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1721 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1529 | THIS->keyboard->register_done (); |
1722 | THIS->keyboard->register_done (); |
1530 | OUTPUT: |
1723 | OUTPUT: |
1531 | 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); |
1532 | |
1732 | |
1533 | void |
1733 | void |
1534 | rxvt_term::screen_cur (...) |
1734 | rxvt_term::screen_cur (...) |
1535 | PROTOTYPE: $;$$ |
1735 | PROTOTYPE: $;$$ |
1536 | ALIAS: |
1736 | ALIAS: |
… | |
… | |
1597 | |
1797 | |
1598 | void |
1798 | void |
1599 | rxvt_term::selection_clear (bool clipboard = false) |
1799 | rxvt_term::selection_clear (bool clipboard = false) |
1600 | |
1800 | |
1601 | void |
1801 | void |
1602 | rxvt_term::clipboard_copy (Time eventtime) |
|
|
1603 | |
|
|
1604 | void |
|
|
1605 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1802 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1606 | CODE: |
1803 | CODE: |
1607 | THIS->selection.op = SELECTION_CONT; |
1804 | THIS->selection.op = SELECTION_CONT; |
1608 | THIS->selection.rect = rect; |
1805 | THIS->selection.rect = rect; |
1609 | THIS->selection_make (eventtime); |
1806 | THIS->selection_make (eventtime); |
1610 | |
1807 | |
1611 | int |
1808 | int |
1612 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1809 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1613 | |
1810 | |
1614 | void |
1811 | void |
1615 | rxvt_term::selection (SV *newtext = 0) |
1812 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1616 | PPCODE: |
1813 | PPCODE: |
1617 | { |
1814 | { |
|
|
1815 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1816 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1817 | |
1618 | if (GIMME_V != G_VOID) |
1818 | if (GIMME_V != G_VOID) |
1619 | XPUSHs (THIS->selection.text |
1819 | XPUSHs (text |
1620 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1820 | ? sv_2mortal (wcs2sv (text, len)) |
1621 | : &PL_sv_undef); |
1821 | : &PL_sv_undef); |
1622 | |
1822 | |
1623 | if (newtext) |
1823 | if (newtext) |
1624 | { |
1824 | { |
1625 | free (THIS->selection.text); |
1825 | free (text); |
1626 | |
1826 | |
1627 | THIS->selection.text = sv2wcs (newtext); |
1827 | text = sv2wcs (newtext); |
1628 | THIS->selection.len = wcslen (THIS->selection.text); |
1828 | len = wcslen (text); |
1629 | } |
1829 | } |
1630 | } |
1830 | } |
1631 | |
1831 | |
1632 | char |
1832 | char |
1633 | rxvt_term::cur_charset () |
1833 | rxvt_term::cur_charset () |
… | |
… | |
1642 | void |
1842 | void |
1643 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1843 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1644 | |
1844 | |
1645 | void |
1845 | void |
1646 | rxvt_term::scr_bell () |
1846 | rxvt_term::scr_bell () |
|
|
1847 | |
|
|
1848 | void |
|
|
1849 | rxvt_term::scr_recolour (bool refresh = true); |
1647 | |
1850 | |
1648 | void |
1851 | void |
1649 | rxvt_term::scr_change_screen (int screen) |
1852 | rxvt_term::scr_change_screen (int screen) |
1650 | |
1853 | |
1651 | void |
1854 | void |
… | |
… | |
1664 | char *str = SvPVbyte (octets, len); |
1867 | char *str = SvPVbyte (octets, len); |
1665 | C_ARGS: |
1868 | C_ARGS: |
1666 | str, len |
1869 | str, len |
1667 | |
1870 | |
1668 | void |
1871 | void |
|
|
1872 | rxvt_term::tt_paste (SV *octets) |
|
|
1873 | INIT: |
|
|
1874 | STRLEN len; |
|
|
1875 | char *str = SvPVbyte (octets, len); |
|
|
1876 | C_ARGS: |
|
|
1877 | str, len |
|
|
1878 | |
|
|
1879 | void |
1669 | rxvt_term::cmd_parse (SV *octets) |
1880 | rxvt_term::cmd_parse (SV *octets) |
1670 | CODE: |
1881 | CODE: |
1671 | { |
1882 | { |
1672 | STRLEN len; |
1883 | STRLEN len; |
1673 | char *str = SvPVbyte (octets, len); |
1884 | char *str = SvPVbyte (octets, len); |
… | |
… | |
1758 | type, format, PropModeReplace, |
1969 | type, format, PropModeReplace, |
1759 | (unsigned char *)data_, len / elemsize); |
1970 | (unsigned char *)data_, len / elemsize); |
1760 | } |
1971 | } |
1761 | |
1972 | |
1762 | Atom |
1973 | Atom |
1763 | 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) |
1764 | C_ARGS: term->dpy, atom_name, only_if_exists |
1975 | C_ARGS: term->dpy, atom_name, only_if_exists |
1765 | |
1976 | |
1766 | char * |
1977 | char * |
1767 | XGetAtomName (rxvt_term *term, Atom atom) |
1978 | XGetAtomName (rxvt_term *term, Atom atom) |
1768 | C_ARGS: term->dpy, atom |
1979 | C_ARGS: term->dpy, atom |
1769 | CLEANUP: |
1980 | CLEANUP: |
1770 | XFree (RETVAL); |
1981 | XFree (RETVAL); |
1771 | |
1982 | |
1772 | void |
1983 | void |
1773 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1984 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1774 | C_ARGS: term->dpy, window, property |
1985 | C_ARGS: term->dpy, window, property |
1775 | |
1986 | |
1776 | Window |
1987 | Window |
1777 | rxvt_term::DefaultRootWindow () |
1988 | rxvt_term::DefaultRootWindow () |
1778 | CODE: |
1989 | CODE: |
1779 | RETVAL = THIS->display->root; |
1990 | RETVAL = THIS->display->root; |
… | |
… | |
1831 | PUSHs (newSVuv (child)); |
2042 | PUSHs (newSVuv (child)); |
1832 | } |
2043 | } |
1833 | } |
2044 | } |
1834 | |
2045 | |
1835 | ############################################################################# |
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 | ############################################################################# |
1836 | # urxvt::overlay |
2144 | # urxvt::overlay |
1837 | ############################################################################# |
2145 | ############################################################################# |
1838 | |
2146 | |
1839 | MODULE = urxvt PACKAGE = urxvt::overlay |
2147 | MODULE = urxvt PACKAGE = urxvt::overlay |
1840 | |
2148 | |
… | |
… | |
1850 | void |
2158 | void |
1851 | overlay::DESTROY () |
2159 | overlay::DESTROY () |
1852 | |
2160 | |
1853 | 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 | |
1854 | |
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, int new_width = 0, int new_height = 0) |
|
|
2251 | INIT: |
|
|
2252 | double matrix[9] = { |
|
|
2253 | p11, p12, p13, |
|
|
2254 | p21, p22, p23, |
|
|
2255 | p31, p32, p33 |
|
|
2256 | }; |
|
|
2257 | C_ARGS: matrix, new_width, new_height |
|
|
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, int new_width = 0, int new_height = 0) |
|
|
2264 | |
|
|
2265 | #endif |
|
|
2266 | |