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. |
… | |
… | |
302 | THIS->refresh_check (); |
302 | THIS->refresh_check (); |
303 | } |
303 | } |
304 | |
304 | |
305 | ///////////////////////////////////////////////////////////////////////////// |
305 | ///////////////////////////////////////////////////////////////////////////// |
306 | |
306 | |
307 | #define IOM_CLASS "urxvt" |
|
|
308 | #define IOM_WARN rxvt_warn |
|
|
309 | #include "iom_perl.h" |
307 | #include "iom_perl.h" |
310 | |
308 | |
311 | ///////////////////////////////////////////////////////////////////////////// |
309 | ///////////////////////////////////////////////////////////////////////////// |
312 | |
310 | |
313 | struct rxvt_perl_interp rxvt_perl; |
311 | struct rxvt_perl_interp rxvt_perl; |
… | |
… | |
329 | { |
327 | { |
330 | if (!perl) |
328 | if (!perl) |
331 | { |
329 | { |
332 | rxvt_push_locale (""); // perl init destroys current locale |
330 | rxvt_push_locale (""); // perl init destroys current locale |
333 | |
331 | |
|
|
332 | { |
334 | perl_environ = rxvt_environ; |
333 | perl_environ = rxvt_environ; |
335 | swap (perl_environ, environ); |
334 | localise_env set_environ (perl_environ); |
336 | |
335 | |
337 | char *args[] = { |
336 | char *args[] = { |
338 | "", |
337 | "", |
339 | "-e" |
338 | "-e" |
340 | "BEGIN {" |
339 | "BEGIN {" |
341 | " urxvt->bootstrap;" |
340 | " urxvt->bootstrap;" |
342 | " unshift @INC, '" LIBDIR "';" |
341 | " unshift @INC, '" LIBDIR "';" |
343 | "}" |
342 | "}" |
344 | "" |
343 | "" |
345 | "use urxvt;" |
344 | "use urxvt;" |
346 | }; |
345 | }; |
347 | int argc = sizeof (args) / sizeof (args[0]); |
346 | int argc = ecb_array_length (args); |
348 | char **argv = args; |
347 | char **argv = args; |
349 | |
348 | |
350 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
349 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
351 | perl = perl_alloc (); |
350 | perl = perl_alloc (); |
352 | perl_construct (perl); |
351 | perl_construct (perl); |
353 | |
352 | |
354 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
353 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
355 | || perl_run (perl)) |
354 | || perl_run (perl)) |
356 | { |
355 | { |
357 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
356 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
358 | |
357 | |
359 | perl_destruct (perl); |
358 | perl_destruct (perl); |
360 | perl_free (perl); |
359 | perl_free (perl); |
361 | perl = 0; |
360 | perl = 0; |
362 | } |
361 | } |
363 | |
362 | } |
364 | swap (perl_environ, environ); |
|
|
365 | |
363 | |
366 | rxvt_pop_locale (); |
364 | rxvt_pop_locale (); |
367 | } |
365 | } |
368 | |
366 | |
369 | if (perl) |
367 | if (perl) |
… | |
… | |
389 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
387 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
390 | { |
388 | { |
391 | if (!perl || !term->perl.self) |
389 | if (!perl || !term->perl.self) |
392 | return false; |
390 | return false; |
393 | |
391 | |
|
|
392 | localise_env set_environ (perl_environ); |
|
|
393 | |
394 | // pre-handling of some events |
394 | // pre-handling of some events |
395 | if (htype == HOOK_REFRESH_END) |
395 | if (htype == HOOK_REFRESH_END) |
396 | { |
396 | { |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | |
398 | |
399 | for (int i = 0; i <= AvFILL (av); i++) |
399 | for (int i = 0; i <= AvFILL (av); i++) |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
401 | } |
401 | } |
402 | |
402 | |
403 | swap (perl_environ, environ); |
|
|
404 | |
|
|
405 | bool event_consumed; |
403 | bool event_consumed; |
406 | |
404 | |
407 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
405 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
408 | || term->perl.should_invoke [htype]) |
406 | || term->perl.should_invoke [htype]) |
409 | try |
|
|
410 | { |
407 | { |
411 | dSP; |
408 | dSP; |
412 | va_list ap; |
409 | va_list ap; |
413 | |
410 | |
414 | va_start (ap, htype); |
411 | va_start (ap, htype); |
415 | |
412 | |
416 | ENTER; |
413 | ENTER; |
417 | SAVETMPS; |
414 | SAVETMPS; |
418 | |
415 | |
419 | PUSHMARK (SP); |
416 | PUSHMARK (SP); |
420 | |
417 | |
|
|
418 | EXTEND (SP, 2); |
421 | XPUSHs (sv_2mortal (newSVterm (term))); |
419 | PUSHs (sv_2mortal (newSVterm (term))); |
422 | XPUSHs (sv_2mortal (newSViv (htype))); |
420 | PUSHs (sv_2mortal (newSViv (htype))); |
423 | |
421 | |
424 | for (;;) { |
422 | for (;;) { |
425 | data_type dt = (data_type)va_arg (ap, int); |
423 | data_type dt = (data_type)va_arg (ap, int); |
426 | |
424 | |
427 | switch (dt) |
425 | switch (dt) |
428 | { |
426 | { |
429 | case DT_INT: |
427 | case DT_INT: |
430 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
428 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
431 | break; |
429 | break; |
432 | |
430 | |
433 | case DT_LONG: |
431 | case DT_LONG: |
434 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
432 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
435 | break; |
433 | break; |
436 | |
434 | |
437 | case DT_STR: |
435 | case DT_STR: |
438 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
436 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
439 | break; |
437 | break; |
440 | |
438 | |
441 | case DT_STR_LEN: |
439 | case DT_STR_LEN: |
442 | { |
440 | { |
443 | char *str = va_arg (ap, char *); |
441 | char *str = va_arg (ap, char *); |
444 | int len = va_arg (ap, int); |
442 | int len = va_arg (ap, int); |
445 | |
443 | |
446 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
444 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
447 | } |
445 | } |
448 | break; |
446 | break; |
449 | |
447 | |
450 | case DT_WCS_LEN: |
448 | case DT_WCS_LEN: |
451 | { |
449 | { |
452 | wchar_t *wstr = va_arg (ap, wchar_t *); |
450 | wchar_t *wstr = va_arg (ap, wchar_t *); |
453 | int wlen = va_arg (ap, int); |
451 | int wlen = va_arg (ap, int); |
454 | |
452 | |
455 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
453 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
456 | } |
454 | } |
457 | break; |
455 | break; |
458 | |
456 | |
459 | case DT_LCS_LEN: |
457 | case DT_LCS_LEN: |
460 | { |
458 | { |
461 | long *lstr = va_arg (ap, long *); |
459 | long *lstr = va_arg (ap, long *); |
462 | int llen = va_arg (ap, int); |
460 | int llen = va_arg (ap, int); |
463 | |
461 | |
464 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
462 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
465 | } |
463 | } |
466 | break; |
464 | break; |
467 | |
465 | |
468 | case DT_XEVENT: |
466 | case DT_XEVENT: |
469 | { |
467 | { |
470 | XEvent *xe = va_arg (ap, XEvent *); |
468 | XEvent *xe = va_arg (ap, XEvent *); |
471 | HV *hv = newHV (); |
469 | HV *hv = newHV (); |
472 | |
470 | |
473 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
471 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
474 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
472 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
475 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
473 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
476 | # undef set |
474 | # undef set |
477 | |
475 | |
478 | setiv (type, xe->type); |
476 | setiv (type, xe->type); |
479 | setiv (send_event, xe->xany.send_event); |
477 | setiv (send_event, xe->xany.send_event); |
480 | setiv (serial, xe->xany.serial); |
478 | setiv (serial, xe->xany.serial); |
481 | |
479 | |
482 | switch (xe->type) |
480 | switch (xe->type) |
483 | { |
481 | { |
484 | case KeyPress: |
482 | case KeyPress: |
485 | case KeyRelease: |
483 | case KeyRelease: |
486 | case ButtonPress: |
484 | case ButtonPress: |
487 | case ButtonRelease: |
485 | case ButtonRelease: |
488 | case MotionNotify: |
486 | case MotionNotify: |
489 | setuv (window, xe->xmotion.window); |
487 | setuv (window, xe->xmotion.window); |
490 | setuv (root, xe->xmotion.root); |
488 | setuv (root, xe->xmotion.root); |
491 | setuv (subwindow, xe->xmotion.subwindow); |
489 | setuv (subwindow, xe->xmotion.subwindow); |
492 | setuv (time, xe->xmotion.time); |
490 | setuv (time, xe->xmotion.time); |
493 | setiv (x, xe->xmotion.x); |
491 | setiv (x, xe->xmotion.x); |
494 | setiv (y, xe->xmotion.y); |
492 | setiv (y, xe->xmotion.y); |
495 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
493 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
496 | setiv (col, xe->xmotion.x / term->fwidth); |
494 | setiv (col, xe->xmotion.x / term->fwidth); |
497 | setiv (x_root, xe->xmotion.x_root); |
495 | setiv (x_root, xe->xmotion.x_root); |
498 | setiv (y_root, xe->xmotion.y_root); |
496 | setiv (y_root, xe->xmotion.y_root); |
499 | setuv (state, xe->xmotion.state); |
497 | setuv (state, xe->xmotion.state); |
500 | |
498 | |
501 | switch (xe->type) |
499 | switch (xe->type) |
502 | { |
500 | { |
503 | case KeyPress: |
501 | case KeyPress: |
504 | case KeyRelease: |
502 | case KeyRelease: |
505 | setuv (keycode, xe->xkey.keycode); |
503 | setuv (keycode, xe->xkey.keycode); |
506 | break; |
504 | break; |
507 | |
505 | |
508 | case ButtonPress: |
506 | case ButtonPress: |
509 | case ButtonRelease: |
507 | case ButtonRelease: |
510 | setuv (button, xe->xbutton.button); |
508 | setuv (button, xe->xbutton.button); |
511 | break; |
509 | break; |
512 | |
510 | |
513 | case MotionNotify: |
511 | case MotionNotify: |
514 | setiv (is_hint, xe->xmotion.is_hint); |
512 | setiv (is_hint, xe->xmotion.is_hint); |
515 | break; |
513 | break; |
516 | } |
514 | } |
517 | |
515 | |
518 | break; |
516 | break; |
519 | |
517 | |
520 | case MapNotify: |
518 | case MapNotify: |
521 | case UnmapNotify: |
519 | case UnmapNotify: |
522 | case ConfigureNotify: |
520 | case ConfigureNotify: |
523 | setuv (event, xe->xconfigure.event); |
521 | setuv (event, xe->xconfigure.event); |
524 | setuv (window, xe->xconfigure.window); |
522 | setuv (window, xe->xconfigure.window); |
525 | |
523 | |
526 | switch (xe->type) |
524 | switch (xe->type) |
527 | { |
525 | { |
528 | case ConfigureNotify: |
526 | case ConfigureNotify: |
529 | setiv (x, xe->xconfigure.x); |
527 | setiv (x, xe->xconfigure.x); |
530 | setiv (y, xe->xconfigure.y); |
528 | setiv (y, xe->xconfigure.y); |
531 | setiv (width, xe->xconfigure.width); |
529 | setiv (width, xe->xconfigure.width); |
532 | setiv (height, xe->xconfigure.height); |
530 | setiv (height, xe->xconfigure.height); |
533 | setuv (above, xe->xconfigure.above); |
531 | setuv (above, xe->xconfigure.above); |
534 | break; |
532 | break; |
535 | } |
533 | } |
536 | |
534 | |
537 | break; |
535 | break; |
538 | |
536 | |
539 | case PropertyNotify: |
537 | case PropertyNotify: |
540 | setuv (window, xe->xproperty.window); |
538 | setuv (window, xe->xproperty.window); |
541 | setuv (atom, xe->xproperty.atom); |
539 | setuv (atom, xe->xproperty.atom); |
542 | setuv (time, xe->xproperty.time); |
540 | setuv (time, xe->xproperty.time); |
543 | setiv (state, xe->xproperty.state); |
541 | setiv (state, xe->xproperty.state); |
544 | break; |
542 | break; |
545 | |
543 | |
546 | case ClientMessage: |
544 | case ClientMessage: |
547 | setuv (window, xe->xclient.window); |
545 | setuv (window, xe->xclient.window); |
548 | setuv (message_type, xe->xclient.message_type); |
546 | setuv (message_type, xe->xclient.message_type); |
549 | setuv (format, xe->xclient.format); |
547 | setuv (format, xe->xclient.format); |
550 | setuv (l0, xe->xclient.data.l[0]); |
548 | setuv (l0, xe->xclient.data.l[0]); |
551 | setuv (l1, xe->xclient.data.l[1]); |
549 | setuv (l1, xe->xclient.data.l[1]); |
552 | setuv (l2, xe->xclient.data.l[2]); |
550 | setuv (l2, xe->xclient.data.l[2]); |
553 | setuv (l3, xe->xclient.data.l[3]); |
551 | setuv (l3, xe->xclient.data.l[3]); |
554 | setuv (l4, xe->xclient.data.l[4]); |
552 | setuv (l4, xe->xclient.data.l[4]); |
555 | break; |
553 | break; |
556 | } |
554 | } |
557 | |
555 | |
558 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
556 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
559 | } |
557 | } |
560 | break; |
558 | break; |
561 | |
559 | |
562 | case DT_END: |
560 | case DT_END: |
563 | goto call; |
561 | goto call; |
564 | |
562 | |
565 | default: |
563 | default: |
566 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
564 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
567 | } |
565 | } |
|
|
566 | } |
|
|
567 | |
|
|
568 | call: |
|
|
569 | va_end (ap); |
|
|
570 | |
|
|
571 | PUTBACK; |
|
|
572 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
573 | SPAGAIN; |
|
|
574 | |
|
|
575 | if (count) |
|
|
576 | { |
|
|
577 | SV *status = POPs; |
|
|
578 | count = SvTRUE (status); |
568 | } |
579 | } |
569 | |
580 | |
570 | call: |
|
|
571 | va_end (ap); |
|
|
572 | |
|
|
573 | PUTBACK; |
581 | 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; |
582 | FREETMPS; |
585 | LEAVE; |
583 | LEAVE; |
586 | |
584 | |
587 | if (SvTRUE (ERRSV)) |
585 | if (SvTRUE (ERRSV)) |
588 | { |
586 | { |
589 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
587 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
590 | ungrab (term); // better lose the grab than the session |
588 | ungrab (term); // better lose the grab than the session |
591 | } |
589 | } |
592 | |
590 | |
593 | event_consumed = !!count; |
591 | event_consumed = !!count; |
594 | } |
592 | } |
595 | catch (...) |
|
|
596 | { |
|
|
597 | swap (perl_environ, environ); |
|
|
598 | throw; |
|
|
599 | } |
|
|
600 | else |
593 | else |
601 | event_consumed = false; |
594 | event_consumed = false; |
602 | |
595 | |
603 | // post-handling of some events |
596 | // post-handling of some events |
604 | if (htype == HOOK_REFRESH_BEGIN) |
597 | if (htype == HOOK_REFRESH_BEGIN) |
… | |
… | |
615 | |
608 | |
616 | // don't allow further calls |
609 | // don't allow further calls |
617 | term->perl.self = 0; |
610 | term->perl.self = 0; |
618 | } |
611 | } |
619 | |
612 | |
620 | swap (perl_environ, environ); |
|
|
621 | |
|
|
622 | return event_consumed; |
613 | return event_consumed; |
|
|
614 | } |
|
|
615 | |
|
|
616 | void |
|
|
617 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
618 | { |
|
|
619 | localise_env set_environ (perl_environ); |
|
|
620 | |
|
|
621 | ENTER; |
|
|
622 | SAVETMPS; |
|
|
623 | |
|
|
624 | dSP; |
|
|
625 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
626 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
627 | |
|
|
628 | if (SvTRUE (ERRSV)) |
|
|
629 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
630 | |
|
|
631 | FREETMPS; |
|
|
632 | LEAVE; |
623 | } |
633 | } |
624 | |
634 | |
625 | ///////////////////////////////////////////////////////////////////////////// |
635 | ///////////////////////////////////////////////////////////////////////////// |
626 | |
636 | |
627 | MODULE = urxvt PACKAGE = urxvt |
637 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
639 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
649 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
640 | # include "hookinc.h" |
650 | # include "hookinc.h" |
641 | # undef def |
651 | # undef def |
642 | |
652 | |
643 | HV *option = get_hv ("urxvt::OPTION", 1); |
653 | HV *option = get_hv ("urxvt::OPTION", 1); |
644 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
654 | # define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
645 | # define nodef(name) |
655 | # define nodef(name) |
646 | # include "optinc.h" |
656 | # include "optinc.h" |
647 | # undef nodef |
657 | # undef nodef |
648 | # undef def |
658 | # undef def |
649 | |
659 | |
… | |
… | |
654 | } *civ, const_iv[] = { |
664 | } *civ, const_iv[] = { |
655 | # define const_iv(name) { # name, (IV)name } |
665 | # define const_iv(name) { # name, (IV)name } |
656 | const_iv (NUM_RESOURCES), |
666 | const_iv (NUM_RESOURCES), |
657 | const_iv (DEFAULT_RSTYLE), |
667 | const_iv (DEFAULT_RSTYLE), |
658 | const_iv (OVERLAY_RSTYLE), |
668 | const_iv (OVERLAY_RSTYLE), |
|
|
669 | const_iv (Color_Bits), |
|
|
670 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
|
|
671 | const_iv (RS_fgShift), const_iv (RS_fgMask), |
|
|
672 | const_iv (RS_Careful), |
|
|
673 | const_iv (RS_fontCount), |
|
|
674 | const_iv (RS_fontShift), |
|
|
675 | const_iv (RS_fontMask), |
|
|
676 | const_iv (RS_baseattrMask), |
|
|
677 | const_iv (RS_attrMask), |
|
|
678 | const_iv (RS_redraw), |
|
|
679 | const_iv (RS_Sel), |
659 | const_iv (RS_Bold), |
680 | const_iv (RS_Bold), |
660 | const_iv (RS_Italic), |
681 | const_iv (RS_Italic), |
661 | const_iv (RS_Blink), |
682 | const_iv (RS_Blink), |
662 | const_iv (RS_RVid), |
683 | const_iv (RS_RVid), |
663 | const_iv (RS_Uline), |
684 | const_iv (RS_Uline), |
… | |
… | |
767 | const_iv (XIMDontChange), |
788 | const_iv (XIMDontChange), |
768 | # endif |
789 | # endif |
769 | # endif |
790 | # endif |
770 | }; |
791 | }; |
771 | |
792 | |
772 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
793 | for (civ = const_iv + ecb_array_length (const_iv); civ-- > const_iv; ) |
773 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
794 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
774 | } |
795 | } |
775 | |
796 | |
776 | void |
797 | void |
777 | warn (const char *msg) |
798 | warn (const char *msg) |
… | |
… | |
849 | |
870 | |
850 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
871 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
851 | if ((*t)->perl.self) |
872 | if ((*t)->perl.self) |
852 | PUSHs (sv_2mortal (newSVterm (*t))); |
873 | PUSHs (sv_2mortal (newSVterm (*t))); |
853 | } |
874 | } |
|
|
875 | |
|
|
876 | IV |
|
|
877 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
878 | CODE: |
|
|
879 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
880 | req->cb_sv = newSVsv (cb); |
|
|
881 | RETVAL = (IV)req; |
|
|
882 | OUTPUT: |
|
|
883 | RETVAL |
|
|
884 | |
|
|
885 | void |
|
|
886 | _delete_selection_request (IV req_) |
|
|
887 | CODE: |
|
|
888 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
889 | delete req; |
854 | |
890 | |
855 | MODULE = urxvt PACKAGE = urxvt::term |
891 | MODULE = urxvt PACKAGE = urxvt::term |
856 | |
892 | |
857 | SV * |
893 | SV * |
858 | _new (AV *env, AV *arg) |
894 | _new (AV *env, AV *arg) |
… | |
… | |
1166 | RETVAL |
1202 | RETVAL |
1167 | |
1203 | |
1168 | Window |
1204 | Window |
1169 | rxvt_term::parent () |
1205 | rxvt_term::parent () |
1170 | CODE: |
1206 | CODE: |
1171 | RETVAL = THIS->parent [0]; |
1207 | RETVAL = THIS->parent; |
1172 | OUTPUT: |
1208 | OUTPUT: |
1173 | RETVAL |
1209 | RETVAL |
1174 | |
1210 | |
1175 | Window |
1211 | Window |
1176 | rxvt_term::vt () |
1212 | rxvt_term::vt () |
… | |
… | |
1445 | # include "rsinc.h" |
1481 | # include "rsinc.h" |
1446 | # undef def |
1482 | # undef def |
1447 | # undef reserve |
1483 | # undef reserve |
1448 | }; |
1484 | }; |
1449 | |
1485 | |
1450 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1486 | rs = rslist + ecb_array_length (rslist); |
1451 | |
1487 | |
1452 | if (*name) |
1488 | if (*name) |
1453 | { |
1489 | { |
1454 | do { |
1490 | do { |
1455 | if (rs-- == rslist) |
1491 | if (rs-- == rslist) |
… | |
… | |
1594 | THIS->selection.screen = screen; |
1630 | THIS->selection.screen = screen; |
1595 | OUTPUT: |
1631 | OUTPUT: |
1596 | RETVAL |
1632 | RETVAL |
1597 | |
1633 | |
1598 | void |
1634 | void |
1599 | rxvt_term::selection_clear () |
1635 | rxvt_term::selection_clear (bool clipboard = false) |
1600 | |
1636 | |
1601 | void |
1637 | void |
1602 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1638 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1603 | CODE: |
1639 | CODE: |
1604 | THIS->selection.op = SELECTION_CONT; |
1640 | THIS->selection.op = SELECTION_CONT; |
1605 | THIS->selection.rect = rect; |
1641 | THIS->selection.rect = rect; |
1606 | THIS->selection_make (eventtime); |
1642 | THIS->selection_make (eventtime); |
1607 | |
1643 | |
1608 | int |
1644 | int |
1609 | rxvt_term::selection_grab (Time eventtime) |
1645 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1610 | |
1646 | |
1611 | void |
1647 | void |
1612 | rxvt_term::selection (SV *newtext = 0) |
1648 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1613 | PPCODE: |
1649 | PPCODE: |
1614 | { |
1650 | { |
|
|
1651 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1652 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1653 | |
1615 | if (GIMME_V != G_VOID) |
1654 | if (GIMME_V != G_VOID) |
1616 | XPUSHs (THIS->selection.text |
1655 | XPUSHs (text |
1617 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1656 | ? sv_2mortal (wcs2sv (text, len)) |
1618 | : &PL_sv_undef); |
1657 | : &PL_sv_undef); |
1619 | |
1658 | |
1620 | if (newtext) |
1659 | if (newtext) |
1621 | { |
1660 | { |
1622 | free (THIS->selection.text); |
1661 | free (text); |
1623 | |
1662 | |
1624 | THIS->selection.text = sv2wcs (newtext); |
1663 | text = sv2wcs (newtext); |
1625 | THIS->selection.len = wcslen (THIS->selection.text); |
1664 | len = wcslen (text); |
1626 | } |
1665 | } |
1627 | } |
1666 | } |
1628 | |
1667 | |
1629 | char |
1668 | char |
1630 | rxvt_term::cur_charset () |
1669 | rxvt_term::cur_charset () |
… | |
… | |
1661 | char *str = SvPVbyte (octets, len); |
1700 | char *str = SvPVbyte (octets, len); |
1662 | C_ARGS: |
1701 | C_ARGS: |
1663 | str, len |
1702 | str, len |
1664 | |
1703 | |
1665 | void |
1704 | void |
|
|
1705 | rxvt_term::tt_paste (SV *octets) |
|
|
1706 | INIT: |
|
|
1707 | STRLEN len; |
|
|
1708 | char *str = SvPVbyte (octets, len); |
|
|
1709 | C_ARGS: |
|
|
1710 | str, len |
|
|
1711 | |
|
|
1712 | void |
1666 | rxvt_term::cmd_parse (SV *octets) |
1713 | rxvt_term::cmd_parse (SV *octets) |
1667 | CODE: |
1714 | CODE: |
1668 | { |
1715 | { |
1669 | STRLEN len; |
1716 | STRLEN len; |
1670 | char *str = SvPVbyte (octets, len); |
1717 | char *str = SvPVbyte (octets, len); |