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) |
370 | { |
368 | { |
371 | // runs outside of perls ENV |
369 | // runs outside of perls ENV |
372 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
370 | 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); |
371 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
372 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
374 | } |
373 | } |
375 | } |
374 | } |
376 | |
375 | |
377 | static void |
376 | static void |
378 | ungrab (rxvt_term *THIS) |
377 | ungrab (rxvt_term *THIS) |
… | |
… | |
389 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
388 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
390 | { |
389 | { |
391 | if (!perl || !term->perl.self) |
390 | if (!perl || !term->perl.self) |
392 | return false; |
391 | return false; |
393 | |
392 | |
|
|
393 | localise_env set_environ (perl_environ); |
|
|
394 | |
394 | // pre-handling of some events |
395 | // pre-handling of some events |
395 | if (htype == HOOK_REFRESH_END) |
396 | if (htype == HOOK_REFRESH_END) |
396 | { |
397 | { |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | |
399 | |
399 | for (int i = 0; i <= AvFILL (av); i++) |
400 | for (int i = 0; i <= AvFILL (av); i++) |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
401 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
401 | } |
402 | } |
|
|
403 | else if (htype == HOOK_DESTROY) |
|
|
404 | { |
|
|
405 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
402 | |
406 | |
403 | swap (perl_environ, environ); |
407 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
408 | { |
|
|
409 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
410 | delete req; |
|
|
411 | } |
|
|
412 | } |
404 | |
413 | |
405 | bool event_consumed; |
414 | bool event_consumed; |
406 | |
415 | |
407 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
416 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
408 | || term->perl.should_invoke [htype]) |
417 | || term->perl.should_invoke [htype]) |
409 | try |
|
|
410 | { |
418 | { |
411 | dSP; |
419 | dSP; |
412 | va_list ap; |
420 | va_list ap; |
413 | |
421 | |
414 | va_start (ap, htype); |
422 | va_start (ap, htype); |
415 | |
423 | |
416 | ENTER; |
424 | ENTER; |
417 | SAVETMPS; |
425 | SAVETMPS; |
418 | |
426 | |
419 | PUSHMARK (SP); |
427 | PUSHMARK (SP); |
420 | |
428 | |
|
|
429 | EXTEND (SP, 2); |
421 | XPUSHs (sv_2mortal (newSVterm (term))); |
430 | PUSHs (sv_2mortal (newSVterm (term))); |
422 | XPUSHs (sv_2mortal (newSViv (htype))); |
431 | PUSHs (sv_2mortal (newSViv (htype))); |
423 | |
432 | |
424 | for (;;) { |
433 | for (;;) { |
425 | data_type dt = (data_type)va_arg (ap, int); |
434 | data_type dt = (data_type)va_arg (ap, int); |
426 | |
435 | |
427 | switch (dt) |
436 | switch (dt) |
428 | { |
437 | { |
429 | case DT_INT: |
438 | case DT_INT: |
430 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
439 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
431 | break; |
440 | break; |
432 | |
441 | |
433 | case DT_LONG: |
442 | case DT_LONG: |
434 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
443 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
435 | break; |
444 | break; |
436 | |
445 | |
437 | case DT_STR: |
446 | case DT_STR: |
438 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
447 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
439 | break; |
448 | break; |
440 | |
449 | |
441 | case DT_STR_LEN: |
450 | case DT_STR_LEN: |
442 | { |
451 | { |
443 | char *str = va_arg (ap, char *); |
452 | char *str = va_arg (ap, char *); |
444 | int len = va_arg (ap, int); |
453 | int len = va_arg (ap, int); |
445 | |
454 | |
446 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
455 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
447 | } |
456 | } |
448 | break; |
457 | break; |
449 | |
458 | |
450 | case DT_WCS_LEN: |
459 | case DT_WCS_LEN: |
451 | { |
460 | { |
452 | wchar_t *wstr = va_arg (ap, wchar_t *); |
461 | wchar_t *wstr = va_arg (ap, wchar_t *); |
453 | int wlen = va_arg (ap, int); |
462 | int wlen = va_arg (ap, int); |
454 | |
463 | |
455 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
464 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
456 | } |
465 | } |
457 | break; |
466 | break; |
458 | |
467 | |
459 | case DT_LCS_LEN: |
468 | case DT_LCS_LEN: |
460 | { |
469 | { |
461 | long *lstr = va_arg (ap, long *); |
470 | long *lstr = va_arg (ap, long *); |
462 | int llen = va_arg (ap, int); |
471 | int llen = va_arg (ap, int); |
463 | |
472 | |
464 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
473 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
465 | } |
474 | } |
466 | break; |
475 | break; |
467 | |
476 | |
468 | case DT_XEVENT: |
477 | case DT_XEVENT: |
469 | { |
478 | { |
470 | XEvent *xe = va_arg (ap, XEvent *); |
479 | XEvent *xe = va_arg (ap, XEvent *); |
471 | HV *hv = newHV (); |
480 | HV *hv = newHV (); |
472 | |
481 | |
473 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
482 | # 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) |
483 | # 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) |
484 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
476 | # undef set |
485 | # undef set |
477 | |
486 | |
478 | setiv (type, xe->type); |
487 | setiv (type, xe->type); |
479 | setiv (send_event, xe->xany.send_event); |
488 | setiv (send_event, xe->xany.send_event); |
480 | setiv (serial, xe->xany.serial); |
489 | setiv (serial, xe->xany.serial); |
481 | |
490 | |
482 | switch (xe->type) |
491 | switch (xe->type) |
483 | { |
492 | { |
484 | case KeyPress: |
493 | case KeyPress: |
485 | case KeyRelease: |
494 | case KeyRelease: |
486 | case ButtonPress: |
495 | case ButtonPress: |
487 | case ButtonRelease: |
496 | case ButtonRelease: |
488 | case MotionNotify: |
497 | case MotionNotify: |
489 | setuv (window, xe->xmotion.window); |
498 | setuv (window, xe->xmotion.window); |
490 | setuv (root, xe->xmotion.root); |
499 | setuv (root, xe->xmotion.root); |
491 | setuv (subwindow, xe->xmotion.subwindow); |
500 | setuv (subwindow, xe->xmotion.subwindow); |
492 | setuv (time, xe->xmotion.time); |
501 | setuv (time, xe->xmotion.time); |
493 | setiv (x, xe->xmotion.x); |
502 | setiv (x, xe->xmotion.x); |
494 | setiv (y, xe->xmotion.y); |
503 | setiv (y, xe->xmotion.y); |
495 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
504 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
496 | setiv (col, xe->xmotion.x / term->fwidth); |
505 | setiv (col, xe->xmotion.x / term->fwidth); |
497 | setiv (x_root, xe->xmotion.x_root); |
506 | setiv (x_root, xe->xmotion.x_root); |
498 | setiv (y_root, xe->xmotion.y_root); |
507 | setiv (y_root, xe->xmotion.y_root); |
499 | setuv (state, xe->xmotion.state); |
508 | setuv (state, xe->xmotion.state); |
500 | |
509 | |
501 | switch (xe->type) |
510 | switch (xe->type) |
502 | { |
511 | { |
503 | case KeyPress: |
512 | case KeyPress: |
504 | case KeyRelease: |
513 | case KeyRelease: |
505 | setuv (keycode, xe->xkey.keycode); |
514 | setuv (keycode, xe->xkey.keycode); |
506 | break; |
515 | break; |
507 | |
516 | |
508 | case ButtonPress: |
517 | case ButtonPress: |
509 | case ButtonRelease: |
518 | case ButtonRelease: |
510 | setuv (button, xe->xbutton.button); |
519 | setuv (button, xe->xbutton.button); |
511 | break; |
520 | break; |
512 | |
521 | |
513 | case MotionNotify: |
522 | case MotionNotify: |
514 | setiv (is_hint, xe->xmotion.is_hint); |
523 | setiv (is_hint, xe->xmotion.is_hint); |
515 | break; |
524 | break; |
516 | } |
525 | } |
517 | |
526 | |
518 | break; |
527 | break; |
519 | |
528 | |
520 | case MapNotify: |
529 | case MapNotify: |
521 | case UnmapNotify: |
530 | case UnmapNotify: |
522 | case ConfigureNotify: |
531 | case ConfigureNotify: |
523 | setuv (event, xe->xconfigure.event); |
532 | setuv (event, xe->xconfigure.event); |
524 | setuv (window, xe->xconfigure.window); |
533 | setuv (window, xe->xconfigure.window); |
525 | |
534 | |
526 | switch (xe->type) |
535 | switch (xe->type) |
527 | { |
536 | { |
528 | case ConfigureNotify: |
537 | case ConfigureNotify: |
529 | setiv (x, xe->xconfigure.x); |
538 | setiv (x, xe->xconfigure.x); |
530 | setiv (y, xe->xconfigure.y); |
539 | setiv (y, xe->xconfigure.y); |
531 | setiv (width, xe->xconfigure.width); |
540 | setiv (width, xe->xconfigure.width); |
532 | setiv (height, xe->xconfigure.height); |
541 | setiv (height, xe->xconfigure.height); |
533 | setuv (above, xe->xconfigure.above); |
542 | setuv (above, xe->xconfigure.above); |
534 | break; |
543 | break; |
535 | } |
544 | } |
536 | |
545 | |
537 | break; |
546 | break; |
538 | |
547 | |
539 | case PropertyNotify: |
548 | case PropertyNotify: |
540 | setuv (window, xe->xproperty.window); |
549 | setuv (window, xe->xproperty.window); |
541 | setuv (atom, xe->xproperty.atom); |
550 | setuv (atom, xe->xproperty.atom); |
542 | setuv (time, xe->xproperty.time); |
551 | setuv (time, xe->xproperty.time); |
543 | setiv (state, xe->xproperty.state); |
552 | setiv (state, xe->xproperty.state); |
544 | break; |
553 | break; |
545 | |
554 | |
546 | case ClientMessage: |
555 | case ClientMessage: |
547 | setuv (window, xe->xclient.window); |
556 | setuv (window, xe->xclient.window); |
548 | setuv (message_type, xe->xclient.message_type); |
557 | setuv (message_type, xe->xclient.message_type); |
549 | setuv (format, xe->xclient.format); |
558 | setuv (format, xe->xclient.format); |
550 | setuv (l0, xe->xclient.data.l[0]); |
559 | setuv (l0, xe->xclient.data.l[0]); |
551 | setuv (l1, xe->xclient.data.l[1]); |
560 | setuv (l1, xe->xclient.data.l[1]); |
552 | setuv (l2, xe->xclient.data.l[2]); |
561 | setuv (l2, xe->xclient.data.l[2]); |
553 | setuv (l3, xe->xclient.data.l[3]); |
562 | setuv (l3, xe->xclient.data.l[3]); |
554 | setuv (l4, xe->xclient.data.l[4]); |
563 | setuv (l4, xe->xclient.data.l[4]); |
555 | break; |
564 | break; |
556 | } |
565 | } |
557 | |
566 | |
558 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
567 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
559 | } |
568 | } |
560 | break; |
569 | break; |
561 | |
570 | |
562 | case DT_END: |
571 | case DT_END: |
563 | goto call; |
572 | goto call; |
564 | |
573 | |
565 | default: |
574 | default: |
566 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
575 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
567 | } |
576 | } |
|
|
577 | } |
|
|
578 | |
|
|
579 | call: |
|
|
580 | va_end (ap); |
|
|
581 | |
|
|
582 | PUTBACK; |
|
|
583 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
584 | SPAGAIN; |
|
|
585 | |
|
|
586 | if (count) |
|
|
587 | { |
|
|
588 | SV *status = POPs; |
|
|
589 | count = SvTRUE (status); |
568 | } |
590 | } |
569 | |
591 | |
570 | call: |
|
|
571 | va_end (ap); |
|
|
572 | |
|
|
573 | PUTBACK; |
592 | 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; |
593 | FREETMPS; |
585 | LEAVE; |
594 | LEAVE; |
586 | |
595 | |
587 | if (SvTRUE (ERRSV)) |
596 | if (SvTRUE (ERRSV)) |
588 | { |
597 | { |
589 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
598 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
590 | ungrab (term); // better lose the grab than the session |
599 | ungrab (term); // better lose the grab than the session |
591 | } |
600 | } |
592 | |
601 | |
593 | event_consumed = !!count; |
602 | event_consumed = !!count; |
594 | } |
603 | } |
595 | catch (...) |
|
|
596 | { |
|
|
597 | swap (perl_environ, environ); |
|
|
598 | throw; |
|
|
599 | } |
|
|
600 | else |
604 | else |
601 | event_consumed = false; |
605 | event_consumed = false; |
602 | |
606 | |
603 | // post-handling of some events |
607 | // post-handling of some events |
604 | if (htype == HOOK_REFRESH_BEGIN) |
608 | if (htype == HOOK_REFRESH_BEGIN) |
… | |
… | |
615 | |
619 | |
616 | // don't allow further calls |
620 | // don't allow further calls |
617 | term->perl.self = 0; |
621 | term->perl.self = 0; |
618 | } |
622 | } |
619 | |
623 | |
620 | swap (perl_environ, environ); |
|
|
621 | |
|
|
622 | return event_consumed; |
624 | return event_consumed; |
|
|
625 | } |
|
|
626 | |
|
|
627 | void |
|
|
628 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
629 | { |
|
|
630 | localise_env set_environ (perl_environ); |
|
|
631 | |
|
|
632 | ENTER; |
|
|
633 | SAVETMPS; |
|
|
634 | |
|
|
635 | dSP; |
|
|
636 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
637 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
638 | |
|
|
639 | if (SvTRUE (ERRSV)) |
|
|
640 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
641 | |
|
|
642 | FREETMPS; |
|
|
643 | LEAVE; |
623 | } |
644 | } |
624 | |
645 | |
625 | ///////////////////////////////////////////////////////////////////////////// |
646 | ///////////////////////////////////////////////////////////////////////////// |
626 | |
647 | |
627 | MODULE = urxvt PACKAGE = urxvt |
648 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
778 | const_iv (XIMDontChange), |
799 | const_iv (XIMDontChange), |
779 | # endif |
800 | # endif |
780 | # endif |
801 | # endif |
781 | }; |
802 | }; |
782 | |
803 | |
783 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
804 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
784 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
805 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
785 | } |
806 | } |
786 | |
807 | |
787 | void |
808 | void |
788 | warn (const char *msg) |
809 | warn (const char *msg) |
789 | CODE: |
810 | CODE: |
… | |
… | |
860 | |
881 | |
861 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
882 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
862 | if ((*t)->perl.self) |
883 | if ((*t)->perl.self) |
863 | PUSHs (sv_2mortal (newSVterm (*t))); |
884 | PUSHs (sv_2mortal (newSVterm (*t))); |
864 | } |
885 | } |
|
|
886 | |
|
|
887 | IV |
|
|
888 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
889 | CODE: |
|
|
890 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
891 | req->cb_sv = newSVsv (cb); |
|
|
892 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
893 | av_push (av, newSViv ((IV)req)); |
|
|
894 | RETVAL = (IV)req; |
|
|
895 | OUTPUT: |
|
|
896 | RETVAL |
|
|
897 | |
|
|
898 | void |
|
|
899 | _delete_selection_request (IV req_) |
|
|
900 | CODE: |
|
|
901 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
902 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
903 | int i; |
|
|
904 | |
|
|
905 | for (i = AvFILL (av); i >= 0; i--) |
|
|
906 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
907 | break; |
|
|
908 | |
|
|
909 | for (; i < AvFILL (av); i++) |
|
|
910 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
911 | |
|
|
912 | av_pop (av); |
|
|
913 | |
|
|
914 | delete req; |
865 | |
915 | |
866 | MODULE = urxvt PACKAGE = urxvt::term |
916 | MODULE = urxvt PACKAGE = urxvt::term |
867 | |
917 | |
868 | SV * |
918 | SV * |
869 | _new (AV *env, AV *arg) |
919 | _new (AV *env, AV *arg) |
… | |
… | |
928 | |
978 | |
929 | void |
979 | void |
930 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
980 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
931 | CODE: |
981 | CODE: |
932 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
982 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
933 | |
|
|
934 | void |
|
|
935 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
936 | CODE: |
|
|
937 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
938 | |
983 | |
939 | bool |
984 | bool |
940 | rxvt_term::grab (Time eventtime, int sync = 0) |
985 | rxvt_term::grab (Time eventtime, int sync = 0) |
941 | CODE: |
986 | CODE: |
942 | { |
987 | { |
… | |
… | |
1177 | RETVAL |
1222 | RETVAL |
1178 | |
1223 | |
1179 | Window |
1224 | Window |
1180 | rxvt_term::parent () |
1225 | rxvt_term::parent () |
1181 | CODE: |
1226 | CODE: |
1182 | RETVAL = THIS->parent [0]; |
1227 | RETVAL = THIS->parent; |
1183 | OUTPUT: |
1228 | OUTPUT: |
1184 | RETVAL |
1229 | RETVAL |
1185 | |
1230 | |
1186 | Window |
1231 | Window |
1187 | rxvt_term::vt () |
1232 | rxvt_term::vt () |
… | |
… | |
1456 | # include "rsinc.h" |
1501 | # include "rsinc.h" |
1457 | # undef def |
1502 | # undef def |
1458 | # undef reserve |
1503 | # undef reserve |
1459 | }; |
1504 | }; |
1460 | |
1505 | |
1461 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1506 | rs = rslist + ecb_array_length (rslist); |
1462 | |
1507 | |
1463 | if (*name) |
1508 | if (*name) |
1464 | { |
1509 | { |
1465 | do { |
1510 | do { |
1466 | if (rs-- == rslist) |
1511 | if (rs-- == rslist) |
… | |
… | |
1538 | CODE: |
1583 | CODE: |
1539 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1584 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1540 | THIS->keyboard->register_done (); |
1585 | THIS->keyboard->register_done (); |
1541 | OUTPUT: |
1586 | OUTPUT: |
1542 | RETVAL |
1587 | RETVAL |
|
|
1588 | |
|
|
1589 | void |
|
|
1590 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1591 | CODE: |
|
|
1592 | wchar_t *wstr = sv2wcs (str); |
|
|
1593 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1594 | free (wstr); |
1543 | |
1595 | |
1544 | void |
1596 | void |
1545 | rxvt_term::screen_cur (...) |
1597 | rxvt_term::screen_cur (...) |
1546 | PROTOTYPE: $;$$ |
1598 | PROTOTYPE: $;$$ |
1547 | ALIAS: |
1599 | ALIAS: |