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.13 by root, Tue Jan 3 04:18:47 2006 UTC vs.
Revision 1.47 by root, Mon Jan 9 02:06:43 2006 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-2005 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com>
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.
26#include <XSUB.h> 26#include <XSUB.h>
27#undef line_t 27#undef line_t
28 28
29#include "../config.h" 29#include "../config.h"
30 30
31#include <cstddef>
31#include <cstdarg> 32#include <cstdarg>
32 33
33#include "rxvt.h" 34#include "rxvt.h"
34#include "iom.h" 35#include "iom.h"
35#include "rxvtutil.h" 36#include "rxvtutil.h"
36#include "rxvtperl.h" 37#include "rxvtperl.h"
37 38
38#include "perlxsi.c" 39#include "perlxsi.c"
39 40
41#if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
42# define GRAB_CURSOR THIS->leftptr_cursor
43#else
44# define GRAB_CURSOR None
45#endif
46
40#undef LINENO 47#undef LINENO
41#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)
42#undef ROW 49#undef ROW
43#define ROW(n) THIS->row_buf [LINENO (n)] 50#define ROW(n) THIS->row_buf [LINENO (n)]
44 51
45///////////////////////////////////////////////////////////////////////////// 52/////////////////////////////////////////////////////////////////////////////
46 53
54static SV *
55taint (SV *sv)
56{
57 SvTAINT (sv);
58 return sv;
59}
60
61static SV *
62taint_if (SV *sv, SV *src)
63{
64 if (SvTAINTED (src))
65 SvTAINT (sv);
66
67 return sv;
68}
69
47static wchar_t * 70static wchar_t *
48sv2wcs (SV *sv) 71sv2wcs (SV *sv)
49{ 72{
50 STRLEN len; 73 STRLEN len;
51 char *str = SvPVutf8 (sv, len); 74 char *str = SvPVutf8 (sv, len);
52 return rxvt_utf8towcs (str, len); 75 return rxvt_utf8towcs (str, len);
53} 76}
54 77
55static SV * 78static SV *
79wcs2sv (wchar_t *wstr, int len = -1)
80{
81 char *str = rxvt_wcstoutf8 (wstr, len);
82
83 SV *sv = newSVpv (str, 0);
84 SvUTF8_on (sv);
85 free (str);
86
87 return sv;
88}
89
90static SV *
56new_ref (HV *hv, const char *klass) 91new_ref (HV *hv, const char *klass)
57{ 92{
58 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); 93 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
59} 94}
60 95
61//TODO: use magic 96//TODO: use magic
62static SV * 97static SV *
63newSVptr (void *ptr, const char *klass) 98newSVptr (void *ptr, const char *klass)
64{ 99{
65 HV *hv = newHV (); 100 HV *hv = newHV ();
66 hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); 101 sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0);
67 return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 102 return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
103}
104
105static void
106clearSVptr (SV *sv)
107{
108 if (SvROK (sv))
109 sv = SvRV (sv);
110
111 hv_clear ((HV *)sv);
112 sv_unmagic (sv, PERL_MAGIC_ext);
68} 113}
69 114
70static long 115static long
71SvPTR (SV *sv, const char *klass) 116SvPTR (SV *sv, const char *klass)
72{ 117{
73 if (!sv_derived_from (sv, klass)) 118 if (!sv_derived_from (sv, klass))
74 croak ("object of type %s expected", klass); 119 croak ("object of type %s expected", klass);
75 120
76 IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); 121 MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext);
77 122
78 if (!iv) 123 if (!mg)
79 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 124 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
80 125
81 return (long)iv; 126 return (long)mg->mg_ptr;
82} 127}
83 128
84#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 129#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self)
85#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 130#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
86 131
87///////////////////////////////////////////////////////////////////////////// 132/////////////////////////////////////////////////////////////////////////////
88 133
89struct perl_watcher 134struct perl_watcher
186 rend_t **rend; 231 rend_t **rend;
187 232
188 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); 233 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
189 ~overlay (); 234 ~overlay ();
190 235
236 void show ();
237 void hide ();
238
191 void swap (); 239 void swap ();
192 240
193 void set (int x, int y, SV *str, SV *rend); 241 void set (int x, int y, SV *str, SV *rend);
194}; 242};
195 243
202 h += 2; 250 h += 2;
203 } 251 }
204 252
205 text = new text_t *[h]; 253 text = new text_t *[h];
206 rend = new rend_t *[h]; 254 rend = new rend_t *[h];
207 255
208 for (int y = 0; y < h; y++) 256 for (int y = 0; y < h; y++)
209 { 257 {
210 text_t *tp = text[y] = new text_t[w]; 258 text_t *tp = text[y] = new text_t[w];
211 rend_t *rp = rend[y] = new rend_t[w]; 259 rend_t *rp = rend[y] = new rend_t[w];
212 260
213 text_t t0, t1, t2; 261 text_t t0, t1, t2;
214 rend_t r = rstyle; 262 rend_t r = rstyle;
215 263
216 if (border == 2) 264 if (border == 2)
217 { 265 {
218 if (y == 0) 266 if (y == 0)
219 t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; 267 t0 = 0x2554, t1 = 0x2550, t2 = 0x2557;
220 else if (y < h - 1) 268 else if (y < h - 1)
221 t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; 269 t0 = 0x2551, t1 = 0x0020, t2 = 0x2551;
222 else 270 else
223 t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; 271 t0 = 0x255a, t1 = 0x2550, t2 = 0x255d;
224 272
225 *tp++ = t0; 273 *tp++ = t0;
226 *rp++ = r; 274 *rp++ = r;
227 275
228 for (int x = w - 2; x-- > 0; ) 276 for (int x = w - 2; x-- > 0; )
229 { 277 {
230 *tp++ = t1; 278 *tp++ = t1;
231 *rp++ = r; 279 *rp++ = r;
232 } 280 }
233 281
234 *tp = t2; 282 *tp = t2;
235 *rp = r; 283 *rp = r;
236 } 284 }
237 else 285 else
238 for (int x = w; x-- > 0; ) 286 for (int x = w; x-- > 0; )
239 { 287 {
240 *tp++ = 0x0020; 288 *tp++ = 0x0020;
241 *rp++ = r; 289 *rp++ = r;
242 } 290 }
243 } 291 }
244 292
293 show ();
245 THIS->want_refresh = 1; 294 THIS->want_refresh = 1;
246} 295}
247 296
248overlay::~overlay () 297overlay::~overlay ()
249{ 298{
299 hide ();
300
250 for (int y = h; y--; ) 301 for (int y = h; y--; )
251 { 302 {
252 delete [] text[y]; 303 delete [] text[y];
253 delete [] rend[y]; 304 delete [] rend[y];
254 } 305 }
257 delete [] rend; 308 delete [] rend;
258 309
259 THIS->want_refresh = 1; 310 THIS->want_refresh = 1;
260} 311}
261 312
313void
314overlay::show ()
315{
316 char key[33]; sprintf (key, "%32lx", (long)this);
317
318 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
319 hv_store (hv, key, 32, newSViv ((long)this), 0);
320}
321
322void
323overlay::hide ()
324{
325 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0);
326
327 if (ovs)
328 {
329 char key[33]; sprintf (key, "%32lx", (long)this);
330
331 HV *hv = (HV *)SvRV (*ovs);
332 hv_delete (hv, key, 32, G_DISCARD);
333 }
334}
335
262void overlay::swap () 336void overlay::swap ()
263{ 337{
264 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 338 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
265 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); 339 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h));
266 340
269 343
270 for (int y = ov_h; y--; ) 344 for (int y = ov_h; y--; )
271 { 345 {
272 text_t *t1 = text [y]; 346 text_t *t1 = text [y];
273 rend_t *r1 = rend [y]; 347 rend_t *r1 = rend [y];
274 348
275 text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; 349 text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x;
276 rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; 350 rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x;
277 351
278 for (int x = ov_w; x--; ) 352 for (int x = ov_w; x--; )
279 { 353 {
280 text_t t = *t1; *t1++ = *t2; *t2++ = t; 354 text_t t = *t1; *t1++ = *t2; *t2++ = t;
281 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); 355 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t));
282 } 356 }
283 } 357 }
284 358
285} 359}
286 360
287void overlay::set (int x, int y, SV *str, SV *rend) 361void overlay::set (int x, int y, SV *text, SV *rend)
288{ 362{
289 x += border; 363 x += border;
290 y += border; 364 y += border;
291 365
292 if (!IN_RANGE_EXC (y, 0, h - border)) 366 if (!IN_RANGE_EXC (y, 0, h - border))
293 return; 367 return;
294 368
295 wchar_t *wstr = sv2wcs (str); 369 wchar_t *wtext = sv2wcs (text);
296 370
297 for (int col = min (wcslen (wstr), w - x - border); col--; ) 371 for (int col = min (wcslen (wtext), w - x - border); col--; )
298 text [y][x + col] = wstr [col]; 372 this->text [y][x + col] = wtext [col];
299 373
300 free (wstr); 374 free (wtext);
375
376 if (rend)
377 {
378 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
379 croak ("rend must be arrayref");
380
381 AV *av = (AV *)SvRV (rend);
382
383 for (int col = min (av_len (av) + 1, w - x - border); col--; )
384 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
385 }
301 386
302 THIS->want_refresh = 1; 387 THIS->want_refresh = 1;
303} 388}
304 389
305 390
327{ 412{
328 if (!perl) 413 if (!perl)
329 { 414 {
330 char *argv[] = { 415 char *argv[] = {
331 "", 416 "",
417 "-T",
332 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 418 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1",
333 }; 419 };
334 420
335 perl = perl_alloc (); 421 perl = perl_alloc ();
336 perl_construct (perl); 422 perl_construct (perl);
337 423
338 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 424 if (perl_parse (perl, xs_init, 3, argv, (char **)NULL)
339 || perl_run (perl)) 425 || perl_run (perl))
340 { 426 {
341 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 427 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
342 428
343 perl_destruct (perl); 429 perl_destruct (perl);
345 perl = 0; 431 perl = 0;
346 } 432 }
347 } 433 }
348} 434}
349 435
436static void
437ungrab (rxvt_term *THIS)
438{
439 if (THIS->perl.grabtime)
440 {
441 XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime);
442 XUngrabPointer (THIS->display->display, THIS->perl.grabtime);
443 THIS->perl.grabtime = 0;
444 }
445}
446
350bool 447bool
351rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 448rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
352{ 449{
353 if (!perl) 450 if (!perl)
354 return false; 451 return false;
355 452
356 if (htype == HOOK_INIT) // first hook ever called 453 if (htype == HOOK_INIT) // first hook ever called
357 { 454 {
358 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 455 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
359 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 456 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
360 } 457 }
458 else if (!term->perl.self)
459 return false; // perl not initialized for this instance
361 else if (htype == HOOK_DESTROY) 460 else if (htype == HOOK_DESTROY)
362 { 461 {
363 // handled later 462 // handled later
364 } 463 }
365 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 464 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
366 { 465 {
367 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); 466 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
368 467
369 if (HvKEYS (hv)) 468 if (HvKEYS (hv))
370 { 469 {
371 hv_iterinit (hv); 470 hv_iterinit (hv);
372 471
401 500
402 case DT_LONG: 501 case DT_LONG:
403 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 502 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
404 break; 503 break;
405 504
406 case DT_STRING: 505 case DT_STR:
407 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 506 XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
507 break;
508
509 case DT_STR_LEN:
510 {
511 char *str = va_arg (ap, char *);
512 int len = va_arg (ap, int);
513
514 XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
515 }
516 break;
517
518 case DT_WCS_LEN:
519 {
520 wchar_t *wstr = va_arg (ap, wchar_t *);
521 int wlen = va_arg (ap, int);
522
523 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
524 }
525 break;
526
527 case DT_XEVENT:
528 {
529 XEvent *xe = va_arg (ap, XEvent *);
530 HV *hv = newHV ();
531
532# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
533# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
534# undef set
535
536 setiv (type, xe->type);
537 setiv (send_event, xe->xany.send_event);
538 setiv (serial, xe->xany.serial);
539
540 switch (xe->type)
541 {
542 case KeyPress:
543 case KeyRelease:
544 case ButtonPress:
545 case ButtonRelease:
546 case MotionNotify:
547 setiv (time, xe->xmotion.time);
548 setiv (x, xe->xmotion.x);
549 setiv (y, xe->xmotion.y);
550 setiv (row, xe->xmotion.y / term->fheight);
551 setiv (col, xe->xmotion.x / term->fwidth);
552 setiv (x_root, xe->xmotion.x_root);
553 setiv (y_root, xe->xmotion.y_root);
554 setiv (state, xe->xmotion.state);
555 break;
556 }
557
558 switch (xe->type)
559 {
560 case KeyPress:
561 case KeyRelease:
562 setiv (keycode, xe->xkey.keycode);
563 break;
564
565 case ButtonPress:
566 case ButtonRelease:
567 setiv (button, xe->xbutton.button);
568 break;
569
570 case MotionNotify:
571 setiv (is_hint, xe->xmotion.is_hint);
572 break;
573 }
574
575 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
576 }
408 break; 577 break;
409 578
410 case DT_END: 579 case DT_END:
411 { 580 {
412 va_end (ap); 581 va_end (ap);
424 PUTBACK; 593 PUTBACK;
425 FREETMPS; 594 FREETMPS;
426 LEAVE; 595 LEAVE;
427 596
428 if (SvTRUE (ERRSV)) 597 if (SvTRUE (ERRSV))
598 {
429 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 599 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
600 ungrab (term); // better lose the grab than the session
601 }
430 602
431 if (htype == HOOK_DESTROY) 603 if (htype == HOOK_DESTROY)
432 { 604 {
433 // TODO: clear magic
434 hv_clear ((HV *)SvRV ((SV *)term->self)); 605 clearSVptr ((SV *)term->perl.self);
435 SvREFCNT_dec ((SV *)term->self); 606 SvREFCNT_dec ((SV *)term->perl.self);
436 } 607 }
437 608
438 return count; 609 return count;
439 } 610 }
440 611
450 621
451PROTOTYPES: ENABLE 622PROTOTYPES: ENABLE
452 623
453BOOT: 624BOOT:
454{ 625{
455# define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) 626 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
456# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); 627
457 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 628 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
458 set_hookname (INIT); 629# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
459 set_hookname (RESET); 630# include "hookinc.h"
460 set_hookname (START); 631# undef def
461 set_hookname (DESTROY);
462 set_hookname (SEL_BEGIN);
463 set_hookname (SEL_EXTEND);
464 set_hookname (SEL_MAKE);
465 set_hookname (SEL_GRAB);
466 set_hookname (FOCUS_IN);
467 set_hookname (FOCUS_OUT);
468 set_hookname (VIEW_CHANGE);
469 set_hookname (SCROLL_BACK);
470 set_hookname (TTY_ACTIVITY);
471 set_hookname (REFRESH_BEGIN);
472 set_hookname (REFRESH_END);
473 set_hookname (KEYBOARD_COMMAND);
474 632
633 HV *option = get_hv ("urxvt::OPTION", 1);
634# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
635# define nodef(name)
636# include "optinc.h"
637# undef nodef
638# undef def
639
640 HV *stash = gv_stashpv ("urxvt", 1);
641# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name));
475 export_const (DEFAULT_RSTYLE); 642 export_const_iv (DEFAULT_RSTYLE);
476 export_const (OVERLAY_RSTYLE); 643 export_const_iv (OVERLAY_RSTYLE);
477 export_const (RS_Bold); 644 export_const_iv (RS_Bold);
478 export_const (RS_Italic); 645 export_const_iv (RS_Italic);
479 export_const (RS_Blink); 646 export_const_iv (RS_Blink);
480 export_const (RS_RVid); 647 export_const_iv (RS_RVid);
481 export_const (RS_Uline); 648 export_const_iv (RS_Uline);
482 649
483 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 650 export_const_iv (CurrentTime);
651 export_const_iv (ShiftMask);
652 export_const_iv (LockMask);
653 export_const_iv (ControlMask);
654 export_const_iv (Mod1Mask);
655 export_const_iv (Mod2Mask);
656 export_const_iv (Mod3Mask);
657 export_const_iv (Mod4Mask);
658 export_const_iv (Mod5Mask);
659 export_const_iv (Button1Mask);
660 export_const_iv (Button2Mask);
661 export_const_iv (Button3Mask);
662 export_const_iv (Button4Mask);
663 export_const_iv (Button5Mask);
664 export_const_iv (AnyModifier);
484} 665}
666
667SV *
668new (...)
669 CODE:
670{
671 stringvec *argv = new stringvec;
672 bool success;
673
674 for (int i = 0; i < items ;i++)
675 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
676
677 rxvt_term *term = new rxvt_term;
678
679 term->argv = argv;
680
681 try
682 {
683 if (!term->init (argv->size (), argv->begin ()))
684 term = 0;
685 }
686 catch (const class rxvt_failure_exception &e)
687 {
688 term->destroy ();
689 croak ("exception caught while initializing new terminal instance");
690 }
691
692 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
693}
694 OUTPUT:
695 RETVAL
485 696
486void 697void
487set_should_invoke (int htype, int value) 698set_should_invoke (int htype, int value)
488 CODE: 699 CODE:
489 rxvt_perl.should_invoke [htype] = value; 700 rxvt_perl.should_invoke [htype] = value;
495 706
496void 707void
497fatal (const char *msg) 708fatal (const char *msg)
498 CODE: 709 CODE:
499 rxvt_fatal ("%s", msg); 710 rxvt_fatal ("%s", msg);
711
712SV *
713untaint (SV *sv)
714 CODE:
715 RETVAL = newSVsv (sv);
716 SvTAINTED_off (RETVAL);
717 OUTPUT:
718 RETVAL
719
720bool
721safe ()
722 CODE:
723 RETVAL = !rxvt_tainted ();
724 OUTPUT:
725 RETVAL
500 726
501NV 727NV
502NOW () 728NOW ()
503 CODE: 729 CODE:
504 RETVAL = NOW; 730 RETVAL = NOW;
552} 778}
553 OUTPUT: 779 OUTPUT:
554 RETVAL 780 RETVAL
555 781
556MODULE = urxvt PACKAGE = urxvt::term 782MODULE = urxvt PACKAGE = urxvt::term
783
784void
785rxvt_term::destroy ()
786
787void
788rxvt_term::grab_button (int button, U32 modifiers)
789 CODE:
790 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
791 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
792 GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
793
794bool
795rxvt_term::grab (U32 eventtime, int sync = 0)
796 CODE:
797{
798 int mode = sync ? GrabModeSync : GrabModeAsync;
799
800 THIS->perl.grabtime = 0;
801
802 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
803 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
804 mode, mode, None, GRAB_CURSOR, eventtime))
805 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
806 THIS->perl.grabtime = eventtime;
807 else
808 XUngrabPointer (THIS->display->display, eventtime);
809
810 RETVAL = !!THIS->perl.grabtime;
811}
812 OUTPUT:
813 RETVAL
814
815void
816rxvt_term::allow_events_async ()
817 CODE:
818 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime);
819
820void
821rxvt_term::allow_events_sync ()
822 CODE:
823 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime);
824
825void
826rxvt_term::allow_events_replay ()
827 CODE:
828 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime);
829 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime);
830
831void
832rxvt_term::ungrab ()
833 CODE:
834 ungrab (THIS);
557 835
558int 836int
559rxvt_term::strwidth (SV *str) 837rxvt_term::strwidth (SV *str)
560 CODE: 838 CODE:
561{ 839{
580 char *mbstr = rxvt_wcstombs (wstr); 858 char *mbstr = rxvt_wcstombs (wstr);
581 rxvt_pop_locale (); 859 rxvt_pop_locale ();
582 860
583 free (wstr); 861 free (wstr);
584 862
585 RETVAL = newSVpv (mbstr, 0); 863 RETVAL = taint_if (newSVpv (mbstr, 0), str);
586 free (mbstr); 864 free (mbstr);
587} 865}
588 OUTPUT: 866 OUTPUT:
589 RETVAL 867 RETVAL
590 868
597 875
598 rxvt_push_locale (THIS->locale); 876 rxvt_push_locale (THIS->locale);
599 wchar_t *wstr = rxvt_mbstowcs (data, len); 877 wchar_t *wstr = rxvt_mbstowcs (data, len);
600 rxvt_pop_locale (); 878 rxvt_pop_locale ();
601 879
602 char *str = rxvt_wcstoutf8 (wstr); 880 RETVAL = taint_if (wcs2sv (wstr), octets);
603 free (wstr); 881 free (wstr);
604
605 RETVAL = newSVpv (str, 0);
606 SvUTF8_on (RETVAL);
607 free (str);
608} 882}
609 OUTPUT: 883 OUTPUT:
610 RETVAL 884 RETVAL
611 885
886#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
887
888#define TERM_OFFSET_width TERM_OFFSET(width)
889#define TERM_OFFSET_height TERM_OFFSET(height)
890#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
891#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
892#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
893#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
894#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
895#define TERM_OFFSET_focus TERM_OFFSET(focus)
896#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
897#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
898#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
899#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved)
900
612int 901int
902rxvt_term::width ()
903 ALIAS:
904 width = TERM_OFFSET_width
905 height = TERM_OFFSET_height
906 fwidth = TERM_OFFSET_fwidth
907 fheight = TERM_OFFSET_fheight
908 fbase = TERM_OFFSET_fbase
909 nrow = TERM_OFFSET_nrow
910 ncol = TERM_OFFSET_ncol
911 focus = TERM_OFFSET_focus
912 mapped = TERM_OFFSET_mapped
913 saveLines = TERM_OFFSET_saveLines
914 total_rows = TERM_OFFSET_total_rows
915 nsaved = TERM_OFFSET_nsaved
916 CODE:
917 RETVAL = *(int *)((char *)THIS + ix);
918 OUTPUT:
919 RETVAL
920
921unsigned int
922rxvt_term::ModLevel3Mask ()
923 ALIAS:
924 ModLevel3Mask = 0
925 ModMetaMask = 1
926 ModNumLockMask = 2
927 CODE:
928 switch (ix)
929 {
930 case 0: RETVAL = THIS->ModLevel3Mask; break;
931 case 1: RETVAL = THIS->ModMetaMask; break;
932 case 2: RETVAL = THIS->ModNumLockMask; break;
933 }
934 OUTPUT:
935 RETVAL
936
937U32
938rxvt_term::parent ()
939 CODE:
940 RETVAL = (U32)THIS->parent [0];
941 OUTPUT:
942 RETVAL
943
944U32
613rxvt_term::nsaved () 945rxvt_term::vt ()
614 CODE: 946 CODE:
947 RETVAL = (U32)THIS->vt;
948 OUTPUT:
949 RETVAL
950
951U32
952rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
953 CODE:
954{
615 RETVAL = THIS->nsaved; 955 RETVAL = THIS->rstyle;
956 THIS->rstyle = new_rstyle;
957}
616 OUTPUT: 958 OUTPUT:
617 RETVAL 959 RETVAL
618 960
619int 961int
620rxvt_term::view_start (int newval = -1) 962rxvt_term::view_start (int newval = -1)
621 CODE: 963 CODE:
622{ 964{
629 } 971 }
630} 972}
631 OUTPUT: 973 OUTPUT:
632 RETVAL 974 RETVAL
633 975
634int
635rxvt_term::nrow ()
636 CODE:
637 RETVAL = THIS->nrow;
638 OUTPUT:
639 RETVAL
640
641int
642rxvt_term::ncol ()
643 CODE:
644 RETVAL = THIS->ncol;
645 OUTPUT:
646 RETVAL
647
648void 976void
649rxvt_term::want_refresh () 977rxvt_term::want_refresh ()
650 CODE: 978 CODE:
651 THIS->want_refresh = 1; 979 THIS->want_refresh = 1;
652 980
653void 981void
654rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) 982rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
655 PPCODE: 983 PPCODE:
656{ 984{
657 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 985 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
658 croak ("row_number number of out range"); 986 XSRETURN_EMPTY;
659 987
660 line_t &l = ROW(row_number); 988 line_t &l = ROW(row_number);
661 989
662 if (GIMME_V != G_VOID) 990 if (GIMME_V != G_VOID)
663 { 991 {
664 wchar_t *wstr = new wchar_t [THIS->ncol]; 992 wchar_t *wstr = new wchar_t [THIS->ncol];
665 993
666 for (int col = 0; col <THIS->ncol; col++) 994 for (int col = 0; col < THIS->ncol; col++)
667 wstr [col] = l.t [col]; 995 wstr [col] = l.t [col];
668 996
669 char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); 997 XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol))));
670 free (wstr);
671 998
672 SV *sv = newSVpv (str, 0); 999 delete [] wstr;
673 SvUTF8_on (sv);
674 XPUSHs (sv_2mortal (sv));
675 free (str);
676 } 1000 }
677 1001
678 if (new_text) 1002 if (new_text)
679 { 1003 {
680 wchar_t *wstr = sv2wcs (new_text); 1004 wchar_t *wstr = sv2wcs (new_text);
681 1005
682 int len = wcslen (wstr); 1006 int len = min (wcslen (wstr) - start_ofs, max_len);
683 1007
684 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1008 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
685 { 1009 {
686 free (wstr); 1010 free (wstr);
687 croak ("new_text extends beyond horizontal margins"); 1011 croak ("new_text extends beyond horizontal margins");
688 } 1012 }
689 1013
690 for (int col = start_col; col < start_col + len; col++) 1014 for (int col = start_col; col < start_col + len; col++)
691 { 1015 {
692 l.t [col] = wstr [col - start_col]; 1016 l.t [col] = wstr [start_ofs + col - start_col];
693 l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); 1017 l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col]));
694 } 1018 }
695 1019
696 free (wstr); 1020 free (wstr);
697 } 1021 }
698} 1022}
699 1023
700void 1024void
701rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) 1025rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
702 PPCODE: 1026 PPCODE:
703{ 1027{
704 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1028 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
705 croak ("row_number number of out range"); 1029 XSRETURN_EMPTY;
706 1030
707 line_t &l = ROW(row_number); 1031 line_t &l = ROW(row_number);
708 1032
709 if (GIMME_V != G_VOID) 1033 if (GIMME_V != G_VOID)
710 { 1034 {
721 { 1045 {
722 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1046 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
723 croak ("new_rend must be arrayref"); 1047 croak ("new_rend must be arrayref");
724 1048
725 AV *av = (AV *)SvRV (new_rend); 1049 AV *av = (AV *)SvRV (new_rend);
726 int len = av_len (av) + 1; 1050 int len = min (av_len (av) + 1 - start_ofs, max_len);
727 1051
728 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1052 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
729 croak ("new_rend array extends beyond horizontal margins"); 1053 croak ("new_rend array extends beyond horizontal margins");
730 1054
731 for (int col = start_col; col < start_col + len; col++) 1055 for (int col = start_col; col < start_col + len; col++)
732 { 1056 {
733 rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; 1057 rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask;
734 1058
735 l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); 1059 l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col]));
736 } 1060 }
737 } 1061 }
738} 1062}
739 1063
740int 1064int
741rxvt_term::ROW_l (int row_number, int new_length = -2) 1065rxvt_term::ROW_l (int row_number, int new_length = -1)
742 CODE: 1066 CODE:
743{ 1067{
744 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 1068 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
745 croak ("row_number number of out range"); 1069 XSRETURN_EMPTY;
746 1070
747 line_t &l = ROW(row_number); 1071 line_t &l = ROW(row_number);
748 RETVAL = l.l; 1072 RETVAL = l.l;
749 1073
750 if (new_length >= -1) 1074 if (new_length >= 0)
751 l.l = new_length; 1075 l.l = new_length;
752} 1076}
753 OUTPUT: 1077 OUTPUT:
754 RETVAL 1078 RETVAL
755 1079
1080bool
1081rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1)
1082 CODE:
1083{
1084 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
1085 XSRETURN_EMPTY;
1086
1087 line_t &l = ROW(row_number);
1088 RETVAL = l.is_longer ();
1089
1090 if (new_is_longer >= 0)
1091 l.is_longer (new_is_longer);
1092}
1093 OUTPUT:
1094 RETVAL
1095
756SV * 1096SV *
757rxvt_term::special_encode (SV *str) 1097rxvt_term::special_encode (SV *string)
758 CODE: 1098 CODE:
759 abort ();//TODO 1099{
1100 wchar_t *wstr = sv2wcs (string);
1101 int wlen = wcslen (wstr);
1102 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer
1103
1104 rxvt_push_locale (THIS->locale);
1105
1106 wchar_t *r = rstr;
1107 for (wchar_t *s = wstr; *s; s++)
1108 if (wcwidth (*s) == 0)
1109 {
1110 if (r == rstr)
1111 croak ("leading combining character unencodable");
1112
1113 unicode_t n = rxvt_compose (r[-1], *s);
1114 if (n == NOCHAR)
1115 n = rxvt_composite.compose (r[-1], *s);
1116
1117 r[-1] = n;
1118 }
1119#if !UNICODE_3
1120 else if (*s >= 0x10000)
1121 *r++ = rxvt_composite.compose (*s);
1122#endif
1123 else
1124 *r++ = *s;
1125
1126 rxvt_pop_locale ();
1127
1128 RETVAL = taint_if (wcs2sv (rstr, r - rstr), string);
1129
1130 delete [] rstr;
1131}
1132 OUTPUT:
1133 RETVAL
760 1134
761SV * 1135SV *
762rxvt_term::special_decode (SV *str) 1136rxvt_term::special_decode (SV *text)
763 CODE: 1137 CODE:
764 abort ();//TODO 1138{
1139 wchar_t *wstr = sv2wcs (text);
1140 int wlen = wcslen (wstr);
1141 int dlen = 0;
1142
1143 // find length
1144 for (wchar_t *s = wstr; *s; s++)
1145 if (*s == NOCHAR)
1146 ;
1147 else if (IS_COMPOSE (*s))
1148 dlen += rxvt_composite.expand (*s, 0);
1149 else
1150 dlen++;
1151
1152 wchar_t *rstr = new wchar_t [dlen];
1153
1154 // decode
1155 wchar_t *r = rstr;
1156 for (wchar_t *s = wstr; *s; s++)
1157 if (*s == NOCHAR)
1158 ;
1159 else if (IS_COMPOSE (*s))
1160 r += rxvt_composite.expand (*s, r);
1161 else
1162 *r++ = *s;
1163
1164 RETVAL = taint_if (wcs2sv (rstr, r - rstr), text);
1165
1166 delete [] rstr;
1167}
1168 OUTPUT:
1169 RETVAL
765 1170
766void 1171void
767rxvt_term::_resource (char *name, int index, SV *newval = 0) 1172rxvt_term::_resource (char *name, int index, SV *newval = 0)
768 PPCODE: 1173 PPCODE:
769{ 1174{
770 struct resval { const char *name; int value; } rslist [] = { 1175 struct resval { const char *name; int value; } rslist [] = {
771# define Rs_def(name) { # name, Rs_ ## name }, 1176# define def(name) { # name, Rs_ ## name },
772# define Rs_reserve(name,count) 1177# define reserve(name,count)
773# include "rsinc.h" 1178# include "rsinc.h"
774# undef Rs_def 1179# undef def
775# undef Rs_reserve 1180# undef reserve
776 }; 1181 };
777 1182
778 struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 1183 struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]);
779 1184
780 do { 1185 do {
786 1191
787 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) 1192 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
788 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); 1193 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);
789 1194
790 if (GIMME_V != G_VOID) 1195 if (GIMME_V != G_VOID)
791 XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); 1196 XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef);
792 1197
793 if (newval) 1198 if (newval)
794 { 1199 {
795 if (SvOK (newval)) 1200 if (SvOK (newval))
796 { 1201 {
801 else 1206 else
802 THIS->rs [index] = 0; 1207 THIS->rs [index] = 0;
803 } 1208 }
804} 1209}
805 1210
1211bool
1212rxvt_term::option (U32 optval, int set = -1)
1213 CODE:
1214{
1215 RETVAL = THIS->options & optval;
1216
1217 if (set >= 0)
1218 {
1219 if (set)
1220 THIS->options |= optval;
1221 else
1222 THIS->options &= ~optval;
1223
1224 switch (optval)
1225 {
1226 case Opt_skipBuiltinGlyphs:
1227 THIS->set_fonts ();
1228 THIS->scr_remap_chars ();
1229 THIS->scr_touch (true);
1230 THIS->want_refresh = 1;
1231 break;
1232
1233 case Opt_cursorUnderline:
1234 THIS->want_refresh = 1;
1235 break;
1236
1237# case Opt_scrollBar_floating:
1238# case Opt_scrollBar_right:
1239# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1240# break;
1241 }
1242 }
1243}
1244 OUTPUT:
1245 RETVAL
1246
806void 1247void
807rxvt_term::selection_mark (...) 1248rxvt_term::screen_cur (...)
808 PROTOTYPE: $;$$ 1249 PROTOTYPE: $;$$
809 ALIAS: 1250 ALIAS:
1251 screen_cur = 0
810 selection_beg = 1 1252 selection_beg = 1
811 selection_end = 2 1253 selection_end = 2
1254 selection_mark = 3
812 PPCODE: 1255 PPCODE:
813{ 1256{
814 row_col_t &sel = ix == 1 ? THIS->selection.beg 1257 row_col_t &rc = ix == 0 ? THIS->screen.cur
1258 : ix == 1 ? THIS->selection.beg
815 : ix == 2 ? THIS->selection.end 1259 : ix == 2 ? THIS->selection.end
816 : THIS->selection.mark; 1260 : THIS->selection.mark;
817 1261
818 if (GIMME_V != G_VOID) 1262 if (GIMME_V != G_VOID)
819 { 1263 {
820 EXTEND (SP, 2); 1264 EXTEND (SP, 2);
821 PUSHs (sv_2mortal (newSViv (sel.row))); 1265 PUSHs (sv_2mortal (newSViv (rc.row)));
822 PUSHs (sv_2mortal (newSViv (sel.col))); 1266 PUSHs (sv_2mortal (newSViv (rc.col)));
823 } 1267 }
824 1268
825 if (items == 3) 1269 if (items == 3)
826 { 1270 {
827 sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 1271 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1);
828 sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); 1272 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1);
829 1273
830 if (ix) 1274 if (ix)
831 THIS->want_refresh = 1; 1275 THIS->want_refresh = 1;
832 } 1276 }
833} 1277}
834 1278
835int 1279int
836rxvt_term::selection_grab (int eventtime) 1280rxvt_term::selection_grab (U32 eventtime)
837 1281
838void 1282void
839rxvt_term::selection (SV *newtext = 0) 1283rxvt_term::selection (SV *newtext = 0)
840 PPCODE: 1284 PPCODE:
841{ 1285{
842 if (GIMME_V != G_VOID) 1286 if (GIMME_V != G_VOID)
843 { 1287 XPUSHs (THIS->selection.text
844 char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); 1288 ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))
845 SV *sv = newSVpv (sel, 0); 1289 : &PL_sv_undef);
846 SvUTF8_on (sv);
847 free (sel);
848 XPUSHs (sv_2mortal (sv));
849 }
850 1290
851 if (newtext) 1291 if (newtext)
852 { 1292 {
853 free (THIS->selection.text); 1293 free (THIS->selection.text);
854 1294
855 THIS->selection.text = sv2wcs (newtext); 1295 THIS->selection.text = sv2wcs (newtext);
856 THIS->selection.len = wcslen (THIS->selection.text); 1296 THIS->selection.len = wcslen (THIS->selection.text);
857 } 1297 }
858} 1298}
859 1299
1300void
1301rxvt_term::scr_add_lines (SV *string)
1302 CODE:
1303{
1304 wchar_t *wstr = sv2wcs (string);
1305 THIS->scr_add_lines (wstr, wcslen (wstr));
1306 free (wstr);
1307}
1308
860void 1309void
861rxvt_term::tt_write (SV *octets) 1310rxvt_term::tt_write (SV *octets)
862 INIT: 1311 INIT:
863 STRLEN len; 1312 STRLEN len;
864 char *str = SvPVbyte (octets, len); 1313 char *str = SvPVbyte (octets, len);
865 C_ARGS: 1314 C_ARGS:
866 (unsigned char *)str, len 1315 str, len
1316
1317void
1318rxvt_term::cmd_parse (SV *octets)
1319 CODE:
1320{
1321 STRLEN len;
1322 char *str = SvPVbyte (octets, len);
1323
1324 char *old_cmdbuf_ptr = THIS->cmdbuf_ptr;
1325 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1326
1327 THIS->cmdbuf_ptr = str;
1328 THIS->cmdbuf_endp = str + len;
1329
1330 rxvt_push_locale (THIS->locale);
1331 THIS->cmd_parse ();
1332 rxvt_pop_locale ();
1333
1334 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1335 THIS->cmdbuf_endp = old_cmdbuf_endp;
1336}
867 1337
868SV * 1338SV *
869rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) 1339rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2)
870 CODE: 1340 CODE:
871{ 1341{
872 overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); 1342 overlay *o = new overlay (THIS, x, y, w, h, rstyle, border);
873 RETVAL = newSVptr ((void *)o, "urxvt::overlay"); 1343 RETVAL = newSVptr ((void *)o, "urxvt::overlay");
874 o->self = (HV *)SvRV (RETVAL); 1344 o->self = (HV *)SvRV (RETVAL);
875
876 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0));
877 char key[33]; sprintf (key, "%32lx", (long)o);
878 hv_store (hv, key, 32, newSViv ((long)o), 0);
879} 1345}
880 OUTPUT: 1346 OUTPUT:
881 RETVAL 1347 RETVAL
882 1348
883MODULE = urxvt PACKAGE = urxvt::overlay 1349MODULE = urxvt PACKAGE = urxvt::overlay
884 1350
885void 1351void
886overlay::set (int x, int y, SV *text, SV *rend = 0) 1352overlay::set (int x, int y, SV *text, SV *rend = 0)
887 1353
888void 1354void
1355overlay::show ()
1356
1357void
1358overlay::hide ()
1359
1360void
889overlay::DESTROY () 1361overlay::DESTROY ()
890 CODE:
891{
892 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->THIS->self), "_overlay", 8, 0);
893 if (ovs)
894 {
895 HV *hv = (HV *)SvRV (*ovs);
896 char key[33]; sprintf (key, "%32lx", (long)THIS);
897 hv_delete (hv, key, 32, G_DISCARD);
898 }
899
900 delete THIS;
901}
902 1362
903MODULE = urxvt PACKAGE = urxvt::timer 1363MODULE = urxvt PACKAGE = urxvt::timer
904 1364
905SV * 1365SV *
906timer::new () 1366timer::new ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines