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.30 by root, Fri Jan 6 05:28:55 2006 UTC vs.
Revision 1.35 by root, Sat Jan 7 04:19: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.
465 465
466 case DT_LONG: 466 case DT_LONG:
467 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 467 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
468 break; 468 break;
469 469
470 case DT_STRING: 470 case DT_STR:
471 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); 471 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
472 break; 472 break;
473 473
474 case DT_STRING_LEN: 474 case DT_STR_LEN:
475 { 475 {
476 char *str = va_arg (ap, char *); 476 char *str = va_arg (ap, char *);
477 int len = va_arg (ap, int); 477 int len = va_arg (ap, int);
478 478
479 XPUSHs (sv_2mortal (newSVpvn (str, len))); 479 XPUSHs (sv_2mortal (newSVpvn (str, len)));
480 } 480 }
481 break; 481 break;
482
483 case DT_WCS_LEN:
484 {
485 wchar_t *wstr = va_arg (ap, wchar_t *);
486 int wlen = va_arg (ap, int);
487
488 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
489 }
490 break;
482 491
483 case DT_XEVENT: 492 case DT_XEVENT:
484 { 493 {
485 XEvent *xe = va_arg (ap, XEvent *); 494 XEvent *xe = va_arg (ap, XEvent *);
486 HV *hv = newHV (); 495 HV *hv = newHV ();
530 539
531 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 540 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
532 } 541 }
533 break; 542 break;
534 543
535 case DT_USTRING_LEN:
536 {
537 unicode_t *ustr = va_arg (ap, unicode_t *);
538 int ulen = va_arg (ap, int);
539 wchar_t *wstr = new wchar_t [ulen];
540
541 for (int i = ulen; i--; )
542 wstr [i] = ustr [i];
543
544 XPUSHs (sv_2mortal (wcs2sv (wstr, ulen)));
545
546 delete [] wstr;
547 }
548
549 case DT_END: 544 case DT_END:
550 { 545 {
551 va_end (ap); 546 va_end (ap);
552 547
553 PUTBACK; 548 PUTBACK;
709 704
710MODULE = urxvt PACKAGE = urxvt::term 705MODULE = urxvt PACKAGE = urxvt::term
711 706
712void 707void
713rxvt_term::destroy () 708rxvt_term::destroy ()
709
710void
711rxvt_term::grab (int eventtime)
712 CODE:
713{
714return;
715 XGrabPointer (THIS->display->display, THIS->vt, 0,
716 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
717 GrabModeAsync, GrabModeAsync, None, None, eventtime);
718 XGrabKeyboard (THIS->display->display, THIS->vt, 0, GrabModeAsync, GrabModeAsync, eventtime);
719}
714 720
715int 721int
716rxvt_term::strwidth (SV *str) 722rxvt_term::strwidth (SV *str)
717 CODE: 723 CODE:
718{ 724{
797 RETVAL = *(int *)((char *)THIS + ix); 803 RETVAL = *(int *)((char *)THIS + ix);
798 OUTPUT: 804 OUTPUT:
799 RETVAL 805 RETVAL
800 806
801U32 807U32
808rxvt_term::parent ()
809 CODE:
810 RETVAL = (U32)THIS->parent [0];
811 OUTPUT:
812 RETVAL
813
814U32
802rxvt_term::vt () 815rxvt_term::vt ()
803 CODE: 816 CODE:
804 RETVAL = THIS->vt; 817 RETVAL = (U32)THIS->vt;
805 OUTPUT: 818 OUTPUT:
806 RETVAL 819 RETVAL
807 820
808U32 821U32
809rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 822rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
846 859
847 if (GIMME_V != G_VOID) 860 if (GIMME_V != G_VOID)
848 { 861 {
849 wchar_t *wstr = new wchar_t [THIS->ncol]; 862 wchar_t *wstr = new wchar_t [THIS->ncol];
850 863
851 for (int col = 0; col <THIS->ncol; col++) 864 for (int col = 0; col < THIS->ncol; col++)
852 wstr [col] = l.t [col]; 865 wstr [col] = l.t [col];
853 866
854 XPUSHs (sv_2mortal (wcs2sv (wstr))); 867 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
855 868
856 delete [] wstr; 869 delete [] wstr;
857 } 870 }
858 871
859 if (new_text) 872 if (new_text)
949} 962}
950 OUTPUT: 963 OUTPUT:
951 RETVAL 964 RETVAL
952 965
953SV * 966SV *
954rxvt_term::special_encode (SV *str) 967rxvt_term::special_encode (SV *string)
955 CODE: 968 CODE:
956 abort ();//TODO 969{
970 wchar_t *wstr = sv2wcs (string);
971 int wlen = wcslen (wstr);
972 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer
973
974 rxvt_push_locale (THIS->locale);
975
976 wchar_t *r = rstr;
977 for (wchar_t *s = wstr; *s; s++)
978 if (wcwidth (*s) == 0)
979 {
980 if (r == rstr)
981 croak ("leading combining character unencodable");
982
983 unicode_t n = rxvt_compose (r[-1], *s);
984 if (n == NOCHAR)
985 n = rxvt_composite.compose (r[-1], *s);
986
987 r[-1] = n;
988 }
989#if !UNICODE_3
990 else if (*s >= 0x10000)
991 *r++ = rxvt_composite.compose (*s);
992#endif
993 else
994 *r++ = *s;
995
996 rxvt_pop_locale ();
997
998 RETVAL = wcs2sv (rstr, r - rstr);
999
1000 delete [] rstr;
1001}
1002 OUTPUT:
1003 RETVAL
957 1004
958SV * 1005SV *
959rxvt_term::special_decode (SV *str) 1006rxvt_term::special_decode (SV *text)
960 CODE: 1007 CODE:
961 abort ();//TODO 1008{
1009 wchar_t *wstr = sv2wcs (text);
1010 int wlen = wcslen (wstr);
1011 int dlen = 0;
1012
1013 // find length
1014 for (wchar_t *s = wstr; *s; s++)
1015 if (*s == NOCHAR)
1016 ;
1017 else if (IS_COMPOSE (*s))
1018 dlen += rxvt_composite.expand (*s, 0);
1019 else
1020 dlen++;
1021
1022 wchar_t *rstr = new wchar_t [dlen];
1023
1024 // decode
1025 wchar_t *r = rstr;
1026 for (wchar_t *s = wstr; *s; s++)
1027 if (*s == NOCHAR)
1028 ;
1029 else if (IS_COMPOSE (*s))
1030 r += rxvt_composite.expand (*s, r);
1031 else
1032 *r++ = *s;
1033
1034 RETVAL = wcs2sv (rstr, r - rstr);
1035
1036 delete [] rstr;
1037}
1038 OUTPUT:
1039 RETVAL
962 1040
963void 1041void
964rxvt_term::_resource (char *name, int index, SV *newval = 0) 1042rxvt_term::_resource (char *name, int index, SV *newval = 0)
965 PPCODE: 1043 PPCODE:
966{ 1044{
1054void 1132void
1055rxvt_term::scr_add_lines (SV *string) 1133rxvt_term::scr_add_lines (SV *string)
1056 CODE: 1134 CODE:
1057{ 1135{
1058 wchar_t *wstr = sv2wcs (string); 1136 wchar_t *wstr = sv2wcs (string);
1059 int wlen = wcslen (wstr);
1060 unicode_t *ustr = new unicode_t [wlen];
1061 int nlines = 0;
1062
1063 for (int i = wlen; i--; )
1064 {
1065 ustr [i] = wstr [i];
1066 nlines += ustr [i] == '\012';
1067 }
1068
1069 THIS->scr_add_lines (ustr, nlines, wlen); 1137 THIS->scr_add_lines (wstr, wcslen (wstr));
1070
1071 free (wstr); 1138 free (wstr);
1072 delete [] ustr;
1073} 1139}
1074 1140
1075void 1141void
1076rxvt_term::tt_write (SV *octets) 1142rxvt_term::tt_write (SV *octets)
1077 INIT: 1143 INIT:
1091 char *old_cmdbuf_endp = THIS->cmdbuf_endp; 1157 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1092 1158
1093 THIS->cmdbuf_ptr = str; 1159 THIS->cmdbuf_ptr = str;
1094 THIS->cmdbuf_endp = str + len; 1160 THIS->cmdbuf_endp = str + len;
1095 1161
1162 rxvt_push_locale (THIS->locale);
1096 THIS->cmd_parse (); 1163 THIS->cmd_parse ();
1164 rxvt_pop_locale ();
1097 1165
1098 THIS->cmdbuf_ptr = old_cmdbuf_ptr; 1166 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1099 THIS->cmdbuf_endp = old_cmdbuf_endp; 1167 THIS->cmdbuf_endp = old_cmdbuf_endp;
1100} 1168}
1101 1169

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines