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.3 by root, Mon Jan 2 18:20:23 2006 UTC vs.
Revision 1.6 by root, Mon Jan 2 21:17:01 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 if (!perl
214 || (!should_invoke [htype] && htype != HOOK_INIT && htype != HOOK_DESTROY))
214 return false; 215 return false;
215 216
216 if (htype == HOOK_INIT) // first hook ever called 217 if (htype == HOOK_INIT) // first hook ever called
217 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 218 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 219
225 if (!should_invoke [htype])
226 return false;
227
228 dSP; 220 dSP;
229 va_list ap; 221 va_list ap;
230 222
231 va_start (ap, htype); 223 va_start (ap, htype);
232 224
249 241
250 case DT_LONG: 242 case DT_LONG:
251 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); 243 XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
252 break; 244 break;
253 245
246 case DT_STRING:
247 XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
248 break;
249
254 case DT_END: 250 case DT_END:
255 { 251 {
256 va_end (ap); 252 va_end (ap);
257 253
258 PUTBACK; 254 PUTBACK;
270 LEAVE; 266 LEAVE;
271 267
272 if (SvTRUE (ERRSV)) 268 if (SvTRUE (ERRSV))
273 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 269 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
274 270
271 if (htype == HOOK_DESTROY)
272 {
273 // TODO: clear magic
274 hv_clear ((HV *)SvRV ((SV *)term->self));
275 SvREFCNT_dec ((SV *)term->self);
276 }
277
275 return count; 278 return count;
276 } 279 }
277 280
278 default: 281 default:
279 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); 282 rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
289 292
290BOOT: 293BOOT:
291{ 294{
292# define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) 295# define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0))
293 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 296 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
294 set_hookname (LOAD);
295 set_hookname (INIT); 297 set_hookname (INIT);
296 set_hookname (RESET); 298 set_hookname (RESET);
297 set_hookname (START); 299 set_hookname (START);
298 set_hookname (DESTROY); 300 set_hookname (DESTROY);
299 set_hookname (SEL_BEGIN); 301 set_hookname (SEL_BEGIN);
305 set_hookname (VIEW_CHANGE); 307 set_hookname (VIEW_CHANGE);
306 set_hookname (SCROLL_BACK); 308 set_hookname (SCROLL_BACK);
307 set_hookname (TTY_ACTIVITY); 309 set_hookname (TTY_ACTIVITY);
308 set_hookname (REFRESH_BEGIN); 310 set_hookname (REFRESH_BEGIN);
309 set_hookname (REFRESH_END); 311 set_hookname (REFRESH_END);
312 set_hookname (KEYBOARD_COMMAND);
310 313
311 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 314 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR);
312} 315}
313 316
314void 317void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines