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.123 by root, Sun Jun 15 14:54:44 2008 UTC vs.
Revision 1.166 by root, Tue Jun 5 11:00:40 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
642 } *civ, const_iv[] = { 693 } *civ, const_iv[] = {
643# define const_iv(name) { # name, (IV)name } 694# define const_iv(name) { # name, (IV)name }
644 const_iv (NUM_RESOURCES), 695 const_iv (NUM_RESOURCES),
645 const_iv (DEFAULT_RSTYLE), 696 const_iv (DEFAULT_RSTYLE),
646 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),
647 const_iv (RS_Bold), 709 const_iv (RS_Bold),
648 const_iv (RS_Italic), 710 const_iv (RS_Italic),
649 const_iv (RS_Blink), 711 const_iv (RS_Blink),
650 const_iv (RS_RVid), 712 const_iv (RS_RVid),
651 const_iv (RS_Uline), 713 const_iv (RS_Uline),
738 const_iv (XIMSecondary), 800 const_iv (XIMSecondary),
739 const_iv (XIMTertiary), 801 const_iv (XIMTertiary),
740 const_iv (XIMVisibleToForward), 802 const_iv (XIMVisibleToForward),
741 const_iv (XIMVisibleToBackword), 803 const_iv (XIMVisibleToBackword),
742 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
743# if 0 816# if 0
744 const_iv (XIMForwardChar), 817 const_iv (XIMForwardChar),
745 const_iv (XIMBackwardChar), 818 const_iv (XIMBackwardChar),
746 const_iv (XIMForwardWord), 819 const_iv (XIMForwardWord),
747 const_iv (XIMBackwardWord), 820 const_iv (XIMBackwardWord),
755 const_iv (XIMDontChange), 828 const_iv (XIMDontChange),
756# endif 829# endif
757# endif 830# endif
758 }; 831 };
759 832
760 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--)
761 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 834 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
762} 835}
763 836
764void 837void
765warn (const char *msg) 838warn (const char *msg)
766 CODE: 839 CODE:
838 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++)
839 if ((*t)->perl.self) 912 if ((*t)->perl.self)
840 PUSHs (sv_2mortal (newSVterm (*t))); 913 PUSHs (sv_2mortal (newSVterm (*t)));
841} 914}
842 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
843MODULE = urxvt PACKAGE = urxvt::term 945MODULE = urxvt PACKAGE = urxvt::term
844 946
845SV * 947SV *
846_new (AV *env, AV *arg) 948_new (AV *env, AV *arg)
847 CODE: 949 CODE:
848{ 950{
849 rxvt_term *term = new rxvt_term; 951 rxvt_term *term = new rxvt_term;
850 952
851 stringvec *argv = new stringvec; 953 stringvec *argv = new stringvec;
852 stringvec *envv = new stringvec;
853
854 for (int i = 0; i <= AvFILL (arg); i++) 954 for (int i = 0; i <= AvFILL (arg); i++)
855 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 955 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
856 956
957 stringvec *envv = new stringvec;
857 for (int i = AvFILL (env) + 1; i--; ) 958 for (int i = AvFILL (env) + 1; i--; )
858 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 959 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
859 960
860 envv->push_back (0);
861
862 try 961 try
863 { 962 {
864 term->init (argv, envv); 963 term->init (argv, envv);
865 } 964 }
866 catch (const class rxvt_failure_exception &e) 965 catch (const class rxvt_failure_exception &e)
879rxvt_term::destroy () 978rxvt_term::destroy ()
880 979
881void 980void
882rxvt_term::set_should_invoke (int htype, int inc) 981rxvt_term::set_should_invoke (int htype, int inc)
883 CODE: 982 CODE:
884 THIS->perl.should_invoke [htype] += inc; 983 uint8_t &count = THIS->perl.should_invoke [htype];
984 uint8_t prev = count;
985 count += inc;
986 if (!prev != !count)
987 {
988 // hook status changed, react
989 switch (htype)
990 {
991 case HOOK_POSITION_CHANGE:
992 if (count)
993 THIS->get_window_origin (THIS->parent_x, THIS->parent_y);
994 }
995 }
885 996
886int 997int
887rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) 998rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
888 CODE: 999 CODE:
889 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, 1000 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1,
905 1016
906void 1017void
907rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 1018rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
908 CODE: 1019 CODE:
909 XUngrabKey (THIS->dpy, keycode, modifiers, window); 1020 XUngrabKey (THIS->dpy, keycode, modifiers, window);
910
911void
912rxvt_term::XUngrabKeyboard (Time eventtime)
913 CODE:
914 XUngrabKeyboard (THIS->dpy, eventtime);
915 1021
916bool 1022bool
917rxvt_term::grab (Time eventtime, int sync = 0) 1023rxvt_term::grab (Time eventtime, int sync = 0)
918 CODE: 1024 CODE:
919{ 1025{
1034 free (wstr); 1140 free (wstr);
1035} 1141}
1036 OUTPUT: 1142 OUTPUT:
1037 RETVAL 1143 RETVAL
1038 1144
1039char *
1040rxvt_term::locale ()
1041 CODE:
1042 RETVAL = THIS->locale;
1043 OUTPUT:
1044 RETVAL
1045
1046#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1145#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1047 1146
1048#define TERM_OFFSET_width TERM_OFFSET(width) 1147#define TERM_OFFSET_width TERM_OFFSET(width)
1049#define TERM_OFFSET_height TERM_OFFSET(height) 1148#define TERM_OFFSET_height TERM_OFFSET(height)
1050#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 1149#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
1051#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 1150#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
1052#define TERM_OFFSET_fbase TERM_OFFSET(fbase) 1151#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
1053#define TERM_OFFSET_nrow TERM_OFFSET(nrow) 1152#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
1054#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1153#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
1055#define TERM_OFFSET_focus TERM_OFFSET(focus) 1154#define TERM_OFFSET_focus TERM_OFFSET(focus)
1056#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1155#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
1057#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) 1156#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth)
1058#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) 1157#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth)
1059#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) 1158#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace)
1159#define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace)
1060#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1160#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
1061#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1161#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
1062#define TERM_OFFSET_top_row TERM_OFFSET(top_row) 1162#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
1063 1163
1064int 1164int
1065rxvt_term::width () 1165rxvt_term::width ()
1066 ALIAS: 1166 ALIAS:
1067 width = TERM_OFFSET_width 1167 width = TERM_OFFSET_width
1068 height = TERM_OFFSET_height 1168 height = TERM_OFFSET_height
1069 fwidth = TERM_OFFSET_fwidth 1169 fwidth = TERM_OFFSET_fwidth
1070 fheight = TERM_OFFSET_fheight 1170 fheight = TERM_OFFSET_fheight
1071 fbase = TERM_OFFSET_fbase 1171 fbase = TERM_OFFSET_fbase
1072 nrow = TERM_OFFSET_nrow 1172 nrow = TERM_OFFSET_nrow
1073 ncol = TERM_OFFSET_ncol 1173 ncol = TERM_OFFSET_ncol
1074 focus = TERM_OFFSET_focus 1174 focus = TERM_OFFSET_focus
1075 mapped = TERM_OFFSET_mapped 1175 mapped = TERM_OFFSET_mapped
1076 int_bwidth = TERM_OFFSET_int_bwidth 1176 int_bwidth = TERM_OFFSET_int_bwidth
1077 ext_bwidth = TERM_OFFSET_ext_bwidth 1177 ext_bwidth = TERM_OFFSET_ext_bwidth
1078 lineSpace = TERM_OFFSET_lineSpace 1178 lineSpace = TERM_OFFSET_lineSpace
1179 letterSpace = TERM_OFFSET_letterSpace
1079 saveLines = TERM_OFFSET_saveLines 1180 saveLines = TERM_OFFSET_saveLines
1080 total_rows = TERM_OFFSET_total_rows 1181 total_rows = TERM_OFFSET_total_rows
1081 top_row = TERM_OFFSET_top_row 1182 top_row = TERM_OFFSET_top_row
1082 CODE: 1183 CODE:
1083 RETVAL = *(int *)((char *)THIS + ix); 1184 RETVAL = *(int *)((char *)THIS + ix);
1084 OUTPUT: 1185 OUTPUT:
1085 RETVAL 1186 RETVAL
1086 1187
1097 { 1198 {
1098 case 0: RETVAL = THIS->ModLevel3Mask; break; 1199 case 0: RETVAL = THIS->ModLevel3Mask; break;
1099 case 1: RETVAL = THIS->ModMetaMask; break; 1200 case 1: RETVAL = THIS->ModMetaMask; break;
1100 case 2: RETVAL = THIS->ModNumLockMask; break; 1201 case 2: RETVAL = THIS->ModNumLockMask; break;
1101 case 3: RETVAL = THIS->current_screen; break; 1202 case 3: RETVAL = THIS->current_screen; break;
1203#ifdef CURSOR_BLINK
1102 case 4: RETVAL = THIS->hidden_cursor; break; 1204 case 4: RETVAL = THIS->hidden_cursor; break;
1205#endif
1103 } 1206 }
1104 OUTPUT: 1207 OUTPUT:
1105 RETVAL 1208 RETVAL
1106 1209
1107char * 1210char *
1150 RETVAL 1253 RETVAL
1151 1254
1152Window 1255Window
1153rxvt_term::parent () 1256rxvt_term::parent ()
1154 CODE: 1257 CODE:
1155 RETVAL = THIS->parent [0]; 1258 RETVAL = THIS->parent;
1156 OUTPUT: 1259 OUTPUT:
1157 RETVAL 1260 RETVAL
1158 1261
1159Window 1262int
1160rxvt_term::vt () 1263rxvt_term::parent_x ()
1161 CODE: 1264 CODE:
1162 RETVAL = THIS->vt; 1265 RETVAL = THIS->parent_x;
1266 OUTPUT:
1267 RETVAL
1268
1269int
1270rxvt_term::parent_y ()
1271 CODE:
1272 RETVAL = THIS->parent_y;
1163 OUTPUT: 1273 OUTPUT:
1164 RETVAL 1274 RETVAL
1165 1275
1166void 1276void
1167rxvt_term::vt_emask_add (U32 emask) 1277rxvt_term::vt_emask_add (U32 emask)
1187 if (newval <= 0) 1297 if (newval <= 0)
1188 THIS->scr_changeview (max (newval, THIS->top_row)); 1298 THIS->scr_changeview (max (newval, THIS->top_row));
1189} 1299}
1190 OUTPUT: 1300 OUTPUT:
1191 RETVAL 1301 RETVAL
1302
1303void
1304rxvt_term::set_urgency (bool enable)
1192 1305
1193void 1306void
1194rxvt_term::focus_in () 1307rxvt_term::focus_in ()
1195 1308
1196void 1309void
1429# include "rsinc.h" 1542# include "rsinc.h"
1430# undef def 1543# undef def
1431# undef reserve 1544# undef reserve
1432 }; 1545 };
1433 1546
1434 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1547 rs = rslist + ecb_array_length (rslist);
1435 1548
1436 if (*name) 1549 if (*name)
1437 { 1550 {
1438 do { 1551 do {
1439 if (rs-- == rslist) 1552 if (rs-- == rslist)
1478 1591
1479 if (set >= 0) 1592 if (set >= 0)
1480 { 1593 {
1481 THIS->set_option (optval, set); 1594 THIS->set_option (optval, set);
1482 1595
1483 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1596 if (THIS->init_done) // avoid doing this before START
1484 switch (optval) 1597 switch (optval)
1485 { 1598 {
1486 case Opt_skipBuiltinGlyphs: 1599 case Opt_skipBuiltinGlyphs:
1487 THIS->set_fonts (); 1600 THIS->set_fonts ();
1488 THIS->scr_remap_chars (); 1601 THIS->scr_remap_chars ();
1489 THIS->scr_touch (true); 1602 THIS->scr_touch (true);
1490 THIS->want_refresh = 1; 1603 THIS->want_refresh = 1;
1491 THIS->refresh_check (); 1604 THIS->refresh_check ();
1492 break; 1605 break;
1606#ifdef CURSOR_BLINK
1607 case Opt_cursorBlink:
1608 THIS->cursor_blink_reset ();
1609 break;
1610#endif
1493 1611
1494 case Opt_cursorUnderline: 1612 case Opt_cursorUnderline:
1495 THIS->want_refresh = 1; 1613 THIS->want_refresh = 1;
1496 THIS->refresh_check (); 1614 THIS->refresh_check ();
1497 break; 1615 break;
1511 CODE: 1629 CODE:
1512 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1630 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1513 THIS->keyboard->register_done (); 1631 THIS->keyboard->register_done ();
1514 OUTPUT: 1632 OUTPUT:
1515 RETVAL 1633 RETVAL
1634
1635void
1636rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1637 CODE:
1638 wchar_t *wstr = sv2wcs (str);
1639 THIS->keyboard->register_user_translation (keysym, state, wstr);
1640 free (wstr);
1516 1641
1517void 1642void
1518rxvt_term::screen_cur (...) 1643rxvt_term::screen_cur (...)
1519 PROTOTYPE: $;$$ 1644 PROTOTYPE: $;$$
1520 ALIAS: 1645 ALIAS:
1534 EXTEND (SP, 2); 1659 EXTEND (SP, 2);
1535 PUSHs (sv_2mortal (newSViv (rc.row))); 1660 PUSHs (sv_2mortal (newSViv (rc.row)));
1536 PUSHs (sv_2mortal (newSViv (rc.col))); 1661 PUSHs (sv_2mortal (newSViv (rc.col)));
1537 } 1662 }
1538 1663
1539 if (items == 3) 1664 if (items >= 3)
1540 { 1665 {
1541 rc.row = SvIV (ST (1)); 1666 rc.row = SvIV (ST (1));
1542 rc.col = SvIV (ST (2)); 1667 rc.col = SvIV (ST (2));
1543 1668
1544 if (ix == 2) 1669 if (ix == 2)
1560 clamp_it (rc.col, 0, THIS->ncol); 1685 clamp_it (rc.col, 0, THIS->ncol);
1561 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1686 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1562 1687
1563 if (ix) 1688 if (ix)
1564 { 1689 {
1690 THIS->selection.screen = THIS->current_screen;
1691
1565 THIS->want_refresh = 1; 1692 THIS->want_refresh = 1;
1566 THIS->refresh_check (); 1693 THIS->refresh_check ();
1567 } 1694 }
1568 } 1695 }
1569} 1696}
1570 1697
1571char 1698int
1572rxvt_term::cur_charset () 1699rxvt_term::selection_screen (int screen = -1)
1573 CODE: 1700 CODE:
1574 RETVAL = THIS->charsets [THIS->screen.charset]; 1701 RETVAL = THIS->selection.screen;
1575 OUTPUT: 1702 if (screen >= 0)
1703 THIS->selection.screen = screen;
1704 OUTPUT:
1576 RETVAL 1705 RETVAL
1577 1706
1578void 1707void
1579rxvt_term::selection_clear () 1708rxvt_term::selection_clear (bool clipboard = false)
1580 1709
1581void 1710void
1582rxvt_term::selection_make (Time eventtime, bool rect = false) 1711rxvt_term::selection_make (Time eventtime, bool rect = false)
1583 CODE: 1712 CODE:
1584 THIS->selection.op = SELECTION_CONT; 1713 THIS->selection.op = SELECTION_CONT;
1585 THIS->selection.rect = rect; 1714 THIS->selection.rect = rect;
1586 THIS->selection_make (eventtime); 1715 THIS->selection_make (eventtime);
1587 1716
1588int 1717int
1589rxvt_term::selection_grab (Time eventtime) 1718rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1590 1719
1591void 1720void
1592rxvt_term::selection (SV *newtext = 0) 1721rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1593 PPCODE: 1722 PPCODE:
1594{ 1723{
1724 wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text;
1725 unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len;
1726
1595 if (GIMME_V != G_VOID) 1727 if (GIMME_V != G_VOID)
1596 XPUSHs (THIS->selection.text 1728 XPUSHs (text
1597 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1729 ? sv_2mortal (wcs2sv (text, len))
1598 : &PL_sv_undef); 1730 : &PL_sv_undef);
1599 1731
1600 if (newtext) 1732 if (newtext)
1601 { 1733 {
1602 free (THIS->selection.text); 1734 free (text);
1603 1735
1604 THIS->selection.text = sv2wcs (newtext); 1736 text = sv2wcs (newtext);
1605 THIS->selection.len = wcslen (THIS->selection.text); 1737 len = wcslen (text);
1606 } 1738 }
1607} 1739}
1740
1741char
1742rxvt_term::cur_charset ()
1743 CODE:
1744 RETVAL = THIS->charsets [THIS->screen.charset];
1745 OUTPUT:
1746 RETVAL
1608 1747
1609void 1748void
1610rxvt_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) 1749rxvt_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)
1611 1750
1612void 1751void
1613rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) 1752rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1614 1753
1615void 1754void
1616rxvt_term::scr_bell () 1755rxvt_term::scr_bell ()
1756
1757void
1758rxvt_term::scr_recolour (bool refresh = true);
1617 1759
1618void 1760void
1619rxvt_term::scr_change_screen (int screen) 1761rxvt_term::scr_change_screen (int screen)
1620 1762
1621void 1763void
1634 char *str = SvPVbyte (octets, len); 1776 char *str = SvPVbyte (octets, len);
1635 C_ARGS: 1777 C_ARGS:
1636 str, len 1778 str, len
1637 1779
1638void 1780void
1781rxvt_term::tt_paste (SV *octets)
1782 INIT:
1783 STRLEN len;
1784 char *str = SvPVbyte (octets, len);
1785 C_ARGS:
1786 str, len
1787
1788void
1639rxvt_term::cmd_parse (SV *octets) 1789rxvt_term::cmd_parse (SV *octets)
1640 CODE: 1790 CODE:
1641{ 1791{
1642 STRLEN len; 1792 STRLEN len;
1643 char *str = SvPVbyte (octets, len); 1793 char *str = SvPVbyte (octets, len);
1728 type, format, PropModeReplace, 1878 type, format, PropModeReplace,
1729 (unsigned char *)data_, len / elemsize); 1879 (unsigned char *)data_, len / elemsize);
1730} 1880}
1731 1881
1732Atom 1882Atom
1733XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) 1883XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE)
1734 C_ARGS: term->dpy, atom_name, only_if_exists 1884 C_ARGS: term->dpy, atom_name, only_if_exists
1735 1885
1736char * 1886char *
1737XGetAtomName (rxvt_term *term, Atom atom) 1887XGetAtomName (rxvt_term *term, Atom atom)
1738 C_ARGS: term->dpy, atom 1888 C_ARGS: term->dpy, atom
1739 CLEANUP: 1889 CLEANUP:
1740 XFree (RETVAL); 1890 XFree (RETVAL);
1741 1891
1742void 1892void
1743XDeleteProperty (rxvt_term *term, Window window, Atom property) 1893XDeleteProperty (rxvt_term *term, Window window, Atom property)
1744 C_ARGS: term->dpy, window, property 1894 C_ARGS: term->dpy, window, property
1745 1895
1746Window 1896Window
1747rxvt_term::DefaultRootWindow () 1897rxvt_term::DefaultRootWindow ()
1748 CODE: 1898 CODE:
1749 RETVAL = THIS->display->root; 1899 RETVAL = THIS->display->root;
1801 PUSHs (newSVuv (child)); 1951 PUSHs (newSVuv (child));
1802 } 1952 }
1803} 1953}
1804 1954
1805############################################################################# 1955#############################################################################
1956# fancy bg bloatstuff (TODO: should be moved up somewhere)
1957
1958# TODO: ugly
1959void
1960rxvt_term::get_geometry ()
1961 PPCODE:
1962 EXTEND (SP, 4);
1963 PUSHs (sv_2mortal (newSViv (THIS->parent_x)));
1964 PUSHs (sv_2mortal (newSViv (THIS->parent_y)));
1965 PUSHs (sv_2mortal (newSViv (THIS->szHint.width)));
1966 PUSHs (sv_2mortal (newSViv (THIS->szHint.height)));
1967
1968#if HAVE_IMG
1969
1970rxvt_img *
1971rxvt_term::new_img (SV *format, int width, int height)
1972 CODE:
1973 XRenderPictFormat *f = SvOK (format)
1974 ? XRenderFindVisualFormat (THIS->dpy, THIS->visual)
1975 : XRenderFindStandardFormat (THIS->dpy, SvIV (format));
1976 RETVAL = new rxvt_img (THIS, f, width, height);
1977 OUTPUT:
1978 RETVAL
1979
1980#if ENABLE_TRANSPARENCY
1981
1982#if 0
1983
1984rxvt_img *
1985rxvt_term::new_img_from_root ()
1986 CODE:
1987 RETVAL = rxvt_img::new_from_root (THIS);
1988 OUTPUT:
1989 RETVAL
1990
1991#endif
1992
1993#endif
1994
1995#if HAVE_PIXBUF
1996
1997rxvt_img *
1998rxvt_term::new_img_from_file (octet_string filename)
1999 CODE:
2000 try
2001 {
2002 RETVAL = rxvt_img::new_from_file (THIS, filename);
2003 }
2004 catch (const class rxvt_failure_exception &e)
2005 {
2006 croak ("new_img_from_file failed");
2007 }
2008 OUTPUT:
2009 RETVAL
2010
2011#endif
2012
2013#if HAVE_BG_PIXMAP
2014
2015void
2016rxvt_term::set_background (rxvt_img *img)
2017 CODE:
2018 THIS->bg_destroy ();
2019 THIS->bg_pixmap = None;
2020 THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH;
2021
2022 if (img) // TODO: cannot be false
2023 {
2024 img->unshare ();
2025 THIS->bg_pixmap = img->steal ();
2026 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH;
2027 THIS->bg_valid_since = ev::now (); // TODO: extra bloat
2028 }
2029
2030#endif
2031
2032#endif
2033
2034#############################################################################
1806# urxvt::overlay 2035# urxvt::overlay
1807############################################################################# 2036#############################################################################
1808 2037
1809MODULE = urxvt PACKAGE = urxvt::overlay 2038MODULE = urxvt PACKAGE = urxvt::overlay
1810 2039
1820void 2049void
1821overlay::DESTROY () 2050overlay::DESTROY ()
1822 2051
1823INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 2052INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1824 2053
2054MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
2055
2056#if HAVE_PIXBUF
2057
2058urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename)
2059 C_ARGS: filename, 0
2060
2061void
2062DESTROY (urxvt::pixbuf self)
2063 CODE:
2064 gdk_pixbuf_unref (self);
2065
2066#endif
2067
2068MODULE = urxvt PACKAGE = urxvt::img
2069
2070#if HAVE_IMG
2071
2072# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
2073# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
2074
2075int
2076rxvt_img::w ()
2077 CODE:
2078 RETVAL = THIS->w;
2079 OUTPUT:
2080 RETVAL
2081
2082int
2083rxvt_img::h ()
2084 CODE:
2085 RETVAL = THIS->h;
2086 OUTPUT:
2087 RETVAL
2088
2089bool
2090rxvt_img::shared ()
2091 CODE:
2092 RETVAL = THIS->shared;
2093 OUTPUT:
2094 RETVAL
2095
2096Pixmap
2097rxvt_img::pm ()
2098 CODE:
2099 RETVAL = THIS->pm;
2100 OUTPUT:
2101 RETVAL
2102
2103void
2104rxvt_img::fill (SV *c)
2105 INIT:
2106 rxvt_color rc;
2107 parse_color (THIS->s, rc, c);
2108 C_ARGS: rc
2109
2110void
2111rxvt_img::DESTROY ()
2112 CODE:
2113 delete THIS;
2114
2115void
2116rxvt_img::blur (int rh, int rv)
2117
2118void
2119rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.)
2120
2121void
2122rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.)
2123
2124void
2125rxvt_img::unshare ()
2126
2127rxvt_img *
2128rxvt_img::clone ()
2129
2130rxvt_img *
2131rxvt_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)
2132 INIT:
2133 double matrix[9] = {
2134 p11, p12, p13,
2135 p21, p22, p23,
2136 p31, p32, p33
2137 };
2138 C_ARGS: new_width, new_height, repeat, matrix
2139
2140rxvt_img *
2141rxvt_img::scale (int new_width, int new_height)
2142
2143rxvt_img *
2144rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, NV phi)
2145
2146#endif
2147

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines