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.127 by root, Sat May 30 08:51:23 2009 UTC vs.
Revision 1.145 by sf-exg, Fri Dec 2 09:03:43 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:
849 881
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}
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;
854 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)
917 978
918void 979void
919rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 980rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
920 CODE: 981 CODE:
921 XUngrabKey (THIS->dpy, keycode, modifiers, window); 982 XUngrabKey (THIS->dpy, keycode, modifiers, window);
922
923void
924rxvt_term::XUngrabKeyboard (Time eventtime)
925 CODE:
926 XUngrabKeyboard (THIS->dpy, eventtime);
927 983
928bool 984bool
929rxvt_term::grab (Time eventtime, int sync = 0) 985rxvt_term::grab (Time eventtime, int sync = 0)
930 CODE: 986 CODE:
931{ 987{
1166 RETVAL 1222 RETVAL
1167 1223
1168Window 1224Window
1169rxvt_term::parent () 1225rxvt_term::parent ()
1170 CODE: 1226 CODE:
1171 RETVAL = THIS->parent [0]; 1227 RETVAL = THIS->parent;
1172 OUTPUT: 1228 OUTPUT:
1173 RETVAL 1229 RETVAL
1174 1230
1175Window 1231Window
1176rxvt_term::vt () 1232rxvt_term::vt ()
1445# include "rsinc.h" 1501# include "rsinc.h"
1446# undef def 1502# undef def
1447# undef reserve 1503# undef reserve
1448 }; 1504 };
1449 1505
1450 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1506 rs = rslist + ecb_array_length (rslist);
1451 1507
1452 if (*name) 1508 if (*name)
1453 { 1509 {
1454 do { 1510 do {
1455 if (rs-- == rslist) 1511 if (rs-- == rslist)
1529 THIS->keyboard->register_done (); 1585 THIS->keyboard->register_done ();
1530 OUTPUT: 1586 OUTPUT:
1531 RETVAL 1587 RETVAL
1532 1588
1533void 1589void
1590rxvt_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);
1595
1596void
1534rxvt_term::screen_cur (...) 1597rxvt_term::screen_cur (...)
1535 PROTOTYPE: $;$$ 1598 PROTOTYPE: $;$$
1536 ALIAS: 1599 ALIAS:
1537 screen_cur = 0 1600 screen_cur = 0
1538 selection_beg = 1 1601 selection_beg = 1
1550 EXTEND (SP, 2); 1613 EXTEND (SP, 2);
1551 PUSHs (sv_2mortal (newSViv (rc.row))); 1614 PUSHs (sv_2mortal (newSViv (rc.row)));
1552 PUSHs (sv_2mortal (newSViv (rc.col))); 1615 PUSHs (sv_2mortal (newSViv (rc.col)));
1553 } 1616 }
1554 1617
1555 if (items == 3) 1618 if (items >= 3)
1556 { 1619 {
1557 rc.row = SvIV (ST (1)); 1620 rc.row = SvIV (ST (1));
1558 rc.col = SvIV (ST (2)); 1621 rc.col = SvIV (ST (2));
1559 1622
1560 if (ix == 2) 1623 if (ix == 2)
1576 clamp_it (rc.col, 0, THIS->ncol); 1639 clamp_it (rc.col, 0, THIS->ncol);
1577 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1640 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1578 1641
1579 if (ix) 1642 if (ix)
1580 { 1643 {
1644 THIS->selection.screen = THIS->current_screen;
1645
1581 THIS->want_refresh = 1; 1646 THIS->want_refresh = 1;
1582 THIS->refresh_check (); 1647 THIS->refresh_check ();
1583 } 1648 }
1584 } 1649 }
1585} 1650}
1586 1651
1587char 1652int
1588rxvt_term::cur_charset () 1653rxvt_term::selection_screen (int screen = -1)
1589 CODE: 1654 CODE:
1590 RETVAL = THIS->charsets [THIS->screen.charset]; 1655 RETVAL = THIS->selection.screen;
1591 OUTPUT: 1656 if (screen >= 0)
1657 THIS->selection.screen = screen;
1658 OUTPUT:
1592 RETVAL 1659 RETVAL
1593 1660
1594void 1661void
1595rxvt_term::selection_clear () 1662rxvt_term::selection_clear (bool clipboard = false)
1596 1663
1597void 1664void
1598rxvt_term::selection_make (Time eventtime, bool rect = false) 1665rxvt_term::selection_make (Time eventtime, bool rect = false)
1599 CODE: 1666 CODE:
1600 THIS->selection.op = SELECTION_CONT; 1667 THIS->selection.op = SELECTION_CONT;
1601 THIS->selection.rect = rect; 1668 THIS->selection.rect = rect;
1602 THIS->selection_make (eventtime); 1669 THIS->selection_make (eventtime);
1603 1670
1604int 1671int
1605rxvt_term::selection_grab (Time eventtime) 1672rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1606 1673
1607void 1674void
1608rxvt_term::selection (SV *newtext = 0) 1675rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1609 PPCODE: 1676 PPCODE:
1610{ 1677{
1678 wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text;
1679 unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len;
1680
1611 if (GIMME_V != G_VOID) 1681 if (GIMME_V != G_VOID)
1612 XPUSHs (THIS->selection.text 1682 XPUSHs (text
1613 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1683 ? sv_2mortal (wcs2sv (text, len))
1614 : &PL_sv_undef); 1684 : &PL_sv_undef);
1615 1685
1616 if (newtext) 1686 if (newtext)
1617 { 1687 {
1618 free (THIS->selection.text); 1688 free (text);
1619 1689
1620 THIS->selection.text = sv2wcs (newtext); 1690 text = sv2wcs (newtext);
1621 THIS->selection.len = wcslen (THIS->selection.text); 1691 len = wcslen (text);
1622 } 1692 }
1623} 1693}
1694
1695char
1696rxvt_term::cur_charset ()
1697 CODE:
1698 RETVAL = THIS->charsets [THIS->screen.charset];
1699 OUTPUT:
1700 RETVAL
1624 1701
1625void 1702void
1626rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline) 1703rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline)
1627 1704
1628void 1705void
1650 char *str = SvPVbyte (octets, len); 1727 char *str = SvPVbyte (octets, len);
1651 C_ARGS: 1728 C_ARGS:
1652 str, len 1729 str, len
1653 1730
1654void 1731void
1732rxvt_term::tt_paste (SV *octets)
1733 INIT:
1734 STRLEN len;
1735 char *str = SvPVbyte (octets, len);
1736 C_ARGS:
1737 str, len
1738
1739void
1655rxvt_term::cmd_parse (SV *octets) 1740rxvt_term::cmd_parse (SV *octets)
1656 CODE: 1741 CODE:
1657{ 1742{
1658 STRLEN len; 1743 STRLEN len;
1659 char *str = SvPVbyte (octets, len); 1744 char *str = SvPVbyte (octets, len);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines