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.155 by root, Sun Jun 3 10:38:22 2012 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.
23#define line_t perl_line_t 23#define line_t perl_line_t
24#include <EXTERN.h> 24#include <EXTERN.h>
25#include <perl.h> 25#include <perl.h>
26#include <XSUB.h> 26#include <XSUB.h>
27#undef line_t 27#undef line_t
28#undef bool // perl defines it's own bool type, except with g++... what a trap
28 29
29#include "../config.h" 30#include "../config.h"
30 31
31#include <cstddef> 32#include <stddef.h>
32#include <cstdarg> 33#include <stdarg.h>
33 34
34#include "unistd.h" 35#include "unistd.h"
35 36
36#include "ev_cpp.h" 37#include "ev_cpp.h"
37#include "rxvt.h" 38#include "rxvt.h"
45 46
46#undef LINENO 47#undef LINENO
47#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) 48#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
48#undef ROW 49#undef ROW
49#define ROW(n) THIS->row_buf [LINENO (n)] 50#define ROW(n) THIS->row_buf [LINENO (n)]
51
52/////////////////////////////////////////////////////////////////////////////
53
54typedef char * octet_string;
55typedef char * utf8_string;
56
57typedef GdkPixbuf * urxvt__pixbuf;
58typedef rxvt_img * urxvt__img;
50 59
51///////////////////////////////////////////////////////////////////////////// 60/////////////////////////////////////////////////////////////////////////////
52 61
53static wchar_t * 62static wchar_t *
54sv2wcs (SV *sv) 63sv2wcs (SV *sv)
302 THIS->refresh_check (); 311 THIS->refresh_check ();
303} 312}
304 313
305///////////////////////////////////////////////////////////////////////////// 314/////////////////////////////////////////////////////////////////////////////
306 315
307#define IOM_CLASS "urxvt"
308#define IOM_WARN rxvt_warn
309#include "iom_perl.h" 316#include "iom_perl.h"
310 317
311///////////////////////////////////////////////////////////////////////////// 318/////////////////////////////////////////////////////////////////////////////
312 319
313struct rxvt_perl_interp rxvt_perl; 320struct rxvt_perl_interp rxvt_perl;
329{ 336{
330 if (!perl) 337 if (!perl)
331 { 338 {
332 rxvt_push_locale (""); // perl init destroys current locale 339 rxvt_push_locale (""); // perl init destroys current locale
333 340
341 {
334 perl_environ = rxvt_environ; 342 perl_environ = rxvt_environ;
335 swap (perl_environ, environ); 343 localise_env set_environ (perl_environ);
336 344
337 char *args[] = { 345 char *args[] = {
338 "", 346 "",
339 "-e" 347 "-e"
340 "BEGIN {" 348 "BEGIN {"
341 " urxvt->bootstrap;" 349 " urxvt->bootstrap;"
342 " unshift @INC, '" LIBDIR "';" 350 " unshift @INC, '" LIBDIR "';"
343 "}" 351 "}"
344 "" 352 ""
345 "use urxvt;" 353 "use urxvt;"
346 }; 354 };
347 int argc = sizeof (args) / sizeof (args[0]); 355 int argc = ecb_array_length (args);
348 char **argv = args; 356 char **argv = args;
349 357
350 PERL_SYS_INIT3 (&argc, &argv, &environ); 358 PERL_SYS_INIT3 (&argc, &argv, &environ);
351 perl = perl_alloc (); 359 perl = perl_alloc ();
352 perl_construct (perl); 360 perl_construct (perl);
353 361
354 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) 362 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL)
355 || perl_run (perl)) 363 || perl_run (perl))
356 { 364 {
357 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 365 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
358 366
359 perl_destruct (perl); 367 perl_destruct (perl);
360 perl_free (perl); 368 perl_free (perl);
361 perl = 0; 369 perl = 0;
362 } 370 }
363 371 }
364 swap (perl_environ, environ);
365 372
366 rxvt_pop_locale (); 373 rxvt_pop_locale ();
367 } 374 }
368 375
369 if (perl) 376 if (perl)
370 { 377 {
371 // runs outside of perls ENV 378 // runs outside of perls ENV
372 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 379 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
373 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); 380 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
381 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
374 } 382 }
375} 383}
376 384
377static void 385static void
378ungrab (rxvt_term *THIS) 386ungrab (rxvt_term *THIS)
389rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 397rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
390{ 398{
391 if (!perl || !term->perl.self) 399 if (!perl || !term->perl.self)
392 return false; 400 return false;
393 401
402 localise_env set_environ (perl_environ);
403
394 // pre-handling of some events 404 // pre-handling of some events
395 if (htype == HOOK_REFRESH_END) 405 if (htype == HOOK_REFRESH_END)
396 { 406 {
397 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 407 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
398 408
399 for (int i = 0; i <= AvFILL (av); i++) 409 for (int i = 0; i <= AvFILL (av); i++)
400 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 410 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
401 } 411 }
412 else if (htype == HOOK_DESTROY)
413 {
414 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
402 415
403 swap (perl_environ, environ); 416 for (int i = AvFILL (av); i >= 0; i--)
417 {
418 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
419 delete req;
420 }
421 }
404 422
405 bool event_consumed; 423 bool event_consumed;
406 424
407 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 425 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
408 || term->perl.should_invoke [htype]) 426 || term->perl.should_invoke [htype])
409 try
410 { 427 {
411 dSP; 428 dSP;
412 va_list ap; 429 va_list ap;
413 430
414 va_start (ap, htype); 431 va_start (ap, htype);
415 432
416 ENTER; 433 ENTER;
417 SAVETMPS; 434 SAVETMPS;
418 435
419 PUSHMARK (SP); 436 PUSHMARK (SP);
420 437
438 EXTEND (SP, 2);
421 XPUSHs (sv_2mortal (newSVterm (term))); 439 PUSHs (sv_2mortal (newSVterm (term)));
422 XPUSHs (sv_2mortal (newSViv (htype))); 440 PUSHs (sv_2mortal (newSViv (htype)));
423 441
424 for (;;) { 442 for (;;) {
425 data_type dt = (data_type)va_arg (ap, int); 443 data_type dt = (data_type)va_arg (ap, int);
426 444
427 switch (dt) 445 switch (dt)
428 { 446 {
429 case DT_INT: 447 case DT_INT:
430 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 448 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
431 break; 449 break;
432 450
433 case DT_LONG: 451 case DT_LONG:
434 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 452 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
435 break; 453 break;
436 454
437 case DT_STR: 455 case DT_STR:
438 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 456 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
439 break; 457 break;
440 458
441 case DT_STR_LEN: 459 case DT_STR_LEN:
442 { 460 {
443 char *str = va_arg (ap, char *); 461 char *str = va_arg (ap, char *);
444 int len = va_arg (ap, int); 462 int len = va_arg (ap, int);
445 463
446 XPUSHs (sv_2mortal (newSVpvn (str, len))); 464 XPUSHs (sv_2mortal (newSVpvn (str, len)));
447 } 465 }
448 break; 466 break;
449 467
450 case DT_WCS_LEN: 468 case DT_WCS_LEN:
451 { 469 {
452 wchar_t *wstr = va_arg (ap, wchar_t *); 470 wchar_t *wstr = va_arg (ap, wchar_t *);
453 int wlen = va_arg (ap, int); 471 int wlen = va_arg (ap, int);
454 472
455 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 473 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
456 } 474 }
457 break; 475 break;
458 476
459 case DT_LCS_LEN: 477 case DT_LCS_LEN:
460 { 478 {
461 long *lstr = va_arg (ap, long *); 479 long *lstr = va_arg (ap, long *);
462 int llen = va_arg (ap, int); 480 int llen = va_arg (ap, int);
463 481
464 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); 482 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
465 } 483 }
466 break; 484 break;
467 485
468 case DT_XEVENT: 486 case DT_XEVENT:
469 { 487 {
470 XEvent *xe = va_arg (ap, XEvent *); 488 XEvent *xe = va_arg (ap, XEvent *);
471 HV *hv = newHV (); 489 HV *hv = newHV ();
472 490
473# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 491# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
474# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 492# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
475# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) 493# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
476# undef set 494# undef set
477 495
478 setiv (type, xe->type); 496 setiv (type, xe->type);
479 setiv (send_event, xe->xany.send_event); 497 setiv (send_event, xe->xany.send_event);
480 setiv (serial, xe->xany.serial); 498 setiv (serial, xe->xany.serial);
481 499
482 switch (xe->type) 500 switch (xe->type)
483 { 501 {
484 case KeyPress: 502 case KeyPress:
485 case KeyRelease: 503 case KeyRelease:
486 case ButtonPress: 504 case ButtonPress:
487 case ButtonRelease: 505 case ButtonRelease:
488 case MotionNotify: 506 case MotionNotify:
489 setuv (window, xe->xmotion.window); 507 setuv (window, xe->xmotion.window);
490 setuv (root, xe->xmotion.root); 508 setuv (root, xe->xmotion.root);
491 setuv (subwindow, xe->xmotion.subwindow); 509 setuv (subwindow, xe->xmotion.subwindow);
492 setuv (time, xe->xmotion.time); 510 setuv (time, xe->xmotion.time);
493 setiv (x, xe->xmotion.x); 511 setiv (x, xe->xmotion.x);
494 setiv (y, xe->xmotion.y); 512 setiv (y, xe->xmotion.y);
495 setiv (row, xe->xmotion.y / term->fheight + term->view_start); 513 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
496 setiv (col, xe->xmotion.x / term->fwidth); 514 setiv (col, xe->xmotion.x / term->fwidth);
497 setiv (x_root, xe->xmotion.x_root); 515 setiv (x_root, xe->xmotion.x_root);
498 setiv (y_root, xe->xmotion.y_root); 516 setiv (y_root, xe->xmotion.y_root);
499 setuv (state, xe->xmotion.state); 517 setuv (state, xe->xmotion.state);
500 518
501 switch (xe->type) 519 switch (xe->type)
502 { 520 {
503 case KeyPress: 521 case KeyPress:
504 case KeyRelease: 522 case KeyRelease:
505 setuv (keycode, xe->xkey.keycode); 523 setuv (keycode, xe->xkey.keycode);
506 break; 524 break;
507 525
508 case ButtonPress: 526 case ButtonPress:
509 case ButtonRelease: 527 case ButtonRelease:
510 setuv (button, xe->xbutton.button); 528 setuv (button, xe->xbutton.button);
511 break; 529 break;
512 530
513 case MotionNotify: 531 case MotionNotify:
514 setiv (is_hint, xe->xmotion.is_hint); 532 setiv (is_hint, xe->xmotion.is_hint);
515 break; 533 break;
516 } 534 }
517 535
518 break; 536 break;
519 537
520 case MapNotify: 538 case MapNotify:
521 case UnmapNotify: 539 case UnmapNotify:
522 case ConfigureNotify: 540 case ConfigureNotify:
523 setuv (event, xe->xconfigure.event); 541 setuv (event, xe->xconfigure.event);
524 setuv (window, xe->xconfigure.window); 542 setuv (window, xe->xconfigure.window);
525 543
526 switch (xe->type) 544 switch (xe->type)
527 { 545 {
528 case ConfigureNotify: 546 case ConfigureNotify:
529 setiv (x, xe->xconfigure.x); 547 setiv (x, xe->xconfigure.x);
530 setiv (y, xe->xconfigure.y); 548 setiv (y, xe->xconfigure.y);
531 setiv (width, xe->xconfigure.width); 549 setiv (width, xe->xconfigure.width);
532 setiv (height, xe->xconfigure.height); 550 setiv (height, xe->xconfigure.height);
533 setuv (above, xe->xconfigure.above); 551 setuv (above, xe->xconfigure.above);
534 break; 552 break;
535 } 553 }
536 554
537 break; 555 break;
538 556
539 case PropertyNotify: 557 case PropertyNotify:
540 setuv (window, xe->xproperty.window); 558 setuv (window, xe->xproperty.window);
541 setuv (atom, xe->xproperty.atom); 559 setuv (atom, xe->xproperty.atom);
542 setuv (time, xe->xproperty.time); 560 setuv (time, xe->xproperty.time);
543 setiv (state, xe->xproperty.state); 561 setiv (state, xe->xproperty.state);
544 break; 562 break;
545 563
546 case ClientMessage: 564 case ClientMessage:
547 setuv (window, xe->xclient.window); 565 setuv (window, xe->xclient.window);
548 setuv (message_type, xe->xclient.message_type); 566 setuv (message_type, xe->xclient.message_type);
549 setuv (format, xe->xclient.format); 567 setuv (format, xe->xclient.format);
550 setuv (l0, xe->xclient.data.l[0]); 568 setuv (l0, xe->xclient.data.l[0]);
551 setuv (l1, xe->xclient.data.l[1]); 569 setuv (l1, xe->xclient.data.l[1]);
552 setuv (l2, xe->xclient.data.l[2]); 570 setuv (l2, xe->xclient.data.l[2]);
553 setuv (l3, xe->xclient.data.l[3]); 571 setuv (l3, xe->xclient.data.l[3]);
554 setuv (l4, xe->xclient.data.l[4]); 572 setuv (l4, xe->xclient.data.l[4]);
555 break; 573 break;
556 } 574 }
557 575
558 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 576 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
559 } 577 }
560 break; 578 break;
561 579
562 case DT_END: 580 case DT_END:
563 goto call; 581 goto call;
564 582
565 default: 583 default:
566 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 584 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
567 } 585 }
586 }
587
588 call:
589 va_end (ap);
590
591 PUTBACK;
592 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
593 SPAGAIN;
594
595 if (count)
596 {
597 SV *status = POPs;
598 count = SvTRUE (status);
568 } 599 }
569 600
570 call:
571 va_end (ap);
572
573 PUTBACK; 601 PUTBACK;
574 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
575 SPAGAIN;
576
577 if (count)
578 {
579 SV *status = POPs;
580 count = SvTRUE (status);
581 }
582
583 PUTBACK;
584 FREETMPS; 602 FREETMPS;
585 LEAVE; 603 LEAVE;
586 604
587 if (SvTRUE (ERRSV)) 605 if (SvTRUE (ERRSV))
588 { 606 {
589 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 607 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
590 ungrab (term); // better lose the grab than the session 608 ungrab (term); // better lose the grab than the session
591 } 609 }
592 610
593 event_consumed = !!count; 611 event_consumed = !!count;
594 } 612 }
595 catch (...)
596 {
597 swap (perl_environ, environ);
598 throw;
599 }
600 else 613 else
601 event_consumed = false; 614 event_consumed = false;
602 615
603 // post-handling of some events 616 // post-handling of some events
604 if (htype == HOOK_REFRESH_BEGIN) 617 if (htype == HOOK_REFRESH_BEGIN)
615 628
616 // don't allow further calls 629 // don't allow further calls
617 term->perl.self = 0; 630 term->perl.self = 0;
618 } 631 }
619 632
620 swap (perl_environ, environ);
621
622 return event_consumed; 633 return event_consumed;
634}
635
636void
637rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
638{
639 localise_env set_environ (perl_environ);
640
641 ENTER;
642 SAVETMPS;
643
644 dSP;
645 XPUSHs (sv_2mortal (newSVpvn (data, len)));
646 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
647
648 if (SvTRUE (ERRSV))
649 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
650
651 FREETMPS;
652 LEAVE;
623} 653}
624 654
625///////////////////////////////////////////////////////////////////////////// 655/////////////////////////////////////////////////////////////////////////////
626 656
627MODULE = urxvt PACKAGE = urxvt 657MODULE = urxvt PACKAGE = urxvt
639# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 669# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
640# include "hookinc.h" 670# include "hookinc.h"
641# undef def 671# undef def
642 672
643 HV *option = get_hv ("urxvt::OPTION", 1); 673 HV *option = get_hv ("urxvt::OPTION", 1);
644# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); 674# define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
645# define nodef(name) 675# define nodef(name)
646# include "optinc.h" 676# include "optinc.h"
647# undef nodef 677# undef nodef
648# undef def 678# undef def
649 679
654 } *civ, const_iv[] = { 684 } *civ, const_iv[] = {
655# define const_iv(name) { # name, (IV)name } 685# define const_iv(name) { # name, (IV)name }
656 const_iv (NUM_RESOURCES), 686 const_iv (NUM_RESOURCES),
657 const_iv (DEFAULT_RSTYLE), 687 const_iv (DEFAULT_RSTYLE),
658 const_iv (OVERLAY_RSTYLE), 688 const_iv (OVERLAY_RSTYLE),
689 const_iv (Color_Bits),
690 const_iv (RS_bgShift), const_iv (RS_bgMask),
691 const_iv (RS_fgShift), const_iv (RS_fgMask),
692 const_iv (RS_Careful),
693 const_iv (RS_fontCount),
694 const_iv (RS_fontShift),
695 const_iv (RS_fontMask),
696 const_iv (RS_baseattrMask),
697 const_iv (RS_attrMask),
698 const_iv (RS_redraw),
699 const_iv (RS_Sel),
659 const_iv (RS_Bold), 700 const_iv (RS_Bold),
660 const_iv (RS_Italic), 701 const_iv (RS_Italic),
661 const_iv (RS_Blink), 702 const_iv (RS_Blink),
662 const_iv (RS_RVid), 703 const_iv (RS_RVid),
663 const_iv (RS_Uline), 704 const_iv (RS_Uline),
767 const_iv (XIMDontChange), 808 const_iv (XIMDontChange),
768# endif 809# endif
769# endif 810# endif
770 }; 811 };
771 812
772 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 813 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
773 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 814 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
774} 815}
775 816
776void 817void
777warn (const char *msg) 818warn (const char *msg)
778 CODE: 819 CODE:
850 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 891 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
851 if ((*t)->perl.self) 892 if ((*t)->perl.self)
852 PUSHs (sv_2mortal (newSVterm (*t))); 893 PUSHs (sv_2mortal (newSVterm (*t)));
853} 894}
854 895
896IV
897_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
898 CODE:
899 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
900 req->cb_sv = newSVsv (cb);
901 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
902 av_push (av, newSViv ((IV)req));
903 RETVAL = (IV)req;
904 OUTPUT:
905 RETVAL
906
907void
908_delete_selection_request (IV req_)
909 CODE:
910 rxvt_selection *req = (rxvt_selection *)req_;
911 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
912 int i;
913
914 for (i = AvFILL (av); i >= 0; i--)
915 if (SvIV (*av_fetch (av, i, 1)) == req_)
916 break;
917
918 for (; i < AvFILL (av); i++)
919 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
920
921 av_pop (av);
922
923 delete req;
924
855MODULE = urxvt PACKAGE = urxvt::term 925MODULE = urxvt PACKAGE = urxvt::term
856 926
857SV * 927SV *
858_new (AV *env, AV *arg) 928_new (AV *env, AV *arg)
859 CODE: 929 CODE:
860{ 930{
861 rxvt_term *term = new rxvt_term; 931 rxvt_term *term = new rxvt_term;
862 932
863 stringvec *argv = new stringvec; 933 stringvec *argv = new stringvec;
864 stringvec *envv = new stringvec;
865
866 for (int i = 0; i <= AvFILL (arg); i++) 934 for (int i = 0; i <= AvFILL (arg); i++)
867 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 935 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
868 936
937 stringvec *envv = new stringvec;
869 for (int i = AvFILL (env) + 1; i--; ) 938 for (int i = AvFILL (env) + 1; i--; )
870 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 939 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
871
872 envv->push_back (0);
873 940
874 try 941 try
875 { 942 {
876 term->init (argv, envv); 943 term->init (argv, envv);
877 } 944 }
917 984
918void 985void
919rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 986rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
920 CODE: 987 CODE:
921 XUngrabKey (THIS->dpy, keycode, modifiers, window); 988 XUngrabKey (THIS->dpy, keycode, modifiers, window);
922
923void
924rxvt_term::XUngrabKeyboard (Time eventtime)
925 CODE:
926 XUngrabKeyboard (THIS->dpy, eventtime);
927 989
928bool 990bool
929rxvt_term::grab (Time eventtime, int sync = 0) 991rxvt_term::grab (Time eventtime, int sync = 0)
930 CODE: 992 CODE:
931{ 993{
1043 rxvt_pop_locale (); 1105 rxvt_pop_locale ();
1044 1106
1045 RETVAL = wcs2sv (wstr); 1107 RETVAL = wcs2sv (wstr);
1046 free (wstr); 1108 free (wstr);
1047} 1109}
1048 OUTPUT:
1049 RETVAL
1050
1051char *
1052rxvt_term::locale ()
1053 CODE:
1054 RETVAL = THIS->locale;
1055 OUTPUT: 1110 OUTPUT:
1056 RETVAL 1111 RETVAL
1057 1112
1058#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1113#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1059 1114
1166 RETVAL 1221 RETVAL
1167 1222
1168Window 1223Window
1169rxvt_term::parent () 1224rxvt_term::parent ()
1170 CODE: 1225 CODE:
1171 RETVAL = THIS->parent [0]; 1226 RETVAL = THIS->parent;
1172 OUTPUT: 1227 OUTPUT:
1173 RETVAL 1228 RETVAL
1174 1229
1175Window 1230Window
1176rxvt_term::vt () 1231rxvt_term::vt ()
1203 if (newval <= 0) 1258 if (newval <= 0)
1204 THIS->scr_changeview (max (newval, THIS->top_row)); 1259 THIS->scr_changeview (max (newval, THIS->top_row));
1205} 1260}
1206 OUTPUT: 1261 OUTPUT:
1207 RETVAL 1262 RETVAL
1263
1264void
1265rxvt_term::set_urgency (bool enable)
1208 1266
1209void 1267void
1210rxvt_term::focus_in () 1268rxvt_term::focus_in ()
1211 1269
1212void 1270void
1445# include "rsinc.h" 1503# include "rsinc.h"
1446# undef def 1504# undef def
1447# undef reserve 1505# undef reserve
1448 }; 1506 };
1449 1507
1450 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1508 rs = rslist + ecb_array_length (rslist);
1451 1509
1452 if (*name) 1510 if (*name)
1453 { 1511 {
1454 do { 1512 do {
1455 if (rs-- == rslist) 1513 if (rs-- == rslist)
1494 1552
1495 if (set >= 0) 1553 if (set >= 0)
1496 { 1554 {
1497 THIS->set_option (optval, set); 1555 THIS->set_option (optval, set);
1498 1556
1499 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1557 if (THIS->init_done) // avoid doing this before START
1500 switch (optval) 1558 switch (optval)
1501 { 1559 {
1502 case Opt_skipBuiltinGlyphs: 1560 case Opt_skipBuiltinGlyphs:
1503 THIS->set_fonts (); 1561 THIS->set_fonts ();
1504 THIS->scr_remap_chars (); 1562 THIS->scr_remap_chars ();
1505 THIS->scr_touch (true); 1563 THIS->scr_touch (true);
1506 THIS->want_refresh = 1; 1564 THIS->want_refresh = 1;
1507 THIS->refresh_check (); 1565 THIS->refresh_check ();
1508 break; 1566 break;
1567#ifdef CURSOR_BLINK
1568 case Opt_cursorBlink:
1569 THIS->cursor_blink_reset ();
1570 break;
1571#endif
1509 1572
1510 case Opt_cursorUnderline: 1573 case Opt_cursorUnderline:
1511 THIS->want_refresh = 1; 1574 THIS->want_refresh = 1;
1512 THIS->refresh_check (); 1575 THIS->refresh_check ();
1513 break; 1576 break;
1527 CODE: 1590 CODE:
1528 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1591 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1529 THIS->keyboard->register_done (); 1592 THIS->keyboard->register_done ();
1530 OUTPUT: 1593 OUTPUT:
1531 RETVAL 1594 RETVAL
1595
1596void
1597rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1598 CODE:
1599 wchar_t *wstr = sv2wcs (str);
1600 THIS->keyboard->register_user_translation (keysym, state, wstr);
1601 free (wstr);
1532 1602
1533void 1603void
1534rxvt_term::screen_cur (...) 1604rxvt_term::screen_cur (...)
1535 PROTOTYPE: $;$$ 1605 PROTOTYPE: $;$$
1536 ALIAS: 1606 ALIAS:
1594 THIS->selection.screen = screen; 1664 THIS->selection.screen = screen;
1595 OUTPUT: 1665 OUTPUT:
1596 RETVAL 1666 RETVAL
1597 1667
1598void 1668void
1599rxvt_term::selection_clear () 1669rxvt_term::selection_clear (bool clipboard = false)
1600 1670
1601void 1671void
1602rxvt_term::selection_make (Time eventtime, bool rect = false) 1672rxvt_term::selection_make (Time eventtime, bool rect = false)
1603 CODE: 1673 CODE:
1604 THIS->selection.op = SELECTION_CONT; 1674 THIS->selection.op = SELECTION_CONT;
1605 THIS->selection.rect = rect; 1675 THIS->selection.rect = rect;
1606 THIS->selection_make (eventtime); 1676 THIS->selection_make (eventtime);
1607 1677
1608int 1678int
1609rxvt_term::selection_grab (Time eventtime) 1679rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1610 1680
1611void 1681void
1612rxvt_term::selection (SV *newtext = 0) 1682rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1613 PPCODE: 1683 PPCODE:
1614{ 1684{
1685 wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text;
1686 unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len;
1687
1615 if (GIMME_V != G_VOID) 1688 if (GIMME_V != G_VOID)
1616 XPUSHs (THIS->selection.text 1689 XPUSHs (text
1617 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1690 ? sv_2mortal (wcs2sv (text, len))
1618 : &PL_sv_undef); 1691 : &PL_sv_undef);
1619 1692
1620 if (newtext) 1693 if (newtext)
1621 { 1694 {
1622 free (THIS->selection.text); 1695 free (text);
1623 1696
1624 THIS->selection.text = sv2wcs (newtext); 1697 text = sv2wcs (newtext);
1625 THIS->selection.len = wcslen (THIS->selection.text); 1698 len = wcslen (text);
1626 } 1699 }
1627} 1700}
1628 1701
1629char 1702char
1630rxvt_term::cur_charset () 1703rxvt_term::cur_charset ()
1661 char *str = SvPVbyte (octets, len); 1734 char *str = SvPVbyte (octets, len);
1662 C_ARGS: 1735 C_ARGS:
1663 str, len 1736 str, len
1664 1737
1665void 1738void
1739rxvt_term::tt_paste (SV *octets)
1740 INIT:
1741 STRLEN len;
1742 char *str = SvPVbyte (octets, len);
1743 C_ARGS:
1744 str, len
1745
1746void
1666rxvt_term::cmd_parse (SV *octets) 1747rxvt_term::cmd_parse (SV *octets)
1667 CODE: 1748 CODE:
1668{ 1749{
1669 STRLEN len; 1750 STRLEN len;
1670 char *str = SvPVbyte (octets, len); 1751 char *str = SvPVbyte (octets, len);
1847void 1928void
1848overlay::DESTROY () 1929overlay::DESTROY ()
1849 1930
1850INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 1931INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1851 1932
1933MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
1934
1935urxvt::pixbuf gdk_pixbuf_new_from_file (octet_string filename, GError **error = 0)
1936
1937void
1938DESTROY (urxvt::pixbuf self)
1939 CODE:
1940 gdk_pixbuf_unref (self);
1941

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines