… | |
… | |
208 | } |
208 | } |
209 | |
209 | |
210 | bool |
210 | bool |
211 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
211 | rxvt_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: |
… | |
… | |
324 | void |
324 | void |
325 | fatal (const char *msg) |
325 | fatal (const char *msg) |
326 | CODE: |
326 | CODE: |
327 | rxvt_fatal ("%s", msg); |
327 | rxvt_fatal ("%s", msg); |
328 | |
328 | |
329 | int |
|
|
330 | wcswidth (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 | |
|
|
340 | NV |
329 | NV |
341 | NOW () |
330 | NOW () |
342 | CODE: |
331 | CODE: |
343 | RETVAL = NOW; |
332 | RETVAL = NOW; |
344 | OUTPUT: |
333 | OUTPUT: |
345 | RETVAL |
334 | RETVAL |
346 | |
335 | |
347 | MODULE = urxvt PACKAGE = urxvt::term |
336 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
337 | |
|
|
338 | int |
|
|
339 | rxvt_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 | |
|
|
353 | SV * |
|
|
354 | rxvt_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 | |
|
|
371 | SV * |
|
|
372 | rxvt_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 | |
349 | void |
392 | void |
350 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
393 | rxvt_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 | |
|
|
506 | void |
|
|
507 | rxvt_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 | |
463 | MODULE = urxvt PACKAGE = urxvt::timer |
514 | MODULE = urxvt PACKAGE = urxvt::timer |
464 | |
515 | |
465 | SV * |
516 | SV * |
466 | timer::new () |
517 | timer::new () |
467 | CODE: |
518 | CODE: |