1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtperl.xs |
2 | * File: rxvtperl.xs |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2005 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
35 | #include "rxvtutil.h" |
35 | #include "rxvtutil.h" |
36 | #include "rxvtperl.h" |
36 | #include "rxvtperl.h" |
37 | |
37 | |
38 | #include "perlxsi.c" |
38 | #include "perlxsi.c" |
39 | |
39 | |
|
|
40 | #undef LINENO |
|
|
41 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
|
|
42 | #undef ROW |
|
|
43 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
44 | |
40 | ///////////////////////////////////////////////////////////////////////////// |
45 | ///////////////////////////////////////////////////////////////////////////// |
41 | |
46 | |
42 | static wchar_t * |
47 | static wchar_t * |
43 | sv2wcs (SV *sv) |
48 | sv2wcs (SV *sv) |
44 | { |
49 | { |
… | |
… | |
46 | char *str = SvPVutf8 (sv, len); |
51 | char *str = SvPVutf8 (sv, len); |
47 | return rxvt_utf8towcs (str, len); |
52 | return rxvt_utf8towcs (str, len); |
48 | } |
53 | } |
49 | |
54 | |
50 | static SV * |
55 | static SV * |
|
|
56 | wcs2sv (wchar_t *wstr, int len = -1) |
|
|
57 | { |
|
|
58 | char *str = rxvt_wcstoutf8 (wstr, len); |
|
|
59 | |
|
|
60 | SV *sv = newSVpv (str, 0); |
|
|
61 | SvUTF8_on (sv); |
|
|
62 | free (str); |
|
|
63 | |
|
|
64 | return sv; |
|
|
65 | } |
|
|
66 | |
|
|
67 | static SV * |
51 | new_ref (HV *hv, const char *klass) |
68 | new_ref (HV *hv, const char *klass) |
52 | { |
69 | { |
53 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
70 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
54 | } |
71 | } |
55 | |
72 | |
56 | //TODO: use magic |
73 | //TODO: use magic |
57 | static SV * |
74 | static SV * |
58 | newSVptr (void *ptr, const char *klass) |
75 | newSVptr (void *ptr, const char *klass) |
59 | { |
76 | { |
60 | HV *hv = newHV (); |
77 | HV *hv = newHV (); |
61 | hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); |
78 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
62 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
79 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
80 | } |
|
|
81 | |
|
|
82 | static void |
|
|
83 | clearSVptr (SV *sv) |
|
|
84 | { |
|
|
85 | if (SvROK (sv)) |
|
|
86 | sv = SvRV (sv); |
|
|
87 | |
|
|
88 | hv_clear ((HV *)sv); |
|
|
89 | sv_unmagic (sv, PERL_MAGIC_ext); |
63 | } |
90 | } |
64 | |
91 | |
65 | static long |
92 | static long |
66 | SvPTR (SV *sv, const char *klass) |
93 | SvPTR (SV *sv, const char *klass) |
67 | { |
94 | { |
68 | if (!sv_derived_from (sv, klass)) |
95 | if (!sv_derived_from (sv, klass)) |
69 | croak ("object of type %s expected", klass); |
96 | croak ("object of type %s expected", klass); |
70 | |
97 | |
71 | IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); |
98 | MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
72 | |
99 | |
73 | if (!iv) |
100 | if (!mg) |
74 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
101 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
75 | |
102 | |
76 | return (long)iv; |
103 | return (long)mg->mg_ptr; |
77 | } |
104 | } |
78 | |
105 | |
79 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
106 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
80 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
107 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
81 | |
108 | |
… | |
… | |
134 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
161 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
135 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
162 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
136 | |
163 | |
137 | struct timer : time_watcher, perl_watcher |
164 | struct timer : time_watcher, perl_watcher |
138 | { |
165 | { |
|
|
166 | tstamp interval; |
|
|
167 | |
139 | timer () |
168 | timer () |
140 | : time_watcher (this, &timer::execute) |
169 | : time_watcher (this, &timer::execute) |
141 | { |
170 | { |
142 | } |
171 | } |
143 | |
172 | |
144 | void execute (time_watcher &w) |
173 | void execute (time_watcher &w) |
145 | { |
174 | { |
|
|
175 | if (interval) |
|
|
176 | start (at + interval); |
|
|
177 | |
146 | invoke ("urxvt::timer", newSVtimer (this)); |
178 | invoke ("urxvt::timer", newSVtimer (this)); |
147 | } |
179 | } |
148 | }; |
180 | }; |
149 | |
181 | |
150 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
182 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
… | |
… | |
160 | void execute (io_watcher &w, short revents) |
192 | void execute (io_watcher &w, short revents) |
161 | { |
193 | { |
162 | invoke ("urxvt::iow", newSViow (this), revents); |
194 | invoke ("urxvt::iow", newSViow (this), revents); |
163 | } |
195 | } |
164 | }; |
196 | }; |
|
|
197 | |
|
|
198 | ///////////////////////////////////////////////////////////////////////////// |
|
|
199 | |
|
|
200 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
|
|
201 | |
|
|
202 | struct overlay { |
|
|
203 | HV *self; |
|
|
204 | rxvt_term *THIS; |
|
|
205 | int x, y, w, h; |
|
|
206 | int border; |
|
|
207 | text_t **text; |
|
|
208 | rend_t **rend; |
|
|
209 | |
|
|
210 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
|
|
211 | ~overlay (); |
|
|
212 | |
|
|
213 | void show (); |
|
|
214 | void hide (); |
|
|
215 | |
|
|
216 | void swap (); |
|
|
217 | |
|
|
218 | void set (int x, int y, SV *str, SV *rend); |
|
|
219 | }; |
|
|
220 | |
|
|
221 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
|
|
222 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) |
|
|
223 | { |
|
|
224 | if (border == 2) |
|
|
225 | { |
|
|
226 | w += 2; |
|
|
227 | h += 2; |
|
|
228 | } |
|
|
229 | |
|
|
230 | text = new text_t *[h]; |
|
|
231 | rend = new rend_t *[h]; |
|
|
232 | |
|
|
233 | for (int y = 0; y < h; y++) |
|
|
234 | { |
|
|
235 | text_t *tp = text[y] = new text_t[w]; |
|
|
236 | rend_t *rp = rend[y] = new rend_t[w]; |
|
|
237 | |
|
|
238 | text_t t0, t1, t2; |
|
|
239 | rend_t r = rstyle; |
|
|
240 | |
|
|
241 | if (border == 2) |
|
|
242 | { |
|
|
243 | if (y == 0) |
|
|
244 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
|
|
245 | else if (y < h - 1) |
|
|
246 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
|
|
247 | else |
|
|
248 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
|
|
249 | |
|
|
250 | *tp++ = t0; |
|
|
251 | *rp++ = r; |
|
|
252 | |
|
|
253 | for (int x = w - 2; x-- > 0; ) |
|
|
254 | { |
|
|
255 | *tp++ = t1; |
|
|
256 | *rp++ = r; |
|
|
257 | } |
|
|
258 | |
|
|
259 | *tp = t2; |
|
|
260 | *rp = r; |
|
|
261 | } |
|
|
262 | else |
|
|
263 | for (int x = w; x-- > 0; ) |
|
|
264 | { |
|
|
265 | *tp++ = 0x0020; |
|
|
266 | *rp++ = r; |
|
|
267 | } |
|
|
268 | } |
|
|
269 | |
|
|
270 | show (); |
|
|
271 | THIS->want_refresh = 1; |
|
|
272 | } |
|
|
273 | |
|
|
274 | overlay::~overlay () |
|
|
275 | { |
|
|
276 | hide (); |
|
|
277 | |
|
|
278 | for (int y = h; y--; ) |
|
|
279 | { |
|
|
280 | delete [] text[y]; |
|
|
281 | delete [] rend[y]; |
|
|
282 | } |
|
|
283 | |
|
|
284 | delete [] text; |
|
|
285 | delete [] rend; |
|
|
286 | |
|
|
287 | THIS->want_refresh = 1; |
|
|
288 | } |
|
|
289 | |
|
|
290 | void |
|
|
291 | overlay::show () |
|
|
292 | { |
|
|
293 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
294 | |
|
|
295 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
|
|
296 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
|
|
297 | } |
|
|
298 | |
|
|
299 | void |
|
|
300 | overlay::hide () |
|
|
301 | { |
|
|
302 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); |
|
|
303 | |
|
|
304 | if (ovs) |
|
|
305 | { |
|
|
306 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
307 | |
|
|
308 | HV *hv = (HV *)SvRV (*ovs); |
|
|
309 | hv_delete (hv, key, 32, G_DISCARD); |
|
|
310 | } |
|
|
311 | } |
|
|
312 | |
|
|
313 | void overlay::swap () |
|
|
314 | { |
|
|
315 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
|
|
316 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
|
|
317 | |
|
|
318 | int ov_w = min (w, THIS->ncol - ov_x); |
|
|
319 | int ov_h = min (h, THIS->nrow - ov_y); |
|
|
320 | |
|
|
321 | for (int y = ov_h; y--; ) |
|
|
322 | { |
|
|
323 | text_t *t1 = text [y]; |
|
|
324 | rend_t *r1 = rend [y]; |
|
|
325 | |
|
|
326 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
|
|
327 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
|
|
328 | |
|
|
329 | for (int x = ov_w; x--; ) |
|
|
330 | { |
|
|
331 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
|
|
332 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
|
|
333 | } |
|
|
334 | } |
|
|
335 | |
|
|
336 | } |
|
|
337 | |
|
|
338 | void overlay::set (int x, int y, SV *text, SV *rend) |
|
|
339 | { |
|
|
340 | x += border; |
|
|
341 | y += border; |
|
|
342 | |
|
|
343 | if (!IN_RANGE_EXC (y, 0, h - border)) |
|
|
344 | return; |
|
|
345 | |
|
|
346 | wchar_t *wtext = sv2wcs (text); |
|
|
347 | |
|
|
348 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
|
|
349 | this->text [y][x + col] = wtext [col]; |
|
|
350 | |
|
|
351 | free (wtext); |
|
|
352 | |
|
|
353 | if (rend) |
|
|
354 | { |
|
|
355 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
|
|
356 | croak ("rend must be arrayref"); |
|
|
357 | |
|
|
358 | AV *av = (AV *)SvRV (rend); |
|
|
359 | |
|
|
360 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
|
|
361 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
|
|
362 | } |
|
|
363 | |
|
|
364 | THIS->want_refresh = 1; |
|
|
365 | } |
|
|
366 | |
165 | |
367 | |
166 | ///////////////////////////////////////////////////////////////////////////// |
368 | ///////////////////////////////////////////////////////////////////////////// |
167 | |
369 | |
168 | struct rxvt_perl_interp rxvt_perl; |
370 | struct rxvt_perl_interp rxvt_perl; |
169 | |
371 | |
… | |
… | |
208 | } |
410 | } |
209 | |
411 | |
210 | bool |
412 | bool |
211 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
413 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
212 | { |
414 | { |
213 | // INIT and DESTROY must be requested by the runtime |
415 | if (!perl) |
214 | |
|
|
215 | if (!perl || !should_invoke [htype]) |
|
|
216 | return false; |
416 | return false; |
217 | |
417 | |
218 | if (htype == HOOK_INIT) // first hook ever called |
418 | if (htype == HOOK_INIT) // first hook ever called |
|
|
419 | { |
219 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
420 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
421 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
|
|
422 | } |
|
|
423 | else if (!term->self) |
|
|
424 | return false; // perl not initialized for this instance |
|
|
425 | else if (htype == HOOK_DESTROY) |
|
|
426 | { |
|
|
427 | // handled later |
|
|
428 | } |
|
|
429 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
430 | { |
|
|
431 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
|
|
432 | |
|
|
433 | if (HvKEYS (hv)) |
|
|
434 | { |
|
|
435 | hv_iterinit (hv); |
|
|
436 | |
|
|
437 | while (HE *he = hv_iternext (hv)) |
|
|
438 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
439 | } |
|
|
440 | } |
|
|
441 | else if (!should_invoke [htype]) |
|
|
442 | return false; |
220 | |
443 | |
221 | dSP; |
444 | dSP; |
222 | va_list ap; |
445 | va_list ap; |
223 | |
446 | |
224 | va_start (ap, htype); |
447 | va_start (ap, htype); |
… | |
… | |
242 | |
465 | |
243 | case DT_LONG: |
466 | case DT_LONG: |
244 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
245 | break; |
468 | break; |
246 | |
469 | |
|
|
470 | case DT_STR: |
|
|
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
472 | break; |
|
|
473 | |
|
|
474 | case DT_STR_LEN: |
|
|
475 | { |
|
|
476 | char *str = va_arg (ap, char *); |
|
|
477 | int len = va_arg (ap, int); |
|
|
478 | |
|
|
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
480 | } |
|
|
481 | break; |
|
|
482 | |
|
|
483 | case DT_WCS_LEN: |
|
|
484 | { |
|
|
485 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
486 | int wlen = va_arg (ap, int); |
|
|
487 | |
|
|
488 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
489 | } |
|
|
490 | |
|
|
491 | case DT_XEVENT: |
|
|
492 | { |
|
|
493 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
494 | HV *hv = newHV (); |
|
|
495 | |
|
|
496 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
497 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
498 | # undef set |
|
|
499 | |
|
|
500 | setiv (type, xe->type); |
|
|
501 | setiv (send_event, xe->xany.send_event); |
|
|
502 | setiv (serial, xe->xany.serial); |
|
|
503 | |
|
|
504 | switch (xe->type) |
|
|
505 | { |
|
|
506 | case KeyPress: |
|
|
507 | case KeyRelease: |
|
|
508 | case ButtonPress: |
|
|
509 | case ButtonRelease: |
|
|
510 | case MotionNotify: |
|
|
511 | setiv (time, xe->xmotion.time); |
|
|
512 | setiv (x, xe->xmotion.x); |
|
|
513 | setiv (y, xe->xmotion.y); |
|
|
514 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
515 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
516 | setiv (x_root, xe->xmotion.x_root); |
|
|
517 | setiv (y_root, xe->xmotion.y_root); |
|
|
518 | setiv (state, xe->xmotion.state); |
|
|
519 | break; |
|
|
520 | } |
|
|
521 | |
|
|
522 | switch (xe->type) |
|
|
523 | { |
|
|
524 | case KeyPress: |
|
|
525 | case KeyRelease: |
|
|
526 | setiv (keycode, xe->xkey.keycode); |
|
|
527 | break; |
|
|
528 | |
|
|
529 | case ButtonPress: |
|
|
530 | case ButtonRelease: |
|
|
531 | setiv (button, xe->xbutton.button); |
|
|
532 | break; |
|
|
533 | |
|
|
534 | case MotionNotify: |
|
|
535 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
536 | break; |
|
|
537 | } |
|
|
538 | |
|
|
539 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
540 | } |
|
|
541 | break; |
|
|
542 | |
247 | case DT_END: |
543 | case DT_END: |
248 | { |
544 | { |
249 | va_end (ap); |
545 | va_end (ap); |
250 | |
546 | |
251 | PUTBACK; |
547 | PUTBACK; |
… | |
… | |
265 | if (SvTRUE (ERRSV)) |
561 | if (SvTRUE (ERRSV)) |
266 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
562 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
267 | |
563 | |
268 | if (htype == HOOK_DESTROY) |
564 | if (htype == HOOK_DESTROY) |
269 | { |
565 | { |
270 | // TODO: clear magic |
|
|
271 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
566 | clearSVptr ((SV *)term->self); |
272 | SvREFCNT_dec ((SV *)term->self); |
567 | SvREFCNT_dec ((SV *)term->self); |
273 | } |
568 | } |
274 | |
569 | |
275 | return count; |
570 | return count; |
276 | } |
571 | } |
… | |
… | |
287 | |
582 | |
288 | PROTOTYPES: ENABLE |
583 | PROTOTYPES: ENABLE |
289 | |
584 | |
290 | BOOT: |
585 | BOOT: |
291 | { |
586 | { |
292 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
587 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
293 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
588 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
294 | set_hookname (LOAD); |
589 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
295 | set_hookname (INIT); |
590 | # include "hookinc.h" |
296 | set_hookname (RESET); |
591 | # undef def |
297 | set_hookname (START); |
592 | |
298 | set_hookname (DESTROY); |
593 | export_const (DEFAULT_RSTYLE); |
299 | set_hookname (SEL_BEGIN); |
594 | export_const (OVERLAY_RSTYLE); |
300 | set_hookname (SEL_EXTEND); |
595 | export_const (RS_Bold); |
301 | set_hookname (SEL_MAKE); |
596 | export_const (RS_Italic); |
302 | set_hookname (SEL_GRAB); |
597 | export_const (RS_Blink); |
303 | set_hookname (FOCUS_IN); |
598 | export_const (RS_RVid); |
304 | set_hookname (FOCUS_OUT); |
599 | export_const (RS_Uline); |
305 | set_hookname (VIEW_CHANGE); |
|
|
306 | set_hookname (SCROLL_BACK); |
|
|
307 | set_hookname (TTY_ACTIVITY); |
|
|
308 | set_hookname (REFRESH_BEGIN); |
|
|
309 | set_hookname (REFRESH_END); |
|
|
310 | |
600 | |
311 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
601 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
312 | } |
602 | } |
|
|
603 | |
|
|
604 | SV * |
|
|
605 | new (...) |
|
|
606 | CODE: |
|
|
607 | { |
|
|
608 | stringvec *argv = new stringvec; |
|
|
609 | bool success; |
|
|
610 | |
|
|
611 | for (int i = 0; i < items ;i++) |
|
|
612 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
613 | |
|
|
614 | rxvt_term *term = new rxvt_term; |
|
|
615 | |
|
|
616 | term->argv = argv; |
|
|
617 | |
|
|
618 | try |
|
|
619 | { |
|
|
620 | if (!term->init (argv->size (), argv->begin ())) |
|
|
621 | term = 0; |
|
|
622 | } |
|
|
623 | catch (const class rxvt_failure_exception &e) |
|
|
624 | { |
|
|
625 | term->destroy (); |
|
|
626 | croak ("exception caught while initializing new terminal instance"); |
|
|
627 | } |
|
|
628 | |
|
|
629 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
|
|
630 | } |
|
|
631 | OUTPUT: |
|
|
632 | RETVAL |
313 | |
633 | |
314 | void |
634 | void |
315 | set_should_invoke (int htype, int value) |
635 | set_should_invoke (int htype, int value) |
316 | CODE: |
636 | CODE: |
317 | rxvt_perl.should_invoke [htype] = value; |
637 | rxvt_perl.should_invoke [htype] = value; |
… | |
… | |
331 | CODE: |
651 | CODE: |
332 | RETVAL = NOW; |
652 | RETVAL = NOW; |
333 | OUTPUT: |
653 | OUTPUT: |
334 | RETVAL |
654 | RETVAL |
335 | |
655 | |
|
|
656 | int |
|
|
657 | GET_BASEFG (int rend) |
|
|
658 | CODE: |
|
|
659 | RETVAL = GET_BASEFG (rend); |
|
|
660 | OUTPUT: |
|
|
661 | RETVAL |
|
|
662 | |
|
|
663 | int |
|
|
664 | GET_BASEBG (int rend) |
|
|
665 | CODE: |
|
|
666 | RETVAL = GET_BASEBG (rend); |
|
|
667 | OUTPUT: |
|
|
668 | RETVAL |
|
|
669 | |
|
|
670 | int |
|
|
671 | SET_FGCOLOR (int rend, int new_color) |
|
|
672 | CODE: |
|
|
673 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
674 | OUTPUT: |
|
|
675 | RETVAL |
|
|
676 | |
|
|
677 | int |
|
|
678 | SET_BGCOLOR (int rend, int new_color) |
|
|
679 | CODE: |
|
|
680 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
681 | OUTPUT: |
|
|
682 | RETVAL |
|
|
683 | |
|
|
684 | int |
|
|
685 | GET_CUSTOM (int rend) |
|
|
686 | CODE: |
|
|
687 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
688 | OUTPUT: |
|
|
689 | RETVAL |
|
|
690 | |
|
|
691 | int |
|
|
692 | SET_CUSTOM (int rend, int new_value) |
|
|
693 | CODE: |
|
|
694 | { |
|
|
695 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
696 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
697 | |
|
|
698 | RETVAL = (rend & ~RS_customMask) |
|
|
699 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
700 | } |
|
|
701 | OUTPUT: |
|
|
702 | RETVAL |
|
|
703 | |
336 | MODULE = urxvt PACKAGE = urxvt::term |
704 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
705 | |
|
|
706 | void |
|
|
707 | rxvt_term::destroy () |
337 | |
708 | |
338 | int |
709 | int |
339 | rxvt_term::strwidth (SV *str) |
710 | rxvt_term::strwidth (SV *str) |
340 | CODE: |
711 | CODE: |
341 | { |
712 | { |
… | |
… | |
377 | |
748 | |
378 | rxvt_push_locale (THIS->locale); |
749 | rxvt_push_locale (THIS->locale); |
379 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
750 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
380 | rxvt_pop_locale (); |
751 | rxvt_pop_locale (); |
381 | |
752 | |
382 | char *str = rxvt_wcstoutf8 (wstr); |
753 | RETVAL = wcs2sv (wstr); |
383 | free (wstr); |
754 | free (wstr); |
|
|
755 | } |
|
|
756 | OUTPUT: |
|
|
757 | RETVAL |
384 | |
758 | |
385 | RETVAL = newSVpv (str, 0); |
759 | # very portable, especially on objects as opposed to pods |
386 | SvUTF8_on (RETVAL); |
760 | #define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0) |
|
|
761 | |
|
|
762 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
763 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
764 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
765 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
766 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
767 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
768 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
769 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
770 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
771 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
772 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
773 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
|
|
774 | |
|
|
775 | int |
|
|
776 | rxvt_term::width () |
|
|
777 | ALIAS: |
|
|
778 | width = TERM_OFFSET_width |
|
|
779 | height = TERM_OFFSET_height |
|
|
780 | fwidth = TERM_OFFSET_fwidth |
|
|
781 | fheight = TERM_OFFSET_fheight |
|
|
782 | fbase = TERM_OFFSET_fbase |
|
|
783 | nrow = TERM_OFFSET_nrow |
|
|
784 | ncol = TERM_OFFSET_ncol |
|
|
785 | focus = TERM_OFFSET_focus |
|
|
786 | mapped = TERM_OFFSET_mapped |
|
|
787 | saveLines = TERM_OFFSET_saveLines |
|
|
788 | total_rows = TERM_OFFSET_total_rows |
|
|
789 | nsaved = TERM_OFFSET_nsaved |
|
|
790 | CODE: |
|
|
791 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
792 | OUTPUT: |
|
|
793 | RETVAL |
|
|
794 | |
|
|
795 | U32 |
|
|
796 | rxvt_term::parent () |
|
|
797 | CODE: |
|
|
798 | RETVAL = (U32)THIS->parent [0]; |
|
|
799 | OUTPUT: |
|
|
800 | RETVAL |
|
|
801 | |
|
|
802 | U32 |
|
|
803 | rxvt_term::vt () |
|
|
804 | CODE: |
|
|
805 | RETVAL = (U32)THIS->vt; |
|
|
806 | OUTPUT: |
|
|
807 | RETVAL |
|
|
808 | |
|
|
809 | U32 |
|
|
810 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
811 | CODE: |
|
|
812 | { |
|
|
813 | RETVAL = THIS->rstyle; |
|
|
814 | THIS->rstyle = new_rstyle; |
|
|
815 | } |
|
|
816 | OUTPUT: |
|
|
817 | RETVAL |
|
|
818 | |
|
|
819 | int |
|
|
820 | rxvt_term::view_start (int newval = -1) |
|
|
821 | CODE: |
|
|
822 | { |
|
|
823 | RETVAL = THIS->view_start; |
|
|
824 | |
|
|
825 | if (newval >= 0) |
|
|
826 | { |
|
|
827 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
828 | THIS->scr_changeview (RETVAL); |
|
|
829 | } |
|
|
830 | } |
|
|
831 | OUTPUT: |
|
|
832 | RETVAL |
|
|
833 | |
|
|
834 | void |
|
|
835 | rxvt_term::want_refresh () |
|
|
836 | CODE: |
|
|
837 | THIS->want_refresh = 1; |
|
|
838 | |
|
|
839 | void |
|
|
840 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
|
|
841 | PPCODE: |
|
|
842 | { |
|
|
843 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
844 | XSRETURN_EMPTY; |
|
|
845 | |
|
|
846 | line_t &l = ROW(row_number); |
|
|
847 | |
|
|
848 | if (GIMME_V != G_VOID) |
|
|
849 | { |
|
|
850 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
|
|
851 | |
|
|
852 | for (int col = 0; col < THIS->ncol; col++) |
|
|
853 | wstr [col] = l.t [col]; |
|
|
854 | |
|
|
855 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
|
|
856 | |
|
|
857 | delete [] wstr; |
|
|
858 | } |
|
|
859 | |
|
|
860 | if (new_text) |
|
|
861 | { |
|
|
862 | wchar_t *wstr = sv2wcs (new_text); |
|
|
863 | |
|
|
864 | int len = min (wcslen (wstr) - start_ofs, max_len); |
|
|
865 | |
|
|
866 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
867 | { |
|
|
868 | free (wstr); |
|
|
869 | croak ("new_text extends beyond horizontal margins"); |
|
|
870 | } |
|
|
871 | |
|
|
872 | for (int col = start_col; col < start_col + len; col++) |
|
|
873 | { |
|
|
874 | l.t [col] = wstr [start_ofs + col - start_col]; |
|
|
875 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
|
|
876 | } |
|
|
877 | |
387 | free (str); |
878 | free (wstr); |
|
|
879 | } |
|
|
880 | } |
|
|
881 | |
|
|
882 | void |
|
|
883 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
|
|
884 | PPCODE: |
|
|
885 | { |
|
|
886 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
887 | XSRETURN_EMPTY; |
|
|
888 | |
|
|
889 | line_t &l = ROW(row_number); |
|
|
890 | |
|
|
891 | if (GIMME_V != G_VOID) |
|
|
892 | { |
|
|
893 | AV *av = newAV (); |
|
|
894 | |
|
|
895 | av_extend (av, THIS->ncol - 1); |
|
|
896 | for (int col = 0; col < THIS->ncol; col++) |
|
|
897 | av_store (av, col, newSViv (l.r [col])); |
|
|
898 | |
|
|
899 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
900 | } |
|
|
901 | |
|
|
902 | if (new_rend) |
|
|
903 | { |
|
|
904 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
|
|
905 | croak ("new_rend must be arrayref"); |
|
|
906 | |
|
|
907 | AV *av = (AV *)SvRV (new_rend); |
|
|
908 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
|
|
909 | |
|
|
910 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
911 | croak ("new_rend array extends beyond horizontal margins"); |
|
|
912 | |
|
|
913 | for (int col = start_col; col < start_col + len; col++) |
|
|
914 | { |
|
|
915 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
|
|
916 | |
|
|
917 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
|
|
918 | } |
|
|
919 | } |
|
|
920 | } |
|
|
921 | |
|
|
922 | int |
|
|
923 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
|
|
924 | CODE: |
|
|
925 | { |
|
|
926 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
927 | XSRETURN_EMPTY; |
|
|
928 | |
|
|
929 | line_t &l = ROW(row_number); |
|
|
930 | RETVAL = l.l; |
|
|
931 | |
|
|
932 | if (new_length >= 0) |
|
|
933 | l.l = new_length; |
|
|
934 | } |
|
|
935 | OUTPUT: |
|
|
936 | RETVAL |
|
|
937 | |
|
|
938 | bool |
|
|
939 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
|
|
940 | CODE: |
|
|
941 | { |
|
|
942 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
943 | XSRETURN_EMPTY; |
|
|
944 | |
|
|
945 | line_t &l = ROW(row_number); |
|
|
946 | RETVAL = l.is_longer (); |
|
|
947 | |
|
|
948 | if (new_is_longer >= 0) |
|
|
949 | l.is_longer (new_is_longer); |
|
|
950 | } |
|
|
951 | OUTPUT: |
|
|
952 | RETVAL |
|
|
953 | |
|
|
954 | SV * |
|
|
955 | rxvt_term::special_encode (SV *string) |
|
|
956 | CODE: |
|
|
957 | { |
|
|
958 | wchar_t *wstr = sv2wcs (string); |
|
|
959 | int wlen = wcslen (wstr); |
|
|
960 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
961 | |
|
|
962 | rxvt_push_locale (THIS->locale); |
|
|
963 | |
|
|
964 | wchar_t *r = rstr; |
|
|
965 | for (wchar_t *s = wstr; *s; s++) |
|
|
966 | if (wcwidth (*s) == 0) |
|
|
967 | { |
|
|
968 | if (r == rstr) |
|
|
969 | croak ("leading combining character unencodable"); |
|
|
970 | |
|
|
971 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
972 | if (n == NOCHAR) |
|
|
973 | n = rxvt_composite.compose (r[-1], *s); |
|
|
974 | |
|
|
975 | r[-1] = n; |
|
|
976 | } |
|
|
977 | #if !UNICODE_3 |
|
|
978 | else if (*s >= 0x10000) |
|
|
979 | *r++ = rxvt_composite.compose (*s); |
|
|
980 | #endif |
|
|
981 | else |
|
|
982 | *r++ = *s; |
|
|
983 | |
|
|
984 | rxvt_pop_locale (); |
|
|
985 | |
|
|
986 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
987 | |
|
|
988 | delete [] rstr; |
|
|
989 | } |
|
|
990 | OUTPUT: |
|
|
991 | RETVAL |
|
|
992 | |
|
|
993 | SV * |
|
|
994 | rxvt_term::special_decode (SV *text) |
|
|
995 | CODE: |
|
|
996 | { |
|
|
997 | wchar_t *wstr = sv2wcs (text); |
|
|
998 | int wlen = wcslen (wstr); |
|
|
999 | int dlen = 0; |
|
|
1000 | |
|
|
1001 | // find length |
|
|
1002 | for (wchar_t *s = wstr; *s; s++) |
|
|
1003 | if (*s == NOCHAR) |
|
|
1004 | ; |
|
|
1005 | else if (IS_COMPOSE (*s)) |
|
|
1006 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1007 | else |
|
|
1008 | dlen++; |
|
|
1009 | |
|
|
1010 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1011 | |
|
|
1012 | // decode |
|
|
1013 | wchar_t *r = rstr; |
|
|
1014 | for (wchar_t *s = wstr; *s; s++) |
|
|
1015 | if (*s == NOCHAR) |
|
|
1016 | ; |
|
|
1017 | else if (IS_COMPOSE (*s)) |
|
|
1018 | r += rxvt_composite.expand (*s, r); |
|
|
1019 | else |
|
|
1020 | *r++ = *s; |
|
|
1021 | |
|
|
1022 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1023 | |
|
|
1024 | delete [] rstr; |
388 | } |
1025 | } |
389 | OUTPUT: |
1026 | OUTPUT: |
390 | RETVAL |
1027 | RETVAL |
391 | |
1028 | |
392 | void |
1029 | void |
393 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1030 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
394 | PPCODE: |
1031 | PPCODE: |
395 | { |
1032 | { |
396 | struct resval { const char *name; int value; } rslist [] = { |
1033 | struct resval { const char *name; int value; } rslist [] = { |
397 | # define Rs_def(name) { # name, Rs_ ## name }, |
1034 | # define def(name) { # name, Rs_ ## name }, |
398 | # define Rs_reserve(name,count) |
1035 | # define reserve(name,count) |
399 | # include "rsinc.h" |
1036 | # include "rsinc.h" |
400 | # undef Rs_def |
1037 | # undef def |
401 | # undef Rs_reserve |
1038 | # undef reserve |
402 | }; |
1039 | }; |
403 | |
1040 | |
404 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1041 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
405 | |
1042 | |
406 | do { |
1043 | do { |
… | |
… | |
428 | THIS->rs [index] = 0; |
1065 | THIS->rs [index] = 0; |
429 | } |
1066 | } |
430 | } |
1067 | } |
431 | |
1068 | |
432 | void |
1069 | void |
433 | rxvt_term::selection_mark (...) |
1070 | rxvt_term::cur (...) |
434 | PROTOTYPE: $;$$ |
1071 | PROTOTYPE: $;$$ |
435 | ALIAS: |
1072 | ALIAS: |
|
|
1073 | screen_cur = 0 |
436 | selection_beg = 1 |
1074 | selection_beg = 1 |
437 | selection_end = 2 |
1075 | selection_end = 2 |
|
|
1076 | selection_mark = 3 |
438 | PPCODE: |
1077 | PPCODE: |
439 | { |
1078 | { |
440 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1079 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1080 | : ix == 1 ? THIS->selection.beg |
441 | : ix == 2 ? THIS->selection.end |
1081 | : ix == 2 ? THIS->selection.end |
442 | : THIS->selection.mark; |
1082 | : THIS->selection.mark; |
443 | |
1083 | |
444 | if (GIMME_V != G_VOID) |
1084 | if (GIMME_V != G_VOID) |
445 | { |
1085 | { |
446 | EXTEND (SP, 2); |
1086 | EXTEND (SP, 2); |
447 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1087 | PUSHs (sv_2mortal (newSViv (rc.row))); |
448 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1088 | PUSHs (sv_2mortal (newSViv (rc.col))); |
449 | } |
1089 | } |
450 | |
1090 | |
451 | if (items == 3) |
1091 | if (items == 3) |
452 | { |
1092 | { |
453 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1093 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
454 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1094 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
455 | |
1095 | |
456 | if (ix) |
1096 | if (ix) |
457 | THIS->want_refresh = 1; |
1097 | THIS->want_refresh = 1; |
458 | } |
1098 | } |
459 | } |
1099 | } |
460 | |
1100 | |
461 | int |
1101 | int |
462 | rxvt_term::selection_grab (int eventtime) |
1102 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
463 | |
1103 | |
464 | void |
1104 | void |
465 | rxvt_term::selection (SV *newtext = 0) |
1105 | rxvt_term::selection (SV *newtext = 0) |
466 | PPCODE: |
1106 | PPCODE: |
467 | { |
1107 | { |
468 | if (GIMME_V != G_VOID) |
1108 | if (GIMME_V != G_VOID) |
469 | { |
1109 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
470 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
471 | SV *sv = newSVpv (sel, 0); |
|
|
472 | SvUTF8_on (sv); |
|
|
473 | free (sel); |
|
|
474 | XPUSHs (sv_2mortal (sv)); |
|
|
475 | } |
|
|
476 | |
1110 | |
477 | if (newtext) |
1111 | if (newtext) |
478 | { |
1112 | { |
479 | free (THIS->selection.text); |
1113 | free (THIS->selection.text); |
480 | |
1114 | |
481 | THIS->selection.text = sv2wcs (newtext); |
1115 | THIS->selection.text = sv2wcs (newtext); |
482 | THIS->selection.len = wcslen (THIS->selection.text); |
1116 | THIS->selection.len = wcslen (THIS->selection.text); |
483 | } |
1117 | } |
484 | } |
1118 | } |
485 | |
|
|
486 | void |
|
|
487 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
|
|
488 | |
1119 | |
489 | void |
1120 | void |
490 | rxvt_term::scr_overlay_off () |
1121 | rxvt_term::scr_add_lines (SV *string) |
491 | |
|
|
492 | void |
|
|
493 | rxvt_term::scr_overlay_set_char (int x, int y, U32 text, U32 rend = OVERLAY_RSTYLE) |
|
|
494 | CODE: |
1122 | CODE: |
495 | THIS->scr_overlay_set (x, y, text, rend); |
|
|
496 | |
|
|
497 | void |
|
|
498 | rxvt_term::scr_overlay_set (int x, int y, SV *text) |
|
|
499 | CODE: |
|
|
500 | { |
1123 | { |
501 | wchar_t *wtext = sv2wcs (text); |
1124 | wchar_t *wstr = sv2wcs (string); |
502 | THIS->scr_overlay_set (x, y, wtext); |
1125 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
503 | free (wtext); |
1126 | free (wstr); |
504 | } |
1127 | } |
505 | |
1128 | |
506 | void |
1129 | void |
507 | rxvt_term::tt_write (SV *octets) |
1130 | rxvt_term::tt_write (SV *octets) |
508 | INIT: |
1131 | INIT: |
509 | STRLEN len; |
1132 | STRLEN len; |
510 | char *str = SvPVbyte (octets, len); |
1133 | char *str = SvPVbyte (octets, len); |
511 | C_ARGS: |
1134 | C_ARGS: |
512 | (unsigned char *)str, len |
1135 | str, len |
|
|
1136 | |
|
|
1137 | void |
|
|
1138 | rxvt_term::cmd_parse (SV *octets) |
|
|
1139 | CODE: |
|
|
1140 | { |
|
|
1141 | STRLEN len; |
|
|
1142 | char *str = SvPVbyte (octets, len); |
|
|
1143 | |
|
|
1144 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1145 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1146 | |
|
|
1147 | THIS->cmdbuf_ptr = str; |
|
|
1148 | THIS->cmdbuf_endp = str + len; |
|
|
1149 | |
|
|
1150 | THIS->cmd_parse (); |
|
|
1151 | |
|
|
1152 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1153 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1154 | } |
|
|
1155 | |
|
|
1156 | SV * |
|
|
1157 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
|
|
1158 | CODE: |
|
|
1159 | { |
|
|
1160 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
|
|
1161 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
|
|
1162 | o->self = (HV *)SvRV (RETVAL); |
|
|
1163 | } |
|
|
1164 | OUTPUT: |
|
|
1165 | RETVAL |
|
|
1166 | |
|
|
1167 | MODULE = urxvt PACKAGE = urxvt::overlay |
|
|
1168 | |
|
|
1169 | void |
|
|
1170 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
|
|
1171 | |
|
|
1172 | void |
|
|
1173 | overlay::show () |
|
|
1174 | |
|
|
1175 | void |
|
|
1176 | overlay::hide () |
|
|
1177 | |
|
|
1178 | void |
|
|
1179 | overlay::DESTROY () |
513 | |
1180 | |
514 | MODULE = urxvt PACKAGE = urxvt::timer |
1181 | MODULE = urxvt PACKAGE = urxvt::timer |
515 | |
1182 | |
516 | SV * |
1183 | SV * |
517 | timer::new () |
1184 | timer::new () |
518 | CODE: |
1185 | CODE: |
519 | timer *w = new timer; |
1186 | timer *w = new timer; |
|
|
1187 | w->start (NOW); |
520 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
1188 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
521 | w->self = (HV *)SvRV (RETVAL); |
1189 | w->self = (HV *)SvRV (RETVAL); |
522 | OUTPUT: |
1190 | OUTPUT: |
523 | RETVAL |
1191 | RETVAL |
524 | |
1192 | |
… | |
… | |
532 | |
1200 | |
533 | NV |
1201 | NV |
534 | timer::at () |
1202 | timer::at () |
535 | CODE: |
1203 | CODE: |
536 | RETVAL = THIS->at; |
1204 | RETVAL = THIS->at; |
|
|
1205 | OUTPUT: |
|
|
1206 | RETVAL |
|
|
1207 | |
|
|
1208 | timer * |
|
|
1209 | timer::interval (NV interval) |
|
|
1210 | CODE: |
|
|
1211 | THIS->interval = interval; |
|
|
1212 | RETVAL = THIS; |
537 | OUTPUT: |
1213 | OUTPUT: |
538 | RETVAL |
1214 | RETVAL |
539 | |
1215 | |
540 | timer * |
1216 | timer * |
541 | timer::set (NV tstamp) |
1217 | timer::set (NV tstamp) |