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.132 by sf-exg, Sat Jul 24 10:20:26 2010 UTC vs.
Revision 1.156 by root, Sun Jun 3 15:54:05 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;
56typedef SV * urxvt_color;
57
58typedef GdkPixbuf * urxvt__pixbuf;
59typedef rxvt_img * urxvt__img;
60
61/////////////////////////////////////////////////////////////////////////////
62
63static void
64parse_color (rxvt_screen *s, rxvt_color &c, SV *sv)
65{
66 //TODO: support component stuff
67 c.set (s, SvPVbyte_nolen (sv));
68}
50 69
51///////////////////////////////////////////////////////////////////////////// 70/////////////////////////////////////////////////////////////////////////////
52 71
53static wchar_t * 72static wchar_t *
54sv2wcs (SV *sv) 73sv2wcs (SV *sv)
302 THIS->refresh_check (); 321 THIS->refresh_check ();
303} 322}
304 323
305///////////////////////////////////////////////////////////////////////////// 324/////////////////////////////////////////////////////////////////////////////
306 325
307#define IOM_CLASS "urxvt"
308#define IOM_WARN rxvt_warn
309#include "iom_perl.h" 326#include "iom_perl.h"
310 327
311///////////////////////////////////////////////////////////////////////////// 328/////////////////////////////////////////////////////////////////////////////
312 329
313struct rxvt_perl_interp rxvt_perl; 330struct rxvt_perl_interp rxvt_perl;
329{ 346{
330 if (!perl) 347 if (!perl)
331 { 348 {
332 rxvt_push_locale (""); // perl init destroys current locale 349 rxvt_push_locale (""); // perl init destroys current locale
333 350
351 {
334 perl_environ = rxvt_environ; 352 perl_environ = rxvt_environ;
335 swap (perl_environ, environ); 353 localise_env set_environ (perl_environ);
336 354
337 char *args[] = { 355 char *args[] = {
338 "", 356 "",
339 "-e" 357 "-e"
340 "BEGIN {" 358 "BEGIN {"
341 " urxvt->bootstrap;" 359 " urxvt->bootstrap;"
342 " unshift @INC, '" LIBDIR "';" 360 " unshift @INC, '" LIBDIR "';"
343 "}" 361 "}"
344 "" 362 ""
345 "use urxvt;" 363 "use urxvt;"
346 }; 364 };
347 int argc = sizeof (args) / sizeof (args[0]); 365 int argc = ecb_array_length (args);
348 char **argv = args; 366 char **argv = args;
349 367
350 PERL_SYS_INIT3 (&argc, &argv, &environ); 368 PERL_SYS_INIT3 (&argc, &argv, &environ);
351 perl = perl_alloc (); 369 perl = perl_alloc ();
352 perl_construct (perl); 370 perl_construct (perl);
353 371
354 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) 372 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL)
355 || perl_run (perl)) 373 || perl_run (perl))
356 { 374 {
357 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 375 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
358 376
359 perl_destruct (perl); 377 perl_destruct (perl);
360 perl_free (perl); 378 perl_free (perl);
361 perl = 0; 379 perl = 0;
362 } 380 }
363 381 }
364 swap (perl_environ, environ);
365 382
366 rxvt_pop_locale (); 383 rxvt_pop_locale ();
367 } 384 }
368 385
369 if (perl) 386 if (perl)
370 { 387 {
371 // runs outside of perls ENV 388 // runs outside of perls ENV
372 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 389 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); 390 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
391 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
374 } 392 }
375} 393}
376 394
377static void 395static void
378ungrab (rxvt_term *THIS) 396ungrab (rxvt_term *THIS)
389rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 407rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
390{ 408{
391 if (!perl || !term->perl.self) 409 if (!perl || !term->perl.self)
392 return false; 410 return false;
393 411
412 localise_env set_environ (perl_environ);
413
394 // pre-handling of some events 414 // pre-handling of some events
395 if (htype == HOOK_REFRESH_END) 415 if (htype == HOOK_REFRESH_END)
396 { 416 {
397 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 417 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
398 418
399 for (int i = 0; i <= AvFILL (av); i++) 419 for (int i = 0; i <= AvFILL (av); i++)
400 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 420 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
401 } 421 }
422 else if (htype == HOOK_DESTROY)
423 {
424 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
402 425
403 swap (perl_environ, environ); 426 for (int i = AvFILL (av); i >= 0; i--)
427 {
428 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
429 delete req;
430 }
431 }
404 432
405 bool event_consumed; 433 bool event_consumed;
406 434
407 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 435 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
408 || term->perl.should_invoke [htype]) 436 || term->perl.should_invoke [htype])
409 try
410 { 437 {
411 dSP; 438 dSP;
412 va_list ap; 439 va_list ap;
413 440
414 va_start (ap, htype); 441 va_start (ap, htype);
415 442
416 ENTER; 443 ENTER;
417 SAVETMPS; 444 SAVETMPS;
418 445
419 PUSHMARK (SP); 446 PUSHMARK (SP);
420 447
448 EXTEND (SP, 2);
421 XPUSHs (sv_2mortal (newSVterm (term))); 449 PUSHs (sv_2mortal (newSVterm (term)));
422 XPUSHs (sv_2mortal (newSViv (htype))); 450 PUSHs (sv_2mortal (newSViv (htype)));
423 451
424 for (;;) { 452 for (;;) {
425 data_type dt = (data_type)va_arg (ap, int); 453 data_type dt = (data_type)va_arg (ap, int);
426 454
427 switch (dt) 455 switch (dt)
428 { 456 {
429 case DT_INT: 457 case DT_INT:
430 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 458 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
431 break; 459 break;
432 460
433 case DT_LONG: 461 case DT_LONG:
434 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 462 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
435 break; 463 break;
436 464
437 case DT_STR: 465 case DT_STR:
438 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 466 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
439 break; 467 break;
440 468
441 case DT_STR_LEN: 469 case DT_STR_LEN:
442 { 470 {
443 char *str = va_arg (ap, char *); 471 char *str = va_arg (ap, char *);
444 int len = va_arg (ap, int); 472 int len = va_arg (ap, int);
445 473
446 XPUSHs (sv_2mortal (newSVpvn (str, len))); 474 XPUSHs (sv_2mortal (newSVpvn (str, len)));
447 } 475 }
448 break; 476 break;
449 477
450 case DT_WCS_LEN: 478 case DT_WCS_LEN:
451 { 479 {
452 wchar_t *wstr = va_arg (ap, wchar_t *); 480 wchar_t *wstr = va_arg (ap, wchar_t *);
453 int wlen = va_arg (ap, int); 481 int wlen = va_arg (ap, int);
454 482
455 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 483 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
456 } 484 }
457 break; 485 break;
458 486
459 case DT_LCS_LEN: 487 case DT_LCS_LEN:
460 { 488 {
461 long *lstr = va_arg (ap, long *); 489 long *lstr = va_arg (ap, long *);
462 int llen = va_arg (ap, int); 490 int llen = va_arg (ap, int);
463 491
464 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); 492 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
465 } 493 }
466 break; 494 break;
467 495
468 case DT_XEVENT: 496 case DT_XEVENT:
469 { 497 {
470 XEvent *xe = va_arg (ap, XEvent *); 498 XEvent *xe = va_arg (ap, XEvent *);
471 HV *hv = newHV (); 499 HV *hv = newHV ();
472 500
473# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 501# 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) 502# 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) 503# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
476# undef set 504# undef set
477 505
478 setiv (type, xe->type); 506 setiv (type, xe->type);
479 setiv (send_event, xe->xany.send_event); 507 setiv (send_event, xe->xany.send_event);
480 setiv (serial, xe->xany.serial); 508 setiv (serial, xe->xany.serial);
481 509
482 switch (xe->type) 510 switch (xe->type)
483 { 511 {
484 case KeyPress: 512 case KeyPress:
485 case KeyRelease: 513 case KeyRelease:
486 case ButtonPress: 514 case ButtonPress:
487 case ButtonRelease: 515 case ButtonRelease:
488 case MotionNotify: 516 case MotionNotify:
489 setuv (window, xe->xmotion.window); 517 setuv (window, xe->xmotion.window);
490 setuv (root, xe->xmotion.root); 518 setuv (root, xe->xmotion.root);
491 setuv (subwindow, xe->xmotion.subwindow); 519 setuv (subwindow, xe->xmotion.subwindow);
492 setuv (time, xe->xmotion.time); 520 setuv (time, xe->xmotion.time);
493 setiv (x, xe->xmotion.x); 521 setiv (x, xe->xmotion.x);
494 setiv (y, xe->xmotion.y); 522 setiv (y, xe->xmotion.y);
495 setiv (row, xe->xmotion.y / term->fheight + term->view_start); 523 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
496 setiv (col, xe->xmotion.x / term->fwidth); 524 setiv (col, xe->xmotion.x / term->fwidth);
497 setiv (x_root, xe->xmotion.x_root); 525 setiv (x_root, xe->xmotion.x_root);
498 setiv (y_root, xe->xmotion.y_root); 526 setiv (y_root, xe->xmotion.y_root);
499 setuv (state, xe->xmotion.state); 527 setuv (state, xe->xmotion.state);
500 528
501 switch (xe->type) 529 switch (xe->type)
502 { 530 {
503 case KeyPress: 531 case KeyPress:
504 case KeyRelease: 532 case KeyRelease:
505 setuv (keycode, xe->xkey.keycode); 533 setuv (keycode, xe->xkey.keycode);
506 break; 534 break;
507 535
508 case ButtonPress: 536 case ButtonPress:
509 case ButtonRelease: 537 case ButtonRelease:
510 setuv (button, xe->xbutton.button); 538 setuv (button, xe->xbutton.button);
511 break; 539 break;
512 540
513 case MotionNotify: 541 case MotionNotify:
514 setiv (is_hint, xe->xmotion.is_hint); 542 setiv (is_hint, xe->xmotion.is_hint);
515 break; 543 break;
516 } 544 }
517 545
518 break; 546 break;
519 547
520 case MapNotify: 548 case MapNotify:
521 case UnmapNotify: 549 case UnmapNotify:
522 case ConfigureNotify: 550 case ConfigureNotify:
523 setuv (event, xe->xconfigure.event); 551 setuv (event, xe->xconfigure.event);
524 setuv (window, xe->xconfigure.window); 552 setuv (window, xe->xconfigure.window);
525 553
526 switch (xe->type) 554 switch (xe->type)
527 { 555 {
528 case ConfigureNotify: 556 case ConfigureNotify:
529 setiv (x, xe->xconfigure.x); 557 setiv (x, xe->xconfigure.x);
530 setiv (y, xe->xconfigure.y); 558 setiv (y, xe->xconfigure.y);
531 setiv (width, xe->xconfigure.width); 559 setiv (width, xe->xconfigure.width);
532 setiv (height, xe->xconfigure.height); 560 setiv (height, xe->xconfigure.height);
533 setuv (above, xe->xconfigure.above); 561 setuv (above, xe->xconfigure.above);
534 break; 562 break;
535 } 563 }
536 564
537 break; 565 break;
538 566
539 case PropertyNotify: 567 case PropertyNotify:
540 setuv (window, xe->xproperty.window); 568 setuv (window, xe->xproperty.window);
541 setuv (atom, xe->xproperty.atom); 569 setuv (atom, xe->xproperty.atom);
542 setuv (time, xe->xproperty.time); 570 setuv (time, xe->xproperty.time);
543 setiv (state, xe->xproperty.state); 571 setiv (state, xe->xproperty.state);
544 break; 572 break;
545 573
546 case ClientMessage: 574 case ClientMessage:
547 setuv (window, xe->xclient.window); 575 setuv (window, xe->xclient.window);
548 setuv (message_type, xe->xclient.message_type); 576 setuv (message_type, xe->xclient.message_type);
549 setuv (format, xe->xclient.format); 577 setuv (format, xe->xclient.format);
550 setuv (l0, xe->xclient.data.l[0]); 578 setuv (l0, xe->xclient.data.l[0]);
551 setuv (l1, xe->xclient.data.l[1]); 579 setuv (l1, xe->xclient.data.l[1]);
552 setuv (l2, xe->xclient.data.l[2]); 580 setuv (l2, xe->xclient.data.l[2]);
553 setuv (l3, xe->xclient.data.l[3]); 581 setuv (l3, xe->xclient.data.l[3]);
554 setuv (l4, xe->xclient.data.l[4]); 582 setuv (l4, xe->xclient.data.l[4]);
555 break; 583 break;
556 } 584 }
557 585
558 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 586 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
559 } 587 }
560 break; 588 break;
561 589
562 case DT_END: 590 case DT_END:
563 goto call; 591 goto call;
564 592
565 default: 593 default:
566 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 594 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
567 } 595 }
596 }
597
598 call:
599 va_end (ap);
600
601 PUTBACK;
602 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
603 SPAGAIN;
604
605 if (count)
606 {
607 SV *status = POPs;
608 count = SvTRUE (status);
568 } 609 }
569 610
570 call:
571 va_end (ap);
572
573 PUTBACK; 611 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; 612 FREETMPS;
585 LEAVE; 613 LEAVE;
586 614
587 if (SvTRUE (ERRSV)) 615 if (SvTRUE (ERRSV))
588 { 616 {
589 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 617 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
590 ungrab (term); // better lose the grab than the session 618 ungrab (term); // better lose the grab than the session
591 } 619 }
592 620
593 event_consumed = !!count; 621 event_consumed = !!count;
594 } 622 }
595 catch (...)
596 {
597 swap (perl_environ, environ);
598 throw;
599 }
600 else 623 else
601 event_consumed = false; 624 event_consumed = false;
602 625
603 // post-handling of some events 626 // post-handling of some events
604 if (htype == HOOK_REFRESH_BEGIN) 627 if (htype == HOOK_REFRESH_BEGIN)
615 638
616 // don't allow further calls 639 // don't allow further calls
617 term->perl.self = 0; 640 term->perl.self = 0;
618 } 641 }
619 642
620 swap (perl_environ, environ);
621
622 return event_consumed; 643 return event_consumed;
644}
645
646void
647rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
648{
649 localise_env set_environ (perl_environ);
650
651 ENTER;
652 SAVETMPS;
653
654 dSP;
655 XPUSHs (sv_2mortal (newSVpvn (data, len)));
656 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
657
658 if (SvTRUE (ERRSV))
659 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
660
661 FREETMPS;
662 LEAVE;
623} 663}
624 664
625///////////////////////////////////////////////////////////////////////////// 665/////////////////////////////////////////////////////////////////////////////
626 666
627MODULE = urxvt PACKAGE = urxvt 667MODULE = urxvt PACKAGE = urxvt
639# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 679# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
640# include "hookinc.h" 680# include "hookinc.h"
641# undef def 681# undef def
642 682
643 HV *option = get_hv ("urxvt::OPTION", 1); 683 HV *option = get_hv ("urxvt::OPTION", 1);
644# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); 684# define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
645# define nodef(name) 685# define nodef(name)
646# include "optinc.h" 686# include "optinc.h"
647# undef nodef 687# undef nodef
648# undef def 688# undef def
649 689
778 const_iv (XIMDontChange), 818 const_iv (XIMDontChange),
779# endif 819# endif
780# endif 820# endif
781 }; 821 };
782 822
783 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 823 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
784 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 824 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
785} 825}
786 826
787void 827void
788warn (const char *msg) 828warn (const char *msg)
789 CODE: 829 CODE:
861 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 901 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
862 if ((*t)->perl.self) 902 if ((*t)->perl.self)
863 PUSHs (sv_2mortal (newSVterm (*t))); 903 PUSHs (sv_2mortal (newSVterm (*t)));
864} 904}
865 905
906IV
907_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
908 CODE:
909 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
910 req->cb_sv = newSVsv (cb);
911 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
912 av_push (av, newSViv ((IV)req));
913 RETVAL = (IV)req;
914 OUTPUT:
915 RETVAL
916
917void
918_delete_selection_request (IV req_)
919 CODE:
920 rxvt_selection *req = (rxvt_selection *)req_;
921 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
922 int i;
923
924 for (i = AvFILL (av); i >= 0; i--)
925 if (SvIV (*av_fetch (av, i, 1)) == req_)
926 break;
927
928 for (; i < AvFILL (av); i++)
929 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
930
931 av_pop (av);
932
933 delete req;
934
866MODULE = urxvt PACKAGE = urxvt::term 935MODULE = urxvt PACKAGE = urxvt::term
867 936
868SV * 937SV *
869_new (AV *env, AV *arg) 938_new (AV *env, AV *arg)
870 CODE: 939 CODE:
871{ 940{
872 rxvt_term *term = new rxvt_term; 941 rxvt_term *term = new rxvt_term;
873 942
874 stringvec *argv = new stringvec; 943 stringvec *argv = new stringvec;
875 stringvec *envv = new stringvec;
876
877 for (int i = 0; i <= AvFILL (arg); i++) 944 for (int i = 0; i <= AvFILL (arg); i++)
878 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 945 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
879 946
947 stringvec *envv = new stringvec;
880 for (int i = AvFILL (env) + 1; i--; ) 948 for (int i = AvFILL (env) + 1; i--; )
881 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 949 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
882
883 envv->push_back (0);
884 950
885 try 951 try
886 { 952 {
887 term->init (argv, envv); 953 term->init (argv, envv);
888 } 954 }
928 994
929void 995void
930rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 996rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
931 CODE: 997 CODE:
932 XUngrabKey (THIS->dpy, keycode, modifiers, window); 998 XUngrabKey (THIS->dpy, keycode, modifiers, window);
933
934void
935rxvt_term::XUngrabKeyboard (Time eventtime)
936 CODE:
937 XUngrabKeyboard (THIS->dpy, eventtime);
938 999
939bool 1000bool
940rxvt_term::grab (Time eventtime, int sync = 0) 1001rxvt_term::grab (Time eventtime, int sync = 0)
941 CODE: 1002 CODE:
942{ 1003{
1054 rxvt_pop_locale (); 1115 rxvt_pop_locale ();
1055 1116
1056 RETVAL = wcs2sv (wstr); 1117 RETVAL = wcs2sv (wstr);
1057 free (wstr); 1118 free (wstr);
1058} 1119}
1059 OUTPUT:
1060 RETVAL
1061
1062char *
1063rxvt_term::locale ()
1064 CODE:
1065 RETVAL = THIS->locale;
1066 OUTPUT: 1120 OUTPUT:
1067 RETVAL 1121 RETVAL
1068 1122
1069#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1123#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1070 1124
1177 RETVAL 1231 RETVAL
1178 1232
1179Window 1233Window
1180rxvt_term::parent () 1234rxvt_term::parent ()
1181 CODE: 1235 CODE:
1182 RETVAL = THIS->parent [0]; 1236 RETVAL = THIS->parent;
1183 OUTPUT: 1237 OUTPUT:
1184 RETVAL 1238 RETVAL
1185 1239
1186Window 1240Window
1187rxvt_term::vt () 1241rxvt_term::vt ()
1214 if (newval <= 0) 1268 if (newval <= 0)
1215 THIS->scr_changeview (max (newval, THIS->top_row)); 1269 THIS->scr_changeview (max (newval, THIS->top_row));
1216} 1270}
1217 OUTPUT: 1271 OUTPUT:
1218 RETVAL 1272 RETVAL
1273
1274void
1275rxvt_term::set_urgency (bool enable)
1219 1276
1220void 1277void
1221rxvt_term::focus_in () 1278rxvt_term::focus_in ()
1222 1279
1223void 1280void
1456# include "rsinc.h" 1513# include "rsinc.h"
1457# undef def 1514# undef def
1458# undef reserve 1515# undef reserve
1459 }; 1516 };
1460 1517
1461 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1518 rs = rslist + ecb_array_length (rslist);
1462 1519
1463 if (*name) 1520 if (*name)
1464 { 1521 {
1465 do { 1522 do {
1466 if (rs-- == rslist) 1523 if (rs-- == rslist)
1505 1562
1506 if (set >= 0) 1563 if (set >= 0)
1507 { 1564 {
1508 THIS->set_option (optval, set); 1565 THIS->set_option (optval, set);
1509 1566
1510 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1567 if (THIS->init_done) // avoid doing this before START
1511 switch (optval) 1568 switch (optval)
1512 { 1569 {
1513 case Opt_skipBuiltinGlyphs: 1570 case Opt_skipBuiltinGlyphs:
1514 THIS->set_fonts (); 1571 THIS->set_fonts ();
1515 THIS->scr_remap_chars (); 1572 THIS->scr_remap_chars ();
1516 THIS->scr_touch (true); 1573 THIS->scr_touch (true);
1517 THIS->want_refresh = 1; 1574 THIS->want_refresh = 1;
1518 THIS->refresh_check (); 1575 THIS->refresh_check ();
1519 break; 1576 break;
1577#ifdef CURSOR_BLINK
1578 case Opt_cursorBlink:
1579 THIS->cursor_blink_reset ();
1580 break;
1581#endif
1520 1582
1521 case Opt_cursorUnderline: 1583 case Opt_cursorUnderline:
1522 THIS->want_refresh = 1; 1584 THIS->want_refresh = 1;
1523 THIS->refresh_check (); 1585 THIS->refresh_check ();
1524 break; 1586 break;
1538 CODE: 1600 CODE:
1539 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1601 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1540 THIS->keyboard->register_done (); 1602 THIS->keyboard->register_done ();
1541 OUTPUT: 1603 OUTPUT:
1542 RETVAL 1604 RETVAL
1605
1606void
1607rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1608 CODE:
1609 wchar_t *wstr = sv2wcs (str);
1610 THIS->keyboard->register_user_translation (keysym, state, wstr);
1611 free (wstr);
1543 1612
1544void 1613void
1545rxvt_term::screen_cur (...) 1614rxvt_term::screen_cur (...)
1546 PROTOTYPE: $;$$ 1615 PROTOTYPE: $;$$
1547 ALIAS: 1616 ALIAS:
1869void 1938void
1870overlay::DESTROY () 1939overlay::DESTROY ()
1871 1940
1872INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 1941INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1873 1942
1943MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
1944
1945#if HAVE_PIXBUF
1946
1947urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename)
1948 C_ARGS: filename, 0
1949
1950void
1951DESTROY (urxvt::pixbuf self)
1952 CODE:
1953 gdk_pixbuf_unref (self);
1954
1955#endif
1956
1957MODULE = urxvt PACKAGE = urxvt::img
1958
1959#if HAVE_IMG
1960
1961# rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height);
1962# rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
1963
1964void fill (urxvt::img self, SV *c)
1965 CODE:
1966 rxvt_color rc;
1967 parse_color (self->s, rc, c);
1968 self->fill (rc);
1969
1970void blur (urxvt::img self, int rh, int rv)
1971 CODE:
1972 self->blur (rh, rv);
1973
1974void brightness (urxvt::img self, double r, double g, double b, double a = 1.)
1975 CODE:
1976 self->brightness (r, g, b, a);
1977
1978void contrast (urxvt::img self, double r, double g, double b, double a = 1.)
1979 CODE:
1980 self->contrast (r, g, b, a);
1981
1982urxvt::img copy (urxvt::img self)
1983 CODE:
1984 RETVAL = self->copy ();
1985 OUTPUT:
1986 RETVAL
1987
1988urxvt::img scale (urxvt::img self, int new_width, int new_height)
1989 CODE:
1990 RETVAL = self->scale (new_width, new_height);
1991 OUTPUT:
1992 RETVAL
1993
1994# rxvt_img *transform (urxvt::img self, int new_width, int new_height, double matrix[16]);
1995
1996#endif
1997

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines