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.1 by root, Mon Jan 2 15:35:43 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
391
392void
393rxvt_term::_resource (char *name, int index, SV *newval = 0)
394 PPCODE:
395{
396 struct resval { const char *name; int value; } rslist [] = {
397# define Rs_def(name) { # name, Rs_ ## name },
398# define Rs_reserve(name,count)
399# include "rsinc.h"
400# undef Rs_def
401# undef Rs_reserve
402 };
403
404 struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]);
405
406 do {
407 if (rs-- == rslist)
408 croak ("no such resource '%s', requested", name);
409 } while (strcmp (name, rs->name));
410
411 index += rs->value;
412
413 if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES))
414 croak ("requested out-of-bound resource %s+%d,", name, index - rs->value);
415
416 if (GIMME_V != G_VOID)
417 XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef);
418
419 if (newval)
420 {
421 if (SvOK (newval))
422 {
423 char *str = strdup (SvPVbyte_nolen (newval));
424 THIS->rs [index] = str;
425 THIS->allocated.push_back (str);
426 }
427 else
428 THIS->rs [index] = 0;
429 }
430}
348 431
349void 432void
350rxvt_term::selection_mark (...) 433rxvt_term::selection_mark (...)
351 PROTOTYPE: $;$$ 434 PROTOTYPE: $;$$
352 ALIAS: 435 ALIAS:
418 wchar_t *wtext = sv2wcs (text); 501 wchar_t *wtext = sv2wcs (text);
419 THIS->scr_overlay_set (x, y, wtext); 502 THIS->scr_overlay_set (x, y, wtext);
420 free (wtext); 503 free (wtext);
421} 504}
422 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
423MODULE = urxvt PACKAGE = urxvt::timer 514MODULE = urxvt PACKAGE = urxvt::timer
424 515
425SV * 516SV *
426timer::new () 517timer::new ()
427 CODE: 518 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines