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 GdkPixbuf * urxvt__pixbuf; |
|
|
58 | typedef rxvt_img * urxvt__img; |
50 | |
59 | |
51 | ///////////////////////////////////////////////////////////////////////////// |
60 | ///////////////////////////////////////////////////////////////////////////// |
52 | |
61 | |
53 | static wchar_t * |
62 | static wchar_t * |
54 | sv2wcs (SV *sv) |
63 | sv2wcs (SV *sv) |
… | |
… | |
302 | THIS->refresh_check (); |
311 | THIS->refresh_check (); |
303 | } |
312 | } |
304 | |
313 | |
305 | ///////////////////////////////////////////////////////////////////////////// |
314 | ///////////////////////////////////////////////////////////////////////////// |
306 | |
315 | |
307 | #define IOM_CLASS "urxvt" |
|
|
308 | #define IOM_WARN rxvt_warn |
|
|
309 | #include "iom_perl.h" |
316 | #include "iom_perl.h" |
310 | |
317 | |
311 | ///////////////////////////////////////////////////////////////////////////// |
318 | ///////////////////////////////////////////////////////////////////////////// |
312 | |
319 | |
313 | struct rxvt_perl_interp rxvt_perl; |
320 | struct rxvt_perl_interp rxvt_perl; |
… | |
… | |
329 | { |
336 | { |
330 | if (!perl) |
337 | if (!perl) |
331 | { |
338 | { |
332 | rxvt_push_locale (""); // perl init destroys current locale |
339 | rxvt_push_locale (""); // perl init destroys current locale |
333 | |
340 | |
|
|
341 | { |
334 | perl_environ = rxvt_environ; |
342 | perl_environ = rxvt_environ; |
335 | swap (perl_environ, environ); |
343 | localise_env set_environ (perl_environ); |
336 | |
344 | |
337 | char *args[] = { |
345 | char *args[] = { |
338 | "", |
346 | "", |
339 | "-e" |
347 | "-e" |
340 | "BEGIN {" |
348 | "BEGIN {" |
341 | " urxvt->bootstrap;" |
349 | " urxvt->bootstrap;" |
342 | " unshift @INC, '" LIBDIR "';" |
350 | " unshift @INC, '" LIBDIR "';" |
343 | "}" |
351 | "}" |
344 | "" |
352 | "" |
345 | "use urxvt;" |
353 | "use urxvt;" |
346 | }; |
354 | }; |
347 | int argc = sizeof (args) / sizeof (args[0]); |
355 | int argc = ecb_array_length (args); |
348 | char **argv = args; |
356 | char **argv = args; |
349 | |
357 | |
350 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
358 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
351 | perl = perl_alloc (); |
359 | perl = perl_alloc (); |
352 | perl_construct (perl); |
360 | perl_construct (perl); |
353 | |
361 | |
354 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
362 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
355 | || perl_run (perl)) |
363 | || perl_run (perl)) |
356 | { |
364 | { |
357 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
365 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
358 | |
366 | |
359 | perl_destruct (perl); |
367 | perl_destruct (perl); |
360 | perl_free (perl); |
368 | perl_free (perl); |
361 | perl = 0; |
369 | perl = 0; |
362 | } |
370 | } |
363 | |
371 | } |
364 | swap (perl_environ, environ); |
|
|
365 | |
372 | |
366 | rxvt_pop_locale (); |
373 | rxvt_pop_locale (); |
367 | } |
374 | } |
368 | |
375 | |
369 | if (perl) |
376 | if (perl) |
370 | { |
377 | { |
371 | // runs outside of perls ENV |
378 | // runs outside of perls ENV |
372 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
379 | 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); |
380 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
381 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
374 | } |
382 | } |
375 | } |
383 | } |
376 | |
384 | |
377 | static void |
385 | static void |
378 | ungrab (rxvt_term *THIS) |
386 | ungrab (rxvt_term *THIS) |
… | |
… | |
389 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
397 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
390 | { |
398 | { |
391 | if (!perl || !term->perl.self) |
399 | if (!perl || !term->perl.self) |
392 | return false; |
400 | return false; |
393 | |
401 | |
|
|
402 | localise_env set_environ (perl_environ); |
|
|
403 | |
394 | // pre-handling of some events |
404 | // pre-handling of some events |
395 | if (htype == HOOK_REFRESH_END) |
405 | if (htype == HOOK_REFRESH_END) |
396 | { |
406 | { |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
407 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | |
408 | |
399 | for (int i = 0; i <= AvFILL (av); i++) |
409 | for (int i = 0; i <= AvFILL (av); i++) |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
410 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
401 | } |
411 | } |
|
|
412 | else if (htype == HOOK_DESTROY) |
|
|
413 | { |
|
|
414 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
402 | |
415 | |
403 | swap (perl_environ, environ); |
416 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
417 | { |
|
|
418 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
419 | delete req; |
|
|
420 | } |
|
|
421 | } |
404 | |
422 | |
405 | bool event_consumed; |
423 | bool event_consumed; |
406 | |
424 | |
407 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
425 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
408 | || term->perl.should_invoke [htype]) |
426 | || term->perl.should_invoke [htype]) |
409 | try |
|
|
410 | { |
427 | { |
411 | dSP; |
428 | dSP; |
412 | va_list ap; |
429 | va_list ap; |
413 | |
430 | |
414 | va_start (ap, htype); |
431 | va_start (ap, htype); |
415 | |
432 | |
416 | ENTER; |
433 | ENTER; |
417 | SAVETMPS; |
434 | SAVETMPS; |
418 | |
435 | |
419 | PUSHMARK (SP); |
436 | PUSHMARK (SP); |
420 | |
437 | |
|
|
438 | EXTEND (SP, 2); |
421 | XPUSHs (sv_2mortal (newSVterm (term))); |
439 | PUSHs (sv_2mortal (newSVterm (term))); |
422 | XPUSHs (sv_2mortal (newSViv (htype))); |
440 | PUSHs (sv_2mortal (newSViv (htype))); |
423 | |
441 | |
424 | for (;;) { |
442 | for (;;) { |
425 | data_type dt = (data_type)va_arg (ap, int); |
443 | data_type dt = (data_type)va_arg (ap, int); |
426 | |
444 | |
427 | switch (dt) |
445 | switch (dt) |
428 | { |
446 | { |
429 | case DT_INT: |
447 | case DT_INT: |
430 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
448 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
431 | break; |
449 | break; |
432 | |
450 | |
433 | case DT_LONG: |
451 | case DT_LONG: |
434 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
452 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
435 | break; |
453 | break; |
436 | |
454 | |
437 | case DT_STR: |
455 | case DT_STR: |
438 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
456 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
439 | break; |
457 | break; |
440 | |
458 | |
441 | case DT_STR_LEN: |
459 | case DT_STR_LEN: |
442 | { |
460 | { |
443 | char *str = va_arg (ap, char *); |
461 | char *str = va_arg (ap, char *); |
444 | int len = va_arg (ap, int); |
462 | int len = va_arg (ap, int); |
445 | |
463 | |
446 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
464 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
447 | } |
465 | } |
448 | break; |
466 | break; |
449 | |
467 | |
450 | case DT_WCS_LEN: |
468 | case DT_WCS_LEN: |
451 | { |
469 | { |
452 | wchar_t *wstr = va_arg (ap, wchar_t *); |
470 | wchar_t *wstr = va_arg (ap, wchar_t *); |
453 | int wlen = va_arg (ap, int); |
471 | int wlen = va_arg (ap, int); |
454 | |
472 | |
455 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
473 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
456 | } |
474 | } |
457 | break; |
475 | break; |
458 | |
476 | |
459 | case DT_LCS_LEN: |
477 | case DT_LCS_LEN: |
460 | { |
478 | { |
461 | long *lstr = va_arg (ap, long *); |
479 | long *lstr = va_arg (ap, long *); |
462 | int llen = va_arg (ap, int); |
480 | int llen = va_arg (ap, int); |
463 | |
481 | |
464 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
482 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
465 | } |
483 | } |
466 | break; |
484 | break; |
467 | |
485 | |
468 | case DT_XEVENT: |
486 | case DT_XEVENT: |
469 | { |
487 | { |
470 | XEvent *xe = va_arg (ap, XEvent *); |
488 | XEvent *xe = va_arg (ap, XEvent *); |
471 | HV *hv = newHV (); |
489 | HV *hv = newHV (); |
472 | |
490 | |
473 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
491 | # 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) |
492 | # 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) |
493 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
476 | # undef set |
494 | # undef set |
477 | |
495 | |
478 | setiv (type, xe->type); |
496 | setiv (type, xe->type); |
479 | setiv (send_event, xe->xany.send_event); |
497 | setiv (send_event, xe->xany.send_event); |
480 | setiv (serial, xe->xany.serial); |
498 | setiv (serial, xe->xany.serial); |
481 | |
499 | |
482 | switch (xe->type) |
500 | switch (xe->type) |
483 | { |
501 | { |
484 | case KeyPress: |
502 | case KeyPress: |
485 | case KeyRelease: |
503 | case KeyRelease: |
486 | case ButtonPress: |
504 | case ButtonPress: |
487 | case ButtonRelease: |
505 | case ButtonRelease: |
488 | case MotionNotify: |
506 | case MotionNotify: |
489 | setuv (window, xe->xmotion.window); |
507 | setuv (window, xe->xmotion.window); |
490 | setuv (root, xe->xmotion.root); |
508 | setuv (root, xe->xmotion.root); |
491 | setuv (subwindow, xe->xmotion.subwindow); |
509 | setuv (subwindow, xe->xmotion.subwindow); |
492 | setuv (time, xe->xmotion.time); |
510 | setuv (time, xe->xmotion.time); |
493 | setiv (x, xe->xmotion.x); |
511 | setiv (x, xe->xmotion.x); |
494 | setiv (y, xe->xmotion.y); |
512 | setiv (y, xe->xmotion.y); |
495 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
513 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
496 | setiv (col, xe->xmotion.x / term->fwidth); |
514 | setiv (col, xe->xmotion.x / term->fwidth); |
497 | setiv (x_root, xe->xmotion.x_root); |
515 | setiv (x_root, xe->xmotion.x_root); |
498 | setiv (y_root, xe->xmotion.y_root); |
516 | setiv (y_root, xe->xmotion.y_root); |
499 | setuv (state, xe->xmotion.state); |
517 | setuv (state, xe->xmotion.state); |
500 | |
518 | |
501 | switch (xe->type) |
519 | switch (xe->type) |
502 | { |
520 | { |
503 | case KeyPress: |
521 | case KeyPress: |
504 | case KeyRelease: |
522 | case KeyRelease: |
505 | setuv (keycode, xe->xkey.keycode); |
523 | setuv (keycode, xe->xkey.keycode); |
506 | break; |
524 | break; |
507 | |
525 | |
508 | case ButtonPress: |
526 | case ButtonPress: |
509 | case ButtonRelease: |
527 | case ButtonRelease: |
510 | setuv (button, xe->xbutton.button); |
528 | setuv (button, xe->xbutton.button); |
511 | break; |
529 | break; |
512 | |
530 | |
513 | case MotionNotify: |
531 | case MotionNotify: |
514 | setiv (is_hint, xe->xmotion.is_hint); |
532 | setiv (is_hint, xe->xmotion.is_hint); |
515 | break; |
533 | break; |
516 | } |
534 | } |
517 | |
535 | |
518 | break; |
536 | break; |
519 | |
537 | |
520 | case MapNotify: |
538 | case MapNotify: |
521 | case UnmapNotify: |
539 | case UnmapNotify: |
522 | case ConfigureNotify: |
540 | case ConfigureNotify: |
523 | setuv (event, xe->xconfigure.event); |
541 | setuv (event, xe->xconfigure.event); |
524 | setuv (window, xe->xconfigure.window); |
542 | setuv (window, xe->xconfigure.window); |
525 | |
543 | |
526 | switch (xe->type) |
544 | switch (xe->type) |
527 | { |
545 | { |
528 | case ConfigureNotify: |
546 | case ConfigureNotify: |
529 | setiv (x, xe->xconfigure.x); |
547 | setiv (x, xe->xconfigure.x); |
530 | setiv (y, xe->xconfigure.y); |
548 | setiv (y, xe->xconfigure.y); |
531 | setiv (width, xe->xconfigure.width); |
549 | setiv (width, xe->xconfigure.width); |
532 | setiv (height, xe->xconfigure.height); |
550 | setiv (height, xe->xconfigure.height); |
533 | setuv (above, xe->xconfigure.above); |
551 | setuv (above, xe->xconfigure.above); |
534 | break; |
552 | break; |
535 | } |
553 | } |
536 | |
554 | |
537 | break; |
555 | break; |
538 | |
556 | |
539 | case PropertyNotify: |
557 | case PropertyNotify: |
540 | setuv (window, xe->xproperty.window); |
558 | setuv (window, xe->xproperty.window); |
541 | setuv (atom, xe->xproperty.atom); |
559 | setuv (atom, xe->xproperty.atom); |
542 | setuv (time, xe->xproperty.time); |
560 | setuv (time, xe->xproperty.time); |
543 | setiv (state, xe->xproperty.state); |
561 | setiv (state, xe->xproperty.state); |
544 | break; |
562 | break; |
545 | |
563 | |
546 | case ClientMessage: |
564 | case ClientMessage: |
547 | setuv (window, xe->xclient.window); |
565 | setuv (window, xe->xclient.window); |
548 | setuv (message_type, xe->xclient.message_type); |
566 | setuv (message_type, xe->xclient.message_type); |
549 | setuv (format, xe->xclient.format); |
567 | setuv (format, xe->xclient.format); |
550 | setuv (l0, xe->xclient.data.l[0]); |
568 | setuv (l0, xe->xclient.data.l[0]); |
551 | setuv (l1, xe->xclient.data.l[1]); |
569 | setuv (l1, xe->xclient.data.l[1]); |
552 | setuv (l2, xe->xclient.data.l[2]); |
570 | setuv (l2, xe->xclient.data.l[2]); |
553 | setuv (l3, xe->xclient.data.l[3]); |
571 | setuv (l3, xe->xclient.data.l[3]); |
554 | setuv (l4, xe->xclient.data.l[4]); |
572 | setuv (l4, xe->xclient.data.l[4]); |
555 | break; |
573 | break; |
556 | } |
574 | } |
557 | |
575 | |
558 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
576 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
559 | } |
577 | } |
560 | break; |
578 | break; |
561 | |
579 | |
562 | case DT_END: |
580 | case DT_END: |
563 | goto call; |
581 | goto call; |
564 | |
582 | |
565 | default: |
583 | default: |
566 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
584 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
567 | } |
585 | } |
|
|
586 | } |
|
|
587 | |
|
|
588 | call: |
|
|
589 | va_end (ap); |
|
|
590 | |
|
|
591 | PUTBACK; |
|
|
592 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
593 | SPAGAIN; |
|
|
594 | |
|
|
595 | if (count) |
|
|
596 | { |
|
|
597 | SV *status = POPs; |
|
|
598 | count = SvTRUE (status); |
568 | } |
599 | } |
569 | |
600 | |
570 | call: |
|
|
571 | va_end (ap); |
|
|
572 | |
|
|
573 | PUTBACK; |
601 | 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; |
602 | FREETMPS; |
585 | LEAVE; |
603 | LEAVE; |
586 | |
604 | |
587 | if (SvTRUE (ERRSV)) |
605 | if (SvTRUE (ERRSV)) |
588 | { |
606 | { |
589 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
607 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
590 | ungrab (term); // better lose the grab than the session |
608 | ungrab (term); // better lose the grab than the session |
591 | } |
609 | } |
592 | |
610 | |
593 | event_consumed = !!count; |
611 | event_consumed = !!count; |
594 | } |
612 | } |
595 | catch (...) |
|
|
596 | { |
|
|
597 | swap (perl_environ, environ); |
|
|
598 | throw; |
|
|
599 | } |
|
|
600 | else |
613 | else |
601 | event_consumed = false; |
614 | event_consumed = false; |
602 | |
615 | |
603 | // post-handling of some events |
616 | // post-handling of some events |
604 | if (htype == HOOK_REFRESH_BEGIN) |
617 | if (htype == HOOK_REFRESH_BEGIN) |
… | |
… | |
615 | |
628 | |
616 | // don't allow further calls |
629 | // don't allow further calls |
617 | term->perl.self = 0; |
630 | term->perl.self = 0; |
618 | } |
631 | } |
619 | |
632 | |
620 | swap (perl_environ, environ); |
|
|
621 | |
|
|
622 | return event_consumed; |
633 | return event_consumed; |
|
|
634 | } |
|
|
635 | |
|
|
636 | void |
|
|
637 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
638 | { |
|
|
639 | localise_env set_environ (perl_environ); |
|
|
640 | |
|
|
641 | ENTER; |
|
|
642 | SAVETMPS; |
|
|
643 | |
|
|
644 | dSP; |
|
|
645 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
646 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
647 | |
|
|
648 | if (SvTRUE (ERRSV)) |
|
|
649 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
650 | |
|
|
651 | FREETMPS; |
|
|
652 | LEAVE; |
623 | } |
653 | } |
624 | |
654 | |
625 | ///////////////////////////////////////////////////////////////////////////// |
655 | ///////////////////////////////////////////////////////////////////////////// |
626 | |
656 | |
627 | MODULE = urxvt PACKAGE = urxvt |
657 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
778 | const_iv (XIMDontChange), |
808 | const_iv (XIMDontChange), |
779 | # endif |
809 | # endif |
780 | # endif |
810 | # endif |
781 | }; |
811 | }; |
782 | |
812 | |
783 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
813 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
784 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
814 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
785 | } |
815 | } |
786 | |
816 | |
787 | void |
817 | void |
788 | warn (const char *msg) |
818 | warn (const char *msg) |
789 | CODE: |
819 | CODE: |
… | |
… | |
861 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
891 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
862 | if ((*t)->perl.self) |
892 | if ((*t)->perl.self) |
863 | PUSHs (sv_2mortal (newSVterm (*t))); |
893 | PUSHs (sv_2mortal (newSVterm (*t))); |
864 | } |
894 | } |
865 | |
895 | |
|
|
896 | IV |
|
|
897 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
898 | CODE: |
|
|
899 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
900 | req->cb_sv = newSVsv (cb); |
|
|
901 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
902 | av_push (av, newSViv ((IV)req)); |
|
|
903 | RETVAL = (IV)req; |
|
|
904 | OUTPUT: |
|
|
905 | RETVAL |
|
|
906 | |
|
|
907 | void |
|
|
908 | _delete_selection_request (IV req_) |
|
|
909 | CODE: |
|
|
910 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
911 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
912 | int i; |
|
|
913 | |
|
|
914 | for (i = AvFILL (av); i >= 0; i--) |
|
|
915 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
916 | break; |
|
|
917 | |
|
|
918 | for (; i < AvFILL (av); i++) |
|
|
919 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
920 | |
|
|
921 | av_pop (av); |
|
|
922 | |
|
|
923 | delete req; |
|
|
924 | |
866 | MODULE = urxvt PACKAGE = urxvt::term |
925 | MODULE = urxvt PACKAGE = urxvt::term |
867 | |
926 | |
868 | SV * |
927 | SV * |
869 | _new (AV *env, AV *arg) |
928 | _new (AV *env, AV *arg) |
870 | CODE: |
929 | CODE: |
871 | { |
930 | { |
872 | rxvt_term *term = new rxvt_term; |
931 | rxvt_term *term = new rxvt_term; |
873 | |
932 | |
874 | stringvec *argv = new stringvec; |
933 | stringvec *argv = new stringvec; |
875 | stringvec *envv = new stringvec; |
|
|
876 | |
|
|
877 | for (int i = 0; i <= AvFILL (arg); i++) |
934 | for (int i = 0; i <= AvFILL (arg); i++) |
878 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
935 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
879 | |
936 | |
|
|
937 | stringvec *envv = new stringvec; |
880 | for (int i = AvFILL (env) + 1; i--; ) |
938 | for (int i = AvFILL (env) + 1; i--; ) |
881 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
939 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
882 | |
|
|
883 | envv->push_back (0); |
|
|
884 | |
940 | |
885 | try |
941 | try |
886 | { |
942 | { |
887 | term->init (argv, envv); |
943 | term->init (argv, envv); |
888 | } |
944 | } |
… | |
… | |
928 | |
984 | |
929 | void |
985 | void |
930 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
986 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
931 | CODE: |
987 | CODE: |
932 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
988 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
933 | |
|
|
934 | void |
|
|
935 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
936 | CODE: |
|
|
937 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
938 | |
989 | |
939 | bool |
990 | bool |
940 | rxvt_term::grab (Time eventtime, int sync = 0) |
991 | rxvt_term::grab (Time eventtime, int sync = 0) |
941 | CODE: |
992 | CODE: |
942 | { |
993 | { |
… | |
… | |
1054 | rxvt_pop_locale (); |
1105 | rxvt_pop_locale (); |
1055 | |
1106 | |
1056 | RETVAL = wcs2sv (wstr); |
1107 | RETVAL = wcs2sv (wstr); |
1057 | free (wstr); |
1108 | free (wstr); |
1058 | } |
1109 | } |
1059 | OUTPUT: |
|
|
1060 | RETVAL |
|
|
1061 | |
|
|
1062 | char * |
|
|
1063 | rxvt_term::locale () |
|
|
1064 | CODE: |
|
|
1065 | RETVAL = THIS->locale; |
|
|
1066 | OUTPUT: |
1110 | OUTPUT: |
1067 | RETVAL |
1111 | RETVAL |
1068 | |
1112 | |
1069 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1113 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1070 | |
1114 | |
… | |
… | |
1177 | RETVAL |
1221 | RETVAL |
1178 | |
1222 | |
1179 | Window |
1223 | Window |
1180 | rxvt_term::parent () |
1224 | rxvt_term::parent () |
1181 | CODE: |
1225 | CODE: |
1182 | RETVAL = THIS->parent [0]; |
1226 | RETVAL = THIS->parent; |
1183 | OUTPUT: |
1227 | OUTPUT: |
1184 | RETVAL |
1228 | RETVAL |
1185 | |
1229 | |
1186 | Window |
1230 | Window |
1187 | rxvt_term::vt () |
1231 | rxvt_term::vt () |
… | |
… | |
1214 | if (newval <= 0) |
1258 | if (newval <= 0) |
1215 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1259 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1216 | } |
1260 | } |
1217 | OUTPUT: |
1261 | OUTPUT: |
1218 | RETVAL |
1262 | RETVAL |
|
|
1263 | |
|
|
1264 | void |
|
|
1265 | rxvt_term::set_urgency (bool enable) |
1219 | |
1266 | |
1220 | void |
1267 | void |
1221 | rxvt_term::focus_in () |
1268 | rxvt_term::focus_in () |
1222 | |
1269 | |
1223 | void |
1270 | void |
… | |
… | |
1456 | # include "rsinc.h" |
1503 | # include "rsinc.h" |
1457 | # undef def |
1504 | # undef def |
1458 | # undef reserve |
1505 | # undef reserve |
1459 | }; |
1506 | }; |
1460 | |
1507 | |
1461 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1508 | rs = rslist + ecb_array_length (rslist); |
1462 | |
1509 | |
1463 | if (*name) |
1510 | if (*name) |
1464 | { |
1511 | { |
1465 | do { |
1512 | do { |
1466 | if (rs-- == rslist) |
1513 | if (rs-- == rslist) |
… | |
… | |
1505 | |
1552 | |
1506 | if (set >= 0) |
1553 | if (set >= 0) |
1507 | { |
1554 | { |
1508 | THIS->set_option (optval, set); |
1555 | THIS->set_option (optval, set); |
1509 | |
1556 | |
1510 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1557 | if (THIS->init_done) // avoid doing this before START |
1511 | switch (optval) |
1558 | switch (optval) |
1512 | { |
1559 | { |
1513 | case Opt_skipBuiltinGlyphs: |
1560 | case Opt_skipBuiltinGlyphs: |
1514 | THIS->set_fonts (); |
1561 | THIS->set_fonts (); |
1515 | THIS->scr_remap_chars (); |
1562 | THIS->scr_remap_chars (); |
1516 | THIS->scr_touch (true); |
1563 | THIS->scr_touch (true); |
1517 | THIS->want_refresh = 1; |
1564 | THIS->want_refresh = 1; |
1518 | THIS->refresh_check (); |
1565 | THIS->refresh_check (); |
1519 | break; |
1566 | break; |
|
|
1567 | #ifdef CURSOR_BLINK |
|
|
1568 | case Opt_cursorBlink: |
|
|
1569 | THIS->cursor_blink_reset (); |
|
|
1570 | break; |
|
|
1571 | #endif |
1520 | |
1572 | |
1521 | case Opt_cursorUnderline: |
1573 | case Opt_cursorUnderline: |
1522 | THIS->want_refresh = 1; |
1574 | THIS->want_refresh = 1; |
1523 | THIS->refresh_check (); |
1575 | THIS->refresh_check (); |
1524 | break; |
1576 | break; |
… | |
… | |
1538 | CODE: |
1590 | CODE: |
1539 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1591 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1540 | THIS->keyboard->register_done (); |
1592 | THIS->keyboard->register_done (); |
1541 | OUTPUT: |
1593 | OUTPUT: |
1542 | RETVAL |
1594 | RETVAL |
|
|
1595 | |
|
|
1596 | void |
|
|
1597 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1598 | CODE: |
|
|
1599 | wchar_t *wstr = sv2wcs (str); |
|
|
1600 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1601 | free (wstr); |
1543 | |
1602 | |
1544 | void |
1603 | void |
1545 | rxvt_term::screen_cur (...) |
1604 | rxvt_term::screen_cur (...) |
1546 | PROTOTYPE: $;$$ |
1605 | PROTOTYPE: $;$$ |
1547 | ALIAS: |
1606 | ALIAS: |
… | |
… | |
1869 | void |
1928 | void |
1870 | overlay::DESTROY () |
1929 | overlay::DESTROY () |
1871 | |
1930 | |
1872 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1931 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1873 | |
1932 | |
|
|
1933 | MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_ |
|
|
1934 | |
|
|
1935 | urxvt::pixbuf gdk_pixbuf_new_from_file (octet_string filename, GError **error = 0) |
|
|
1936 | |
|
|
1937 | void |
|
|
1938 | DESTROY (urxvt::pixbuf self) |
|
|
1939 | CODE: |
|
|
1940 | gdk_pixbuf_unref (self); |
|
|
1941 | |