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.28 by root, Fri Jan 6 02:58:02 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_USTRING_LEN: 474 case DT_STR_LEN:
475 { 475 {
476 unicode_t *ustr = va_arg (ap, unicode_t *); 476 char *str = va_arg (ap, char *);
477 int ulen = va_arg (ap, int); 477 int len = va_arg (ap, int);
478
479 XPUSHs (sv_2mortal (newSVpvn (str, len)));
480 }
481 break;
482
483 case DT_WCS_LEN:
484 {
478 wchar_t *wstr = new wchar_t [ulen]; 485 wchar_t *wstr = va_arg (ap, wchar_t *);
486 int wlen = va_arg (ap, int);
479 487
480 for (int i = ulen; i--; )
481 wstr [i] = ustr [i];
482
483 XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); 488 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
489 }
490 break;
484 491
485 delete [] wstr; 492 case DT_XEVENT:
486 } 493 {
494 XEvent *xe = va_arg (ap, XEvent *);
495 HV *hv = newHV ();
496
497# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
498# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
499# undef set
500
501 setiv (type, xe->type);
502 setiv (send_event, xe->xany.send_event);
503 setiv (serial, xe->xany.serial);
504
505 switch (xe->type)
506 {
507 case KeyPress:
508 case KeyRelease:
509 case ButtonPress:
510 case ButtonRelease:
511 case MotionNotify:
512 setiv (time, xe->xmotion.time);
513 setiv (x, xe->xmotion.x);
514 setiv (y, xe->xmotion.y);
515 setiv (row, xe->xmotion.y / term->fheight);
516 setiv (col, xe->xmotion.x / term->fwidth);
517 setiv (x_root, xe->xmotion.x_root);
518 setiv (y_root, xe->xmotion.y_root);
519 setiv (state, xe->xmotion.state);
520 break;
521 }
522
523 switch (xe->type)
524 {
525 case KeyPress:
526 case KeyRelease:
527 setiv (keycode, xe->xkey.keycode);
528 break;
529
530 case ButtonPress:
531 case ButtonRelease:
532 setiv (button, xe->xbutton.button);
533 break;
534
535 case MotionNotify:
536 setiv (is_hint, xe->xmotion.is_hint);
537 break;
538 }
539
540 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
541 }
542 break;
487 543
488 case DT_END: 544 case DT_END:
489 { 545 {
490 va_end (ap); 546 va_end (ap);
491 547
736 RETVAL = *(int *)((char *)THIS + ix); 792 RETVAL = *(int *)((char *)THIS + ix);
737 OUTPUT: 793 OUTPUT:
738 RETVAL 794 RETVAL
739 795
740U32 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
741rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) 811rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
742 CODE: 812 CODE:
743{ 813{
744 RETVAL = THIS->rstyle; 814 RETVAL = THIS->rstyle;
745 THIS->rstyle = new_rstyle; 815 THIS->rstyle = new_rstyle;
778 848
779 if (GIMME_V != G_VOID) 849 if (GIMME_V != G_VOID)
780 { 850 {
781 wchar_t *wstr = new wchar_t [THIS->ncol]; 851 wchar_t *wstr = new wchar_t [THIS->ncol];
782 852
783 for (int col = 0; col <THIS->ncol; col++) 853 for (int col = 0; col < THIS->ncol; col++)
784 wstr [col] = l.t [col]; 854 wstr [col] = l.t [col];
785 855
786 XPUSHs (sv_2mortal (wcs2sv (wstr))); 856 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
787 857
788 delete [] wstr; 858 delete [] wstr;
789 } 859 }
790 860
791 if (new_text) 861 if (new_text)
881} 951}
882 OUTPUT: 952 OUTPUT:
883 RETVAL 953 RETVAL
884 954
885SV * 955SV *
886rxvt_term::special_encode (SV *str) 956rxvt_term::special_encode (SV *string)
887 CODE: 957 CODE:
888 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
889 993
890SV * 994SV *
891rxvt_term::special_decode (SV *str) 995rxvt_term::special_decode (SV *text)
892 CODE: 996 CODE:
893 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
894 1029
895void 1030void
896rxvt_term::_resource (char *name, int index, SV *newval = 0) 1031rxvt_term::_resource (char *name, int index, SV *newval = 0)
897 PPCODE: 1032 PPCODE:
898{ 1033{
986void 1121void
987rxvt_term::scr_add_lines (SV *string) 1122rxvt_term::scr_add_lines (SV *string)
988 CODE: 1123 CODE:
989{ 1124{
990 wchar_t *wstr = sv2wcs (string); 1125 wchar_t *wstr = sv2wcs (string);
991 int wlen = wcslen (wstr);
992 unicode_t *ustr = new unicode_t [wlen];
993 int nlines = 0;
994
995 for (int i = wlen; i--; )
996 {
997 ustr [i] = wstr [i];
998 nlines += ustr [i] == '\012';
999 }
1000
1001 THIS->scr_add_lines (ustr, nlines, wlen); 1126 THIS->scr_add_lines (wstr, wcslen (wstr));
1002
1003 free (wstr); 1127 free (wstr);
1004 delete [] ustr;
1005} 1128}
1006 1129
1007void 1130void
1008rxvt_term::tt_write (SV *octets) 1131rxvt_term::tt_write (SV *octets)
1009 INIT: 1132 INIT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines