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.125 by root, Fri Aug 22 15:36:45 2008 UTC vs.
Revision 1.165 by root, Mon Jun 4 21:33:47 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"
48#undef ROW 49#undef ROW
49#define ROW(n) THIS->row_buf [LINENO (n)] 50#define ROW(n) THIS->row_buf [LINENO (n)]
50 51
51///////////////////////////////////////////////////////////////////////////// 52/////////////////////////////////////////////////////////////////////////////
52 53
54typedef char * octet_string;
55typedef char * utf8_string;
56
57typedef GdkPixbuf * urxvt__pixbuf;
58typedef rxvt_img * urxvt__img;
59
60/////////////////////////////////////////////////////////////////////////////
61
62static void
63parse_color (rxvt_screen *s, rxvt_color &c, SV *sv)
64{
65 //TODO: support component stuff
66 c.set (s, SvPVbyte_nolen (sv));
67}
68
69/////////////////////////////////////////////////////////////////////////////
70
53static wchar_t * 71static wchar_t *
54sv2wcs (SV *sv) 72sv2wcs (SV *sv)
55{ 73{
56 STRLEN len; 74 STRLEN len;
57 char *str = SvPVutf8 (sv, len); 75 char *str = SvPVutf8 (sv, len);
107 125
108///////////////////////////////////////////////////////////////////////////// 126/////////////////////////////////////////////////////////////////////////////
109 127
110#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 128#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
111 129
112class overlay { 130class overlay : overlay_base
131{
113 rxvt_term *THIS; 132 rxvt_term *THIS;
114 AV *overlay_av; 133 AV *overlay_av;
115 int x, y, w, h;
116 int border; 134 int border;
117 text_t **text;
118 rend_t **rend;
119 135
120public: 136public:
121 HV *self; 137 HV *self;
122 138
123 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); 139 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
130 146
131 void set (int x, int y, SV *str, SV *rend); 147 void set (int x, int y, SV *str, SV *rend);
132}; 148};
133 149
134overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) 150overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border)
135: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) 151: THIS(THIS), border(border == 2), overlay_av (0)
136{ 152{
153 x = x_;
154 y = y_;
155 w = w_;
156 h = h_;
157
137 if (w < 0) w = 0; 158 if (w < 0) w = 0;
138 if (h < 0) h = 0; 159 if (h < 0) h = 0;
139 160
140 if (border == 2) 161 if (border == 2)
141 { 162 {
245 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); 266 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h));
246 267
247 int ov_w = min (w, THIS->ncol - ov_x); 268 int ov_w = min (w, THIS->ncol - ov_x);
248 int ov_h = min (h, THIS->nrow - ov_y); 269 int ov_h = min (h, THIS->nrow - ov_y);
249 270
271 // hide cursor if it is within the overlay area
272 if (IN_RANGE_EXC (THIS->screen.cur.col - ov_x, 0, ov_w)
273 && IN_RANGE_EXC (THIS->screen.cur.row - ov_y, 0, ov_h))
274 THIS->screen.flags &= ~Screen_VisibleCursor;
275
250 for (int y = ov_h; y--; ) 276 for (int y = ov_h; y--; )
251 { 277 {
252 text_t *t1 = text [y]; 278 text_t *t1 = text [y];
253 rend_t *r1 = rend [y]; 279 rend_t *r1 = rend [y];
254 280
294 THIS->refresh_check (); 320 THIS->refresh_check ();
295} 321}
296 322
297///////////////////////////////////////////////////////////////////////////// 323/////////////////////////////////////////////////////////////////////////////
298 324
299#define IOM_CLASS "urxvt"
300#define IOM_WARN rxvt_warn
301#include "iom_perl.h" 325#include "iom_perl.h"
302 326
303///////////////////////////////////////////////////////////////////////////// 327/////////////////////////////////////////////////////////////////////////////
304 328
305struct rxvt_perl_interp rxvt_perl; 329struct rxvt_perl_interp rxvt_perl;
321{ 345{
322 if (!perl) 346 if (!perl)
323 { 347 {
324 rxvt_push_locale (""); // perl init destroys current locale 348 rxvt_push_locale (""); // perl init destroys current locale
325 349
350 {
326 perl_environ = rxvt_environ; 351 perl_environ = rxvt_environ;
327 swap (perl_environ, environ); 352 localise_env set_environ (perl_environ);
328 353
329 char *args[] = { 354 char *args[] = {
330 "", 355 "",
331 "-e" 356 "-e"
332 "BEGIN {" 357 "BEGIN {"
333 " urxvt->bootstrap;" 358 " urxvt->bootstrap;"
334 " unshift @INC, '" LIBDIR "';" 359 " unshift @INC, '" LIBDIR "';"
335 "}" 360 "}"
336 "" 361 ""
337 "use urxvt;" 362 "use urxvt;"
338 }; 363 };
339 int argc = sizeof (args) / sizeof (args[0]); 364 int argc = ecb_array_length (args);
340 char **argv = args; 365 char **argv = args;
341 366
342 PERL_SYS_INIT3 (&argc, &argv, &environ); 367 PERL_SYS_INIT3 (&argc, &argv, &environ);
343 perl = perl_alloc (); 368 perl = perl_alloc ();
344 perl_construct (perl); 369 perl_construct (perl);
345 370
346 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) 371 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL)
347 || perl_run (perl)) 372 || perl_run (perl))
348 { 373 {
349 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 374 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
350 375
351 perl_destruct (perl); 376 perl_destruct (perl);
352 perl_free (perl); 377 perl_free (perl);
353 perl = 0; 378 perl = 0;
354 } 379 }
355 380 }
356 swap (perl_environ, environ);
357 381
358 rxvt_pop_locale (); 382 rxvt_pop_locale ();
359 } 383 }
360 384
361 if (perl) 385 if (perl)
362 { 386 {
363 // runs outside of perls ENV 387 // runs outside of perls ENV
364 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 388 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
365 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); 389 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
390 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
366 } 391 }
367} 392}
368 393
369static void 394static void
370ungrab (rxvt_term *THIS) 395ungrab (rxvt_term *THIS)
381rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 406rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
382{ 407{
383 if (!perl || !term->perl.self) 408 if (!perl || !term->perl.self)
384 return false; 409 return false;
385 410
411 localise_env set_environ (perl_environ);
412
386 // pre-handling of some events 413 // pre-handling of some events
387 if (htype == HOOK_REFRESH_END) 414 if (htype == HOOK_REFRESH_END)
388 { 415 {
389 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 416 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
390 417
391 for (int i = 0; i <= AvFILL (av); i++) 418 for (int i = 0; i <= AvFILL (av); i++)
392 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 419 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
393 } 420 }
421 else if (htype == HOOK_DESTROY)
422 {
423 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
394 424
395 swap (perl_environ, environ); 425 for (int i = AvFILL (av); i >= 0; i--)
426 {
427 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
428 delete req;
429 }
430 }
396 431
397 bool event_consumed; 432 bool event_consumed;
398 433
399 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 434 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
400 || term->perl.should_invoke [htype]) 435 || term->perl.should_invoke [htype])
401 try
402 { 436 {
403 dSP; 437 dSP;
404 va_list ap; 438 va_list ap;
405 439
406 va_start (ap, htype); 440 va_start (ap, htype);
407 441
408 ENTER; 442 ENTER;
409 SAVETMPS; 443 SAVETMPS;
410 444
411 PUSHMARK (SP); 445 PUSHMARK (SP);
412 446
447 EXTEND (SP, 2);
413 XPUSHs (sv_2mortal (newSVterm (term))); 448 PUSHs (sv_2mortal (newSVterm (term)));
414 XPUSHs (sv_2mortal (newSViv (htype))); 449 PUSHs (sv_2mortal (newSViv (htype)));
415 450
416 for (;;) { 451 for (;;) {
417 data_type dt = (data_type)va_arg (ap, int); 452 data_type dt = (data_type)va_arg (ap, int);
418 453
419 switch (dt) 454 switch (dt)
420 { 455 {
421 case DT_INT: 456 case DT_INT:
422 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 457 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
423 break; 458 break;
424 459
425 case DT_LONG: 460 case DT_LONG:
426 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 461 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
427 break; 462 break;
428 463
429 case DT_STR: 464 case DT_STR:
430 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 465 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
431 break; 466 break;
432 467
433 case DT_STR_LEN: 468 case DT_STR_LEN:
434 { 469 {
435 char *str = va_arg (ap, char *); 470 char *str = va_arg (ap, char *);
436 int len = va_arg (ap, int); 471 int len = va_arg (ap, int);
437 472
438 XPUSHs (sv_2mortal (newSVpvn (str, len))); 473 XPUSHs (sv_2mortal (newSVpvn (str, len)));
439 } 474 }
440 break; 475 break;
441 476
442 case DT_WCS_LEN: 477 case DT_WCS_LEN:
443 { 478 {
444 wchar_t *wstr = va_arg (ap, wchar_t *); 479 wchar_t *wstr = va_arg (ap, wchar_t *);
445 int wlen = va_arg (ap, int); 480 int wlen = va_arg (ap, int);
446 481
447 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 482 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
448 } 483 }
449 break; 484 break;
450 485
451 case DT_LCS_LEN: 486 case DT_LCS_LEN:
452 { 487 {
453 long *lstr = va_arg (ap, long *); 488 long *lstr = va_arg (ap, long *);
454 int llen = va_arg (ap, int); 489 int llen = va_arg (ap, int);
455 490
456 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); 491 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
457 } 492 }
458 break; 493 break;
459 494
460 case DT_XEVENT: 495 case DT_XEVENT:
461 { 496 {
462 XEvent *xe = va_arg (ap, XEvent *); 497 XEvent *xe = va_arg (ap, XEvent *);
463 HV *hv = newHV (); 498 HV *hv = newHV ();
464 499
465# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 500# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
466# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 501# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
467# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) 502# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
468# undef set 503# undef set
469 504
470 setiv (type, xe->type); 505 setiv (type, xe->type);
471 setiv (send_event, xe->xany.send_event); 506 setiv (send_event, xe->xany.send_event);
472 setiv (serial, xe->xany.serial); 507 setiv (serial, xe->xany.serial);
473 508
474 switch (xe->type) 509 switch (xe->type)
475 { 510 {
476 case KeyPress: 511 case KeyPress:
477 case KeyRelease: 512 case KeyRelease:
478 case ButtonPress: 513 case ButtonPress:
479 case ButtonRelease: 514 case ButtonRelease:
480 case MotionNotify: 515 case MotionNotify:
481 setuv (window, xe->xmotion.window); 516 setuv (window, xe->xmotion.window);
482 setuv (root, xe->xmotion.root); 517 setuv (root, xe->xmotion.root);
483 setuv (subwindow, xe->xmotion.subwindow); 518 setuv (subwindow, xe->xmotion.subwindow);
484 setuv (time, xe->xmotion.time); 519 setuv (time, xe->xmotion.time);
485 setiv (x, xe->xmotion.x); 520 setiv (x, xe->xmotion.x);
486 setiv (y, xe->xmotion.y); 521 setiv (y, xe->xmotion.y);
487 setiv (row, xe->xmotion.y / term->fheight + term->view_start); 522 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
488 setiv (col, xe->xmotion.x / term->fwidth); 523 setiv (col, xe->xmotion.x / term->fwidth);
489 setiv (x_root, xe->xmotion.x_root); 524 setiv (x_root, xe->xmotion.x_root);
490 setiv (y_root, xe->xmotion.y_root); 525 setiv (y_root, xe->xmotion.y_root);
491 setuv (state, xe->xmotion.state); 526 setuv (state, xe->xmotion.state);
492 527
493 switch (xe->type) 528 switch (xe->type)
494 { 529 {
495 case KeyPress: 530 case KeyPress:
496 case KeyRelease: 531 case KeyRelease:
497 setuv (keycode, xe->xkey.keycode); 532 setuv (keycode, xe->xkey.keycode);
498 break; 533 break;
499 534
500 case ButtonPress: 535 case ButtonPress:
501 case ButtonRelease: 536 case ButtonRelease:
502 setuv (button, xe->xbutton.button); 537 setuv (button, xe->xbutton.button);
503 break; 538 break;
504 539
505 case MotionNotify: 540 case MotionNotify:
506 setiv (is_hint, xe->xmotion.is_hint); 541 setiv (is_hint, xe->xmotion.is_hint);
507 break; 542 break;
508 } 543 }
509 544
510 break; 545 break;
511 546
512 case MapNotify: 547 case MapNotify:
513 case UnmapNotify: 548 case UnmapNotify:
514 case ConfigureNotify: 549 case ConfigureNotify:
515 setuv (event, xe->xconfigure.event); 550 setuv (event, xe->xconfigure.event);
516 setuv (window, xe->xconfigure.window); 551 setuv (window, xe->xconfigure.window);
517 552
518 switch (xe->type) 553 switch (xe->type)
519 { 554 {
520 case ConfigureNotify: 555 case ConfigureNotify:
521 setiv (x, xe->xconfigure.x); 556 setiv (x, xe->xconfigure.x);
522 setiv (y, xe->xconfigure.y); 557 setiv (y, xe->xconfigure.y);
523 setiv (width, xe->xconfigure.width); 558 setiv (width, xe->xconfigure.width);
524 setiv (height, xe->xconfigure.height); 559 setiv (height, xe->xconfigure.height);
525 setuv (above, xe->xconfigure.above); 560 setuv (above, xe->xconfigure.above);
526 break; 561 break;
527 } 562 }
528 563
529 break; 564 break;
530 565
531 case PropertyNotify: 566 case PropertyNotify:
532 setuv (window, xe->xproperty.window); 567 setuv (window, xe->xproperty.window);
533 setuv (atom, xe->xproperty.atom); 568 setuv (atom, xe->xproperty.atom);
534 setuv (time, xe->xproperty.time); 569 setuv (time, xe->xproperty.time);
535 setiv (state, xe->xproperty.state); 570 setiv (state, xe->xproperty.state);
536 break; 571 break;
537 572
538 case ClientMessage: 573 case ClientMessage:
539 setuv (window, xe->xclient.window); 574 setuv (window, xe->xclient.window);
540 setuv (message_type, xe->xclient.message_type); 575 setuv (message_type, xe->xclient.message_type);
541 setuv (format, xe->xclient.format); 576 setuv (format, xe->xclient.format);
542 setuv (l0, xe->xclient.data.l[0]); 577 setuv (l0, xe->xclient.data.l[0]);
543 setuv (l1, xe->xclient.data.l[1]); 578 setuv (l1, xe->xclient.data.l[1]);
544 setuv (l2, xe->xclient.data.l[2]); 579 setuv (l2, xe->xclient.data.l[2]);
545 setuv (l3, xe->xclient.data.l[3]); 580 setuv (l3, xe->xclient.data.l[3]);
546 setuv (l4, xe->xclient.data.l[4]); 581 setuv (l4, xe->xclient.data.l[4]);
547 break; 582 break;
548 } 583 }
549 584
550 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 585 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
551 } 586 }
552 break; 587 break;
553 588
554 case DT_END: 589 case DT_END:
555 goto call; 590 goto call;
556 591
557 default: 592 default:
558 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 593 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
559 } 594 }
595 }
596
597 call:
598 va_end (ap);
599
600 PUTBACK;
601 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
602 SPAGAIN;
603
604 if (count)
605 {
606 SV *status = POPs;
607 count = SvTRUE (status);
560 } 608 }
561 609
562 call:
563 va_end (ap);
564
565 PUTBACK; 610 PUTBACK;
566 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
567 SPAGAIN;
568
569 if (count)
570 {
571 SV *status = POPs;
572 count = SvTRUE (status);
573 }
574
575 PUTBACK;
576 FREETMPS; 611 FREETMPS;
577 LEAVE; 612 LEAVE;
578 613
579 if (SvTRUE (ERRSV)) 614 if (SvTRUE (ERRSV))
580 { 615 {
581 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 616 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
582 ungrab (term); // better lose the grab than the session 617 ungrab (term); // better lose the grab than the session
583 } 618 }
584 619
585 event_consumed = !!count; 620 event_consumed = !!count;
586 } 621 }
587 catch (...)
588 {
589 swap (perl_environ, environ);
590 throw;
591 }
592 else 622 else
593 event_consumed = false; 623 event_consumed = false;
594 624
595 // post-handling of some events 625 // post-handling of some events
596 if (htype == HOOK_REFRESH_BEGIN) 626 if (htype == HOOK_REFRESH_BEGIN)
607 637
608 // don't allow further calls 638 // don't allow further calls
609 term->perl.self = 0; 639 term->perl.self = 0;
610 } 640 }
611 641
612 swap (perl_environ, environ);
613
614 return event_consumed; 642 return event_consumed;
643}
644
645void
646rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
647{
648 localise_env set_environ (perl_environ);
649
650 ENTER;
651 SAVETMPS;
652
653 dSP;
654 XPUSHs (sv_2mortal (newSVpvn (data, len)));
655 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
656
657 if (SvTRUE (ERRSV))
658 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
659
660 FREETMPS;
661 LEAVE;
615} 662}
616 663
617///////////////////////////////////////////////////////////////////////////// 664/////////////////////////////////////////////////////////////////////////////
618 665
619MODULE = urxvt PACKAGE = urxvt 666MODULE = urxvt PACKAGE = urxvt
631# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 678# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
632# include "hookinc.h" 679# include "hookinc.h"
633# undef def 680# undef def
634 681
635 HV *option = get_hv ("urxvt::OPTION", 1); 682 HV *option = get_hv ("urxvt::OPTION", 1);
636# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); 683# define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
637# define nodef(name) 684# define nodef(name)
638# include "optinc.h" 685# include "optinc.h"
639# undef nodef 686# undef nodef
640# undef def 687# undef def
641 688
646 } *civ, const_iv[] = { 693 } *civ, const_iv[] = {
647# define const_iv(name) { # name, (IV)name } 694# define const_iv(name) { # name, (IV)name }
648 const_iv (NUM_RESOURCES), 695 const_iv (NUM_RESOURCES),
649 const_iv (DEFAULT_RSTYLE), 696 const_iv (DEFAULT_RSTYLE),
650 const_iv (OVERLAY_RSTYLE), 697 const_iv (OVERLAY_RSTYLE),
698 const_iv (Color_Bits),
699 const_iv (RS_bgShift), const_iv (RS_bgMask),
700 const_iv (RS_fgShift), const_iv (RS_fgMask),
701 const_iv (RS_Careful),
702 const_iv (RS_fontCount),
703 const_iv (RS_fontShift),
704 const_iv (RS_fontMask),
705 const_iv (RS_baseattrMask),
706 const_iv (RS_attrMask),
707 const_iv (RS_redraw),
708 const_iv (RS_Sel),
651 const_iv (RS_Bold), 709 const_iv (RS_Bold),
652 const_iv (RS_Italic), 710 const_iv (RS_Italic),
653 const_iv (RS_Blink), 711 const_iv (RS_Blink),
654 const_iv (RS_RVid), 712 const_iv (RS_RVid),
655 const_iv (RS_Uline), 713 const_iv (RS_Uline),
742 const_iv (XIMSecondary), 800 const_iv (XIMSecondary),
743 const_iv (XIMTertiary), 801 const_iv (XIMTertiary),
744 const_iv (XIMVisibleToForward), 802 const_iv (XIMVisibleToForward),
745 const_iv (XIMVisibleToBackword), 803 const_iv (XIMVisibleToBackword),
746 const_iv (XIMVisibleToCenter), 804 const_iv (XIMVisibleToCenter),
805#if XRENDER
806 const_iv (PictStandardARGB32),
807 const_iv (PictStandardRGB24),
808 const_iv (PictStandardA8),
809 const_iv (PictStandardA4),
810 const_iv (PictStandardA1),
811 const_iv (RepeatNone),
812 const_iv (RepeatNormal),
813 const_iv (RepeatPad),
814 const_iv (RepeatReflect),
815#endif
747# if 0 816# if 0
748 const_iv (XIMForwardChar), 817 const_iv (XIMForwardChar),
749 const_iv (XIMBackwardChar), 818 const_iv (XIMBackwardChar),
750 const_iv (XIMForwardWord), 819 const_iv (XIMForwardWord),
751 const_iv (XIMBackwardWord), 820 const_iv (XIMBackwardWord),
759 const_iv (XIMDontChange), 828 const_iv (XIMDontChange),
760# endif 829# endif
761# endif 830# endif
762 }; 831 };
763 832
764 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 833 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
765 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 834 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
766} 835}
767 836
768void 837void
769warn (const char *msg) 838warn (const char *msg)
770 CODE: 839 CODE:
842 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 911 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
843 if ((*t)->perl.self) 912 if ((*t)->perl.self)
844 PUSHs (sv_2mortal (newSVterm (*t))); 913 PUSHs (sv_2mortal (newSVterm (*t)));
845} 914}
846 915
916IV
917_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
918 CODE:
919 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
920 req->cb_sv = newSVsv (cb);
921 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
922 av_push (av, newSViv ((IV)req));
923 RETVAL = (IV)req;
924 OUTPUT:
925 RETVAL
926
927void
928_delete_selection_request (IV req_)
929 CODE:
930 rxvt_selection *req = (rxvt_selection *)req_;
931 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
932 int i;
933
934 for (i = AvFILL (av); i >= 0; i--)
935 if (SvIV (*av_fetch (av, i, 1)) == req_)
936 break;
937
938 for (; i < AvFILL (av); i++)
939 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
940
941 av_pop (av);
942
943 delete req;
944
847MODULE = urxvt PACKAGE = urxvt::term 945MODULE = urxvt PACKAGE = urxvt::term
848 946
849SV * 947SV *
850_new (AV *env, AV *arg) 948_new (AV *env, AV *arg)
851 CODE: 949 CODE:
852{ 950{
853 rxvt_term *term = new rxvt_term; 951 rxvt_term *term = new rxvt_term;
854 952
855 stringvec *argv = new stringvec; 953 stringvec *argv = new stringvec;
856 stringvec *envv = new stringvec;
857
858 for (int i = 0; i <= AvFILL (arg); i++) 954 for (int i = 0; i <= AvFILL (arg); i++)
859 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 955 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
860 956
957 stringvec *envv = new stringvec;
861 for (int i = AvFILL (env) + 1; i--; ) 958 for (int i = AvFILL (env) + 1; i--; )
862 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 959 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
863
864 envv->push_back (0);
865 960
866 try 961 try
867 { 962 {
868 term->init (argv, envv); 963 term->init (argv, envv);
869 } 964 }
909 1004
910void 1005void
911rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 1006rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
912 CODE: 1007 CODE:
913 XUngrabKey (THIS->dpy, keycode, modifiers, window); 1008 XUngrabKey (THIS->dpy, keycode, modifiers, window);
914
915void
916rxvt_term::XUngrabKeyboard (Time eventtime)
917 CODE:
918 XUngrabKeyboard (THIS->dpy, eventtime);
919 1009
920bool 1010bool
921rxvt_term::grab (Time eventtime, int sync = 0) 1011rxvt_term::grab (Time eventtime, int sync = 0)
922 CODE: 1012 CODE:
923{ 1013{
1038 free (wstr); 1128 free (wstr);
1039} 1129}
1040 OUTPUT: 1130 OUTPUT:
1041 RETVAL 1131 RETVAL
1042 1132
1043char *
1044rxvt_term::locale ()
1045 CODE:
1046 RETVAL = THIS->locale;
1047 OUTPUT:
1048 RETVAL
1049
1050#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1133#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1051 1134
1052#define TERM_OFFSET_width TERM_OFFSET(width) 1135#define TERM_OFFSET_width TERM_OFFSET(width)
1053#define TERM_OFFSET_height TERM_OFFSET(height) 1136#define TERM_OFFSET_height TERM_OFFSET(height)
1054#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 1137#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
1055#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 1138#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
1056#define TERM_OFFSET_fbase TERM_OFFSET(fbase) 1139#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
1057#define TERM_OFFSET_nrow TERM_OFFSET(nrow) 1140#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
1058#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1141#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
1059#define TERM_OFFSET_focus TERM_OFFSET(focus) 1142#define TERM_OFFSET_focus TERM_OFFSET(focus)
1060#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1143#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
1061#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) 1144#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth)
1062#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) 1145#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth)
1063#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) 1146#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace)
1147#define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace)
1064#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1148#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
1065#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1149#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
1066#define TERM_OFFSET_top_row TERM_OFFSET(top_row) 1150#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
1067 1151
1068int 1152int
1069rxvt_term::width () 1153rxvt_term::width ()
1070 ALIAS: 1154 ALIAS:
1071 width = TERM_OFFSET_width 1155 width = TERM_OFFSET_width
1072 height = TERM_OFFSET_height 1156 height = TERM_OFFSET_height
1073 fwidth = TERM_OFFSET_fwidth 1157 fwidth = TERM_OFFSET_fwidth
1074 fheight = TERM_OFFSET_fheight 1158 fheight = TERM_OFFSET_fheight
1075 fbase = TERM_OFFSET_fbase 1159 fbase = TERM_OFFSET_fbase
1076 nrow = TERM_OFFSET_nrow 1160 nrow = TERM_OFFSET_nrow
1077 ncol = TERM_OFFSET_ncol 1161 ncol = TERM_OFFSET_ncol
1078 focus = TERM_OFFSET_focus 1162 focus = TERM_OFFSET_focus
1079 mapped = TERM_OFFSET_mapped 1163 mapped = TERM_OFFSET_mapped
1080 int_bwidth = TERM_OFFSET_int_bwidth 1164 int_bwidth = TERM_OFFSET_int_bwidth
1081 ext_bwidth = TERM_OFFSET_ext_bwidth 1165 ext_bwidth = TERM_OFFSET_ext_bwidth
1082 lineSpace = TERM_OFFSET_lineSpace 1166 lineSpace = TERM_OFFSET_lineSpace
1167 letterSpace = TERM_OFFSET_letterSpace
1083 saveLines = TERM_OFFSET_saveLines 1168 saveLines = TERM_OFFSET_saveLines
1084 total_rows = TERM_OFFSET_total_rows 1169 total_rows = TERM_OFFSET_total_rows
1085 top_row = TERM_OFFSET_top_row 1170 top_row = TERM_OFFSET_top_row
1086 CODE: 1171 CODE:
1087 RETVAL = *(int *)((char *)THIS + ix); 1172 RETVAL = *(int *)((char *)THIS + ix);
1088 OUTPUT: 1173 OUTPUT:
1089 RETVAL 1174 RETVAL
1090 1175
1156 RETVAL 1241 RETVAL
1157 1242
1158Window 1243Window
1159rxvt_term::parent () 1244rxvt_term::parent ()
1160 CODE: 1245 CODE:
1161 RETVAL = THIS->parent [0]; 1246 RETVAL = THIS->parent;
1162 OUTPUT: 1247 OUTPUT:
1163 RETVAL 1248 RETVAL
1164 1249
1165Window 1250Window
1166rxvt_term::vt () 1251rxvt_term::vt ()
1193 if (newval <= 0) 1278 if (newval <= 0)
1194 THIS->scr_changeview (max (newval, THIS->top_row)); 1279 THIS->scr_changeview (max (newval, THIS->top_row));
1195} 1280}
1196 OUTPUT: 1281 OUTPUT:
1197 RETVAL 1282 RETVAL
1283
1284void
1285rxvt_term::set_urgency (bool enable)
1198 1286
1199void 1287void
1200rxvt_term::focus_in () 1288rxvt_term::focus_in ()
1201 1289
1202void 1290void
1435# include "rsinc.h" 1523# include "rsinc.h"
1436# undef def 1524# undef def
1437# undef reserve 1525# undef reserve
1438 }; 1526 };
1439 1527
1440 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1528 rs = rslist + ecb_array_length (rslist);
1441 1529
1442 if (*name) 1530 if (*name)
1443 { 1531 {
1444 do { 1532 do {
1445 if (rs-- == rslist) 1533 if (rs-- == rslist)
1484 1572
1485 if (set >= 0) 1573 if (set >= 0)
1486 { 1574 {
1487 THIS->set_option (optval, set); 1575 THIS->set_option (optval, set);
1488 1576
1489 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1577 if (THIS->init_done) // avoid doing this before START
1490 switch (optval) 1578 switch (optval)
1491 { 1579 {
1492 case Opt_skipBuiltinGlyphs: 1580 case Opt_skipBuiltinGlyphs:
1493 THIS->set_fonts (); 1581 THIS->set_fonts ();
1494 THIS->scr_remap_chars (); 1582 THIS->scr_remap_chars ();
1495 THIS->scr_touch (true); 1583 THIS->scr_touch (true);
1496 THIS->want_refresh = 1; 1584 THIS->want_refresh = 1;
1497 THIS->refresh_check (); 1585 THIS->refresh_check ();
1498 break; 1586 break;
1587#ifdef CURSOR_BLINK
1588 case Opt_cursorBlink:
1589 THIS->cursor_blink_reset ();
1590 break;
1591#endif
1499 1592
1500 case Opt_cursorUnderline: 1593 case Opt_cursorUnderline:
1501 THIS->want_refresh = 1; 1594 THIS->want_refresh = 1;
1502 THIS->refresh_check (); 1595 THIS->refresh_check ();
1503 break; 1596 break;
1517 CODE: 1610 CODE:
1518 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1611 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1519 THIS->keyboard->register_done (); 1612 THIS->keyboard->register_done ();
1520 OUTPUT: 1613 OUTPUT:
1521 RETVAL 1614 RETVAL
1615
1616void
1617rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1618 CODE:
1619 wchar_t *wstr = sv2wcs (str);
1620 THIS->keyboard->register_user_translation (keysym, state, wstr);
1621 free (wstr);
1522 1622
1523void 1623void
1524rxvt_term::screen_cur (...) 1624rxvt_term::screen_cur (...)
1525 PROTOTYPE: $;$$ 1625 PROTOTYPE: $;$$
1526 ALIAS: 1626 ALIAS:
1540 EXTEND (SP, 2); 1640 EXTEND (SP, 2);
1541 PUSHs (sv_2mortal (newSViv (rc.row))); 1641 PUSHs (sv_2mortal (newSViv (rc.row)));
1542 PUSHs (sv_2mortal (newSViv (rc.col))); 1642 PUSHs (sv_2mortal (newSViv (rc.col)));
1543 } 1643 }
1544 1644
1545 if (items == 3) 1645 if (items >= 3)
1546 { 1646 {
1547 rc.row = SvIV (ST (1)); 1647 rc.row = SvIV (ST (1));
1548 rc.col = SvIV (ST (2)); 1648 rc.col = SvIV (ST (2));
1549 1649
1550 if (ix == 2) 1650 if (ix == 2)
1566 clamp_it (rc.col, 0, THIS->ncol); 1666 clamp_it (rc.col, 0, THIS->ncol);
1567 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1667 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1568 1668
1569 if (ix) 1669 if (ix)
1570 { 1670 {
1671 THIS->selection.screen = THIS->current_screen;
1672
1571 THIS->want_refresh = 1; 1673 THIS->want_refresh = 1;
1572 THIS->refresh_check (); 1674 THIS->refresh_check ();
1573 } 1675 }
1574 } 1676 }
1575} 1677}
1576 1678
1577char 1679int
1578rxvt_term::cur_charset () 1680rxvt_term::selection_screen (int screen = -1)
1579 CODE: 1681 CODE:
1580 RETVAL = THIS->charsets [THIS->screen.charset]; 1682 RETVAL = THIS->selection.screen;
1581 OUTPUT: 1683 if (screen >= 0)
1684 THIS->selection.screen = screen;
1685 OUTPUT:
1582 RETVAL 1686 RETVAL
1583 1687
1584void 1688void
1585rxvt_term::selection_clear () 1689rxvt_term::selection_clear (bool clipboard = false)
1586 1690
1587void 1691void
1588rxvt_term::selection_make (Time eventtime, bool rect = false) 1692rxvt_term::selection_make (Time eventtime, bool rect = false)
1589 CODE: 1693 CODE:
1590 THIS->selection.op = SELECTION_CONT; 1694 THIS->selection.op = SELECTION_CONT;
1591 THIS->selection.rect = rect; 1695 THIS->selection.rect = rect;
1592 THIS->selection_make (eventtime); 1696 THIS->selection_make (eventtime);
1593 1697
1594int 1698int
1595rxvt_term::selection_grab (Time eventtime) 1699rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1596 1700
1597void 1701void
1598rxvt_term::selection (SV *newtext = 0) 1702rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1599 PPCODE: 1703 PPCODE:
1600{ 1704{
1705 wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text;
1706 unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len;
1707
1601 if (GIMME_V != G_VOID) 1708 if (GIMME_V != G_VOID)
1602 XPUSHs (THIS->selection.text 1709 XPUSHs (text
1603 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1710 ? sv_2mortal (wcs2sv (text, len))
1604 : &PL_sv_undef); 1711 : &PL_sv_undef);
1605 1712
1606 if (newtext) 1713 if (newtext)
1607 { 1714 {
1608 free (THIS->selection.text); 1715 free (text);
1609 1716
1610 THIS->selection.text = sv2wcs (newtext); 1717 text = sv2wcs (newtext);
1611 THIS->selection.len = wcslen (THIS->selection.text); 1718 len = wcslen (text);
1612 } 1719 }
1613} 1720}
1721
1722char
1723rxvt_term::cur_charset ()
1724 CODE:
1725 RETVAL = THIS->charsets [THIS->screen.charset];
1726 OUTPUT:
1727 RETVAL
1614 1728
1615void 1729void
1616rxvt_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) 1730rxvt_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)
1617 1731
1618void 1732void
1619rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) 1733rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1620 1734
1621void 1735void
1622rxvt_term::scr_bell () 1736rxvt_term::scr_bell ()
1737
1738void
1739rxvt_term::scr_recolour (bool refresh = true);
1623 1740
1624void 1741void
1625rxvt_term::scr_change_screen (int screen) 1742rxvt_term::scr_change_screen (int screen)
1626 1743
1627void 1744void
1640 char *str = SvPVbyte (octets, len); 1757 char *str = SvPVbyte (octets, len);
1641 C_ARGS: 1758 C_ARGS:
1642 str, len 1759 str, len
1643 1760
1644void 1761void
1762rxvt_term::tt_paste (SV *octets)
1763 INIT:
1764 STRLEN len;
1765 char *str = SvPVbyte (octets, len);
1766 C_ARGS:
1767 str, len
1768
1769void
1645rxvt_term::cmd_parse (SV *octets) 1770rxvt_term::cmd_parse (SV *octets)
1646 CODE: 1771 CODE:
1647{ 1772{
1648 STRLEN len; 1773 STRLEN len;
1649 char *str = SvPVbyte (octets, len); 1774 char *str = SvPVbyte (octets, len);
1734 type, format, PropModeReplace, 1859 type, format, PropModeReplace,
1735 (unsigned char *)data_, len / elemsize); 1860 (unsigned char *)data_, len / elemsize);
1736} 1861}
1737 1862
1738Atom 1863Atom
1739XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) 1864XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE)
1740 C_ARGS: term->dpy, atom_name, only_if_exists 1865 C_ARGS: term->dpy, atom_name, only_if_exists
1741 1866
1742char * 1867char *
1743XGetAtomName (rxvt_term *term, Atom atom) 1868XGetAtomName (rxvt_term *term, Atom atom)
1744 C_ARGS: term->dpy, atom 1869 C_ARGS: term->dpy, atom
1745 CLEANUP: 1870 CLEANUP:
1746 XFree (RETVAL); 1871 XFree (RETVAL);
1747 1872
1748void 1873void
1749XDeleteProperty (rxvt_term *term, Window window, Atom property) 1874XDeleteProperty (rxvt_term *term, Window window, Atom property)
1750 C_ARGS: term->dpy, window, property 1875 C_ARGS: term->dpy, window, property
1751 1876
1752Window 1877Window
1753rxvt_term::DefaultRootWindow () 1878rxvt_term::DefaultRootWindow ()
1754 CODE: 1879 CODE:
1755 RETVAL = THIS->display->root; 1880 RETVAL = THIS->display->root;
1807 PUSHs (newSVuv (child)); 1932 PUSHs (newSVuv (child));
1808 } 1933 }
1809} 1934}
1810 1935
1811############################################################################# 1936#############################################################################
1937# fancy bg bloatstuff (TODO: should be moved up somewhere)
1938
1939# TODO: ugly
1940void
1941rxvt_term::get_geometry ()
1942 PPCODE:
1943 Window wdummy;
1944 int x, y;
1945 XWindowAttributes wattr;
1946 XGetWindowAttributes (THIS->dpy, THIS->parent, &wattr);
1947 XTranslateCoordinates (THIS->dpy, THIS->parent, wattr.root,
1948 -wattr.border_width, -wattr.border_width,
1949 &x, &y, &wdummy);
1950 EXTEND (SP, 4);
1951 PUSHs (sv_2mortal (newSViv (x)));
1952 PUSHs (sv_2mortal (newSViv (y)));
1953 PUSHs (sv_2mortal (newSViv (wattr.width)));
1954 PUSHs (sv_2mortal (newSViv (wattr.height)));
1955
1956#if HAVE_IMG
1957
1958rxvt_img *
1959rxvt_term::new_img (SV *format, int width, int height)
1960 CODE:
1961 XRenderPictFormat *f = SvOK (format)
1962 ? XRenderFindVisualFormat (THIS->dpy, THIS->visual)
1963 : XRenderFindStandardFormat (THIS->dpy, SvIV (format));
1964 RETVAL = new rxvt_img (THIS, f, width, height);
1965 OUTPUT:
1966 RETVAL
1967
1968#if ENABLE_TRANSPARENCY
1969
1970#if 0
1971
1972rxvt_img *
1973rxvt_term::new_img_from_root ()
1974 CODE:
1975 RETVAL = rxvt_img::new_from_root (THIS);
1976 OUTPUT:
1977 RETVAL
1978
1979#endif
1980
1981#endif
1982
1983#if HAVE_PIXBUF
1984
1985rxvt_img *
1986rxvt_term::new_img_from_file (octet_string filename)
1987 CODE:
1988 try
1989 {
1990 RETVAL = rxvt_img::new_from_file (THIS, filename);
1991 }
1992 catch (const class rxvt_failure_exception &e)
1993 {
1994 croak ("new_img_from_file failed");
1995 }
1996 OUTPUT:
1997 RETVAL
1998
1999#endif
2000
2001#if HAVE_BG_PIXMAP
2002
2003void
2004rxvt_term::set_background (rxvt_img *img)
2005 CODE:
2006 THIS->bg_destroy ();
2007 THIS->bg_pixmap = None;
2008 THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH;
2009
2010 if (img) // TODO: cannot be false
2011 {
2012 img->unshare ();
2013 THIS->bg_pixmap = img->steal ();
2014 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH;
2015 THIS->bg_valid_since = ev::now (); // TODO: extra bloat
2016 }
2017
2018#endif
2019
2020#endif
2021
2022#############################################################################
1812# urxvt::overlay 2023# urxvt::overlay
1813############################################################################# 2024#############################################################################
1814 2025
1815MODULE = urxvt PACKAGE = urxvt::overlay 2026MODULE = urxvt PACKAGE = urxvt::overlay
1816 2027
1826void 2037void
1827overlay::DESTROY () 2038overlay::DESTROY ()
1828 2039
1829INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 2040INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1830 2041
2042MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
2043
2044#if HAVE_PIXBUF
2045
2046urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename)
2047 C_ARGS: filename, 0
2048
2049void
2050DESTROY (urxvt::pixbuf self)
2051 CODE:
2052 gdk_pixbuf_unref (self);
2053
2054#endif
2055
2056MODULE = urxvt PACKAGE = urxvt::img
2057
2058#if HAVE_IMG
2059
2060# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
2061# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
2062
2063int
2064rxvt_img::w ()
2065 CODE:
2066 RETVAL = THIS->w;
2067 OUTPUT:
2068 RETVAL
2069
2070int
2071rxvt_img::h ()
2072 CODE:
2073 RETVAL = THIS->h;
2074 OUTPUT:
2075 RETVAL
2076
2077bool
2078rxvt_img::shared ()
2079 CODE:
2080 RETVAL = THIS->shared;
2081 OUTPUT:
2082 RETVAL
2083
2084Pixmap
2085rxvt_img::pm ()
2086 CODE:
2087 RETVAL = THIS->pm;
2088 OUTPUT:
2089 RETVAL
2090
2091void
2092rxvt_img::fill (SV *c)
2093 INIT:
2094 rxvt_color rc;
2095 parse_color (THIS->s, rc, c);
2096 C_ARGS: rc
2097
2098void
2099rxvt_img::DESTROY ()
2100 CODE:
2101 delete THIS;
2102
2103void
2104rxvt_img::blur (int rh, int rv)
2105
2106void
2107rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.)
2108
2109void
2110rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.)
2111
2112void
2113rxvt_img::unshare ()
2114
2115rxvt_img *
2116rxvt_img::clone ()
2117
2118rxvt_img *
2119rxvt_img::transform (int new_width, int new_height, int repeat, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33)
2120 INIT:
2121 double matrix[9] = {
2122 p11, p12, p13,
2123 p21, p22, p23,
2124 p31, p32, p33
2125 };
2126 C_ARGS: new_width, new_height, repeat, matrix
2127
2128rxvt_img *
2129rxvt_img::scale (int new_width, int new_height)
2130
2131rxvt_img *
2132rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, NV phi)
2133
2134#endif
2135

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines