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.88 by root, Sun Jan 22 00:36:59 2006 UTC vs.
Revision 1.93 by root, Wed Jan 25 15:02:47 2006 UTC

244 244
245///////////////////////////////////////////////////////////////////////////// 245/////////////////////////////////////////////////////////////////////////////
246 246
247#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") 247#define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay")
248 248
249struct overlay { 249class overlay {
250 HV *self;
251 bool visible;
252 rxvt_term *THIS; 250 rxvt_term *THIS;
251 AV *overlay_av;
253 int x, y, w, h; 252 int x, y, w, h;
254 int border; 253 int border;
255 text_t **text; 254 text_t **text;
256 rend_t **rend; 255 rend_t **rend;
257 256
257public:
258 HV *self;
259
258 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); 260 overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border);
259 ~overlay (); 261 ~overlay ();
260 262
261 void show (); 263 void show ();
262 void hide (); 264 void hide ();
265 267
266 void set (int x, int y, SV *str, SV *rend); 268 void set (int x, int y, SV *str, SV *rend);
267}; 269};
268 270
269overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) 271overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border)
270: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), visible(false) 272: THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0)
271{ 273{
272 if (border == 2) 274 if (border == 2)
273 { 275 {
274 w += 2; 276 w += 2;
275 h += 2; 277 h += 2;
314 *rp++ = r; 316 *rp++ = r;
315 } 317 }
316 } 318 }
317 319
318 show (); 320 show ();
319 THIS->want_refresh = 1;
320} 321}
321 322
322overlay::~overlay () 323overlay::~overlay ()
323{ 324{
324 hide (); 325 hide ();
329 delete [] rend[y]; 330 delete [] rend[y];
330 } 331 }
331 332
332 delete [] text; 333 delete [] text;
333 delete [] rend; 334 delete [] rend;
335}
336
337void
338overlay::show ()
339{
340 if (overlay_av)
341 return;
342
343 overlay_av = (AV *)SvREFCNT_inc (SvRV (
344 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)
345 ));
346 av_push (overlay_av, newSViv ((long)this));
334 347
335 THIS->want_refresh = 1; 348 THIS->want_refresh = 1;
336} 349}
337 350
338void 351void
339overlay::show () 352overlay::hide ()
340{ 353{
341 if (visible) 354 if (!overlay_av)
342 return; 355 return;
343 356
344 visible = true;
345
346 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
347 av_push (av, newSViv ((long)this));
348}
349
350void
351overlay::hide ()
352{
353 if (!visible)
354 return;
355
356 visible = false;
357
358 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
359
360 int i; 357 int i;
361 358
362 for (i = AvFILL (av); i >= 0; i--) 359 for (i = AvFILL (overlay_av); i >= 0; i--)
363 if (SvIV (*av_fetch (av, i, 1)) == (long)this) 360 if (SvIV (*av_fetch (overlay_av, i, 1)) == (long)this)
364 { 361 {
365 av_delete (av, i, G_DISCARD); 362 av_delete (overlay_av, i, G_DISCARD);
366 break; 363 break;
367 } 364 }
368 365
369 for (; i < AvFILL (av); i++) 366 for (; i < AvFILL (overlay_av); i++)
370 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); 367 av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0)));
371 368
372 av_pop (av); 369 av_pop (overlay_av);
370
371 SvREFCNT_dec (overlay_av);
372 overlay_av = 0;
373
374 THIS->want_refresh = 1;
373} 375}
374 376
375void overlay::swap () 377void overlay::swap ()
376{ 378{
377 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 379 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
554 break; 556 break;
555 557
556 case DT_STR_LEN: 558 case DT_STR_LEN:
557 { 559 {
558 char *str = va_arg (ap, char *); 560 char *str = va_arg (ap, char *);
559 int len = va_arg (ap, int); 561 int len = va_arg (ap, int);
560 562
563 printf ("pushing str %p:%d\n", str,len);//D
561 XPUSHs (sv_2mortal (newSVpvn (str, len))); 564 XPUSHs (sv_2mortal (newSVpvn (str, len)));
562 } 565 }
563 break; 566 break;
564 567
565 case DT_WCS_LEN: 568 case DT_WCS_LEN:
566 { 569 {
567 wchar_t *wstr = va_arg (ap, wchar_t *); 570 wchar_t *wstr = va_arg (ap, wchar_t *);
568 int wlen = va_arg (ap, int); 571 int wlen = va_arg (ap, int);
569 572
570 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); 573 XPUSHs (sv_2mortal (wcs2sv (wstr, wlen)));
574 }
575 break;
576
577 case DT_LCS_LEN:
578 {
579 long *lstr = va_arg (ap, long *);
580 int llen = va_arg (ap, int);
581
582 XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long))));
571 } 583 }
572 break; 584 break;
573 585
574 case DT_XEVENT: 586 case DT_XEVENT:
575 { 587 {
576 XEvent *xe = va_arg (ap, XEvent *); 588 XEvent *xe = va_arg (ap, XEvent *);
577 HV *hv = newHV (); 589 HV *hv = newHV ();
578 590
579# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) 591# 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) 592# 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) 593# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0)
582# undef set 594# undef set
583 595
584 setiv (type, xe->type); 596 setiv (type, xe->type);
585 setiv (send_event, xe->xany.send_event); 597 setiv (send_event, xe->xany.send_event);
586 setiv (serial, xe->xany.serial); 598 setiv (serial, xe->xany.serial);
587 599
716 } 728 }
717 else if (htype == HOOK_DESTROY) 729 else if (htype == HOOK_DESTROY)
718 { 730 {
719 clearSVptr ((SV *)term->perl.self); 731 clearSVptr ((SV *)term->perl.self);
720 SvREFCNT_dec ((SV *)term->perl.self); 732 SvREFCNT_dec ((SV *)term->perl.self);
733
734 // don't allow further calls
735 term->perl.self = 0;
721 } 736 }
722 737
723 swap (perl_environ, environ); 738 swap (perl_environ, environ);
724 739
725 return event_consumed; 740 return event_consumed;
842 const_iv (SelectionRequest), 857 const_iv (SelectionRequest),
843 const_iv (SelectionNotify), 858 const_iv (SelectionNotify),
844 const_iv (ColormapNotify), 859 const_iv (ColormapNotify),
845 const_iv (ClientMessage), 860 const_iv (ClientMessage),
846 const_iv (MappingNotify), 861 const_iv (MappingNotify),
862# if ENABLE_XIM_ONTHESPOT
863 const_iv (XIMReverse),
864 const_iv (XIMUnderline),
865 const_iv (XIMHighlight),
866 const_iv (XIMPrimary),
867 const_iv (XIMSecondary),
868 const_iv (XIMTertiary),
869 const_iv (XIMVisibleToForward),
870 const_iv (XIMVisibleToBackword),
871 const_iv (XIMVisibleToCenter),
872# if 0
873 const_iv (XIMForwardChar),
874 const_iv (XIMBackwardChar),
875 const_iv (XIMForwardWord),
876 const_iv (XIMBackwardWord),
877 const_iv (XIMCaretUp),
878 const_iv (XIMCaretDown),
879 const_iv (XIMNextLine),
880 const_iv (XIMPreviousLine),
881 const_iv (XIMLineStart),
882 const_iv (XIMLineEnd),
883 const_iv (XIMAbsolutePosition),
884 const_iv (XIMDontChange),
885# endif
886# endif
847 }; 887 };
848 888
849 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); 889 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
850 civ-- > const_iv; ) 890 civ-- > const_iv; )
851 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 891 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1174 if (events != EVENT_UNDEF) 1214 if (events != EVENT_UNDEF)
1175 THIS->pty_ev.set (events); 1215 THIS->pty_ev.set (events);
1176 OUTPUT: 1216 OUTPUT:
1177 RETVAL 1217 RETVAL
1178 1218
1219int
1220rxvt_term::pty_fd ()
1221 CODE:
1222 RETVAL = THIS->pty->pty;
1223 OUTPUT:
1224 RETVAL
1225
1179Window 1226Window
1180rxvt_term::parent () 1227rxvt_term::parent ()
1181 CODE: 1228 CODE:
1182 RETVAL = THIS->parent [0]; 1229 RETVAL = THIS->parent [0];
1183 OUTPUT: 1230 OUTPUT:
1237 1284
1238 line_t &l = ROW(row_number); 1285 line_t &l = ROW(row_number);
1239 1286
1240 if (GIMME_V != G_VOID) 1287 if (GIMME_V != G_VOID)
1241 { 1288 {
1242 wchar_t *wstr = new wchar_t [THIS->ncol]; 1289 wchar_t *wstr = rxvt_temp_buf<wchar_t> (THIS->ncol);
1243 1290
1244 for (int col = 0; col < THIS->ncol; col++) 1291 for (int col = 0; col < THIS->ncol; col++)
1245 wstr [col] = l.t [col]; 1292 wstr [col] = l.t [col];
1246 1293
1247 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); 1294 XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol)));
1248
1249 delete [] wstr;
1250 } 1295 }
1251 1296
1252 if (new_text) 1297 if (new_text)
1253 { 1298 {
1254 wchar_t *wstr = sv2wcs (new_text); 1299 wchar_t *wstr = sv2wcs (new_text);
1347rxvt_term::special_encode (SV *string) 1392rxvt_term::special_encode (SV *string)
1348 CODE: 1393 CODE:
1349{ 1394{
1350 wchar_t *wstr = sv2wcs (string); 1395 wchar_t *wstr = sv2wcs (string);
1351 int wlen = wcslen (wstr); 1396 int wlen = wcslen (wstr);
1352 wchar_t *rstr = new wchar_t [wlen]; // cannot become longer 1397 wchar_t *rstr = rxvt_temp_buf<wchar_t> (wlen * 2); // cannot become longer
1353 1398
1354 rxvt_push_locale (THIS->locale); 1399 rxvt_push_locale (THIS->locale);
1355 1400
1356 wchar_t *r = rstr; 1401 wchar_t *r = rstr;
1357 for (wchar_t *s = wstr; *s; s++) 1402 for (wchar_t *s = wstr; *s; s++)
1403 {
1404 int w = WCWIDTH (*s);
1405
1358 if (wcwidth (*s) == 0) 1406 if (w == 0)
1359 { 1407 {
1360 if (r == rstr) 1408 if (r == rstr)
1361 croak ("leading combining character unencodable"); 1409 croak ("leading combining character unencodable");
1362 1410
1363 unicode_t n = rxvt_compose (r[-1], *s); 1411 unicode_t n = rxvt_compose (r[-1], *s);
1364 if (n == NOCHAR) 1412 if (n == NOCHAR)
1365 n = rxvt_composite.compose (r[-1], *s); 1413 n = rxvt_composite.compose (r[-1], *s);
1366 1414
1367 r[-1] = n; 1415 r[-1] = n;
1368 } 1416 }
1369#if !UNICODE_3 1417#if !UNICODE_3
1370 else if (*s >= 0x10000) 1418 else if (*s >= 0x10000)
1371 *r++ = rxvt_composite.compose (*s); 1419 *r++ = rxvt_composite.compose (*s);
1372#endif 1420#endif
1373 else 1421 else
1374 *r++ = *s; 1422 *r++ = *s;
1423
1424 // the *2 above only allows wcwidth <= 2
1425 if (w > 1)
1426 *r++ = NOCHAR;
1427 }
1375 1428
1376 rxvt_pop_locale (); 1429 rxvt_pop_locale ();
1377 1430
1378 RETVAL = wcs2sv (rstr, r - rstr); 1431 RETVAL = wcs2sv (rstr, r - rstr);
1379
1380 delete [] rstr;
1381} 1432}
1382 OUTPUT: 1433 OUTPUT:
1383 RETVAL 1434 RETVAL
1384 1435
1385SV * 1436SV *
1397 else if (IS_COMPOSE (*s)) 1448 else if (IS_COMPOSE (*s))
1398 dlen += rxvt_composite.expand (*s, 0); 1449 dlen += rxvt_composite.expand (*s, 0);
1399 else 1450 else
1400 dlen++; 1451 dlen++;
1401 1452
1402 wchar_t *rstr = new wchar_t [dlen]; 1453 wchar_t *rstr = rxvt_temp_buf<wchar_t> (dlen);
1403 1454
1404 // decode 1455 // decode
1405 wchar_t *r = rstr; 1456 wchar_t *r = rstr;
1406 for (wchar_t *s = wstr; *s; s++) 1457 for (wchar_t *s = wstr; *s; s++)
1407 if (*s == NOCHAR) 1458 if (*s == NOCHAR)
1410 r += rxvt_composite.expand (*s, r); 1461 r += rxvt_composite.expand (*s, r);
1411 else 1462 else
1412 *r++ = *s; 1463 *r++ = *s;
1413 1464
1414 RETVAL = wcs2sv (rstr, r - rstr); 1465 RETVAL = wcs2sv (rstr, r - rstr);
1415
1416 delete [] rstr;
1417} 1466}
1418 OUTPUT: 1467 OUTPUT:
1419 RETVAL 1468 RETVAL
1420 1469
1421void 1470void
1531 if (items == 3) 1580 if (items == 3)
1532 { 1581 {
1533 rc.row = SvIV (ST (1)); 1582 rc.row = SvIV (ST (1));
1534 rc.col = SvIV (ST (2)); 1583 rc.col = SvIV (ST (2));
1535 1584
1536 if (ix == 2 && rc.col == 0) 1585 if (ix == 2)
1537 { 1586 {
1587 if (rc.col == 0)
1588 {
1589 // col == 0 means end of previous line
1538 rc.row--; 1590 rc.row--;
1539 rc.col = THIS->ncol; 1591 rc.col = THIS->ncol;
1592 }
1593 else if (IN_RANGE_EXC (rc.row, THIS->top_row, THIS->nrow)
1594 && rc.col > ROW(rc.row).l)
1595 {
1596 // col >= length means while line and add newline
1597 rc.col = THIS->ncol;
1598 }
1540 } 1599 }
1541 1600
1542 clamp_it (rc.col, 0, THIS->ncol); 1601 clamp_it (rc.col, 0, THIS->ncol);
1543 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1602 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1544 1603
1552 CODE: 1611 CODE:
1553 RETVAL = THIS->charsets [THIS->screen.charset]; 1612 RETVAL = THIS->charsets [THIS->screen.charset];
1554 OUTPUT: 1613 OUTPUT:
1555 RETVAL 1614 RETVAL
1556 1615
1557#void 1616void
1558#rxvt_term::selection_clear () 1617rxvt_term::selection_clear ()
1559 1618
1560void 1619void
1561rxvt_term::selection_make (Time eventtime, bool rect = false) 1620rxvt_term::selection_make (Time eventtime, bool rect = false)
1562 CODE: 1621 CODE:
1563 THIS->selection.op = SELECTION_CONT; 1622 THIS->selection.op = SELECTION_CONT;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines