ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtperl.xs
(Generate patch)

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.128 by root, Sat Dec 26 09:42:16 2009 UTC vs.
Revision 1.147 by sf-exg, Tue Dec 6 11:29:52 2011 UTC

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
313struct rxvt_perl_interp rxvt_perl; 311struct 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
377static void 376static void
378ungrab (rxvt_term *THIS) 377ungrab (rxvt_term *THIS)
389rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 388rxvt_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
627void
628rxvt_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
627MODULE = urxvt PACKAGE = urxvt 648MODULE = urxvt PACKAGE = urxvt
639# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 660# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
640# include "hookinc.h" 661# include "hookinc.h"
641# undef def 662# undef def
642 663
643 HV *option = get_hv ("urxvt::OPTION", 1); 664 HV *option = get_hv ("urxvt::OPTION", 1);
644# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); 665# define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
645# define nodef(name) 666# define nodef(name)
646# include "optinc.h" 667# include "optinc.h"
647# undef nodef 668# undef nodef
648# undef def 669# undef def
649 670
654 } *civ, const_iv[] = { 675 } *civ, const_iv[] = {
655# define const_iv(name) { # name, (IV)name } 676# define const_iv(name) { # name, (IV)name }
656 const_iv (NUM_RESOURCES), 677 const_iv (NUM_RESOURCES),
657 const_iv (DEFAULT_RSTYLE), 678 const_iv (DEFAULT_RSTYLE),
658 const_iv (OVERLAY_RSTYLE), 679 const_iv (OVERLAY_RSTYLE),
680 const_iv (Color_Bits),
681 const_iv (RS_bgShift), const_iv (RS_bgMask),
682 const_iv (RS_fgShift), const_iv (RS_fgMask),
683 const_iv (RS_Careful),
684 const_iv (RS_fontCount),
685 const_iv (RS_fontShift),
686 const_iv (RS_fontMask),
687 const_iv (RS_baseattrMask),
688 const_iv (RS_attrMask),
689 const_iv (RS_redraw),
690 const_iv (RS_Sel),
659 const_iv (RS_Bold), 691 const_iv (RS_Bold),
660 const_iv (RS_Italic), 692 const_iv (RS_Italic),
661 const_iv (RS_Blink), 693 const_iv (RS_Blink),
662 const_iv (RS_RVid), 694 const_iv (RS_RVid),
663 const_iv (RS_Uline), 695 const_iv (RS_Uline),
767 const_iv (XIMDontChange), 799 const_iv (XIMDontChange),
768# endif 800# endif
769# endif 801# endif
770 }; 802 };
771 803
772 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--)
773 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 805 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
774} 806}
775 807
776void 808void
777warn (const char *msg) 809warn (const char *msg)
778 CODE: 810 CODE:
850 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++)
851 if ((*t)->perl.self) 883 if ((*t)->perl.self)
852 PUSHs (sv_2mortal (newSVterm (*t))); 884 PUSHs (sv_2mortal (newSVterm (*t)));
853} 885}
854 886
887IV
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
898void
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;
915
855MODULE = urxvt PACKAGE = urxvt::term 916MODULE = urxvt PACKAGE = urxvt::term
856 917
857SV * 918SV *
858_new (AV *env, AV *arg) 919_new (AV *env, AV *arg)
859 CODE: 920 CODE:
866 for (int i = 0; i <= AvFILL (arg); i++) 927 for (int i = 0; i <= AvFILL (arg); i++)
867 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 928 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
868 929
869 for (int i = AvFILL (env) + 1; i--; ) 930 for (int i = AvFILL (env) + 1; i--; )
870 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 931 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
871
872 envv->push_back (0);
873 932
874 try 933 try
875 { 934 {
876 term->init (argv, envv); 935 term->init (argv, envv);
877 } 936 }
917 976
918void 977void
919rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 978rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
920 CODE: 979 CODE:
921 XUngrabKey (THIS->dpy, keycode, modifiers, window); 980 XUngrabKey (THIS->dpy, keycode, modifiers, window);
922
923void
924rxvt_term::XUngrabKeyboard (Time eventtime)
925 CODE:
926 XUngrabKeyboard (THIS->dpy, eventtime);
927 981
928bool 982bool
929rxvt_term::grab (Time eventtime, int sync = 0) 983rxvt_term::grab (Time eventtime, int sync = 0)
930 CODE: 984 CODE:
931{ 985{
1166 RETVAL 1220 RETVAL
1167 1221
1168Window 1222Window
1169rxvt_term::parent () 1223rxvt_term::parent ()
1170 CODE: 1224 CODE:
1171 RETVAL = THIS->parent [0]; 1225 RETVAL = THIS->parent;
1172 OUTPUT: 1226 OUTPUT:
1173 RETVAL 1227 RETVAL
1174 1228
1175Window 1229Window
1176rxvt_term::vt () 1230rxvt_term::vt ()
1203 if (newval <= 0) 1257 if (newval <= 0)
1204 THIS->scr_changeview (max (newval, THIS->top_row)); 1258 THIS->scr_changeview (max (newval, THIS->top_row));
1205} 1259}
1206 OUTPUT: 1260 OUTPUT:
1207 RETVAL 1261 RETVAL
1262
1263void
1264rxvt_term::set_urgency (bool enable)
1208 1265
1209void 1266void
1210rxvt_term::focus_in () 1267rxvt_term::focus_in ()
1211 1268
1212void 1269void
1445# include "rsinc.h" 1502# include "rsinc.h"
1446# undef def 1503# undef def
1447# undef reserve 1504# undef reserve
1448 }; 1505 };
1449 1506
1450 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1507 rs = rslist + ecb_array_length (rslist);
1451 1508
1452 if (*name) 1509 if (*name)
1453 { 1510 {
1454 do { 1511 do {
1455 if (rs-- == rslist) 1512 if (rs-- == rslist)
1527 CODE: 1584 CODE:
1528 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1585 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1529 THIS->keyboard->register_done (); 1586 THIS->keyboard->register_done ();
1530 OUTPUT: 1587 OUTPUT:
1531 RETVAL 1588 RETVAL
1589
1590void
1591rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1592 CODE:
1593 wchar_t *wstr = sv2wcs (str);
1594 THIS->keyboard->register_user_translation (keysym, state, wstr);
1595 free (wstr);
1532 1596
1533void 1597void
1534rxvt_term::screen_cur (...) 1598rxvt_term::screen_cur (...)
1535 PROTOTYPE: $;$$ 1599 PROTOTYPE: $;$$
1536 ALIAS: 1600 ALIAS:
1594 THIS->selection.screen = screen; 1658 THIS->selection.screen = screen;
1595 OUTPUT: 1659 OUTPUT:
1596 RETVAL 1660 RETVAL
1597 1661
1598void 1662void
1599rxvt_term::selection_clear () 1663rxvt_term::selection_clear (bool clipboard = false)
1600 1664
1601void 1665void
1602rxvt_term::selection_make (Time eventtime, bool rect = false) 1666rxvt_term::selection_make (Time eventtime, bool rect = false)
1603 CODE: 1667 CODE:
1604 THIS->selection.op = SELECTION_CONT; 1668 THIS->selection.op = SELECTION_CONT;
1605 THIS->selection.rect = rect; 1669 THIS->selection.rect = rect;
1606 THIS->selection_make (eventtime); 1670 THIS->selection_make (eventtime);
1607 1671
1608int 1672int
1609rxvt_term::selection_grab (Time eventtime) 1673rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1610 1674
1611void 1675void
1612rxvt_term::selection (SV *newtext = 0) 1676rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1613 PPCODE: 1677 PPCODE:
1614{ 1678{
1679 wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text;
1680 unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len;
1681
1615 if (GIMME_V != G_VOID) 1682 if (GIMME_V != G_VOID)
1616 XPUSHs (THIS->selection.text 1683 XPUSHs (text
1617 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1684 ? sv_2mortal (wcs2sv (text, len))
1618 : &PL_sv_undef); 1685 : &PL_sv_undef);
1619 1686
1620 if (newtext) 1687 if (newtext)
1621 { 1688 {
1622 free (THIS->selection.text); 1689 free (text);
1623 1690
1624 THIS->selection.text = sv2wcs (newtext); 1691 text = sv2wcs (newtext);
1625 THIS->selection.len = wcslen (THIS->selection.text); 1692 len = wcslen (text);
1626 } 1693 }
1627} 1694}
1628 1695
1629char 1696char
1630rxvt_term::cur_charset () 1697rxvt_term::cur_charset ()
1661 char *str = SvPVbyte (octets, len); 1728 char *str = SvPVbyte (octets, len);
1662 C_ARGS: 1729 C_ARGS:
1663 str, len 1730 str, len
1664 1731
1665void 1732void
1733rxvt_term::tt_paste (SV *octets)
1734 INIT:
1735 STRLEN len;
1736 char *str = SvPVbyte (octets, len);
1737 C_ARGS:
1738 str, len
1739
1740void
1666rxvt_term::cmd_parse (SV *octets) 1741rxvt_term::cmd_parse (SV *octets)
1667 CODE: 1742 CODE:
1668{ 1743{
1669 STRLEN len; 1744 STRLEN len;
1670 char *str = SvPVbyte (octets, len); 1745 char *str = SvPVbyte (octets, len);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines