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.83 by root, Fri Jan 20 15:40:39 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
596 setuv (root, xe->xmotion.root); 606 setuv (root, xe->xmotion.root);
597 setuv (subwindow, xe->xmotion.subwindow); 607 setuv (subwindow, xe->xmotion.subwindow);
598 setuv (time, xe->xmotion.time); 608 setuv (time, xe->xmotion.time);
599 setiv (x, xe->xmotion.x); 609 setiv (x, xe->xmotion.x);
600 setiv (y, xe->xmotion.y); 610 setiv (y, xe->xmotion.y);
601 setiv (row, xe->xmotion.y / term->fheight); 611 setiv (row, xe->xmotion.y / term->fheight + term->view_start);
602 setiv (col, xe->xmotion.x / term->fwidth); 612 setiv (col, xe->xmotion.x / term->fwidth);
603 setiv (x_root, xe->xmotion.x_root); 613 setiv (x_root, xe->xmotion.x_root);
604 setiv (y_root, xe->xmotion.y_root); 614 setiv (y_root, xe->xmotion.y_root);
605 setuv (state, xe->xmotion.state); 615 setuv (state, xe->xmotion.state);
606 616
640 break; 650 break;
641 } 651 }
642 652
643 break; 653 break;
644 654
655 case PropertyNotify:
656 setuv (window, xe->xproperty.window);
657 setuv (atom, xe->xproperty.atom);
658 setuv (time, xe->xproperty.time);
659 setiv (state, xe->xproperty.state);
660 break;
661
645 case ClientMessage: 662 case ClientMessage:
646 setuv (window, xe->xclient.window); 663 setuv (window, xe->xclient.window);
647 setuv (message_type, xe->xclient.message_type); 664 setuv (message_type, xe->xclient.message_type);
648 setuv (format, xe->xclient.format); 665 setuv (format, xe->xclient.format);
649 setuv (l0, xe->xclient.data.l[0]); 666 setuv (l0, xe->xclient.data.l[0]);
650 setuv (l1, xe->xclient.data.l[1]); 667 setuv (l1, xe->xclient.data.l[1]);
651 setuv (l2, xe->xclient.data.l[2]); 668 setuv (l2, xe->xclient.data.l[2]);
652 setuv (l3, xe->xclient.data.l[3]); 669 setuv (l3, xe->xclient.data.l[3]);
653 setuv (l4, xe->xclient.data.l[4]); 670 setuv (l4, xe->xclient.data.l[4]);
671 break;
654 } 672 }
655 673
656 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 674 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
657 } 675 }
658 break; 676 break;
708 } 726 }
709 else if (htype == HOOK_DESTROY) 727 else if (htype == HOOK_DESTROY)
710 { 728 {
711 clearSVptr ((SV *)term->perl.self); 729 clearSVptr ((SV *)term->perl.self);
712 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;
713 } 734 }
714 735
715 swap (perl_environ, environ); 736 swap (perl_environ, environ);
716 737
717 return event_consumed; 738 return event_consumed;
834 const_iv (SelectionRequest), 855 const_iv (SelectionRequest),
835 const_iv (SelectionNotify), 856 const_iv (SelectionNotify),
836 const_iv (ColormapNotify), 857 const_iv (ColormapNotify),
837 const_iv (ClientMessage), 858 const_iv (ClientMessage),
838 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
839 }; 885 };
840 886
841 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); 887 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
842 civ-- > const_iv; ) 888 civ-- > const_iv; )
843 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 889 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
920 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) 966 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
921 croak ("first argument to urxvt::term->_new must be arrayref"); 967 croak ("first argument to urxvt::term->_new must be arrayref");
922 968
923 rxvt_term *term = new rxvt_term; 969 rxvt_term *term = new rxvt_term;
924 970
925 term->argv = new stringvec; 971 stringvec *argv = new stringvec;
926 term->envv = new stringvec; 972 stringvec *envv = new stringvec;
927 973
928 for (int i = 1; i < items; i++) 974 for (int i = 1; i < items; i++)
929 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); 975 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
930 976
931 AV *envv = (AV *)SvRV (ST (0)); 977 AV *env = (AV *)SvRV (ST (0));
932 for (int i = AvFILL (envv) + 1; i--; ) 978 for (int i = AvFILL (env) + 1; i--; )
933 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); 979 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
934 980
935 term->envv->push_back (0); 981 envv->push_back (0);
936 982
937 bool success; 983 bool success;
938 984
939 try 985 try
940 { 986 {
941 success = term->init (term->argv->size (), term->argv->begin ()); 987 success = term->init (argv, envv);
942 } 988 }
943 catch (const class rxvt_failure_exception &e) 989 catch (const class rxvt_failure_exception &e)
944 { 990 {
945 success = false; 991 success = false;
946 } 992 }
1109rxvt_term::ModLevel3Mask () 1155rxvt_term::ModLevel3Mask ()
1110 ALIAS: 1156 ALIAS:
1111 ModLevel3Mask = 0 1157 ModLevel3Mask = 0
1112 ModMetaMask = 1 1158 ModMetaMask = 1
1113 ModNumLockMask = 2 1159 ModNumLockMask = 2
1160 current_screen = 3
1161 hidden_cursor = 4
1114 CODE: 1162 CODE:
1115 switch (ix) 1163 switch (ix)
1116 { 1164 {
1117 case 0: RETVAL = THIS->ModLevel3Mask; break; 1165 case 0: RETVAL = THIS->ModLevel3Mask; break;
1118 case 1: RETVAL = THIS->ModMetaMask; break; 1166 case 1: RETVAL = THIS->ModMetaMask; break;
1119 case 2: RETVAL = THIS->ModNumLockMask; break; 1167 case 2: RETVAL = THIS->ModNumLockMask; break;
1168 case 3: RETVAL = THIS->current_screen; break;
1169 case 4: RETVAL = THIS->hidden_cursor; break;
1120 } 1170 }
1121 OUTPUT: 1171 OUTPUT:
1122 RETVAL 1172 RETVAL
1123 1173
1124char * 1174char *
1162 if (events != EVENT_UNDEF) 1212 if (events != EVENT_UNDEF)
1163 THIS->pty_ev.set (events); 1213 THIS->pty_ev.set (events);
1164 OUTPUT: 1214 OUTPUT:
1165 RETVAL 1215 RETVAL
1166 1216
1217int
1218rxvt_term::pty_fd ()
1219 CODE:
1220 RETVAL = THIS->pty->pty;
1221 OUTPUT:
1222 RETVAL
1223
1167Window 1224Window
1168rxvt_term::parent () 1225rxvt_term::parent ()
1169 CODE: 1226 CODE:
1170 RETVAL = THIS->parent [0]; 1227 RETVAL = THIS->parent [0];
1171 OUTPUT: 1228 OUTPUT:
1225 1282
1226 line_t &l = ROW(row_number); 1283 line_t &l = ROW(row_number);
1227 1284
1228 if (GIMME_V != G_VOID) 1285 if (GIMME_V != G_VOID)
1229 { 1286 {
1230 wchar_t *wstr = new wchar_t [THIS->ncol]; 1287 wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol);
1231 1288
1232 for (int col = 0; col < THIS->ncol; col++) 1289 for (int col = 0; col < THIS->ncol; col++)
1233 wstr [col] = l.t [col]; 1290 wstr [col] = l.t [col];
1234 1291
1235 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); 1292 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1236
1237 delete [] wstr;
1238 } 1293 }
1239 1294
1240 if (new_text) 1295 if (new_text)
1241 { 1296 {
1242 wchar_t *wstr = sv2wcs (new_text); 1297 wchar_t *wstr = sv2wcs (new_text);
1335rxvt_term::special_encode (SV *string) 1390rxvt_term::special_encode (SV *string)
1336 CODE: 1391 CODE:
1337{ 1392{
1338 wchar_t *wstr = sv2wcs (string); 1393 wchar_t *wstr = sv2wcs (string);
1339 int wlen = wcslen (wstr); 1394 int wlen = wcslen (wstr);
1340 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer 1395 wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer
1341 1396
1342 rxvt_push_locale (THIS->locale); 1397 rxvt_push_locale (THIS->locale);
1343 1398
1344 wchar_t *r = rstr; 1399 wchar_t *r = rstr;
1345 for (wchar_t *s = wstr; *s; s++) 1400 for (wchar_t *s = wstr; *s; s++)
1401 {
1402 int w = WCWIDTH (*s);
1403
1346 if (wcwidth (*s) == 0) 1404 if (w == 0)
1347 { 1405 {
1348 if (r == rstr) 1406 if (r == rstr)
1349 croak ("leading combining character unencodable"); 1407 croak ("leading combining character unencodable");
1350 1408
1351 unicode_t n = rxvt_compose (r[-1], *s); 1409 unicode_t n = rxvt_compose (r[-1], *s);
1352 if (n == NOCHAR) 1410 if (n == NOCHAR)
1353 n = rxvt_composite.compose (r[-1], *s); 1411 n = rxvt_composite.compose (r[-1], *s);
1354 1412
1355 r[-1] = n; 1413 r[-1] = n;
1356 } 1414 }
1357#if !UNICODE_3 1415#if !UNICODE_3
1358 else if (*s >= 0x10000) 1416 else if (*s >= 0x10000)
1359 *r++ = rxvt_composite.compose (*s); 1417 *r++ = rxvt_composite.compose (*s);
1360#endif 1418#endif
1361 else 1419 else
1362 *r++ = *s; 1420 *r++ = *s;
1421
1422 // the *2 above only allows wcwidth <= 2
1423 if (w > 1)
1424 *r++ = NOCHAR;
1425 }
1363 1426
1364 rxvt_pop_locale (); 1427 rxvt_pop_locale ();
1365 1428
1366 RETVAL = wcs2sv (rstr, r - rstr); 1429 RETVAL = wcs2sv (rstr, r - rstr);
1367
1368 delete [] rstr;
1369} 1430}
1370 OUTPUT: 1431 OUTPUT:
1371 RETVAL 1432 RETVAL
1372 1433
1373SV * 1434SV *
1385 else if (IS_COMPOSE (*s)) 1446 else if (IS_COMPOSE (*s))
1386 dlen += rxvt_composite.expand (*s, 0); 1447 dlen += rxvt_composite.expand (*s, 0);
1387 else 1448 else
1388 dlen++; 1449 dlen++;
1389 1450
1390 wchar_t *rstr = new wchar_t [dlen]; 1451 wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen);
1391 1452
1392 // decode 1453 // decode
1393 wchar_t *r = rstr; 1454 wchar_t *r = rstr;
1394 for (wchar_t *s = wstr; *s; s++) 1455 for (wchar_t *s = wstr; *s; s++)
1395 if (*s == NOCHAR) 1456 if (*s == NOCHAR)
1398 r += rxvt_composite.expand (*s, r); 1459 r += rxvt_composite.expand (*s, r);
1399 else 1460 else
1400 *r++ = *s; 1461 *r++ = *s;
1401 1462
1402 RETVAL = wcs2sv (rstr, r - rstr); 1463 RETVAL = wcs2sv (rstr, r - rstr);
1403
1404 delete [] rstr;
1405} 1464}
1406 OUTPUT: 1465 OUTPUT:
1407 RETVAL 1466 RETVAL
1408 1467
1409void 1468void
1519 if (items == 3) 1578 if (items == 3)
1520 { 1579 {
1521 rc.row = SvIV (ST (1)); 1580 rc.row = SvIV (ST (1));
1522 rc.col = SvIV (ST (2)); 1581 rc.col = SvIV (ST (2));
1523 1582
1524 if (ix == 2 && rc.col == 0) 1583 if (ix == 2)
1525 { 1584 {
1585 if (rc.col == 0)
1586 {
1587 // col == 0 means end of previous line
1526 rc.row--; 1588 rc.row--;
1527 rc.col = THIS->ncol; 1589 rc.col = THIS->ncol;
1590 }
1591 else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow)
1592 && rc.col > ROW(rc.row).l)
1593 {
1594 // col >= length means while line and add newline
1595 rc.col = THIS->ncol;
1596 }
1528 } 1597 }
1529 1598
1530 clamp_it (rc.col, 0, THIS->ncol); 1599 clamp_it (rc.col, 0, THIS->ncol);
1531 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1600 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1532 1601
1579void 1648void
1580rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) 1649rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1581 1650
1582void 1651void
1583rxvt_term::scr_bell () 1652rxvt_term::scr_bell ()
1653
1654void
1655rxvt_term::scr_change_screen (int screen)
1584 1656
1585void 1657void
1586rxvt_term::scr_add_lines (SV *string) 1658rxvt_term::scr_add_lines (SV *string)
1587 CODE: 1659 CODE:
1588{ 1660{
1738XUnmapWindow (rxvt_term *term, Window window) 1810XUnmapWindow (rxvt_term *term, Window window)
1739 C_ARGS: term->display->display, window 1811 C_ARGS: term->display->display, window
1740 1812
1741void 1813void
1742XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) 1814XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height)
1743 C_ARGS: term->display->display, (Window)window, x, y, width, height 1815 C_ARGS: term->display->display, window, x, y, width, height
1816
1817void
1818rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0)
1819 CODE:
1820{
1821 XWindowAttributes attr;
1822 XGetWindowAttributes (THIS->display->display, window, &attr);
1823 XSelectInput (THIS->display->display, window, attr.your_event_mask | add_events & ~del_events);
1824}
1744 1825
1745void 1826void
1746rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) 1827rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y)
1747 PPCODE: 1828 PPCODE:
1748{ 1829{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines