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.2 by root, Mon Jan 2 17:17:02 2006 UTC vs.
Revision 1.4 by root, Mon Jan 2 19:05:05 2006 UTC

208} 208}
209 209
210bool 210bool
211rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 211rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
212{ 212{
213 if (!perl) 213 // INIT and DESTROY must be requested by the runtime
214
215 if (!perl || !should_invoke [htype])
214 return false; 216 return false;
215 217
216 if (htype == HOOK_INIT) // first hook ever called 218 if (htype == HOOK_INIT) // first hook ever called
217 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 219 term->self = (void *)newSVptr ((void *)term, "urxvt::term");
218 else if (htype == HOOK_DESTROY)
219 {
220 // TODO: clear magic
221 hv_clear ((HV *)SvRV ((SV *)term->self));
222 SvREFCNT_dec ((SV *)term->self);
223 }
224 220
225 if (!should_invoke [htype])
226 return false;
227
228 dSP; 221 dSP;
229 va_list ap; 222 va_list ap;
230 223
231 va_start (ap, htype); 224 va_start (ap, htype);
232 225
269 FREETMPS; 262 FREETMPS;
270 LEAVE; 263 LEAVE;
271 264
272 if (SvTRUE (ERRSV)) 265 if (SvTRUE (ERRSV))
273 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 266 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
267
268 if (htype == HOOK_DESTROY)
269 {
270 // TODO: clear magic
271 hv_clear ((HV *)SvRV ((SV *)term->self));
272 SvREFCNT_dec ((SV *)term->self);
273 }
274 274
275 return count; 275 return count;
276 } 276 }
277 277
278 default: 278 default:
324void 324void
325fatal (const char *msg) 325fatal (const char *msg)
326 CODE: 326 CODE:
327 rxvt_fatal ("%s", msg); 327 rxvt_fatal ("%s", msg);
328 328
329int
330wcswidth (SV *str)
331 CODE:
332{
333 wchar_t *wstr = sv2wcs (str);
334 RETVAL = wcswidth (wstr, wcslen (wstr));
335 free (wstr);
336}
337 OUTPUT:
338 RETVAL
339
340NV 329NV
341NOW () 330NOW ()
342 CODE: 331 CODE:
343 RETVAL = NOW; 332 RETVAL = NOW;
344 OUTPUT: 333 OUTPUT:
345 RETVAL 334 RETVAL
346 335
347MODULE = urxvt PACKAGE = urxvt::term 336MODULE = urxvt PACKAGE = urxvt::term
337
338int
339rxvt_term::strwidth (SV *str)
340 CODE:
341{
342 wchar_t *wstr = sv2wcs (str);
343
344 rxvt_push_locale (THIS->locale);
345 RETVAL = wcswidth (wstr, wcslen (wstr));
346 rxvt_pop_locale ();
347
348 free (wstr);
349}
350 OUTPUT:
351 RETVAL
352
353SV *
354rxvt_term::locale_encode (SV *str)
355 CODE:
356{
357 wchar_t *wstr = sv2wcs (str);
358
359 rxvt_push_locale (THIS->locale);
360 char *mbstr = rxvt_wcstombs (wstr);
361 rxvt_pop_locale ();
362
363 free (wstr);
364
365 RETVAL = newSVpv (mbstr, 0);
366 free (mbstr);
367}
368 OUTPUT:
369 RETVAL
370
371SV *
372rxvt_term::locale_decode (SV *octets)
373 CODE:
374{
375 STRLEN len;
376 char *data = SvPVbyte (octets, len);
377
378 rxvt_push_locale (THIS->locale);
379 wchar_t *wstr = rxvt_mbstowcs (data, len);
380 rxvt_pop_locale ();
381
382 char *str = rxvt_wcstoutf8 (wstr);
383 free (wstr);
384
385 RETVAL = newSVpv (str, 0);
386 SvUTF8_on (RETVAL);
387 free (str);
388}
389 OUTPUT:
390 RETVAL
348 391
349void 392void
350rxvt_term::_resource (char *name, int index, SV *newval = 0) 393rxvt_term::_resource (char *name, int index, SV *newval = 0)
351 PPCODE: 394 PPCODE:
352{ 395{
458 wchar_t *wtext = sv2wcs (text); 501 wchar_t *wtext = sv2wcs (text);
459 THIS->scr_overlay_set (x, y, wtext); 502 THIS->scr_overlay_set (x, y, wtext);
460 free (wtext); 503 free (wtext);
461} 504}
462 505
506void
507rxvt_term::tt_write (SV *octets)
508 INIT:
509 STRLEN len;
510 char *str = SvPVbyte (octets, len);
511 C_ARGS:
512 (unsigned char *)str, len
513
463MODULE = urxvt PACKAGE = urxvt::timer 514MODULE = urxvt PACKAGE = urxvt::timer
464 515
465SV * 516SV *
466timer::new () 517timer::new ()
467 CODE: 518 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines