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.111 by root, Thu Dec 14 17:33:53 2006 UTC vs.
Revision 1.151 by root, Thu Jan 19 13:04:12 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-2006 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 <cstddef>
32#include <cstdarg> 33#include <cstdarg>
33 34
34#include "unistd.h" 35#include "unistd.h"
35 36
36#include "iom.h" 37#include "ev_cpp.h"
37#include "rxvt.h" 38#include "rxvt.h"
38#include "keyboard.h" 39#include "keyboard.h"
39#include "rxvtutil.h" 40#include "rxvtutil.h"
40#include "rxvtperl.h" 41#include "rxvtperl.h"
41 42
42#include "perlxsi.c" 43#include "perlxsi.c"
43 44
44#ifdef HAVE_SCROLLBARS
45# define GRAB_CURSOR THIS->leftptr_cursor 45#define GRAB_CURSOR THIS->scrollBar.leftptr_cursor
46#else
47# define GRAB_CURSOR None
48#endif
49 46
50#undef LINENO 47#undef LINENO
51#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) 48#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
52#undef ROW 49#undef ROW
53#define ROW(n) THIS->row_buf [LINENO (n)] 50#define ROW(n) THIS->row_buf [LINENO (n)]
73 70
74 return sv; 71 return sv;
75} 72}
76 73
77static SV * 74static SV *
78new_ref (HV *hv, const char *klass)
79{
80 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
81}
82
83static SV *
84newSVptr (void *ptr, const char *klass) 75newSVptr (void *ptr, const char *klass)
85{ 76{
86 HV *hv = newHV (); 77 HV *hv = newHV ();
87 sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); 78 sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0);
88 return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 79 return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
117 108
118///////////////////////////////////////////////////////////////////////////// 109/////////////////////////////////////////////////////////////////////////////
119 110
120#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 111#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
121 112
122class overlay { 113class overlay : overlay_base
114{
123 rxvt_term *THIS; 115 rxvt_term *THIS;
124 AV *overlay_av; 116 AV *overlay_av;
125 int x, y, w, h;
126 int border; 117 int border;
127 text_t **text;
128 rend_t **rend;
129 118
130public: 119public:
131 HV *self; 120 HV *self;
132 121
133 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); 122 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
140 129
141 void set (int x, int y, SV *str, SV *rend); 130 void set (int x, int y, SV *str, SV *rend);
142}; 131};
143 132
144overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) 133overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border)
145: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) 134: THIS(THIS), border(border == 2), overlay_av (0)
146{ 135{
136 x = x_;
137 y = y_;
138 w = w_;
139 h = h_;
140
147 if (w < 0) w = 0; 141 if (w < 0) w = 0;
148 if (h < 0) h = 0; 142 if (h < 0) h = 0;
149 143
150 if (border == 2) 144 if (border == 2)
151 { 145 {
220 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) 214 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)
221 )); 215 ));
222 av_push (overlay_av, newSViv ((long)this)); 216 av_push (overlay_av, newSViv ((long)this));
223 217
224 THIS->want_refresh = 1; 218 THIS->want_refresh = 1;
219 THIS->refresh_check ();
225} 220}
226 221
227void 222void
228overlay::hide () 223overlay::hide ()
229{ 224{
243 238
244 SvREFCNT_dec (overlay_av); 239 SvREFCNT_dec (overlay_av);
245 overlay_av = 0; 240 overlay_av = 0;
246 241
247 THIS->want_refresh = 1; 242 THIS->want_refresh = 1;
243 THIS->refresh_check ();
248} 244}
249 245
250void overlay::swap () 246void overlay::swap ()
251{ 247{
252 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 248 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
253 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); 249 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h));
254 250
255 int ov_w = min (w, THIS->ncol - ov_x); 251 int ov_w = min (w, THIS->ncol - ov_x);
256 int ov_h = min (h, THIS->nrow - ov_y); 252 int ov_h = min (h, THIS->nrow - ov_y);
253
254 // hide cursor if it is within the overlay area
255 if (IN_RANGE_EXC (THIS->screen.cur.col - ov_x, 0, ov_w)
256 && IN_RANGE_EXC (THIS->screen.cur.row - ov_y, 0, ov_h))
257 THIS->screen.flags &= ~Screen_VisibleCursor;
257 258
258 for (int y = ov_h; y--; ) 259 for (int y = ov_h; y--; )
259 { 260 {
260 text_t *t1 = text [y]; 261 text_t *t1 = text [y];
261 rend_t *r1 = rend [y]; 262 rend_t *r1 = rend [y];
297 for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) 298 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
298 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 299 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
299 } 300 }
300 301
301 THIS->want_refresh = 1; 302 THIS->want_refresh = 1;
303 THIS->refresh_check ();
302} 304}
303 305
304///////////////////////////////////////////////////////////////////////////// 306/////////////////////////////////////////////////////////////////////////////
305 307
306#define IOM_CLASS "urxvt"
307#include <iom_perl.h> 308#include "iom_perl.h"
308 309
309///////////////////////////////////////////////////////////////////////////// 310/////////////////////////////////////////////////////////////////////////////
310 311
311struct rxvt_perl_interp rxvt_perl; 312struct rxvt_perl_interp rxvt_perl;
312 313
316{ 317{
317 if (perl) 318 if (perl)
318 { 319 {
319 perl_destruct (perl); 320 perl_destruct (perl);
320 perl_free (perl); 321 perl_free (perl);
322 PERL_SYS_TERM ();
321 } 323 }
322} 324}
323 325
324void 326void
325rxvt_perl_interp::init (rxvt_term *term) 327rxvt_perl_interp::init (rxvt_term *term)
326{ 328{
327 if (!perl) 329 if (!perl)
328 { 330 {
329 rxvt_push_locale (""); // perl init destroys current locale 331 rxvt_push_locale (""); // perl init destroys current locale
330 332
333 {
331 perl_environ = rxvt_environ; 334 perl_environ = rxvt_environ;
332 swap (perl_environ, environ); 335 localise_env set_environ (perl_environ);
333 336
334 char *argv[] = { 337 char *args[] = {
335 "", 338 "",
336 "-e" 339 "-e"
337 "BEGIN {" 340 "BEGIN {"
338 " urxvt->bootstrap;" 341 " urxvt->bootstrap;"
339 " unshift @INC, '" LIBDIR "';" 342 " unshift @INC, '" LIBDIR "';"
340 "}" 343 "}"
341 "" 344 ""
342 "use urxvt;" 345 "use urxvt;"
343 }; 346 };
347 int argc = ecb_array_length (args);
348 char **argv = args;
344 349
350 PERL_SYS_INIT3 (&argc, &argv, &environ);
345 perl = perl_alloc (); 351 perl = perl_alloc ();
346 perl_construct (perl); 352 perl_construct (perl);
347 353
348 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 354 if (perl_parse (perl, xs_init, argc, argv, (char **)NULL)
349 || perl_run (perl)) 355 || perl_run (perl))
350 { 356 {
351 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 357 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
352 358
353 perl_destruct (perl); 359 perl_destruct (perl);
354 perl_free (perl); 360 perl_free (perl);
355 perl = 0; 361 perl = 0;
356 } 362 }
357 363 }
358 swap (perl_environ, environ);
359 364
360 rxvt_pop_locale (); 365 rxvt_pop_locale ();
361 } 366 }
362 367
363 if (perl) 368 if (perl)
364 { 369 {
365 // runs outside of perls ENV 370 // runs outside of perls ENV
366 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 371 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
367 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); 372 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
373 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
368 } 374 }
369} 375}
370 376
371static void 377static void
372ungrab (rxvt_term *THIS) 378ungrab (rxvt_term *THIS)
383rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 389rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
384{ 390{
385 if (!perl || !term->perl.self) 391 if (!perl || !term->perl.self)
386 return false; 392 return false;
387 393
394 localise_env set_environ (perl_environ);
395
388 // pre-handling of some events 396 // pre-handling of some events
389 if (htype == HOOK_REFRESH_END) 397 if (htype == HOOK_REFRESH_END)
390 { 398 {
391 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 399 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
392 400
393 for (int i = 0; i <= AvFILL (av); i++) 401 for (int i = 0; i <= AvFILL (av); i++)
394 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 402 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
395 } 403 }
404 else if (htype == HOOK_DESTROY)
405 {
406 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
396 407
397 swap (perl_environ, environ); 408 for (int i = AvFILL (av); i >= 0; i--)
409 {
410 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
411 delete req;
412 }
413 }
398 414
399 bool event_consumed; 415 bool event_consumed;
400 416
401 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 417 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
402 || term->perl.should_invoke [htype]) 418 || term->perl.should_invoke [htype])
403 try
404 { 419 {
405 dSP; 420 dSP;
406 va_list ap; 421 va_list ap;
407 422
408 va_start (ap, htype); 423 va_start (ap, htype);
409 424
410 ENTER; 425 ENTER;
411 SAVETMPS; 426 SAVETMPS;
412 427
413 PUSHMARK (SP); 428 PUSHMARK (SP);
414 429
430 EXTEND (SP, 2);
415 XPUSHs (sv_2mortal (newSVterm (term))); 431 PUSHs (sv_2mortal (newSVterm (term)));
416 XPUSHs (sv_2mortal (newSViv (htype))); 432 PUSHs (sv_2mortal (newSViv (htype)));
417 433
418 for (;;) { 434 for (;;) {
419 data_type dt = (data_type)va_arg (ap, int); 435 data_type dt = (data_type)va_arg (ap, int);
420 436
421 switch (dt) 437 switch (dt)
422 { 438 {
423 case DT_INT: 439 case DT_INT:
424 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); 440 XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
425 break; 441 break;
426 442
427 case DT_LONG: 443 case DT_LONG:
428 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 444 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
429 break; 445 break;
430 446
431 case DT_STR: 447 case DT_STR:
432 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 448 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
433 break; 449 break;
434 450
435 case DT_STR_LEN: 451 case DT_STR_LEN:
436 { 452 {
437 char *str = va_arg (ap, char *); 453 char *str = va_arg (ap, char *);
438 int len = va_arg (ap, int); 454 int len = va_arg (ap, int);
439 455
440 XPUSHs (sv_2mortal (newSVpvn (str, len))); 456 XPUSHs (sv_2mortal (newSVpvn (str, len)));
441 } 457 }
442 break; 458 break;
443 459
444 case DT_WCS_LEN: 460 case DT_WCS_LEN:
445 { 461 {
446 wchar_t *wstr = va_arg (ap, wchar_t *); 462 wchar_t *wstr = va_arg (ap, wchar_t *);
447 int wlen = va_arg (ap, int); 463 int wlen = va_arg (ap, int);
448 464
449 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 465 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
450 } 466 }
451 break; 467 break;
452 468
453 case DT_LCS_LEN: 469 case DT_LCS_LEN:
454 { 470 {
455 long *lstr = va_arg (ap, long *); 471 long *lstr = va_arg (ap, long *);
456 int llen = va_arg (ap, int); 472 int llen = va_arg (ap, int);
457 473
458 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); 474 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
459 } 475 }
460 break; 476 break;
461 477
462 case DT_XEVENT: 478 case DT_XEVENT:
463 { 479 {
464 XEvent *xe = va_arg (ap, XEvent *); 480 XEvent *xe = va_arg (ap, XEvent *);
465 HV *hv = newHV (); 481 HV *hv = newHV ();
466 482
467# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 483# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
468# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 484# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
469# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) 485# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
470# undef set 486# undef set
471 487
472 setiv (type, xe->type); 488 setiv (type, xe->type);
473 setiv (send_event, xe->xany.send_event); 489 setiv (send_event, xe->xany.send_event);
474 setiv (serial, xe->xany.serial); 490 setiv (serial, xe->xany.serial);
475 491
476 switch (xe->type) 492 switch (xe->type)
477 { 493 {
478 case KeyPress: 494 case KeyPress:
479 case KeyRelease: 495 case KeyRelease:
480 case ButtonPress: 496 case ButtonPress:
481 case ButtonRelease: 497 case ButtonRelease:
482 case MotionNotify: 498 case MotionNotify:
483 setuv (window, xe->xmotion.window); 499 setuv (window, xe->xmotion.window);
484 setuv (root, xe->xmotion.root); 500 setuv (root, xe->xmotion.root);
485 setuv (subwindow, xe->xmotion.subwindow); 501 setuv (subwindow, xe->xmotion.subwindow);
486 setuv (time, xe->xmotion.time); 502 setuv (time, xe->xmotion.time);
487 setiv (x, xe->xmotion.x); 503 setiv (x, xe->xmotion.x);
488 setiv (y, xe->xmotion.y); 504 setiv (y, xe->xmotion.y);
489 setiv (row, xe->xmotion.y / term->fheight + term->view_start); 505 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
490 setiv (col, xe->xmotion.x / term->fwidth); 506 setiv (col, xe->xmotion.x / term->fwidth);
491 setiv (x_root, xe->xmotion.x_root); 507 setiv (x_root, xe->xmotion.x_root);
492 setiv (y_root, xe->xmotion.y_root); 508 setiv (y_root, xe->xmotion.y_root);
493 setuv (state, xe->xmotion.state); 509 setuv (state, xe->xmotion.state);
494 510
495 switch (xe->type) 511 switch (xe->type)
496 { 512 {
497 case KeyPress: 513 case KeyPress:
498 case KeyRelease: 514 case KeyRelease:
499 setuv (keycode, xe->xkey.keycode); 515 setuv (keycode, xe->xkey.keycode);
500 break; 516 break;
501 517
502 case ButtonPress: 518 case ButtonPress:
503 case ButtonRelease: 519 case ButtonRelease:
504 setuv (button, xe->xbutton.button); 520 setuv (button, xe->xbutton.button);
505 break; 521 break;
506 522
507 case MotionNotify: 523 case MotionNotify:
508 setiv (is_hint, xe->xmotion.is_hint); 524 setiv (is_hint, xe->xmotion.is_hint);
509 break; 525 break;
510 } 526 }
511 527
512 break; 528 break;
513 529
514 case MapNotify: 530 case MapNotify:
515 case UnmapNotify: 531 case UnmapNotify:
516 case ConfigureNotify: 532 case ConfigureNotify:
517 setuv (event, xe->xconfigure.event); 533 setuv (event, xe->xconfigure.event);
518 setuv (window, xe->xconfigure.window); 534 setuv (window, xe->xconfigure.window);
519 535
520 switch (xe->type) 536 switch (xe->type)
521 { 537 {
522 case ConfigureNotify: 538 case ConfigureNotify:
523 setiv (x, xe->xconfigure.x); 539 setiv (x, xe->xconfigure.x);
524 setiv (y, xe->xconfigure.y); 540 setiv (y, xe->xconfigure.y);
525 setiv (width, xe->xconfigure.width); 541 setiv (width, xe->xconfigure.width);
526 setiv (height, xe->xconfigure.height); 542 setiv (height, xe->xconfigure.height);
527 setuv (above, xe->xconfigure.above); 543 setuv (above, xe->xconfigure.above);
528 break; 544 break;
529 } 545 }
530 546
531 break; 547 break;
532 548
533 case PropertyNotify: 549 case PropertyNotify:
534 setuv (window, xe->xproperty.window); 550 setuv (window, xe->xproperty.window);
535 setuv (atom, xe->xproperty.atom); 551 setuv (atom, xe->xproperty.atom);
536 setuv (time, xe->xproperty.time); 552 setuv (time, xe->xproperty.time);
537 setiv (state, xe->xproperty.state); 553 setiv (state, xe->xproperty.state);
538 break; 554 break;
539 555
540 case ClientMessage: 556 case ClientMessage:
541 setuv (window, xe->xclient.window); 557 setuv (window, xe->xclient.window);
542 setuv (message_type, xe->xclient.message_type); 558 setuv (message_type, xe->xclient.message_type);
543 setuv (format, xe->xclient.format); 559 setuv (format, xe->xclient.format);
544 setuv (l0, xe->xclient.data.l[0]); 560 setuv (l0, xe->xclient.data.l[0]);
545 setuv (l1, xe->xclient.data.l[1]); 561 setuv (l1, xe->xclient.data.l[1]);
546 setuv (l2, xe->xclient.data.l[2]); 562 setuv (l2, xe->xclient.data.l[2]);
547 setuv (l3, xe->xclient.data.l[3]); 563 setuv (l3, xe->xclient.data.l[3]);
548 setuv (l4, xe->xclient.data.l[4]); 564 setuv (l4, xe->xclient.data.l[4]);
549 break; 565 break;
550 } 566 }
551 567
552 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 568 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
553 } 569 }
554 break; 570 break;
555 571
556 case DT_END: 572 case DT_END:
557 goto call; 573 goto call;
558 574
559 default: 575 default:
560 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 576 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
561 } 577 }
578 }
579
580 call:
581 va_end (ap);
582
583 PUTBACK;
584 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
585 SPAGAIN;
586
587 if (count)
588 {
589 SV *status = POPs;
590 count = SvTRUE (status);
562 } 591 }
563 592
564 call:
565 va_end (ap);
566
567 PUTBACK; 593 PUTBACK;
568 int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
569 SPAGAIN;
570
571 if (count)
572 {
573 SV *status = POPs;
574 count = SvTRUE (status);
575 }
576
577 PUTBACK;
578 FREETMPS; 594 FREETMPS;
579 LEAVE; 595 LEAVE;
580 596
581 if (SvTRUE (ERRSV)) 597 if (SvTRUE (ERRSV))
582 { 598 {
583 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 599 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV));
584 ungrab (term); // better lose the grab than the session 600 ungrab (term); // better lose the grab than the session
585 } 601 }
586 602
587 event_consumed = !!count; 603 event_consumed = !!count;
588 } 604 }
589 catch (...)
590 {
591 swap (perl_environ, environ);
592 throw;
593 }
594 else 605 else
595 event_consumed = false; 606 event_consumed = false;
596 607
597 // post-handling of some events 608 // post-handling of some events
598 if (htype == HOOK_REFRESH_BEGIN) 609 if (htype == HOOK_REFRESH_BEGIN)
599 { 610 {
600 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 611 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
601 612
602 for (int i = AvFILL (av); i >= 0; i--) 613 for (int i = AvFILL (av); i >= 0; i--)
603 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 614 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
604 } 615 }
605 else if (htype == HOOK_DESTROY) 616 else if (htype == HOOK_DESTROY)
606 { 617 {
607 clearSVptr ((SV *)term->perl.self); 618 clearSVptr ((SV *)term->perl.self);
608 SvREFCNT_dec ((SV *)term->perl.self); 619 SvREFCNT_dec ((SV *)term->perl.self);
609 620
610 // don't allow further calls 621 // don't allow further calls
611 term->perl.self = 0; 622 term->perl.self = 0;
612 } 623 }
613 624
614 swap (perl_environ, environ);
615
616 return event_consumed; 625 return event_consumed;
626}
627
628void
629rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len)
630{
631 localise_env set_environ (perl_environ);
632
633 ENTER;
634 SAVETMPS;
635
636 dSP;
637 XPUSHs (sv_2mortal (newSVpvn (data, len)));
638 call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL);
639
640 if (SvTRUE (ERRSV))
641 rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV));
642
643 FREETMPS;
644 LEAVE;
617} 645}
618 646
619///////////////////////////////////////////////////////////////////////////// 647/////////////////////////////////////////////////////////////////////////////
620 648
621MODULE = urxvt PACKAGE = urxvt 649MODULE = urxvt PACKAGE = urxvt
633# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 661# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
634# include "hookinc.h" 662# include "hookinc.h"
635# undef def 663# undef def
636 664
637 HV *option = get_hv ("urxvt::OPTION", 1); 665 HV *option = get_hv ("urxvt::OPTION", 1);
638# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); 666# define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
639# define nodef(name) 667# define nodef(name)
640# include "optinc.h" 668# include "optinc.h"
641# undef nodef 669# undef nodef
642# undef def 670# undef def
643 671
645 static const struct { 673 static const struct {
646 const char *name; 674 const char *name;
647 IV iv; 675 IV iv;
648 } *civ, const_iv[] = { 676 } *civ, const_iv[] = {
649# define const_iv(name) { # name, (IV)name } 677# define const_iv(name) { # name, (IV)name }
678 const_iv (NUM_RESOURCES),
650 const_iv (DEFAULT_RSTYLE), 679 const_iv (DEFAULT_RSTYLE),
651 const_iv (OVERLAY_RSTYLE), 680 const_iv (OVERLAY_RSTYLE),
681 const_iv (Color_Bits),
682 const_iv (RS_bgShift), const_iv (RS_bgMask),
683 const_iv (RS_fgShift), const_iv (RS_fgMask),
684 const_iv (RS_Careful),
685 const_iv (RS_fontCount),
686 const_iv (RS_fontShift),
687 const_iv (RS_fontMask),
688 const_iv (RS_baseattrMask),
689 const_iv (RS_attrMask),
690 const_iv (RS_redraw),
691 const_iv (RS_Sel),
652 const_iv (RS_Bold), 692 const_iv (RS_Bold),
653 const_iv (RS_Italic), 693 const_iv (RS_Italic),
654 const_iv (RS_Blink), 694 const_iv (RS_Blink),
655 const_iv (RS_RVid), 695 const_iv (RS_RVid),
656 const_iv (RS_Uline), 696 const_iv (RS_Uline),
760 const_iv (XIMDontChange), 800 const_iv (XIMDontChange),
761# endif 801# endif
762# endif 802# endif
763 }; 803 };
764 804
765 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 805 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
766 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 806 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
767} 807}
768 808
769void 809void
770warn (const char *msg) 810warn (const char *msg)
771 CODE: 811 CODE:
780_exit (int status) 820_exit (int status)
781 821
782NV 822NV
783NOW () 823NOW ()
784 CODE: 824 CODE:
785 RETVAL = NOW; 825 RETVAL = ev::now ();
786 OUTPUT: 826 OUTPUT:
787 RETVAL 827 RETVAL
788 828
789int 829int
790GET_BASEFG (int rend) 830GET_BASEFG (int rend)
843 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 883 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
844 if ((*t)->perl.self) 884 if ((*t)->perl.self)
845 PUSHs (sv_2mortal (newSVterm (*t))); 885 PUSHs (sv_2mortal (newSVterm (*t)));
846} 886}
847 887
888IV
889_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
890 CODE:
891 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
892 req->cb_sv = newSVsv (cb);
893 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
894 av_push (av, newSViv ((IV)req));
895 RETVAL = (IV)req;
896 OUTPUT:
897 RETVAL
898
899void
900_delete_selection_request (IV req_)
901 CODE:
902 rxvt_selection *req = (rxvt_selection *)req_;
903 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
904 int i;
905
906 for (i = AvFILL (av); i >= 0; i--)
907 if (SvIV (*av_fetch (av, i, 1)) == req_)
908 break;
909
910 for (; i < AvFILL (av); i++)
911 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
912
913 av_pop (av);
914
915 delete req;
916
848MODULE = urxvt PACKAGE = urxvt::term 917MODULE = urxvt PACKAGE = urxvt::term
849 918
850SV * 919SV *
851_new (AV *env, AV *arg) 920_new (AV *env, AV *arg)
852 CODE: 921 CODE:
853{ 922{
854 rxvt_term *term = new rxvt_term; 923 rxvt_term *term = new rxvt_term;
855 924
856 stringvec *argv = new stringvec; 925 stringvec *argv = new stringvec;
857 stringvec *envv = new stringvec;
858
859 for (int i = 0; i <= AvFILL (arg); i++) 926 for (int i = 0; i <= AvFILL (arg); i++)
860 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 927 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
861 928
929 stringvec *envv = new stringvec;
862 for (int i = AvFILL (env) + 1; i--; ) 930 for (int i = AvFILL (env) + 1; i--; )
863 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 931 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
864 932
865 envv->push_back (0);
866
867 bool success;
868
869 try 933 try
870 { 934 {
871 success = term->init (argv, envv); 935 term->init (argv, envv);
872 } 936 }
873 catch (const class rxvt_failure_exception &e) 937 catch (const class rxvt_failure_exception &e)
874 {
875 success = false;
876 }
877
878 if (!success)
879 { 938 {
880 term->destroy (); 939 term->destroy ();
881 croak ("error while initializing new terminal instance"); 940 croak ("error while initializing new terminal instance");
882 } 941 }
883 942
917 976
918void 977void
919rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 978rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
920 CODE: 979 CODE:
921 XUngrabKey (THIS->dpy, keycode, modifiers, window); 980 XUngrabKey (THIS->dpy, keycode, modifiers, window);
922
923void
924rxvt_term::XUngrabKeyboard (Time eventtime)
925 CODE:
926 XUngrabKeyboard (THIS->dpy, eventtime);
927 981
928bool 982bool
929rxvt_term::grab (Time eventtime, int sync = 0) 983rxvt_term::grab (Time eventtime, int sync = 0)
930 CODE: 984 CODE:
931{ 985{
1046 free (wstr); 1100 free (wstr);
1047} 1101}
1048 OUTPUT: 1102 OUTPUT:
1049 RETVAL 1103 RETVAL
1050 1104
1051char *
1052rxvt_term::locale ()
1053 CODE:
1054 RETVAL = THIS->locale;
1055 OUTPUT:
1056 RETVAL
1057
1058#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1105#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1059 1106
1060#define TERM_OFFSET_width TERM_OFFSET(width) 1107#define TERM_OFFSET_width TERM_OFFSET(width)
1061#define TERM_OFFSET_height TERM_OFFSET(height) 1108#define TERM_OFFSET_height TERM_OFFSET(height)
1062#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 1109#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
1063#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 1110#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
1064#define TERM_OFFSET_fbase TERM_OFFSET(fbase) 1111#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
1065#define TERM_OFFSET_nrow TERM_OFFSET(nrow) 1112#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
1066#define TERM_OFFSET_ncol TERM_OFFSET(ncol) 1113#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
1067#define TERM_OFFSET_focus TERM_OFFSET(focus) 1114#define TERM_OFFSET_focus TERM_OFFSET(focus)
1068#define TERM_OFFSET_mapped TERM_OFFSET(mapped) 1115#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
1069#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) 1116#define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth)
1070#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) 1117#define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth)
1071#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) 1118#define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace)
1119#define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace)
1072#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1120#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
1073#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1121#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
1074#define TERM_OFFSET_top_row TERM_OFFSET(top_row) 1122#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
1075 1123
1076int 1124int
1077rxvt_term::width () 1125rxvt_term::width ()
1078 ALIAS: 1126 ALIAS:
1079 width = TERM_OFFSET_width 1127 width = TERM_OFFSET_width
1080 height = TERM_OFFSET_height 1128 height = TERM_OFFSET_height
1081 fwidth = TERM_OFFSET_fwidth 1129 fwidth = TERM_OFFSET_fwidth
1082 fheight = TERM_OFFSET_fheight 1130 fheight = TERM_OFFSET_fheight
1083 fbase = TERM_OFFSET_fbase 1131 fbase = TERM_OFFSET_fbase
1084 nrow = TERM_OFFSET_nrow 1132 nrow = TERM_OFFSET_nrow
1085 ncol = TERM_OFFSET_ncol 1133 ncol = TERM_OFFSET_ncol
1086 focus = TERM_OFFSET_focus 1134 focus = TERM_OFFSET_focus
1087 mapped = TERM_OFFSET_mapped 1135 mapped = TERM_OFFSET_mapped
1088 int_bwidth = TERM_OFFSET_int_bwidth 1136 int_bwidth = TERM_OFFSET_int_bwidth
1089 ext_bwidth = TERM_OFFSET_ext_bwidth 1137 ext_bwidth = TERM_OFFSET_ext_bwidth
1090 lineSpace = TERM_OFFSET_lineSpace 1138 lineSpace = TERM_OFFSET_lineSpace
1139 letterSpace = TERM_OFFSET_letterSpace
1091 saveLines = TERM_OFFSET_saveLines 1140 saveLines = TERM_OFFSET_saveLines
1092 total_rows = TERM_OFFSET_total_rows 1141 total_rows = TERM_OFFSET_total_rows
1093 top_row = TERM_OFFSET_top_row 1142 top_row = TERM_OFFSET_top_row
1094 CODE: 1143 CODE:
1095 RETVAL = *(int *)((char *)THIS + ix); 1144 RETVAL = *(int *)((char *)THIS + ix);
1096 OUTPUT: 1145 OUTPUT:
1097 RETVAL 1146 RETVAL
1098 1147
1109 { 1158 {
1110 case 0: RETVAL = THIS->ModLevel3Mask; break; 1159 case 0: RETVAL = THIS->ModLevel3Mask; break;
1111 case 1: RETVAL = THIS->ModMetaMask; break; 1160 case 1: RETVAL = THIS->ModMetaMask; break;
1112 case 2: RETVAL = THIS->ModNumLockMask; break; 1161 case 2: RETVAL = THIS->ModNumLockMask; break;
1113 case 3: RETVAL = THIS->current_screen; break; 1162 case 3: RETVAL = THIS->current_screen; break;
1163#ifdef CURSOR_BLINK
1114 case 4: RETVAL = THIS->hidden_cursor; break; 1164 case 4: RETVAL = THIS->hidden_cursor; break;
1165#endif
1115 } 1166 }
1116 OUTPUT: 1167 OUTPUT:
1117 RETVAL 1168 RETVAL
1118 1169
1119char * 1170char *
1144 if (*i) 1195 if (*i)
1145 PUSHs (sv_2mortal (newSVpv (*i, 0))); 1196 PUSHs (sv_2mortal (newSVpv (*i, 0)));
1146} 1197}
1147 1198
1148int 1199int
1149rxvt_term::pty_ev_events (int events = EVENT_UNDEF) 1200rxvt_term::pty_ev_events (int events = ev::UNDEF)
1150 CODE: 1201 CODE:
1151 RETVAL = THIS->pty_ev.events; 1202 RETVAL = THIS->pty_ev.events;
1152 if (events != EVENT_UNDEF) 1203 if (events != ev::UNDEF)
1153 THIS->pty_ev.set (events); 1204 THIS->pty_ev.set (events);
1154 OUTPUT: 1205 OUTPUT:
1155 RETVAL 1206 RETVAL
1156 1207
1157int 1208int
1162 RETVAL 1213 RETVAL
1163 1214
1164Window 1215Window
1165rxvt_term::parent () 1216rxvt_term::parent ()
1166 CODE: 1217 CODE:
1167 RETVAL = THIS->parent [0]; 1218 RETVAL = THIS->parent;
1168 OUTPUT: 1219 OUTPUT:
1169 RETVAL 1220 RETVAL
1170 1221
1171Window 1222Window
1172rxvt_term::vt () 1223rxvt_term::vt ()
1199 if (newval <= 0) 1250 if (newval <= 0)
1200 THIS->scr_changeview (max (newval, THIS->top_row)); 1251 THIS->scr_changeview (max (newval, THIS->top_row));
1201} 1252}
1202 OUTPUT: 1253 OUTPUT:
1203 RETVAL 1254 RETVAL
1255
1256void
1257rxvt_term::set_urgency (bool enable)
1204 1258
1205void 1259void
1206rxvt_term::focus_in () 1260rxvt_term::focus_in ()
1207 1261
1208void 1262void
1236 1290
1237void 1291void
1238rxvt_term::want_refresh () 1292rxvt_term::want_refresh ()
1239 CODE: 1293 CODE:
1240 THIS->want_refresh = 1; 1294 THIS->want_refresh = 1;
1295 THIS->refresh_check ();
1241 1296
1242void 1297void
1243rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1298rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1244 PPCODE: 1299 PPCODE:
1245{ 1300{
1400SV * 1455SV *
1401rxvt_term::special_decode (SV *text) 1456rxvt_term::special_decode (SV *text)
1402 CODE: 1457 CODE:
1403{ 1458{
1404 wchar_t *wstr = sv2wcs (text); 1459 wchar_t *wstr = sv2wcs (text);
1405 int wlen = wcslen (wstr);
1406 int dlen = 0; 1460 int dlen = 0;
1407 1461
1408 // find length 1462 // find length
1409 for (wchar_t *s = wstr; *s; s++) 1463 for (wchar_t *s = wstr; *s; s++)
1410 if (*s == NOCHAR) 1464 if (*s == NOCHAR)
1441# include "rsinc.h" 1495# include "rsinc.h"
1442# undef def 1496# undef def
1443# undef reserve 1497# undef reserve
1444 }; 1498 };
1445 1499
1446 rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1500 rs = rslist + ecb_array_length (rslist);
1447 1501
1502 if (*name)
1448 do { 1503 {
1504 do {
1449 if (rs-- == rslist) 1505 if (rs-- == rslist)
1450 croak ("no such resource '%s', requested", name); 1506 croak ("no such resource '%s', requested", name);
1451 } while (strcmp (name, rs->name)); 1507 } while (strcmp (name, rs->name));
1452 1508
1453 index += rs->value; 1509 index += rs->value;
1510 }
1511 else
1512 {
1513 --rs;
1514 name = "";
1515 }
1454 1516
1455 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1517 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
1456 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); 1518 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);
1457 1519
1458 if (GIMME_V != G_VOID) 1520 if (GIMME_V != G_VOID)
1473 1535
1474const char * 1536const char *
1475rxvt_term::x_resource (const char *name) 1537rxvt_term::x_resource (const char *name)
1476 1538
1477bool 1539bool
1478rxvt_term::option (U32 optval, int set = -1) 1540rxvt_term::option (U8 optval, int set = -1)
1479 CODE: 1541 CODE:
1480{ 1542{
1481 RETVAL = THIS->options & optval; 1543 RETVAL = THIS->option (optval);
1482 1544
1483 if (set >= 0) 1545 if (set >= 0)
1484 { 1546 {
1485 if (set)
1486 THIS->options |= optval; 1547 THIS->set_option (optval, set);
1487 else
1488 THIS->options &= ~optval;
1489 1548
1490 if (THIS->check_ev.is_active ()) // avoid doing this before START 1549 if (THIS->init_done) // avoid doing this before START
1491 switch (optval) 1550 switch (optval)
1492 { 1551 {
1493 case Opt_skipBuiltinGlyphs: 1552 case Opt_skipBuiltinGlyphs:
1494 THIS->set_fonts (); 1553 THIS->set_fonts ();
1495 THIS->scr_remap_chars (); 1554 THIS->scr_remap_chars ();
1496 THIS->scr_touch (true); 1555 THIS->scr_touch (true);
1497 THIS->want_refresh = 1; 1556 THIS->want_refresh = 1;
1557 THIS->refresh_check ();
1498 break; 1558 break;
1499 1559
1500 case Opt_cursorUnderline: 1560 case Opt_cursorUnderline:
1501 THIS->want_refresh = 1; 1561 THIS->want_refresh = 1;
1562 THIS->refresh_check ();
1502 break; 1563 break;
1503 1564
1504# case Opt_scrollBar_floating: 1565# case Opt_scrollBar_floating:
1505# case Opt_scrollBar_right: 1566# case Opt_scrollBar_right:
1506# THIS->resize_all_windows (THIS->width, THIS->height, 1); 1567# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1516 CODE: 1577 CODE:
1517 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1578 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1518 THIS->keyboard->register_done (); 1579 THIS->keyboard->register_done ();
1519 OUTPUT: 1580 OUTPUT:
1520 RETVAL 1581 RETVAL
1582
1583void
1584rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1585 CODE:
1586 wchar_t *wstr = sv2wcs (str);
1587 THIS->keyboard->register_user_translation (keysym, state, wstr);
1588 free (wstr);
1521 1589
1522void 1590void
1523rxvt_term::screen_cur (...) 1591rxvt_term::screen_cur (...)
1524 PROTOTYPE: $;$$ 1592 PROTOTYPE: $;$$
1525 ALIAS: 1593 ALIAS:
1539 EXTEND (SP, 2); 1607 EXTEND (SP, 2);
1540 PUSHs (sv_2mortal (newSViv (rc.row))); 1608 PUSHs (sv_2mortal (newSViv (rc.row)));
1541 PUSHs (sv_2mortal (newSViv (rc.col))); 1609 PUSHs (sv_2mortal (newSViv (rc.col)));
1542 } 1610 }
1543 1611
1544 if (items == 3) 1612 if (items >= 3)
1545 { 1613 {
1546 rc.row = SvIV (ST (1)); 1614 rc.row = SvIV (ST (1));
1547 rc.col = SvIV (ST (2)); 1615 rc.col = SvIV (ST (2));
1548 1616
1549 if (ix == 2) 1617 if (ix == 2)
1564 1632
1565 clamp_it (rc.col, 0, THIS->ncol); 1633 clamp_it (rc.col, 0, THIS->ncol);
1566 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1634 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1567 1635
1568 if (ix) 1636 if (ix)
1637 {
1638 THIS->selection.screen = THIS->current_screen;
1639
1569 THIS->want_refresh = 1; 1640 THIS->want_refresh = 1;
1641 THIS->refresh_check ();
1570 } 1642 }
1643 }
1571} 1644}
1572 1645
1573char 1646int
1574rxvt_term::cur_charset () 1647rxvt_term::selection_screen (int screen = -1)
1575 CODE: 1648 CODE:
1576 RETVAL = THIS->charsets [THIS->screen.charset]; 1649 RETVAL = THIS->selection.screen;
1577 OUTPUT: 1650 if (screen >= 0)
1651 THIS->selection.screen = screen;
1652 OUTPUT:
1578 RETVAL 1653 RETVAL
1579 1654
1580void 1655void
1581rxvt_term::selection_clear () 1656rxvt_term::selection_clear (bool clipboard = false)
1582 1657
1583void 1658void
1584rxvt_term::selection_make (Time eventtime, bool rect = false) 1659rxvt_term::selection_make (Time eventtime, bool rect = false)
1585 CODE: 1660 CODE:
1586 THIS->selection.op = SELECTION_CONT; 1661 THIS->selection.op = SELECTION_CONT;
1587 THIS->selection.rect = rect; 1662 THIS->selection.rect = rect;
1588 THIS->selection_make (eventtime); 1663 THIS->selection_make (eventtime);
1589 1664
1590int 1665int
1591rxvt_term::selection_grab (Time eventtime) 1666rxvt_term::selection_grab (Time eventtime, bool clipboard = false)
1592 1667
1593void 1668void
1594rxvt_term::selection (SV *newtext = 0) 1669rxvt_term::selection (SV *newtext = 0, bool clipboard = false)
1595 PPCODE: 1670 PPCODE:
1596{ 1671{
1672 wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text;
1673 unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len;
1674
1597 if (GIMME_V != G_VOID) 1675 if (GIMME_V != G_VOID)
1598 XPUSHs (THIS->selection.text 1676 XPUSHs (text
1599 ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) 1677 ? sv_2mortal (wcs2sv (text, len))
1600 : &PL_sv_undef); 1678 : &PL_sv_undef);
1601 1679
1602 if (newtext) 1680 if (newtext)
1603 { 1681 {
1604 free (THIS->selection.text); 1682 free (text);
1605 1683
1606 THIS->selection.text = sv2wcs (newtext); 1684 text = sv2wcs (newtext);
1607 THIS->selection.len = wcslen (THIS->selection.text); 1685 len = wcslen (text);
1608 } 1686 }
1609} 1687}
1688
1689char
1690rxvt_term::cur_charset ()
1691 CODE:
1692 RETVAL = THIS->charsets [THIS->screen.charset];
1693 OUTPUT:
1694 RETVAL
1610 1695
1611void 1696void
1612rxvt_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) 1697rxvt_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)
1613 1698
1614void 1699void
1636 char *str = SvPVbyte (octets, len); 1721 char *str = SvPVbyte (octets, len);
1637 C_ARGS: 1722 C_ARGS:
1638 str, len 1723 str, len
1639 1724
1640void 1725void
1726rxvt_term::tt_paste (SV *octets)
1727 INIT:
1728 STRLEN len;
1729 char *str = SvPVbyte (octets, len);
1730 C_ARGS:
1731 str, len
1732
1733void
1641rxvt_term::cmd_parse (SV *octets) 1734rxvt_term::cmd_parse (SV *octets)
1642 CODE: 1735 CODE:
1643{ 1736{
1644 STRLEN len; 1737 STRLEN len;
1645 char *str = SvPVbyte (octets, len); 1738 char *str = SvPVbyte (octets, len);
1681 Atom *props = XListProperties (THIS->dpy, window, &count); 1774 Atom *props = XListProperties (THIS->dpy, window, &count);
1682 1775
1683 EXTEND (SP, count); 1776 EXTEND (SP, count);
1684 while (count--) 1777 while (count--)
1685 PUSHs (newSVuv ((U32)props [count])); 1778 PUSHs (newSVuv ((U32)props [count]));
1686 1779
1687 XFree (props); 1780 XFree (props);
1688} 1781}
1689 1782
1690void 1783void
1691rxvt_term::XGetWindowProperty (Window window, Atom property) 1784rxvt_term::XGetWindowProperty (Window window, Atom property)
1714 XFree (prop); 1807 XFree (prop);
1715 } 1808 }
1716} 1809}
1717 1810
1718void 1811void
1719rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) 1812rxvt_term::XChangeProperty (Window window, Atom property, Atom type, int format, SV *data)
1720 CODE: 1813 CODE:
1721{ 1814{
1722 STRLEN len; 1815 STRLEN len;
1723 char *data_ = SvPVbyte (data, len); 1816 char *data_ = SvPVbyte (data, len);
1724 1817

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines