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.26 by root, Thu Jan 5 21:21:49 2006 UTC vs.
Revision 1.41 by root, Sun Jan 8 03:07:05 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
101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 108 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
102 109
103 return (long)mg->mg_ptr; 110 return (long)mg->mg_ptr;
104} 111}
105 112
106#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 113#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self)
107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 114#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
108 115
109///////////////////////////////////////////////////////////////////////////// 116/////////////////////////////////////////////////////////////////////////////
110 117
111struct perl_watcher 118struct perl_watcher
290void 297void
291overlay::show () 298overlay::show ()
292{ 299{
293 char key[33]; sprintf (key, "%32lx", (long)this); 300 char key[33]; sprintf (key, "%32lx", (long)this);
294 301
295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); 302 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
296 hv_store (hv, key, 32, newSViv ((long)this), 0); 303 hv_store (hv, key, 32, newSViv ((long)this), 0);
297} 304}
298 305
299void 306void
300overlay::hide () 307overlay::hide ()
301{ 308{
302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); 309 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0);
303 310
304 if (ovs) 311 if (ovs)
305 { 312 {
306 char key[33]; sprintf (key, "%32lx", (long)this); 313 char key[33]; sprintf (key, "%32lx", (long)this);
307 314
415 if (!perl) 422 if (!perl)
416 return false; 423 return false;
417 424
418 if (htype == HOOK_INIT) // first hook ever called 425 if (htype == HOOK_INIT) // first hook ever called
419 { 426 {
420 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 427 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
421 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 428 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
422 } 429 }
423 else if (!term->self) 430 else if (!term->perl.self)
424 return false; // perl not initialized for this instance 431 return false; // perl not initialized for this instance
425 else if (htype == HOOK_DESTROY) 432 else if (htype == HOOK_DESTROY)
426 { 433 {
427 // handled later 434 // handled later
428 } 435 }
429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 436 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
430 { 437 {
431 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); 438 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
432 439
433 if (HvKEYS (hv)) 440 if (HvKEYS (hv))
434 { 441 {
435 hv_iterinit (hv); 442 hv_iterinit (hv);
436 443
465 472
466 case DT_LONG: 473 case DT_LONG:
467 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 474 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
468 break; 475 break;
469 476
470 case DT_STRING: 477 case DT_STR:
471 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 478 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
472 break; 479 break;
473 480
474 case DT_USTRING_LEN: 481 case DT_STR_LEN:
475 { 482 {
476 unicode_t *ustr = va_arg (ap, unicode_t *); 483 char *str = va_arg (ap, char *);
477 int ulen = va_arg (ap, int); 484 int len = va_arg (ap, int);
485
486 XPUSHs (sv_2mortal (newSVpvn (str, len)));
487 }
488 break;
489
490 case DT_WCS_LEN:
491 {
478 wchar_t *wstr = new wchar_t [ulen]; 492 wchar_t *wstr = va_arg (ap, wchar_t *);
493 int wlen = va_arg (ap, int);
479 494
480 for (int i = ulen; i--; )
481 wstr [i] = ustr [i];
482
483 XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); 495 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
496 }
497 break;
484 498
485 delete [] wstr; 499 case DT_XEVENT:
486 } 500 {
501 XEvent *xe = va_arg (ap, XEvent *);
502 HV *hv = newHV ();
503
504# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
505# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
506# undef set
507
508 setiv (type, xe->type);
509 setiv (send_event, xe->xany.send_event);
510 setiv (serial, xe->xany.serial);
511
512 switch (xe->type)
513 {
514 case KeyPress:
515 case KeyRelease:
516 case ButtonPress:
517 case ButtonRelease:
518 case MotionNotify:
519 setiv (time, xe->xmotion.time);
520 setiv (x, xe->xmotion.x);
521 setiv (y, xe->xmotion.y);
522 setiv (row, xe->xmotion.y / term->fheight);
523 setiv (col, xe->xmotion.x / term->fwidth);
524 setiv (x_root, xe->xmotion.x_root);
525 setiv (y_root, xe->xmotion.y_root);
526 setiv (state, xe->xmotion.state);
527 break;
528 }
529
530 switch (xe->type)
531 {
532 case KeyPress:
533 case KeyRelease:
534 setiv (keycode, xe->xkey.keycode);
535 break;
536
537 case ButtonPress:
538 case ButtonRelease:
539 setiv (button, xe->xbutton.button);
540 break;
541
542 case MotionNotify:
543 setiv (is_hint, xe->xmotion.is_hint);
544 break;
545 }
546
547 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
548 }
549 break;
487 550
488 case DT_END: 551 case DT_END:
489 { 552 {
490 va_end (ap); 553 va_end (ap);
491 554
506 if (SvTRUE (ERRSV)) 569 if (SvTRUE (ERRSV))
507 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 570 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
508 571
509 if (htype == HOOK_DESTROY) 572 if (htype == HOOK_DESTROY)
510 { 573 {
511 clearSVptr ((SV *)term->self); 574 clearSVptr ((SV *)term->perl.self);
512 SvREFCNT_dec ((SV *)term->self); 575 SvREFCNT_dec ((SV *)term->perl.self);
513 } 576 }
514 577
515 return count; 578 return count;
516 } 579 }
517 580
527 590
528PROTOTYPES: ENABLE 591PROTOTYPES: ENABLE
529 592
530BOOT: 593BOOT:
531{ 594{
532# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); 595 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
596
533 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 597 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
534# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 598# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
535# include "hookinc.h" 599# include "hookinc.h"
536# undef def 600# undef def
537 601
602 HV *option = get_hv ("urxvt::OPTION", 1);
603# define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0);
604# define nodef(name)
605# include "optinc.h"
606# undef nodef
607# undef def
608
609 HV *stash = gv_stashpv ("urxvt", 1);
610# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name));
538 export_const (DEFAULT_RSTYLE); 611 export_const_iv (DEFAULT_RSTYLE);
539 export_const (OVERLAY_RSTYLE); 612 export_const_iv (OVERLAY_RSTYLE);
540 export_const (RS_Bold); 613 export_const_iv (RS_Bold);
541 export_const (RS_Italic); 614 export_const_iv (RS_Italic);
542 export_const (RS_Blink); 615 export_const_iv (RS_Blink);
543 export_const (RS_RVid); 616 export_const_iv (RS_RVid);
544 export_const (RS_Uline); 617 export_const_iv (RS_Uline);
545 618
546 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 619 export_const_iv (CurrentTime);
620 export_const_iv (ShiftMask);
621 export_const_iv (LockMask);
622 export_const_iv (ControlMask);
623 export_const_iv (Mod1Mask);
624 export_const_iv (Mod2Mask);
625 export_const_iv (Mod3Mask);
626 export_const_iv (Mod4Mask);
627 export_const_iv (Mod5Mask);
628 export_const_iv (Button1Mask);
629 export_const_iv (Button2Mask);
630 export_const_iv (Button3Mask);
631 export_const_iv (Button4Mask);
632 export_const_iv (Button5Mask);
633 export_const_iv (AnyModifier);
547} 634}
635
636SV *
637new (...)
638 CODE:
639{
640 stringvec *argv = new stringvec;
641 bool success;
642
643 for (int i = 0; i < items ;i++)
644 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
645
646 rxvt_term *term = new rxvt_term;
647
648 term->argv = argv;
649
650 try
651 {
652 if (!term->init (argv->size (), argv->begin ()))
653 term = 0;
654 }
655 catch (const class rxvt_failure_exception &e)
656 {
657 term->destroy ();
658 croak ("exception caught while initializing new terminal instance");
659 }
660
661 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
662}
663 OUTPUT:
664 RETVAL
548 665
549void 666void
550set_should_invoke (int htype, int value) 667set_should_invoke (int htype, int value)
551 CODE: 668 CODE:
552 rxvt_perl.should_invoke [htype] = value; 669 rxvt_perl.should_invoke [htype] = value;
615} 732}
616 OUTPUT: 733 OUTPUT:
617 RETVAL 734 RETVAL
618 735
619MODULE = urxvt PACKAGE = urxvt::term 736MODULE = urxvt PACKAGE = urxvt::term
737
738void
739rxvt_term::destroy ()
740
741void
742rxvt_term::grab_button (int button, U32 modifiers)
743 CODE:
744 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
745 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
746 GrabModeSync, GrabModeSync, None, GRAB_CURSOR);
747
748bool
749rxvt_term::grab (U32 eventtime, int sync = 0)
750 CODE:
751{
752 int mode = sync ? GrabModeSync : GrabModeAsync;
753
754 THIS->perl.grabtime = 0;
755
756 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
757 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
758 mode, mode, None, GRAB_CURSOR, eventtime))
759 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
760 THIS->perl.grabtime = eventtime;
761 else
762 XUngrabPointer (THIS->display->display, eventtime);
763
764 RETVAL = !!THIS->perl.grabtime;
765}
766 OUTPUT:
767 RETVAL
768
769void
770rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime)
771 CODE:
772 XAllowEvents (THIS->display->display, AsyncBoth, eventtime);
773
774void
775rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime)
776 CODE:
777 XAllowEvents (THIS->display->display, SyncBoth, eventtime);
778
779void
780rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime)
781 CODE:
782 XAllowEvents (THIS->display->display, ReplayPointer, eventtime);
783 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime);
784
785void
786rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime)
787 CODE:
788 THIS->perl.grabtime = 0;
789 XUngrabKeyboard (THIS->display->display, eventtime);
790 XUngrabPointer (THIS->display->display, eventtime);
620 791
621int 792int
622rxvt_term::strwidth (SV *str) 793rxvt_term::strwidth (SV *str)
623 CODE: 794 CODE:
624{ 795{
666 free (wstr); 837 free (wstr);
667} 838}
668 OUTPUT: 839 OUTPUT:
669 RETVAL 840 RETVAL
670 841
671# very portable, especially on objects as opposed to pods 842#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
672#define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0)
673 843
674#define TERM_OFFSET_width TERM_OFFSET(width) 844#define TERM_OFFSET_width TERM_OFFSET(width)
675#define TERM_OFFSET_height TERM_OFFSET(height) 845#define TERM_OFFSET_height TERM_OFFSET(height)
676#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) 846#define TERM_OFFSET_fwidth TERM_OFFSET(fwidth)
677#define TERM_OFFSET_fheight TERM_OFFSET(fheight) 847#define TERM_OFFSET_fheight TERM_OFFSET(fheight)
702 CODE: 872 CODE:
703 RETVAL = *(int *)((char *)THIS + ix); 873 RETVAL = *(int *)((char *)THIS + ix);
704 OUTPUT: 874 OUTPUT:
705 RETVAL 875 RETVAL
706 876
877unsigned int
878rxvt_term::ModLevel3Mask ()
879 ALIAS:
880 ModLevel3Mask = 0
881 ModMetaMask = 1
882 ModNumLockMask = 2
883 CODE:
884 switch (ix)
885 {
886 case 0: RETVAL = THIS->ModLevel3Mask; break;
887 case 1: RETVAL = THIS->ModMetaMask; break;
888 case 2: RETVAL = THIS->ModNumLockMask; break;
889 }
890 OUTPUT:
891 RETVAL
892
893U32
894rxvt_term::parent ()
895 CODE:
896 RETVAL = (U32)THIS->parent [0];
897 OUTPUT:
898 RETVAL
899
900U32
901rxvt_term::vt ()
902 CODE:
903 RETVAL = (U32)THIS->vt;
904 OUTPUT:
905 RETVAL
906
707U32 907U32
708rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 908rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
709 CODE: 909 CODE:
710{ 910{
711 RETVAL = THIS->rstyle; 911 RETVAL = THIS->rstyle;
733rxvt_term::want_refresh () 933rxvt_term::want_refresh ()
734 CODE: 934 CODE:
735 THIS->want_refresh = 1; 935 THIS->want_refresh = 1;
736 936
737void 937void
738rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) 938rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
739 PPCODE: 939 PPCODE:
740{ 940{
741 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 941 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
742 XSRETURN_EMPTY; 942 XSRETURN_EMPTY;
743 943
745 945
746 if (GIMME_V != G_VOID) 946 if (GIMME_V != G_VOID)
747 { 947 {
748 wchar_t *wstr = new wchar_t [THIS->ncol]; 948 wchar_t *wstr = new wchar_t [THIS->ncol];
749 949
750 for (int col = 0; col <THIS->ncol; col++) 950 for (int col = 0; col < THIS->ncol; col++)
751 wstr [col] = l.t [col]; 951 wstr [col] = l.t [col];
752 952
753 XPUSHs (sv_2mortal (wcs2sv (wstr))); 953 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
754 954
755 delete [] wstr; 955 delete [] wstr;
756 } 956 }
757 957
758 if (new_text) 958 if (new_text)
759 { 959 {
760 wchar_t *wstr = sv2wcs (new_text); 960 wchar_t *wstr = sv2wcs (new_text);
761 961
762 int len = wcslen (wstr); 962 int len = min (wcslen (wstr) - start_ofs, max_len);
763 963
764 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 964 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
765 { 965 {
766 free (wstr); 966 free (wstr);
767 croak ("new_text extends beyond horizontal margins"); 967 croak ("new_text extends beyond horizontal margins");
768 } 968 }
769 969
770 for (int col = start_col; col < start_col + len; col++) 970 for (int col = start_col; col < start_col + len; col++)
771 { 971 {
772 l.t [col] = wstr [col - start_col]; 972 l.t [col] = wstr [start_ofs + col - start_col];
773 l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); 973 l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col]));
774 } 974 }
775 975
776 free (wstr); 976 free (wstr);
777 } 977 }
778} 978}
779 979
780void 980void
781rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) 981rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
782 PPCODE: 982 PPCODE:
783{ 983{
784 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) 984 if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
785 XSRETURN_EMPTY; 985 XSRETURN_EMPTY;
786 986
801 { 1001 {
802 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) 1002 if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV)
803 croak ("new_rend must be arrayref"); 1003 croak ("new_rend must be arrayref");
804 1004
805 AV *av = (AV *)SvRV (new_rend); 1005 AV *av = (AV *)SvRV (new_rend);
806 int len = av_len (av) + 1; 1006 int len = min (av_len (av) + 1 - start_ofs, max_len);
807 1007
808 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) 1008 if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len))
809 croak ("new_rend array extends beyond horizontal margins"); 1009 croak ("new_rend array extends beyond horizontal margins");
810 1010
811 for (int col = start_col; col < start_col + len; col++) 1011 for (int col = start_col; col < start_col + len; col++)
812 { 1012 {
813 rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; 1013 rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask;
814 1014
815 l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); 1015 l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col]));
816 } 1016 }
817 } 1017 }
818} 1018}
848} 1048}
849 OUTPUT: 1049 OUTPUT:
850 RETVAL 1050 RETVAL
851 1051
852SV * 1052SV *
853rxvt_term::special_encode (SV *str) 1053rxvt_term::special_encode (SV *string)
854 CODE: 1054 CODE:
855 abort ();//TODO 1055{
1056 wchar_t *wstr = sv2wcs (string);
1057 int wlen = wcslen (wstr);
1058 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer
1059
1060 rxvt_push_locale (THIS->locale);
1061
1062 wchar_t *r = rstr;
1063 for (wchar_t *s = wstr; *s; s++)
1064 if (wcwidth (*s) == 0)
1065 {
1066 if (r == rstr)
1067 croak ("leading combining character unencodable");
1068
1069 unicode_t n = rxvt_compose (r[-1], *s);
1070 if (n == NOCHAR)
1071 n = rxvt_composite.compose (r[-1], *s);
1072
1073 r[-1] = n;
1074 }
1075#if !UNICODE_3
1076 else if (*s >= 0x10000)
1077 *r++ = rxvt_composite.compose (*s);
1078#endif
1079 else
1080 *r++ = *s;
1081
1082 rxvt_pop_locale ();
1083
1084 RETVAL = wcs2sv (rstr, r - rstr);
1085
1086 delete [] rstr;
1087}
1088 OUTPUT:
1089 RETVAL
856 1090
857SV * 1091SV *
858rxvt_term::special_decode (SV *str) 1092rxvt_term::special_decode (SV *text)
859 CODE: 1093 CODE:
860 abort ();//TODO 1094{
1095 wchar_t *wstr = sv2wcs (text);
1096 int wlen = wcslen (wstr);
1097 int dlen = 0;
1098
1099 // find length
1100 for (wchar_t *s = wstr; *s; s++)
1101 if (*s == NOCHAR)
1102 ;
1103 else if (IS_COMPOSE (*s))
1104 dlen += rxvt_composite.expand (*s, 0);
1105 else
1106 dlen++;
1107
1108 wchar_t *rstr = new wchar_t [dlen];
1109
1110 // decode
1111 wchar_t *r = rstr;
1112 for (wchar_t *s = wstr; *s; s++)
1113 if (*s == NOCHAR)
1114 ;
1115 else if (IS_COMPOSE (*s))
1116 r += rxvt_composite.expand (*s, r);
1117 else
1118 *r++ = *s;
1119
1120 RETVAL = wcs2sv (rstr, r - rstr);
1121
1122 delete [] rstr;
1123}
1124 OUTPUT:
1125 RETVAL
861 1126
862void 1127void
863rxvt_term::_resource (char *name, int index, SV *newval = 0) 1128rxvt_term::_resource (char *name, int index, SV *newval = 0)
864 PPCODE: 1129 PPCODE:
865{ 1130{
897 else 1162 else
898 THIS->rs [index] = 0; 1163 THIS->rs [index] = 0;
899 } 1164 }
900} 1165}
901 1166
1167bool
1168rxvt_term::option (U32 optval, int set = -1)
1169 CODE:
1170{
1171 RETVAL = THIS->options & optval;
1172
1173 if (set >= 0)
1174 {
1175 if (set)
1176 THIS->options |= optval;
1177 else
1178 THIS->options &= ~optval;
1179
1180 switch (optval)
1181 {
1182 case Opt_skipBuiltinGlyphs:
1183 THIS->set_fonts ();
1184 THIS->scr_remap_chars ();
1185 THIS->scr_touch (true);
1186 THIS->want_refresh = 1;
1187 break;
1188
1189 case Opt_cursorUnderline:
1190 THIS->want_refresh = 1;
1191 break;
1192
1193# case Opt_scrollBar_floating:
1194# case Opt_scrollBar_right:
1195# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1196# break;
1197 }
1198 }
1199}
1200 OUTPUT:
1201 RETVAL
1202
902void 1203void
903rxvt_term::cur (...) 1204rxvt_term::cur (...)
904 PROTOTYPE: $;$$ 1205 PROTOTYPE: $;$$
905 ALIAS: 1206 ALIAS:
906 screen_cur = 0 1207 screen_cur = 0
930 THIS->want_refresh = 1; 1231 THIS->want_refresh = 1;
931 } 1232 }
932} 1233}
933 1234
934int 1235int
935rxvt_term::selection_grab (int eventtime = CurrentTime) 1236rxvt_term::selection_grab (U32 eventtime)
936 1237
937void 1238void
938rxvt_term::selection (SV *newtext = 0) 1239rxvt_term::selection (SV *newtext = 0)
939 PPCODE: 1240 PPCODE:
940{ 1241{
953void 1254void
954rxvt_term::scr_add_lines (SV *string) 1255rxvt_term::scr_add_lines (SV *string)
955 CODE: 1256 CODE:
956{ 1257{
957 wchar_t *wstr = sv2wcs (string); 1258 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--; )
963 {
964 ustr [i] = wstr [i];
965 nlines += ustr [i] == '\012';
966 }
967
968 THIS->scr_add_lines (ustr, nlines, wlen); 1259 THIS->scr_add_lines (wstr, wcslen (wstr));
969
970 free (wstr); 1260 free (wstr);
971 delete [] ustr;
972} 1261}
973 1262
974void 1263void
975rxvt_term::tt_write (SV *octets) 1264rxvt_term::tt_write (SV *octets)
976 INIT: 1265 INIT:
977 STRLEN len; 1266 STRLEN len;
978 char *str = SvPVbyte (octets, len); 1267 char *str = SvPVbyte (octets, len);
979 C_ARGS: 1268 C_ARGS:
980 str, len 1269 str, len
981 1270
1271void
1272rxvt_term::cmd_parse (SV *octets)
1273 CODE:
1274{
1275 STRLEN len;
1276 char *str = SvPVbyte (octets, len);
1277
1278 char *old_cmdbuf_ptr = THIS->cmdbuf_ptr;
1279 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1280
1281 THIS->cmdbuf_ptr = str;
1282 THIS->cmdbuf_endp = str + len;
1283
1284 rxvt_push_locale (THIS->locale);
1285 THIS->cmd_parse ();
1286 rxvt_pop_locale ();
1287
1288 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1289 THIS->cmdbuf_endp = old_cmdbuf_endp;
1290}
1291
982SV * 1292SV *
983rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) 1293rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2)
984 CODE: 1294 CODE:
985{ 1295{
986 overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); 1296 overlay *o = new overlay (THIS, x, y, w, h, rstyle, border);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines