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.122 by root, Sun Jun 15 14:07:58 2008 UTC vs.
Revision 1.161 by root, Mon Jun 4 15:43: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"
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;
310{ 334{
311 if (perl) 335 if (perl)
312 { 336 {
313 perl_destruct (perl); 337 perl_destruct (perl);
314 perl_free (perl); 338 perl_free (perl);
339 PERL_SYS_TERM ();
315 } 340 }
316} 341}
317 342
318void 343void
319rxvt_perl_interp::init (rxvt_term *term) 344rxvt_perl_interp::init (rxvt_term *term)
320{ 345{
321 if (!perl) 346 if (!perl)
322 { 347 {
323 rxvt_push_locale (""); // perl init destroys current locale 348 rxvt_push_locale (""); // perl init destroys current locale
324 349
350 {
325 perl_environ = rxvt_environ; 351 perl_environ = rxvt_environ;
326 swap (perl_environ, environ); 352 localise_env set_environ (perl_environ);
327 353
328 char *argv[] = { 354 char *args[] = {
329 "", 355 "",
330 "-e" 356 "-e"
331 "BEGIN {" 357 "BEGIN {"
332 " urxvt->bootstrap;" 358 " urxvt->bootstrap;"
333 " unshift @INC, '" LIBDIR "';" 359 " unshift @INC, '" LIBDIR "';"
334 "}" 360 "}"
335 "" 361 ""
336 "use urxvt;" 362 "use urxvt;"
337 }; 363 };
364 int argc = ecb_array_length (args);
365 char **argv = args;
338 366
367 PERL_SYS_INIT3 (&argc, &argv, &environ);
339 perl = perl_alloc (); 368 perl = perl_alloc ();
340 perl_construct (perl); 369 perl_construct (perl);
341 370
342 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 371 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL)
343 || perl_run (perl)) 372 || perl_run (perl))
344 { 373 {
345 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 374 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
346 375
347 perl_destruct (perl); 376 perl_destruct (perl);
348 perl_free (perl); 377 perl_free (perl);
349 perl = 0; 378 perl = 0;
350 } 379 }
351 380 }
352 swap (perl_environ, environ);
353 381
354 rxvt_pop_locale (); 382 rxvt_pop_locale ();
355 } 383 }
356 384
357 if (perl) 385 if (perl)
358 { 386 {
359 // runs outside of perls ENV 387 // runs outside of perls ENV
360 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 388 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
361 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);
362 } 391 }
363} 392}
364 393
365static void 394static void
366ungrab (rxvt_term *THIS) 395ungrab (rxvt_term *THIS)
377rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 406rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
378{ 407{
379 if (!perl || !term->perl.self) 408 if (!perl || !term->perl.self)
380 return false; 409 return false;
381 410
411 localise_env set_environ (perl_environ);
412
382 // pre-handling of some events 413 // pre-handling of some events
383 if (htype == HOOK_REFRESH_END) 414 if (htype == HOOK_REFRESH_END)
384 { 415 {
385 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));
386 417
387 for (int i = 0; i <= AvFILL (av); i++) 418 for (int i = 0; i <= AvFILL (av); i++)
388 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 419 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
389 } 420 }
421 else if (htype == HOOK_DESTROY)
422 {
423 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
390 424
391 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 }
392 431
393 bool event_consumed; 432 bool event_consumed;
394 433
395 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 434 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
396 || term->perl.should_invoke [htype]) 435 || term->perl.should_invoke [htype])
397 try
398 { 436 {
399 dSP; 437 dSP;
400 va_list ap; 438 va_list ap;
401 439
402 va_start (ap, htype); 440 va_start (ap, htype);
403 441
404 ENTER; 442 ENTER;
405 SAVETMPS; 443 SAVETMPS;
406 444
407 PUSHMARK (SP); 445 PUSHMARK (SP);
408 446
447 EXTEND (SP, 2);
409 XPUSHs (sv_2mortal (newSVterm (term))); 448 PUSHs (sv_2mortal (newSVterm (term)));
410 XPUSHs (sv_2mortal (newSViv (htype))); 449 PUSHs (sv_2mortal (newSViv (htype)));
411 450
412 for (;;) { 451 for (;;) {
413 data_type dt = (data_type)va_arg (ap, int); 452 data_type dt = (data_type)va_arg (ap, int);
414 453
415 switch (dt) 454 switch (dt)
416 { 455 {
417 case DT_INT: 456 case DT_INT:
418 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 457 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
419 break; 458 break;
420 459
421 case DT_LONG: 460 case DT_LONG:
422 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 461 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
423 break; 462 break;
424 463
425 case DT_STR: 464 case DT_STR:
426 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 465 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
427 break; 466 break;
428 467
429 case DT_STR_LEN: 468 case DT_STR_LEN:
430 { 469 {
431 char *str = va_arg (ap, char *); 470 char *str = va_arg (ap, char *);
432 int len = va_arg (ap, int); 471 int len = va_arg (ap, int);
433 472
434 XPUSHs (sv_2mortal (newSVpvn (str, len))); 473 XPUSHs (sv_2mortal (newSVpvn (str, len)));
435 } 474 }
436 break; 475 break;
437 476
438 case DT_WCS_LEN: 477 case DT_WCS_LEN:
439 { 478 {
440 wchar_t *wstr = va_arg (ap, wchar_t *); 479 wchar_t *wstr = va_arg (ap, wchar_t *);
441 int wlen = va_arg (ap, int); 480 int wlen = va_arg (ap, int);
442 481
443 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 482 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
444 } 483 }
445 break; 484 break;
446 485
447 case DT_LCS_LEN: 486 case DT_LCS_LEN:
448 { 487 {
449 long *lstr = va_arg (ap, long *); 488 long *lstr = va_arg (ap, long *);
450 int llen = va_arg (ap, int); 489 int llen = va_arg (ap, int);
451 490
452 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); 491 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
453 } 492 }
454 break; 493 break;
455 494
456 case DT_XEVENT: 495 case DT_XEVENT:
457 { 496 {
458 XEvent *xe = va_arg (ap, XEvent *); 497 XEvent *xe = va_arg (ap, XEvent *);
459 HV *hv = newHV (); 498 HV *hv = newHV ();
460 499
461# 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)
462# 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)
463# 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)
464# undef set 503# undef set
465 504
466 setiv (type, xe->type); 505 setiv (type, xe->type);
467 setiv (send_event, xe->xany.send_event); 506 setiv (send_event, xe->xany.send_event);
468 setiv (serial, xe->xany.serial); 507 setiv (serial, xe->xany.serial);
469 508
470 switch (xe->type) 509 switch (xe->type)
471 { 510 {
472 case KeyPress: 511 case KeyPress:
473 case KeyRelease: 512 case KeyRelease:
474 case ButtonPress: 513 case ButtonPress:
475 case ButtonRelease: 514 case ButtonRelease:
476 case MotionNotify: 515 case MotionNotify:
477 setuv (window, xe->xmotion.window); 516 setuv (window, xe->xmotion.window);
478 setuv (root, xe->xmotion.root); 517 setuv (root, xe->xmotion.root);
479 setuv (subwindow, xe->xmotion.subwindow); 518 setuv (subwindow, xe->xmotion.subwindow);
480 setuv (time, xe->xmotion.time); 519 setuv (time, xe->xmotion.time);
481 setiv (x, xe->xmotion.x); 520 setiv (x, xe->xmotion.x);
482 setiv (y, xe->xmotion.y); 521 setiv (y, xe->xmotion.y);
483 setiv (row, xe->xmotion.y / term->fheight + term->view_start); 522 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
484 setiv (col, xe->xmotion.x / term->fwidth); 523 setiv (col, xe->xmotion.x / term->fwidth);
485 setiv (x_root, xe->xmotion.x_root); 524 setiv (x_root, xe->xmotion.x_root);
486 setiv (y_root, xe->xmotion.y_root); 525 setiv (y_root, xe->xmotion.y_root);
487 setuv (state, xe->xmotion.state); 526 setuv (state, xe->xmotion.state);
488 527
489 switch (xe->type) 528 switch (xe->type)
490 { 529 {
491 case KeyPress: 530 case KeyPress:
492 case KeyRelease: 531 case KeyRelease:
493 setuv (keycode, xe->xkey.keycode); 532 setuv (keycode, xe->xkey.keycode);
494 break; 533 break;
495 534
496 case ButtonPress: 535 case ButtonPress:
497 case ButtonRelease: 536 case ButtonRelease:
498 setuv (button, xe->xbutton.button); 537 setuv (button, xe->xbutton.button);
499 break; 538 break;
500 539
501 case MotionNotify: 540 case MotionNotify:
502 setiv (is_hint, xe->xmotion.is_hint); 541 setiv (is_hint, xe->xmotion.is_hint);
503 break; 542 break;
504 } 543 }
505 544
506 break; 545 break;
507 546
508 case MapNotify: 547 case MapNotify:
509 case UnmapNotify: 548 case UnmapNotify:
510 case ConfigureNotify: 549 case ConfigureNotify:
511 setuv (event, xe->xconfigure.event); 550 setuv (event, xe->xconfigure.event);
512 setuv (window, xe->xconfigure.window); 551 setuv (window, xe->xconfigure.window);
513 552
514 switch (xe->type) 553 switch (xe->type)
515 { 554 {
516 case ConfigureNotify: 555 case ConfigureNotify:
517 setiv (x, xe->xconfigure.x); 556 setiv (x, xe->xconfigure.x);
518 setiv (y, xe->xconfigure.y); 557 setiv (y, xe->xconfigure.y);
519 setiv (width, xe->xconfigure.width); 558 setiv (width, xe->xconfigure.width);
520 setiv (height, xe->xconfigure.height); 559 setiv (height, xe->xconfigure.height);
521 setuv (above, xe->xconfigure.above); 560 setuv (above, xe->xconfigure.above);
522 break; 561 break;
523 } 562 }
524 563
525 break; 564 break;
526 565
527 case PropertyNotify: 566 case PropertyNotify:
528 setuv (window, xe->xproperty.window); 567 setuv (window, xe->xproperty.window);
529 setuv (atom, xe->xproperty.atom); 568 setuv (atom, xe->xproperty.atom);
530 setuv (time, xe->xproperty.time); 569 setuv (time, xe->xproperty.time);
531 setiv (state, xe->xproperty.state); 570 setiv (state, xe->xproperty.state);
532 break; 571 break;
533 572
534 case ClientMessage: 573 case ClientMessage:
535 setuv (window, xe->xclient.window); 574 setuv (window, xe->xclient.window);
536 setuv (message_type, xe->xclient.message_type); 575 setuv (message_type, xe->xclient.message_type);
537 setuv (format, xe->xclient.format); 576 setuv (format, xe->xclient.format);
538 setuv (l0, xe->xclient.data.l[0]); 577 setuv (l0, xe->xclient.data.l[0]);
539 setuv (l1, xe->xclient.data.l[1]); 578 setuv (l1, xe->xclient.data.l[1]);
540 setuv (l2, xe->xclient.data.l[2]); 579 setuv (l2, xe->xclient.data.l[2]);
541 setuv (l3, xe->xclient.data.l[3]); 580 setuv (l3, xe->xclient.data.l[3]);
542 setuv (l4, xe->xclient.data.l[4]); 581 setuv (l4, xe->xclient.data.l[4]);
543 break; 582 break;
544 } 583 }
545 584
546 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 585 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
547 } 586 }
548 break; 587 break;
549 588
550 case DT_END: 589 case DT_END:
551 goto call; 590 goto call;
552 591
553 default: 592 default:
554 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 593 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
555 } 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);
556 } 608 }
557 609
558 call:
559 va_end (ap);
560
561 PUTBACK; 610 PUTBACK;
562 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
563 SPAGAIN;
564
565 if (count)
566 {
567 SV *status = POPs;
568 count = SvTRUE (status);
569 }
570
571 PUTBACK;
572 FREETMPS; 611 FREETMPS;
573 LEAVE; 612 LEAVE;
574 613
575 if (SvTRUE (ERRSV)) 614 if (SvTRUE (ERRSV))
576 { 615 {
577 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));
578 ungrab (term); // better lose the grab than the session 617 ungrab (term); // better lose the grab than the session
579 } 618 }
580 619
581 event_consumed = !!count; 620 event_consumed = !!count;
582 } 621 }
583 catch (...)
584 {
585 swap (perl_environ, environ);
586 throw;
587 }
588 else 622 else
589 event_consumed = false; 623 event_consumed = false;
590 624
591 // post-handling of some events 625 // post-handling of some events
592 if (htype == HOOK_REFRESH_BEGIN) 626 if (htype == HOOK_REFRESH_BEGIN)
603 637
604 // don't allow further calls 638 // don't allow further calls
605 term->perl.self = 0; 639 term->perl.self = 0;
606 } 640 }
607 641
608 swap (perl_environ, environ);
609
610 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;
611} 662}
612 663
613///////////////////////////////////////////////////////////////////////////// 664/////////////////////////////////////////////////////////////////////////////
614 665
615MODULE = urxvt PACKAGE = urxvt 666MODULE = urxvt PACKAGE = urxvt
627# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 678# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
628# include "hookinc.h" 679# include "hookinc.h"
629# undef def 680# undef def
630 681
631 HV *option = get_hv ("urxvt::OPTION", 1); 682 HV *option = get_hv ("urxvt::OPTION", 1);
632# 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);
633# define nodef(name) 684# define nodef(name)
634# include "optinc.h" 685# include "optinc.h"
635# undef nodef 686# undef nodef
636# undef def 687# undef def
637 688
639 static const struct { 690 static const struct {
640 const char *name; 691 const char *name;
641 IV iv; 692 IV iv;
642 } *civ, const_iv[] = { 693 } *civ, const_iv[] = {
643# define const_iv(name) { # name, (IV)name } 694# define const_iv(name) { # name, (IV)name }
695 const_iv (NUM_RESOURCES),
644 const_iv (DEFAULT_RSTYLE), 696 const_iv (DEFAULT_RSTYLE),
645 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),
646 const_iv (RS_Bold), 709 const_iv (RS_Bold),
647 const_iv (RS_Italic), 710 const_iv (RS_Italic),
648 const_iv (RS_Blink), 711 const_iv (RS_Blink),
649 const_iv (RS_RVid), 712 const_iv (RS_RVid),
650 const_iv (RS_Uline), 713 const_iv (RS_Uline),
737 const_iv (XIMSecondary), 800 const_iv (XIMSecondary),
738 const_iv (XIMTertiary), 801 const_iv (XIMTertiary),
739 const_iv (XIMVisibleToForward), 802 const_iv (XIMVisibleToForward),
740 const_iv (XIMVisibleToBackword), 803 const_iv (XIMVisibleToBackword),
741 const_iv (XIMVisibleToCenter), 804 const_iv (XIMVisibleToCenter),
805#if HAVE_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
742# if 0 816# if 0
743 const_iv (XIMForwardChar), 817 const_iv (XIMForwardChar),
744 const_iv (XIMBackwardChar), 818 const_iv (XIMBackwardChar),
745 const_iv (XIMForwardWord), 819 const_iv (XIMForwardWord),
746 const_iv (XIMBackwardWord), 820 const_iv (XIMBackwardWord),
754 const_iv (XIMDontChange), 828 const_iv (XIMDontChange),
755# endif 829# endif
756# endif 830# endif
757 }; 831 };
758 832
759 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--)
760 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 834 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
761} 835}
762 836
763void 837void
764warn (const char *msg) 838warn (const char *msg)
765 CODE: 839 CODE:
837 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++)
838 if ((*t)->perl.self) 912 if ((*t)->perl.self)
839 PUSHs (sv_2mortal (newSVterm (*t))); 913 PUSHs (sv_2mortal (newSVterm (*t)));
840} 914}
841 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
842MODULE = urxvt PACKAGE = urxvt::term 945MODULE = urxvt PACKAGE = urxvt::term
843 946
844SV * 947SV *
845_new (AV *env, AV *arg) 948_new (AV *env, AV *arg)
846 CODE: 949 CODE:
847{ 950{
848 rxvt_term *term = new rxvt_term; 951 rxvt_term *term = new rxvt_term;
849 952
850 stringvec *argv = new stringvec; 953 stringvec *argv = new stringvec;
851 stringvec *envv = new stringvec;
852
853 for (int i = 0; i <= AvFILL (arg); i++) 954 for (int i = 0; i <= AvFILL (arg); i++)
854 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 955 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
855 956
957 stringvec *envv = new stringvec;
856 for (int i = AvFILL (env) + 1; i--; ) 958 for (int i = AvFILL (env) + 1; i--; )
857 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 959 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
858
859 envv->push_back (0);
860 960
861 try 961 try
862 { 962 {
863 term->init (argv, envv); 963 term->init (argv, envv);
864 } 964 }
904 1004
905void 1005void
906rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 1006rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
907 CODE: 1007 CODE:
908 XUngrabKey (THIS->dpy, keycode, modifiers, window); 1008 XUngrabKey (THIS->dpy, keycode, modifiers, window);
909
910void
911rxvt_term::XUngrabKeyboard (Time eventtime)
912 CODE:
913 XUngrabKeyboard (THIS->dpy, eventtime);
914 1009
915bool 1010bool
916rxvt_term::grab (Time eventtime, int sync = 0) 1011rxvt_term::grab (Time eventtime, int sync = 0)
917 CODE: 1012 CODE:
918{ 1013{
1033 free (wstr); 1128 free (wstr);
1034} 1129}
1035 OUTPUT: 1130 OUTPUT:
1036 RETVAL 1131 RETVAL
1037 1132
1038char *
1039rxvt_term::locale ()
1040 CODE:
1041 RETVAL = THIS->locale;
1042 OUTPUT:
1043 RETVAL
1044
1045#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1133#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1046 1134
1047#define TERM_OFFSET_width TERM_OFFSET(width) 1135#define TERM_OFFSET_width TERM_OFFSET(width)
1048#define TERM_OFFSET_height TERM_OFFSET(height) 1136#define TERM_OFFSET_height TERM_OFFSET(height)
1049#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 1137#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
1050#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 1138#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
1051#define TERM_OFFSET_fbase TERM_OFFSET(fbase) 1139#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
1052#define TERM_OFFSET_nrow TERM_OFFSET(nrow) 1140#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
1053#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1141#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
1054#define TERM_OFFSET_focus TERM_OFFSET(focus) 1142#define TERM_OFFSET_focus TERM_OFFSET(focus)
1055#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1143#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
1056#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) 1144#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth)
1057#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) 1145#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth)
1058#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) 1146#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace)
1147#define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace)
1059#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1148#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
1060#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1149#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
1061#define TERM_OFFSET_top_row TERM_OFFSET(top_row) 1150#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
1062 1151
1063int 1152int
1064rxvt_term::width () 1153rxvt_term::width ()
1065 ALIAS: 1154 ALIAS:
1066 width = TERM_OFFSET_width 1155 width = TERM_OFFSET_width
1067 height = TERM_OFFSET_height 1156 height = TERM_OFFSET_height
1068 fwidth = TERM_OFFSET_fwidth 1157 fwidth = TERM_OFFSET_fwidth
1069 fheight = TERM_OFFSET_fheight 1158 fheight = TERM_OFFSET_fheight
1070 fbase = TERM_OFFSET_fbase 1159 fbase = TERM_OFFSET_fbase
1071 nrow = TERM_OFFSET_nrow 1160 nrow = TERM_OFFSET_nrow
1072 ncol = TERM_OFFSET_ncol 1161 ncol = TERM_OFFSET_ncol
1073 focus = TERM_OFFSET_focus 1162 focus = TERM_OFFSET_focus
1074 mapped = TERM_OFFSET_mapped 1163 mapped = TERM_OFFSET_mapped
1075 int_bwidth = TERM_OFFSET_int_bwidth 1164 int_bwidth = TERM_OFFSET_int_bwidth
1076 ext_bwidth = TERM_OFFSET_ext_bwidth 1165 ext_bwidth = TERM_OFFSET_ext_bwidth
1077 lineSpace = TERM_OFFSET_lineSpace 1166 lineSpace = TERM_OFFSET_lineSpace
1167 letterSpace = TERM_OFFSET_letterSpace
1078 saveLines = TERM_OFFSET_saveLines 1168 saveLines = TERM_OFFSET_saveLines
1079 total_rows = TERM_OFFSET_total_rows 1169 total_rows = TERM_OFFSET_total_rows
1080 top_row = TERM_OFFSET_top_row 1170 top_row = TERM_OFFSET_top_row
1081 CODE: 1171 CODE:
1082 RETVAL = *(int *)((char *)THIS + ix); 1172 RETVAL = *(int *)((char *)THIS + ix);
1083 OUTPUT: 1173 OUTPUT:
1084 RETVAL 1174 RETVAL
1085 1175
1096 { 1186 {
1097 case 0: RETVAL = THIS->ModLevel3Mask; break; 1187 case 0: RETVAL = THIS->ModLevel3Mask; break;
1098 case 1: RETVAL = THIS->ModMetaMask; break; 1188 case 1: RETVAL = THIS->ModMetaMask; break;
1099 case 2: RETVAL = THIS->ModNumLockMask; break; 1189 case 2: RETVAL = THIS->ModNumLockMask; break;
1100 case 3: RETVAL = THIS->current_screen; break; 1190 case 3: RETVAL = THIS->current_screen; break;
1191#ifdef CURSOR_BLINK
1101 case 4: RETVAL = THIS->hidden_cursor; break; 1192 case 4: RETVAL = THIS->hidden_cursor; break;
1193#endif
1102 } 1194 }
1103 OUTPUT: 1195 OUTPUT:
1104 RETVAL 1196 RETVAL
1105 1197
1106char * 1198char *
1149 RETVAL 1241 RETVAL
1150 1242
1151Window 1243Window
1152rxvt_term::parent () 1244rxvt_term::parent ()
1153 CODE: 1245 CODE:
1154 RETVAL = THIS->parent [0]; 1246 RETVAL = THIS->parent;
1155 OUTPUT: 1247 OUTPUT:
1156 RETVAL 1248 RETVAL
1157 1249
1158Window 1250Window
1159rxvt_term::vt () 1251rxvt_term::vt ()
1186 if (newval <= 0) 1278 if (newval <= 0)
1187 THIS->scr_changeview (max (newval, THIS->top_row)); 1279 THIS->scr_changeview (max (newval, THIS->top_row));
1188} 1280}
1189 OUTPUT: 1281 OUTPUT:
1190 RETVAL 1282 RETVAL
1283
1284void
1285rxvt_term::set_urgency (bool enable)
1191 1286
1192void 1287void
1193rxvt_term::focus_in () 1288rxvt_term::focus_in ()
1194 1289
1195void 1290void
1428# include "rsinc.h" 1523# include "rsinc.h"
1429# undef def 1524# undef def
1430# undef reserve 1525# undef reserve
1431 }; 1526 };
1432 1527
1433 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1528 rs = rslist + ecb_array_length (rslist);
1434 1529
1530 if (*name)
1435 do { 1531 {
1532 do {
1436 if (rs-- == rslist) 1533 if (rs-- == rslist)
1437 croak ("no such resource '%s', requested", name); 1534 croak ("no such resource '%s', requested", name);
1438 } while (strcmp (name, rs->name)); 1535 } while (strcmp (name, rs->name));
1439 1536
1440 index += rs->value; 1537 index += rs->value;
1538 }
1539 else
1540 {
1541 --rs;
1542 name = "";
1543 }
1441 1544
1442 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1545 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
1443 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); 1546 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);
1444 1547
1445 if (GIMME_V != G_VOID) 1548 if (GIMME_V != G_VOID)
1469 1572
1470 if (set >= 0) 1573 if (set >= 0)
1471 { 1574 {
1472 THIS->set_option (optval, set); 1575 THIS->set_option (optval, set);
1473 1576
1474 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1577 if (THIS->init_done) // avoid doing this before START
1475 switch (optval) 1578 switch (optval)
1476 { 1579 {
1477 case Opt_skipBuiltinGlyphs: 1580 case Opt_skipBuiltinGlyphs:
1478 THIS->set_fonts (); 1581 THIS->set_fonts ();
1479 THIS->scr_remap_chars (); 1582 THIS->scr_remap_chars ();
1480 THIS->scr_touch (true); 1583 THIS->scr_touch (true);
1481 THIS->want_refresh = 1; 1584 THIS->want_refresh = 1;
1482 THIS->refresh_check (); 1585 THIS->refresh_check ();
1483 break; 1586 break;
1587#ifdef CURSOR_BLINK
1588 case Opt_cursorBlink:
1589 THIS->cursor_blink_reset ();
1590 break;
1591#endif
1484 1592
1485 case Opt_cursorUnderline: 1593 case Opt_cursorUnderline:
1486 THIS->want_refresh = 1; 1594 THIS->want_refresh = 1;
1487 THIS->refresh_check (); 1595 THIS->refresh_check ();
1488 break; 1596 break;
1502 CODE: 1610 CODE:
1503 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1611 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1504 THIS->keyboard->register_done (); 1612 THIS->keyboard->register_done ();
1505 OUTPUT: 1613 OUTPUT:
1506 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);
1507 1622
1508void 1623void
1509rxvt_term::screen_cur (...) 1624rxvt_term::screen_cur (...)
1510 PROTOTYPE: $;$$ 1625 PROTOTYPE: $;$$
1511 ALIAS: 1626 ALIAS:
1525 EXTEND (SP, 2); 1640 EXTEND (SP, 2);
1526 PUSHs (sv_2mortal (newSViv (rc.row))); 1641 PUSHs (sv_2mortal (newSViv (rc.row)));
1527 PUSHs (sv_2mortal (newSViv (rc.col))); 1642 PUSHs (sv_2mortal (newSViv (rc.col)));
1528 } 1643 }
1529 1644
1530 if (items == 3) 1645 if (items >= 3)
1531 { 1646 {
1532 rc.row = SvIV (ST (1)); 1647 rc.row = SvIV (ST (1));
1533 rc.col = SvIV (ST (2)); 1648 rc.col = SvIV (ST (2));
1534 1649
1535 if (ix == 2) 1650 if (ix == 2)
1551 clamp_it (rc.col, 0, THIS->ncol); 1666 clamp_it (rc.col, 0, THIS->ncol);
1552 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1667 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1553 1668
1554 if (ix) 1669 if (ix)
1555 { 1670 {
1671 THIS->selection.screen = THIS->current_screen;
1672
1556 THIS->want_refresh = 1; 1673 THIS->want_refresh = 1;
1557 THIS->refresh_check (); 1674 THIS->refresh_check ();
1558 } 1675 }
1559 } 1676 }
1560} 1677}
1561 1678
1562char 1679int
1563rxvt_term::cur_charset () 1680rxvt_term::selection_screen (int screen = -1)
1564 CODE: 1681 CODE:
1565 RETVAL = THIS->charsets [THIS->screen.charset]; 1682 RETVAL = THIS->selection.screen;
1566 OUTPUT: 1683 if (screen >= 0)
1684 THIS->selection.screen = screen;
1685 OUTPUT:
1567 RETVAL 1686 RETVAL
1568 1687
1569void 1688void
1570rxvt_term::selection_clear () 1689rxvt_term::selection_clear (bool clipboard = false)
1571 1690
1572void 1691void
1573rxvt_term::selection_make (Time eventtime, bool rect = false) 1692rxvt_term::selection_make (Time eventtime, bool rect = false)
1574 CODE: 1693 CODE:
1575 THIS->selection.op = SELECTION_CONT; 1694 THIS->selection.op = SELECTION_CONT;
1576 THIS->selection.rect = rect; 1695 THIS->selection.rect = rect;
1577 THIS->selection_make (eventtime); 1696 THIS->selection_make (eventtime);
1578 1697
1579int 1698int
1580rxvt_term::selection_grab (Time eventtime) 1699rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1581 1700
1582void 1701void
1583rxvt_term::selection (SV *newtext = 0) 1702rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1584 PPCODE: 1703 PPCODE:
1585{ 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
1586 if (GIMME_V != G_VOID) 1708 if (GIMME_V != G_VOID)
1587 XPUSHs (THIS->selection.text 1709 XPUSHs (text
1588 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1710 ? sv_2mortal (wcs2sv (text, len))
1589 : &PL_sv_undef); 1711 : &PL_sv_undef);
1590 1712
1591 if (newtext) 1713 if (newtext)
1592 { 1714 {
1593 free (THIS->selection.text); 1715 free (text);
1594 1716
1595 THIS->selection.text = sv2wcs (newtext); 1717 text = sv2wcs (newtext);
1596 THIS->selection.len = wcslen (THIS->selection.text); 1718 len = wcslen (text);
1597 } 1719 }
1598} 1720}
1721
1722char
1723rxvt_term::cur_charset ()
1724 CODE:
1725 RETVAL = THIS->charsets [THIS->screen.charset];
1726 OUTPUT:
1727 RETVAL
1599 1728
1600void 1729void
1601rxvt_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)
1602 1731
1603void 1732void
1604rxvt_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)
1605 1734
1606void 1735void
1607rxvt_term::scr_bell () 1736rxvt_term::scr_bell ()
1737
1738void
1739rxvt_term::scr_recolour (bool refresh = true);
1608 1740
1609void 1741void
1610rxvt_term::scr_change_screen (int screen) 1742rxvt_term::scr_change_screen (int screen)
1611 1743
1612void 1744void
1625 char *str = SvPVbyte (octets, len); 1757 char *str = SvPVbyte (octets, len);
1626 C_ARGS: 1758 C_ARGS:
1627 str, len 1759 str, len
1628 1760
1629void 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
1630rxvt_term::cmd_parse (SV *octets) 1770rxvt_term::cmd_parse (SV *octets)
1631 CODE: 1771 CODE:
1632{ 1772{
1633 STRLEN len; 1773 STRLEN len;
1634 char *str = SvPVbyte (octets, len); 1774 char *str = SvPVbyte (octets, len);
1719 type, format, PropModeReplace, 1859 type, format, PropModeReplace,
1720 (unsigned char *)data_, len / elemsize); 1860 (unsigned char *)data_, len / elemsize);
1721} 1861}
1722 1862
1723Atom 1863Atom
1724XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) 1864XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE)
1725 C_ARGS: term->dpy, atom_name, only_if_exists 1865 C_ARGS: term->dpy, atom_name, only_if_exists
1726 1866
1727char * 1867char *
1728XGetAtomName (rxvt_term *term, Atom atom) 1868XGetAtomName (rxvt_term *term, Atom atom)
1729 C_ARGS: term->dpy, atom 1869 C_ARGS: term->dpy, atom
1730 CLEANUP: 1870 CLEANUP:
1731 XFree (RETVAL); 1871 XFree (RETVAL);
1732 1872
1733void 1873void
1734XDeleteProperty (rxvt_term *term, Window window, Atom property) 1874XDeleteProperty (rxvt_term *term, Window window, Atom property)
1735 C_ARGS: term->dpy, window, property 1875 C_ARGS: term->dpy, window, property
1736 1876
1737Window 1877Window
1738rxvt_term::DefaultRootWindow () 1878rxvt_term::DefaultRootWindow ()
1739 CODE: 1879 CODE:
1740 RETVAL = THIS->display->root; 1880 RETVAL = THIS->display->root;
1792 PUSHs (newSVuv (child)); 1932 PUSHs (newSVuv (child));
1793 } 1933 }
1794} 1934}
1795 1935
1796############################################################################# 1936#############################################################################
1937# fancy bg bloatstuff (TODO: should be moved up somewhere)
1938
1939#if ENABLE_TRANSPARENCY
1940
1941#if 0
1942
1943rxvt_img *
1944rxvt_term::new_img_from_root ()
1945 CODE:
1946 RETVAL = rxvt_img::new_from_root (THIS);
1947 OUTPUT:
1948 RETVAL
1949
1950#endif
1951
1952#endif
1953
1954#if HAVE_PIXBUF
1955
1956rxvt_img *
1957rxvt_term::new_img_from_file (octet_string filename)
1958 CODE:
1959 try
1960 {
1961 RETVAL = rxvt_img::new_from_file (THIS, filename);
1962 }
1963 catch (const class rxvt_failure_exception &e)
1964 {
1965 croak ("new_img_from_file failed");
1966 }
1967 OUTPUT:
1968 RETVAL
1969
1970#endif
1971
1972#if HAVE_BG_PIXMAP
1973
1974void
1975rxvt_term::set_background (rxvt_img *img)
1976 CODE:
1977 THIS->bg_destroy ();
1978 THIS->bg_pixmap = None;
1979 THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH;
1980
1981 if (img) // TODO: cannot be false
1982 {
1983 img->unshare ();
1984 THIS->bg_pixmap = img->steal ();
1985 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH;
1986 THIS->bg_valid_since = ev::now (); // TODO: extra bloat
1987 }
1988
1989#endif
1990
1991#############################################################################
1797# urxvt::overlay 1992# urxvt::overlay
1798############################################################################# 1993#############################################################################
1799 1994
1800MODULE = urxvt PACKAGE = urxvt::overlay 1995MODULE = urxvt PACKAGE = urxvt::overlay
1801 1996
1811void 2006void
1812overlay::DESTROY () 2007overlay::DESTROY ()
1813 2008
1814INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 2009INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1815 2010
2011MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
2012
2013#if HAVE_PIXBUF
2014
2015urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename)
2016 C_ARGS: filename, 0
2017
2018void
2019DESTROY (urxvt::pixbuf self)
2020 CODE:
2021 gdk_pixbuf_unref (self);
2022
2023#endif
2024
2025MODULE = urxvt PACKAGE = urxvt::img
2026
2027#if HAVE_IMG
2028
2029# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
2030# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
2031
2032void
2033rxvt_img::fill (SV *c)
2034 INIT:
2035 rxvt_color rc;
2036 parse_color (THIS->s, rc, c);
2037 C_ARGS: rc
2038
2039void
2040rxvt_img::DESTROY ()
2041 CODE:
2042 delete THIS;
2043
2044void
2045rxvt_img::blur (int rh, int rv)
2046
2047void
2048rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.)
2049
2050void
2051rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.)
2052
2053void
2054rxvt_img::unshare ()
2055
2056rxvt_img *
2057rxvt_img::clone ()
2058
2059rxvt_img *
2060rxvt_img::scale (int new_width, int new_height)
2061
2062rxvt_img *
2063rxvt_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)
2064 INIT:
2065 double matrix[9] = {
2066 p11, p12, p13,
2067 p21, p22, p23,
2068 p31, p32, p33
2069 };
2070 C_ARGS: new_width, new_height, repeat, matrix
2071
2072#endif
2073

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines