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.87 by root, Sat Jan 21 08:07:38 2006 UTC vs.
Revision 1.91 by root, Wed Jan 25 00:42:21 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
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
847 }; 884 };
848 885
849 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); 886 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
850 civ-- > const_iv; ) 887 civ-- > const_iv; )
851 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 888 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
928 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) 965 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
929 croak ("first argument to urxvt::term->_new must be arrayref"); 966 croak ("first argument to urxvt::term->_new must be arrayref");
930 967
931 rxvt_term *term = new rxvt_term; 968 rxvt_term *term = new rxvt_term;
932 969
933 term->argv = new stringvec; 970 stringvec *argv = new stringvec;
934 term->envv = new stringvec; 971 stringvec *envv = new stringvec;
935 972
936 for (int i = 1; i < items; i++) 973 for (int i = 1; i < items; i++)
937 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); 974 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
938 975
939 AV *envv = (AV *)SvRV (ST (0)); 976 AV *env = (AV *)SvRV (ST (0));
940 for (int i = AvFILL (envv) + 1; i--; ) 977 for (int i = AvFILL (env) + 1; i--; )
941 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); 978 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
942 979
943 term->envv->push_back (0); 980 envv->push_back (0);
944 981
945 bool success; 982 bool success;
946 983
947 try 984 try
948 { 985 {
949 success = term->init (term->argv->size (), term->argv->begin ()); 986 success = term->init (argv, envv);
950 } 987 }
951 catch (const class rxvt_failure_exception &e) 988 catch (const class rxvt_failure_exception &e)
952 { 989 {
953 success = false; 990 success = false;
954 } 991 }
1174 if (events != EVENT_UNDEF) 1211 if (events != EVENT_UNDEF)
1175 THIS->pty_ev.set (events); 1212 THIS->pty_ev.set (events);
1176 OUTPUT: 1213 OUTPUT:
1177 RETVAL 1214 RETVAL
1178 1215
1216int
1217rxvt_term::pty_fd ()
1218 CODE:
1219 RETVAL = THIS->pty->pty;
1220 OUTPUT:
1221 RETVAL
1222
1179Window 1223Window
1180rxvt_term::parent () 1224rxvt_term::parent ()
1181 CODE: 1225 CODE:
1182 RETVAL = THIS->parent [0]; 1226 RETVAL = THIS->parent [0];
1183 OUTPUT: 1227 OUTPUT:
1237 1281
1238 line_t &l = ROW(row_number); 1282 line_t &l = ROW(row_number);
1239 1283
1240 if (GIMME_V != G_VOID) 1284 if (GIMME_V != G_VOID)
1241 { 1285 {
1242 wchar_t *wstr = new wchar_t [THIS->ncol]; 1286 wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol);
1243 1287
1244 for (int col = 0; col < THIS->ncol; col++) 1288 for (int col = 0; col < THIS->ncol; col++)
1245 wstr [col] = l.t [col]; 1289 wstr [col] = l.t [col];
1246 1290
1247 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); 1291 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1248
1249 delete [] wstr;
1250 } 1292 }
1251 1293
1252 if (new_text) 1294 if (new_text)
1253 { 1295 {
1254 wchar_t *wstr = sv2wcs (new_text); 1296 wchar_t *wstr = sv2wcs (new_text);
1347rxvt_term::special_encode (SV *string) 1389rxvt_term::special_encode (SV *string)
1348 CODE: 1390 CODE:
1349{ 1391{
1350 wchar_t *wstr = sv2wcs (string); 1392 wchar_t *wstr = sv2wcs (string);
1351 int wlen = wcslen (wstr); 1393 int wlen = wcslen (wstr);
1352 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer 1394 wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer
1353 1395
1354 rxvt_push_locale (THIS->locale); 1396 rxvt_push_locale (THIS->locale);
1355 1397
1356 wchar_t *r = rstr; 1398 wchar_t *r = rstr;
1357 for (wchar_t *s = wstr; *s; s++) 1399 for (wchar_t *s = wstr; *s; s++)
1400 {
1401 int w = WCWIDTH (*s);
1402
1358 if (wcwidth (*s) == 0) 1403 if (w == 0)
1359 { 1404 {
1360 if (r == rstr) 1405 if (r == rstr)
1361 croak ("leading combining character unencodable"); 1406 croak ("leading combining character unencodable");
1362 1407
1363 unicode_t n = rxvt_compose (r[-1], *s); 1408 unicode_t n = rxvt_compose (r[-1], *s);
1364 if (n == NOCHAR) 1409 if (n == NOCHAR)
1365 n = rxvt_composite.compose (r[-1], *s); 1410 n = rxvt_composite.compose (r[-1], *s);
1366 1411
1367 r[-1] = n; 1412 r[-1] = n;
1368 } 1413 }
1369#if !UNICODE_3 1414#if !UNICODE_3
1370 else if (*s >= 0x10000) 1415 else if (*s >= 0x10000)
1371 *r++ = rxvt_composite.compose (*s); 1416 *r++ = rxvt_composite.compose (*s);
1372#endif 1417#endif
1373 else 1418 else
1374 *r++ = *s; 1419 *r++ = *s;
1420
1421 // the *2 above only allows wcwidth <= 2
1422 if (w > 1)
1423 *r++ = NOCHAR;
1424 }
1375 1425
1376 rxvt_pop_locale (); 1426 rxvt_pop_locale ();
1377 1427
1378 RETVAL = wcs2sv (rstr, r - rstr); 1428 RETVAL = wcs2sv (rstr, r - rstr);
1379
1380 delete [] rstr;
1381} 1429}
1382 OUTPUT: 1430 OUTPUT:
1383 RETVAL 1431 RETVAL
1384 1432
1385SV * 1433SV *
1397 else if (IS_COMPOSE (*s)) 1445 else if (IS_COMPOSE (*s))
1398 dlen += rxvt_composite.expand (*s, 0); 1446 dlen += rxvt_composite.expand (*s, 0);
1399 else 1447 else
1400 dlen++; 1448 dlen++;
1401 1449
1402 wchar_t *rstr = new wchar_t [dlen]; 1450 wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen);
1403 1451
1404 // decode 1452 // decode
1405 wchar_t *r = rstr; 1453 wchar_t *r = rstr;
1406 for (wchar_t *s = wstr; *s; s++) 1454 for (wchar_t *s = wstr; *s; s++)
1407 if (*s == NOCHAR) 1455 if (*s == NOCHAR)
1410 r += rxvt_composite.expand (*s, r); 1458 r += rxvt_composite.expand (*s, r);
1411 else 1459 else
1412 *r++ = *s; 1460 *r++ = *s;
1413 1461
1414 RETVAL = wcs2sv (rstr, r - rstr); 1462 RETVAL = wcs2sv (rstr, r - rstr);
1415
1416 delete [] rstr;
1417} 1463}
1418 OUTPUT: 1464 OUTPUT:
1419 RETVAL 1465 RETVAL
1420 1466
1421void 1467void
1531 if (items == 3) 1577 if (items == 3)
1532 { 1578 {
1533 rc.row = SvIV (ST (1)); 1579 rc.row = SvIV (ST (1));
1534 rc.col = SvIV (ST (2)); 1580 rc.col = SvIV (ST (2));
1535 1581
1536 if (ix == 2 && rc.col == 0) 1582 if (ix == 2)
1537 { 1583 {
1584 if (rc.col == 0)
1585 {
1586 // col == 0 means end of previous line
1538 rc.row--; 1587 rc.row--;
1539 rc.col = THIS->ncol; 1588 rc.col = THIS->ncol;
1589 }
1590 else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow)
1591 && rc.col > ROW(rc.row).l)
1592 {
1593 // col >= length means while line and add newline
1594 rc.col = THIS->ncol;
1595 }
1540 } 1596 }
1541 1597
1542 clamp_it (rc.col, 0, THIS->ncol); 1598 clamp_it (rc.col, 0, THIS->ncol);
1543 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1599 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1544 1600

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines