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.90 by root, Sun Jan 22 20:39:47 2006 UTC vs.
Revision 1.92 by root, Wed Jan 25 00:57:57 2006 UTC

554 break; 554 break;
555 555
556 case DT_STR_LEN: 556 case DT_STR_LEN:
557 { 557 {
558 char *str = va_arg (ap, char *); 558 char *str = va_arg (ap, char *);
559 int len = va_arg (ap, int); 559 int len = va_arg (ap, int);
560 560
561 printf ("pushing str %p:%d\n", str,len);//D
561 XPUSHs (sv_2mortal (newSVpvn (str, len))); 562 XPUSHs (sv_2mortal (newSVpvn (str, len)));
562 } 563 }
563 break; 564 break;
564 565
565 case DT_WCS_LEN: 566 case DT_WCS_LEN:
566 { 567 {
567 wchar_t *wstr = va_arg (ap, wchar_t *); 568 wchar_t *wstr = va_arg (ap, wchar_t *);
568 int wlen = va_arg (ap, int); 569 int wlen = va_arg (ap, int);
569 570
570 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 571 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
572 }
573 break;
574
575 case DT_LCS_LEN:
576 {
577 long *lstr = va_arg (ap, long *);
578 int llen = va_arg (ap, int);
579
580 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
571 } 581 }
572 break; 582 break;
573 583
574 case DT_XEVENT: 584 case DT_XEVENT:
575 { 585 {
576 XEvent *xe = va_arg (ap, XEvent *); 586 XEvent *xe = va_arg (ap, XEvent *);
577 HV *hv = newHV (); 587 HV *hv = newHV ();
578 588
579# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 589# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0)
580# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) 590# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0)
581# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) 591# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
582# undef set 592# undef set
583 593
584 setiv (type, xe->type); 594 setiv (type, xe->type);
585 setiv (send_event, xe->xany.send_event); 595 setiv (send_event, xe->xany.send_event);
586 setiv (serial, xe->xany.serial); 596 setiv (serial, xe->xany.serial);
587 597
716 } 726 }
717 else if (htype == HOOK_DESTROY) 727 else if (htype == HOOK_DESTROY)
718 { 728 {
719 clearSVptr ((SV *)term->perl.self); 729 clearSVptr ((SV *)term->perl.self);
720 SvREFCNT_dec ((SV *)term->perl.self); 730 SvREFCNT_dec ((SV *)term->perl.self);
731
732 // don't allow further calls
733 term->perl.self = 0;
721 } 734 }
722 735
723 swap (perl_environ, environ); 736 swap (perl_environ, environ);
724 737
725 return event_consumed; 738 return event_consumed;
842 const_iv (SelectionRequest), 855 const_iv (SelectionRequest),
843 const_iv (SelectionNotify), 856 const_iv (SelectionNotify),
844 const_iv (ColormapNotify), 857 const_iv (ColormapNotify),
845 const_iv (ClientMessage), 858 const_iv (ClientMessage),
846 const_iv (MappingNotify), 859 const_iv (MappingNotify),
860# if ENABLE_XIM_ONTHESPOT
861 const_iv (XIMReverse),
862 const_iv (XIMUnderline),
863 const_iv (XIMHighlight),
864 const_iv (XIMPrimary),
865 const_iv (XIMSecondary),
866 const_iv (XIMTertiary),
867 const_iv (XIMVisibleToForward),
868 const_iv (XIMVisibleToBackword),
869 const_iv (XIMVisibleToCenter),
870# if 0
871 const_iv (XIMForwardChar),
872 const_iv (XIMBackwardChar),
873 const_iv (XIMForwardWord),
874 const_iv (XIMBackwardWord),
875 const_iv (XIMCaretUp),
876 const_iv (XIMCaretDown),
877 const_iv (XIMNextLine),
878 const_iv (XIMPreviousLine),
879 const_iv (XIMLineStart),
880 const_iv (XIMLineEnd),
881 const_iv (XIMAbsolutePosition),
882 const_iv (XIMDontChange),
883# endif
884# endif
847 }; 885 };
848 886
849 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); 887 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
850 civ-- > const_iv; ) 888 civ-- > const_iv; )
851 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 889 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1244 1282
1245 line_t &l = ROW(row_number); 1283 line_t &l = ROW(row_number);
1246 1284
1247 if (GIMME_V != G_VOID) 1285 if (GIMME_V != G_VOID)
1248 { 1286 {
1249 wchar_t *wstr = new wchar_t [THIS->ncol]; 1287 wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol);
1250 1288
1251 for (int col = 0; col < THIS->ncol; col++) 1289 for (int col = 0; col < THIS->ncol; col++)
1252 wstr [col] = l.t [col]; 1290 wstr [col] = l.t [col];
1253 1291
1254 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); 1292 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1255
1256 delete [] wstr;
1257 } 1293 }
1258 1294
1259 if (new_text) 1295 if (new_text)
1260 { 1296 {
1261 wchar_t *wstr = sv2wcs (new_text); 1297 wchar_t *wstr = sv2wcs (new_text);
1354rxvt_term::special_encode (SV *string) 1390rxvt_term::special_encode (SV *string)
1355 CODE: 1391 CODE:
1356{ 1392{
1357 wchar_t *wstr = sv2wcs (string); 1393 wchar_t *wstr = sv2wcs (string);
1358 int wlen = wcslen (wstr); 1394 int wlen = wcslen (wstr);
1359 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer 1395 wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer
1360 1396
1361 rxvt_push_locale (THIS->locale); 1397 rxvt_push_locale (THIS->locale);
1362 1398
1363 wchar_t *r = rstr; 1399 wchar_t *r = rstr;
1364 for (wchar_t *s = wstr; *s; s++) 1400 for (wchar_t *s = wstr; *s; s++)
1401 {
1402 int w = WCWIDTH (*s);
1403
1365 if (wcwidth (*s) == 0) 1404 if (w == 0)
1366 { 1405 {
1367 if (r == rstr) 1406 if (r == rstr)
1368 croak ("leading combining character unencodable"); 1407 croak ("leading combining character unencodable");
1369 1408
1370 unicode_t n = rxvt_compose (r[-1], *s); 1409 unicode_t n = rxvt_compose (r[-1], *s);
1371 if (n == NOCHAR) 1410 if (n == NOCHAR)
1372 n = rxvt_composite.compose (r[-1], *s); 1411 n = rxvt_composite.compose (r[-1], *s);
1373 1412
1374 r[-1] = n; 1413 r[-1] = n;
1375 } 1414 }
1376#if !UNICODE_3 1415#if !UNICODE_3
1377 else if (*s >= 0x10000) 1416 else if (*s >= 0x10000)
1378 *r++ = rxvt_composite.compose (*s); 1417 *r++ = rxvt_composite.compose (*s);
1379#endif 1418#endif
1380 else 1419 else
1381 *r++ = *s; 1420 *r++ = *s;
1421
1422 // the *2 above only allows wcwidth <= 2
1423 if (w > 1)
1424 *r++ = NOCHAR;
1425 }
1382 1426
1383 rxvt_pop_locale (); 1427 rxvt_pop_locale ();
1384 1428
1385 RETVAL = wcs2sv (rstr, r - rstr); 1429 RETVAL = wcs2sv (rstr, r - rstr);
1386
1387 delete [] rstr;
1388} 1430}
1389 OUTPUT: 1431 OUTPUT:
1390 RETVAL 1432 RETVAL
1391 1433
1392SV * 1434SV *
1404 else if (IS_COMPOSE (*s)) 1446 else if (IS_COMPOSE (*s))
1405 dlen += rxvt_composite.expand (*s, 0); 1447 dlen += rxvt_composite.expand (*s, 0);
1406 else 1448 else
1407 dlen++; 1449 dlen++;
1408 1450
1409 wchar_t *rstr = new wchar_t [dlen]; 1451 wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen);
1410 1452
1411 // decode 1453 // decode
1412 wchar_t *r = rstr; 1454 wchar_t *r = rstr;
1413 for (wchar_t *s = wstr; *s; s++) 1455 for (wchar_t *s = wstr; *s; s++)
1414 if (*s == NOCHAR) 1456 if (*s == NOCHAR)
1417 r += rxvt_composite.expand (*s, r); 1459 r += rxvt_composite.expand (*s, r);
1418 else 1460 else
1419 *r++ = *s; 1461 *r++ = *s;
1420 1462
1421 RETVAL = wcs2sv (rstr, r - rstr); 1463 RETVAL = wcs2sv (rstr, r - rstr);
1422
1423 delete [] rstr;
1424} 1464}
1425 OUTPUT: 1465 OUTPUT:
1426 RETVAL 1466 RETVAL
1427 1467
1428void 1468void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines