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.29 by root, Fri Jan 6 03:40:19 2006 UTC vs.
Revision 1.34 by root, Fri Jan 6 21:06:09 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 ();
501 case ButtonRelease: 510 case ButtonRelease:
502 case MotionNotify: 511 case MotionNotify:
503 setiv (time, xe->xmotion.time); 512 setiv (time, xe->xmotion.time);
504 setiv (x, xe->xmotion.x); 513 setiv (x, xe->xmotion.x);
505 setiv (y, xe->xmotion.y); 514 setiv (y, xe->xmotion.y);
515 setiv (row, xe->xmotion.y / term->fheight);
516 setiv (col, xe->xmotion.x / term->fwidth);
506 setiv (x_root, xe->xmotion.x_root); 517 setiv (x_root, xe->xmotion.x_root);
507 setiv (y_root, xe->xmotion.y_root); 518 setiv (y_root, xe->xmotion.y_root);
508 setiv (state, xe->xmotion.state); 519 setiv (state, xe->xmotion.state);
509 break; 520 break;
510 } 521 }
527 } 538 }
528 539
529 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 540 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
530 } 541 }
531 break; 542 break;
532
533 case DT_USTRING_LEN:
534 {
535 unicode_t *ustr = va_arg (ap, unicode_t *);
536 int ulen = va_arg (ap, int);
537 wchar_t *wstr = new wchar_t [ulen];
538
539 for (int i = ulen; i--; )
540 wstr [i] = ustr [i];
541
542 XPUSHs (sv_2mortal (wcs2sv (wstr, ulen)));
543
544 delete [] wstr;
545 }
546 543
547 case DT_END: 544 case DT_END:
548 { 545 {
549 va_end (ap); 546 va_end (ap);
550 547
795 RETVAL = *(int *)((char *)THIS + ix); 792 RETVAL = *(int *)((char *)THIS + ix);
796 OUTPUT: 793 OUTPUT:
797 RETVAL 794 RETVAL
798 795
799U32 796U32
797rxvt_term::parent ()
798 CODE:
799 RETVAL = (U32)THIS->parent [0];
800 OUTPUT:
801 RETVAL
802
803U32
804rxvt_term::vt ()
805 CODE:
806 RETVAL = (U32)THIS->vt;
807 OUTPUT:
808 RETVAL
809
810U32
800rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 811rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
801 CODE: 812 CODE:
802{ 813{
803 RETVAL = THIS->rstyle; 814 RETVAL = THIS->rstyle;
804 THIS->rstyle = new_rstyle; 815 THIS->rstyle = new_rstyle;
837 848
838 if (GIMME_V != G_VOID) 849 if (GIMME_V != G_VOID)
839 { 850 {
840 wchar_t *wstr = new wchar_t [THIS->ncol]; 851 wchar_t *wstr = new wchar_t [THIS->ncol];
841 852
842 for (int col = 0; col <THIS->ncol; col++) 853 for (int col = 0; col < THIS->ncol; col++)
843 wstr [col] = l.t [col]; 854 wstr [col] = l.t [col];
844 855
845 XPUSHs (sv_2mortal (wcs2sv (wstr))); 856 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
846 857
847 delete [] wstr; 858 delete [] wstr;
848 } 859 }
849 860
850 if (new_text) 861 if (new_text)
940} 951}
941 OUTPUT: 952 OUTPUT:
942 RETVAL 953 RETVAL
943 954
944SV * 955SV *
945rxvt_term::special_encode (SV *str) 956rxvt_term::special_encode (SV *string)
946 CODE: 957 CODE:
947 abort ();//TODO 958{
959 wchar_t *wstr = sv2wcs (string);
960 int wlen = wcslen (wstr);
961 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer
962
963 rxvt_push_locale (THIS->locale);
964
965 wchar_t *r = rstr;
966 for (wchar_t *s = wstr; *s; s++)
967 if (wcwidth (*s) == 0)
968 {
969 if (r == rstr)
970 croak ("leading combining character unencodable");
971
972 unicode_t n = rxvt_compose (r[-1], *s);
973 if (n == NOCHAR)
974 n = rxvt_composite.compose (r[-1], *s);
975
976 r[-1] = n;
977 }
978#if !UNICODE_3
979 else if (*s >= 0x10000)
980 *r++ = rxvt_composite.compose (*s);
981#endif
982 else
983 *r++ = *s;
984
985 rxvt_pop_locale ();
986
987 RETVAL = wcs2sv (rstr, r - rstr);
988
989 delete [] rstr;
990}
991 OUTPUT:
992 RETVAL
948 993
949SV * 994SV *
950rxvt_term::special_decode (SV *str) 995rxvt_term::special_decode (SV *text)
951 CODE: 996 CODE:
952 abort ();//TODO 997{
998 wchar_t *wstr = sv2wcs (text);
999 int wlen = wcslen (wstr);
1000 int dlen = 0;
1001
1002 // find length
1003 for (wchar_t *s = wstr; *s; s++)
1004 if (*s == NOCHAR)
1005 ;
1006 else if (IS_COMPOSE (*s))
1007 dlen += rxvt_composite.expand (*s, 0);
1008 else
1009 dlen++;
1010
1011 wchar_t *rstr = new wchar_t [dlen];
1012
1013 // decode
1014 wchar_t *r = rstr;
1015 for (wchar_t *s = wstr; *s; s++)
1016 if (*s == NOCHAR)
1017 ;
1018 else if (IS_COMPOSE (*s))
1019 r += rxvt_composite.expand (*s, r);
1020 else
1021 *r++ = *s;
1022
1023 RETVAL = wcs2sv (rstr, r - rstr);
1024
1025 delete [] rstr;
1026}
1027 OUTPUT:
1028 RETVAL
953 1029
954void 1030void
955rxvt_term::_resource (char *name, int index, SV *newval = 0) 1031rxvt_term::_resource (char *name, int index, SV *newval = 0)
956 PPCODE: 1032 PPCODE:
957{ 1033{
1045void 1121void
1046rxvt_term::scr_add_lines (SV *string) 1122rxvt_term::scr_add_lines (SV *string)
1047 CODE: 1123 CODE:
1048{ 1124{
1049 wchar_t *wstr = sv2wcs (string); 1125 wchar_t *wstr = sv2wcs (string);
1050 int wlen = wcslen (wstr);
1051 unicode_t *ustr = new unicode_t [wlen];
1052 int nlines = 0;
1053
1054 for (int i = wlen; i--; )
1055 {
1056 ustr [i] = wstr [i];
1057 nlines += ustr [i] == '\012';
1058 }
1059
1060 THIS->scr_add_lines (ustr, nlines, wlen); 1126 THIS->scr_add_lines (wstr, wcslen (wstr));
1061
1062 free (wstr); 1127 free (wstr);
1063 delete [] ustr;
1064} 1128}
1065 1129
1066void 1130void
1067rxvt_term::tt_write (SV *octets) 1131rxvt_term::tt_write (SV *octets)
1068 INIT: 1132 INIT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines