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.15 by root, Tue Jan 3 16:32:33 2006 UTC vs.
Revision 1.27 by root, Fri Jan 6 01:16:58 2006 UTC

51 char *str = SvPVutf8 (sv, len); 51 char *str = SvPVutf8 (sv, len);
52 return rxvt_utf8towcs (str, len); 52 return rxvt_utf8towcs (str, len);
53} 53}
54 54
55static SV * 55static SV *
56wcs2sv (wchar_t *wstr, int len = -1)
57{
58 char *str = rxvt_wcstoutf8 (wstr, len);
59
60 SV *sv = newSVpv (str, 0);
61 SvUTF8_on (sv);
62 free (str);
63
64 return sv;
65}
66
67static SV *
56new_ref (HV *hv, const char *klass) 68new_ref (HV *hv, const char *klass)
57{ 69{
58 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); 70 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
59} 71}
60 72
61//TODO: use magic 73//TODO: use magic
62static SV * 74static SV *
63newSVptr (void *ptr, const char *klass) 75newSVptr (void *ptr, const char *klass)
64{ 76{
65 HV *hv = newHV (); 77 HV *hv = newHV ();
66 hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); 78 sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0);
67 return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 79 return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
80}
81
82static void
83clearSVptr (SV *sv)
84{
85 if (SvROK (sv))
86 sv = SvRV (sv);
87
88 hv_clear ((HV *)sv);
89 sv_unmagic (sv, PERL_MAGIC_ext);
68} 90}
69 91
70static long 92static long
71SvPTR (SV *sv, const char *klass) 93SvPTR (SV *sv, const char *klass)
72{ 94{
73 if (!sv_derived_from (sv, klass)) 95 if (!sv_derived_from (sv, klass))
74 croak ("object of type %s expected", klass); 96 croak ("object of type %s expected", klass);
75 97
76 IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); 98 MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext);
77 99
78 if (!iv) 100 if (!mg)
79 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
80 102
81 return (long)iv; 103 return (long)mg->mg_ptr;
82} 104}
83 105
84#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 106#define newSVterm(term) SvREFCNT_inc ((SV *)term->self)
85#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
86 108
186 rend_t **rend; 208 rend_t **rend;
187 209
188 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); 210 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
189 ~overlay (); 211 ~overlay ();
190 212
213 void show ();
214 void hide ();
215
191 void swap (); 216 void swap ();
192 217
193 void set (int x, int y, SV *str, SV *rend); 218 void set (int x, int y, SV *str, SV *rend);
194}; 219};
195 220
202 h += 2; 227 h += 2;
203 } 228 }
204 229
205 text = new text_t *[h]; 230 text = new text_t *[h];
206 rend = new rend_t *[h]; 231 rend = new rend_t *[h];
207 232
208 for (int y = 0; y < h; y++) 233 for (int y = 0; y < h; y++)
209 { 234 {
210 text_t *tp = text[y] = new text_t[w]; 235 text_t *tp = text[y] = new text_t[w];
211 rend_t *rp = rend[y] = new rend_t[w]; 236 rend_t *rp = rend[y] = new rend_t[w];
212 237
213 text_t t0, t1, t2; 238 text_t t0, t1, t2;
214 rend_t r = rstyle; 239 rend_t r = rstyle;
215 240
216 if (border == 2) 241 if (border == 2)
217 { 242 {
218 if (y == 0) 243 if (y == 0)
219 t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; 244 t0 = 0x2554, t1 = 0x2550, t2 = 0x2557;
220 else if (y < h - 1) 245 else if (y < h - 1)
221 t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; 246 t0 = 0x2551, t1 = 0x0020, t2 = 0x2551;
222 else 247 else
223 t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; 248 t0 = 0x255a, t1 = 0x2550, t2 = 0x255d;
224 249
225 *tp++ = t0; 250 *tp++ = t0;
226 *rp++ = r; 251 *rp++ = r;
227 252
228 for (int x = w - 2; x-- > 0; ) 253 for (int x = w - 2; x-- > 0; )
229 { 254 {
230 *tp++ = t1; 255 *tp++ = t1;
231 *rp++ = r; 256 *rp++ = r;
232 } 257 }
233 258
234 *tp = t2; 259 *tp = t2;
235 *rp = r; 260 *rp = r;
236 } 261 }
237 else 262 else
238 for (int x = w; x-- > 0; ) 263 for (int x = w; x-- > 0; )
239 { 264 {
240 *tp++ = 0x0020; 265 *tp++ = 0x0020;
241 *rp++ = r; 266 *rp++ = r;
242 } 267 }
243 } 268 }
244 269
270 show ();
245 THIS->want_refresh = 1; 271 THIS->want_refresh = 1;
246} 272}
247 273
248overlay::~overlay () 274overlay::~overlay ()
249{ 275{
276 hide ();
277
250 for (int y = h; y--; ) 278 for (int y = h; y--; )
251 { 279 {
252 delete [] text[y]; 280 delete [] text[y];
253 delete [] rend[y]; 281 delete [] rend[y];
254 } 282 }
257 delete [] rend; 285 delete [] rend;
258 286
259 THIS->want_refresh = 1; 287 THIS->want_refresh = 1;
260} 288}
261 289
290void
291overlay::show ()
292{
293 char key[33]; sprintf (key, "%32lx", (long)this);
294
295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0));
296 hv_store (hv, key, 32, newSViv ((long)this), 0);
297}
298
299void
300overlay::hide ()
301{
302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0);
303
304 if (ovs)
305 {
306 char key[33]; sprintf (key, "%32lx", (long)this);
307
308 HV *hv = (HV *)SvRV (*ovs);
309 hv_delete (hv, key, 32, G_DISCARD);
310 }
311}
312
262void overlay::swap () 313void overlay::swap ()
263{ 314{
264 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 315 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)); 316 int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h));
266 317
269 320
270 for (int y = ov_h; y--; ) 321 for (int y = ov_h; y--; )
271 { 322 {
272 text_t *t1 = text [y]; 323 text_t *t1 = text [y];
273 rend_t *r1 = rend [y]; 324 rend_t *r1 = rend [y];
274 325
275 text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; 326 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; 327 rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x;
277 328
278 for (int x = ov_w; x--; ) 329 for (int x = ov_w; x--; )
279 { 330 {
280 text_t t = *t1; *t1++ = *t2; *t2++ = t; 331 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)); 332 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t));
282 } 333 }
283 } 334 }
284 335
294 345
295 wchar_t *wtext = sv2wcs (text); 346 wchar_t *wtext = sv2wcs (text);
296 347
297 for (int col = min (wcslen (wtext), w - x - border); col--; ) 348 for (int col = min (wcslen (wtext), w - x - border); col--; )
298 this->text [y][x + col] = wtext [col]; 349 this->text [y][x + col] = wtext [col];
299 350
300 free (wtext); 351 free (wtext);
301 352
302 if (rend) 353 if (rend)
303 { 354 {
304 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) 355 if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV)
361bool 412bool
362rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 413rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
363{ 414{
364 if (!perl) 415 if (!perl)
365 return false; 416 return false;
366 417
367 if (htype == HOOK_INIT) // first hook ever called 418 if (htype == HOOK_INIT) // first hook ever called
368 { 419 {
369 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 420 term->self = (void *)newSVptr ((void *)term, "urxvt::term");
370 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 421 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
371 } 422 }
423 else if (!term->self)
424 return false; // perl not initialized for this instance
372 else if (htype == HOOK_DESTROY) 425 else if (htype == HOOK_DESTROY)
373 { 426 {
374 // handled later 427 // handled later
375 } 428 }
376 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
416 469
417 case DT_STRING: 470 case DT_STRING:
418 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 471 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
419 break; 472 break;
420 473
474 case DT_USTRING_LEN:
475 {
476 unicode_t *ustr = va_arg (ap, unicode_t *);
477 int ulen = va_arg (ap, int);
478 wchar_t *wstr = new wchar_t [ulen];
479
480 for (int i = ulen; i--; )
481 wstr [i] = ustr [i];
482
483 XPUSHs (sv_2mortal (wcs2sv (wstr, ulen)));
484
485 delete [] wstr;
486 }
487
421 case DT_END: 488 case DT_END:
422 { 489 {
423 va_end (ap); 490 va_end (ap);
424 491
425 PUTBACK; 492 PUTBACK;
439 if (SvTRUE (ERRSV)) 506 if (SvTRUE (ERRSV))
440 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 507 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
441 508
442 if (htype == HOOK_DESTROY) 509 if (htype == HOOK_DESTROY)
443 { 510 {
444 // TODO: clear magic
445 hv_clear ((HV *)SvRV ((SV *)term->self)); 511 clearSVptr ((SV *)term->self);
446 SvREFCNT_dec ((SV *)term->self); 512 SvREFCNT_dec ((SV *)term->self);
447 } 513 }
448 514
449 return count; 515 return count;
450 } 516 }
461 527
462PROTOTYPES: ENABLE 528PROTOTYPES: ENABLE
463 529
464BOOT: 530BOOT:
465{ 531{
466# define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0))
467# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); 532# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name));
468 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 533 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
469 set_hookname (INIT); 534# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
470 set_hookname (RESET); 535# include "hookinc.h"
471 set_hookname (START); 536# undef def
472 set_hookname (DESTROY);
473 set_hookname (SEL_BEGIN);
474 set_hookname (SEL_EXTEND);
475 set_hookname (SEL_MAKE);
476 set_hookname (SEL_GRAB);
477 set_hookname (FOCUS_IN);
478 set_hookname (FOCUS_OUT);
479 set_hookname (VIEW_CHANGE);
480 set_hookname (SCROLL_BACK);
481 set_hookname (TTY_ACTIVITY);
482 set_hookname (REFRESH_BEGIN);
483 set_hookname (REFRESH_END);
484 set_hookname (KEYBOARD_COMMAND);
485 537
486 export_const (DEFAULT_RSTYLE); 538 export_const (DEFAULT_RSTYLE);
487 export_const (OVERLAY_RSTYLE); 539 export_const (OVERLAY_RSTYLE);
488 export_const (RS_Bold); 540 export_const (RS_Bold);
489 export_const (RS_Italic); 541 export_const (RS_Italic);
608 660
609 rxvt_push_locale (THIS->locale); 661 rxvt_push_locale (THIS->locale);
610 wchar_t *wstr = rxvt_mbstowcs (data, len); 662 wchar_t *wstr = rxvt_mbstowcs (data, len);
611 rxvt_pop_locale (); 663 rxvt_pop_locale ();
612 664
613 char *str = rxvt_wcstoutf8 (wstr); 665 RETVAL = wcs2sv (wstr);
614 free (wstr); 666 free (wstr);
615
616 RETVAL = newSVpv (str, 0);
617 SvUTF8_on (RETVAL);
618 free (str);
619} 667}
620 OUTPUT: 668 OUTPUT:
621 RETVAL 669 RETVAL
622 670
671# very portable, especially on objects as opposed to pods
672#define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0)
673
674#define TERM_OFFSET_width TERM_OFFSET(width)
675#define TERM_OFFSET_height TERM_OFFSET(height)
676#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
677#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
678#define TERM_OFFSET_fbase TERM_OFFSET(fbase)
679#define TERM_OFFSET_nrow TERM_OFFSET(nrow)
680#define TERM_OFFSET_ncol TERM_OFFSET(ncol)
681#define TERM_OFFSET_focus TERM_OFFSET(focus)
682#define TERM_OFFSET_mapped TERM_OFFSET(mapped)
683#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
684#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
685#define TERM_OFFSET_nsaved TERM_OFFSET(nsaved)
686
623int 687int
624rxvt_term::nsaved () 688rxvt_term::width ()
689 ALIAS:
690 width = TERM_OFFSET_width
691 height = TERM_OFFSET_height
692 fwidth = TERM_OFFSET_fwidth
693 fheight = TERM_OFFSET_fheight
694 fbase = TERM_OFFSET_fbase
695 nrow = TERM_OFFSET_nrow
696 ncol = TERM_OFFSET_ncol
697 focus = TERM_OFFSET_focus
698 mapped = TERM_OFFSET_mapped
699 saveLines = TERM_OFFSET_saveLines
700 total_rows = TERM_OFFSET_total_rows
701 nsaved = TERM_OFFSET_nsaved
625 CODE: 702 CODE:
703 RETVAL = *(int *)((char *)THIS + ix);
704 OUTPUT:
705 RETVAL
706
707U32
708rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
709 CODE:
710{
626 RETVAL = THIS->nsaved; 711 RETVAL = THIS->rstyle;
712 THIS->rstyle = new_rstyle;
713}
627 OUTPUT: 714 OUTPUT:
628 RETVAL 715 RETVAL
629 716
630int 717int
631rxvt_term::view_start (int newval = -1) 718rxvt_term::view_start (int newval = -1)
632 CODE: 719 CODE:
633{ 720{
640 } 727 }
641} 728}
642 OUTPUT: 729 OUTPUT:
643 RETVAL 730 RETVAL
644 731
645int
646rxvt_term::nrow ()
647 CODE:
648 RETVAL = THIS->nrow;
649 OUTPUT:
650 RETVAL
651
652int
653rxvt_term::ncol ()
654 CODE:
655 RETVAL = THIS->ncol;
656 OUTPUT:
657 RETVAL
658
659void 732void
660rxvt_term::want_refresh () 733rxvt_term::want_refresh ()
661 CODE: 734 CODE:
662 THIS->want_refresh = 1; 735 THIS->want_refresh = 1;
663 736
664void 737void
665rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) 738rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
666 PPCODE: 739 PPCODE:
667{ 740{
668 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 741 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
669 croak ("row_number number of out range"); 742 XSRETURN_EMPTY;
670 743
671 line_t &l = ROW(row_number); 744 line_t &l = ROW(row_number);
672 745
673 if (GIMME_V != G_VOID) 746 if (GIMME_V != G_VOID)
674 { 747 {
675 wchar_t *wstr = new wchar_t [THIS->ncol]; 748 wchar_t *wstr = new wchar_t [THIS->ncol];
676 749
677 for (int col = 0; col <THIS->ncol; col++) 750 for (int col = 0; col <THIS->ncol; col++)
678 wstr [col] = l.t [col]; 751 wstr [col] = l.t [col];
679 752
680 char *str = rxvt_wcstoutf8 (wstr, THIS->ncol);
681 free (wstr);
682
683 SV *sv = newSVpv (str, 0);
684 SvUTF8_on (sv);
685 XPUSHs (sv_2mortal (sv)); 753 XPUSHs (sv_2mortal (wcs2sv (wstr)));
686 free (str); 754
755 delete [] wstr;
687 } 756 }
688 757
689 if (new_text) 758 if (new_text)
690 { 759 {
691 wchar_t *wstr = sv2wcs (new_text); 760 wchar_t *wstr = sv2wcs (new_text);
692 761
693 int len = wcslen (wstr); 762 int len = min (wcslen (wstr) - start_ofs, max_len);
694 763
695 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 764 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
696 { 765 {
697 free (wstr); 766 free (wstr);
698 croak ("new_text extends beyond horizontal margins"); 767 croak ("new_text extends beyond horizontal margins");
699 } 768 }
700 769
701 for (int col = start_col; col < start_col + len; col++) 770 for (int col = start_col; col < start_col + len; col++)
702 { 771 {
703 l.t [col] = wstr [col - start_col]; 772 l.t [col] = wstr [start_ofs + col - start_col];
704 l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); 773 l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col]));
705 } 774 }
706 775
707 free (wstr); 776 free (wstr);
708 } 777 }
709} 778}
710 779
711void 780void
712rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) 781rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
713 PPCODE: 782 PPCODE:
714{ 783{
715 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 784 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
716 croak ("row_number number of out range"); 785 XSRETURN_EMPTY;
717 786
718 line_t &l = ROW(row_number); 787 line_t &l = ROW(row_number);
719 788
720 if (GIMME_V != G_VOID) 789 if (GIMME_V != G_VOID)
721 { 790 {
732 { 801 {
733 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 802 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
734 croak ("new_rend must be arrayref"); 803 croak ("new_rend must be arrayref");
735 804
736 AV *av = (AV *)SvRV (new_rend); 805 AV *av = (AV *)SvRV (new_rend);
737 int len = av_len (av) + 1; 806 int len = min (av_len (av) + 1 - start_ofs, max_len);
738 807
739 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 808 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
740 croak ("new_rend array extends beyond horizontal margins"); 809 croak ("new_rend array extends beyond horizontal margins");
741 810
742 for (int col = start_col; col < start_col + len; col++) 811 for (int col = start_col; col < start_col + len; col++)
743 { 812 {
744 rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; 813 rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask;
745 814
746 l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); 815 l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col]));
747 } 816 }
748 } 817 }
749} 818}
750 819
751int 820int
752rxvt_term::ROW_l (int row_number, int new_length = -2) 821rxvt_term::ROW_l (int row_number, int new_length = -1)
753 CODE: 822 CODE:
754{ 823{
755 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 824 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
756 croak ("row_number number of out range"); 825 XSRETURN_EMPTY;
757 826
758 line_t &l = ROW(row_number); 827 line_t &l = ROW(row_number);
759 RETVAL = l.l; 828 RETVAL = l.l;
760 829
761 if (new_length >= -1) 830 if (new_length >= 0)
762 l.l = new_length; 831 l.l = new_length;
832}
833 OUTPUT:
834 RETVAL
835
836bool
837rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1)
838 CODE:
839{
840 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
841 XSRETURN_EMPTY;
842
843 line_t &l = ROW(row_number);
844 RETVAL = l.is_longer ();
845
846 if (new_is_longer >= 0)
847 l.is_longer (new_is_longer);
763} 848}
764 OUTPUT: 849 OUTPUT:
765 RETVAL 850 RETVAL
766 851
767SV * 852SV *
777void 862void
778rxvt_term::_resource (char *name, int index, SV *newval = 0) 863rxvt_term::_resource (char *name, int index, SV *newval = 0)
779 PPCODE: 864 PPCODE:
780{ 865{
781 struct resval { const char *name; int value; } rslist [] = { 866 struct resval { const char *name; int value; } rslist [] = {
782# define Rs_def(name) { # name, Rs_ ## name }, 867# define def(name) { # name, Rs_ ## name },
783# define Rs_reserve(name,count) 868# define reserve(name,count)
784# include "rsinc.h" 869# include "rsinc.h"
785# undef Rs_def 870# undef def
786# undef Rs_reserve 871# undef reserve
787 }; 872 };
788 873
789 struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); 874 struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]);
790 875
791 do { 876 do {
813 THIS->rs [index] = 0; 898 THIS->rs [index] = 0;
814 } 899 }
815} 900}
816 901
817void 902void
818rxvt_term::selection_mark (...) 903rxvt_term::cur (...)
819 PROTOTYPE: $;$$ 904 PROTOTYPE: $;$$
820 ALIAS: 905 ALIAS:
906 screen_cur = 0
821 selection_beg = 1 907 selection_beg = 1
822 selection_end = 2 908 selection_end = 2
909 selection_mark = 3
823 PPCODE: 910 PPCODE:
824{ 911{
825 row_col_t &sel = ix == 1 ? THIS->selection.beg 912 row_col_t &rc = ix == 0 ? THIS->screen.cur
913 : ix == 1 ? THIS->selection.beg
826 : ix == 2 ? THIS->selection.end 914 : ix == 2 ? THIS->selection.end
827 : THIS->selection.mark; 915 : THIS->selection.mark;
828 916
829 if (GIMME_V != G_VOID) 917 if (GIMME_V != G_VOID)
830 { 918 {
831 EXTEND (SP, 2); 919 EXTEND (SP, 2);
832 PUSHs (sv_2mortal (newSViv (sel.row))); 920 PUSHs (sv_2mortal (newSViv (rc.row)));
833 PUSHs (sv_2mortal (newSViv (sel.col))); 921 PUSHs (sv_2mortal (newSViv (rc.col)));
834 } 922 }
835 923
836 if (items == 3) 924 if (items == 3)
837 { 925 {
838 sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); 926 rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1);
839 sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); 927 rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1);
840 928
841 if (ix) 929 if (ix)
842 THIS->want_refresh = 1; 930 THIS->want_refresh = 1;
843 } 931 }
844} 932}
849void 937void
850rxvt_term::selection (SV *newtext = 0) 938rxvt_term::selection (SV *newtext = 0)
851 PPCODE: 939 PPCODE:
852{ 940{
853 if (GIMME_V != G_VOID) 941 if (GIMME_V != G_VOID)
854 { 942 XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)));
855 char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len);
856 SV *sv = newSVpv (sel, 0);
857 SvUTF8_on (sv);
858 free (sel);
859 XPUSHs (sv_2mortal (sv));
860 }
861 943
862 if (newtext) 944 if (newtext)
863 { 945 {
864 free (THIS->selection.text); 946 free (THIS->selection.text);
865 947
866 THIS->selection.text = sv2wcs (newtext); 948 THIS->selection.text = sv2wcs (newtext);
867 THIS->selection.len = wcslen (THIS->selection.text); 949 THIS->selection.len = wcslen (THIS->selection.text);
868 } 950 }
869} 951}
952
953void
954rxvt_term::scr_add_lines (SV *string)
955 CODE:
956{
957 wchar_t *wstr = sv2wcs (string);
958 int wlen = wcslen (wstr);
959 unicode_t *ustr = new unicode_t [wlen];
960 int nlines = 0;
961
962 for (int i = wlen; i--; )
870 963 {
964 ustr [i] = wstr [i];
965 nlines += ustr [i] == '\012';
966 }
967
968 THIS->scr_add_lines (ustr, nlines, wlen);
969
970 free (wstr);
971 delete [] ustr;
972}
973
871void 974void
872rxvt_term::tt_write (SV *octets) 975rxvt_term::tt_write (SV *octets)
873 INIT: 976 INIT:
874 STRLEN len; 977 STRLEN len;
875 char *str = SvPVbyte (octets, len); 978 char *str = SvPVbyte (octets, len);
876 C_ARGS: 979 C_ARGS:
877 (unsigned char *)str, len 980 str, len
878 981
879SV * 982SV *
880rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) 983rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2)
881 CODE: 984 CODE:
882{ 985{
883 overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); 986 overlay *o = new overlay (THIS, x, y, w, h, rstyle, border);
884 RETVAL = newSVptr ((void *)o, "urxvt::overlay"); 987 RETVAL = newSVptr ((void *)o, "urxvt::overlay");
885 o->self = (HV *)SvRV (RETVAL); 988 o->self = (HV *)SvRV (RETVAL);
886
887 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0));
888 char key[33]; sprintf (key, "%32lx", (long)o);
889 hv_store (hv, key, 32, newSViv ((long)o), 0);
890} 989}
891 OUTPUT: 990 OUTPUT:
892 RETVAL 991 RETVAL
893 992
894MODULE = urxvt PACKAGE = urxvt::overlay 993MODULE = urxvt PACKAGE = urxvt::overlay
895 994
896void 995void
897overlay::set (int x, int y, SV *text, SV *rend = 0) 996overlay::set (int x, int y, SV *text, SV *rend = 0)
898 997
899void 998void
999overlay::show ()
1000
1001void
1002overlay::hide ()
1003
1004void
900overlay::DESTROY () 1005overlay::DESTROY ()
901 CODE:
902{
903 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->THIS->self), "_overlay", 8, 0);
904 if (ovs)
905 {
906 HV *hv = (HV *)SvRV (*ovs);
907 char key[33]; sprintf (key, "%32lx", (long)THIS);
908 hv_delete (hv, key, 32, G_DISCARD);
909 }
910
911 delete THIS;
912}
913 1006
914MODULE = urxvt PACKAGE = urxvt::timer 1007MODULE = urxvt PACKAGE = urxvt::timer
915 1008
916SV * 1009SV *
917timer::new () 1010timer::new ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines