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. |
… | |
… | |
51 | char *str = SvPVutf8 (sv, len); |
51 | char *str = SvPVutf8 (sv, len); |
52 | return rxvt_utf8towcs (str, len); |
52 | return rxvt_utf8towcs (str, len); |
53 | } |
53 | } |
54 | |
54 | |
55 | 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 * |
56 | new_ref (HV *hv, const char *klass) |
68 | new_ref (HV *hv, const char *klass) |
57 | { |
69 | { |
58 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
70 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
59 | } |
71 | } |
60 | |
72 | |
61 | //TODO: use magic |
73 | //TODO: use magic |
62 | static SV * |
74 | static SV * |
63 | newSVptr (void *ptr, const char *klass) |
75 | newSVptr (void *ptr, const char *klass) |
64 | { |
76 | { |
65 | HV *hv = newHV (); |
77 | HV *hv = newHV (); |
66 | hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); |
78 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
67 | 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); |
68 | } |
90 | } |
69 | |
91 | |
70 | static long |
92 | static long |
71 | SvPTR (SV *sv, const char *klass) |
93 | SvPTR (SV *sv, const char *klass) |
72 | { |
94 | { |
73 | if (!sv_derived_from (sv, klass)) |
95 | if (!sv_derived_from (sv, klass)) |
74 | croak ("object of type %s expected", klass); |
96 | croak ("object of type %s expected", klass); |
75 | |
97 | |
76 | IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); |
98 | MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
77 | |
99 | |
78 | if (!iv) |
100 | if (!mg) |
79 | 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); |
80 | |
102 | |
81 | return (long)iv; |
103 | return (long)mg->mg_ptr; |
82 | } |
104 | } |
83 | |
105 | |
84 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
106 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
85 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
107 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
86 | |
108 | |
… | |
… | |
139 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
161 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
140 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
162 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
141 | |
163 | |
142 | struct timer : time_watcher, perl_watcher |
164 | struct timer : time_watcher, perl_watcher |
143 | { |
165 | { |
|
|
166 | tstamp interval; |
|
|
167 | |
144 | timer () |
168 | timer () |
145 | : time_watcher (this, &timer::execute) |
169 | : time_watcher (this, &timer::execute) |
146 | { |
170 | { |
147 | } |
171 | } |
148 | |
172 | |
149 | void execute (time_watcher &w) |
173 | void execute (time_watcher &w) |
150 | { |
174 | { |
|
|
175 | if (interval) |
|
|
176 | start (at + interval); |
|
|
177 | |
151 | invoke ("urxvt::timer", newSVtimer (this)); |
178 | invoke ("urxvt::timer", newSVtimer (this)); |
152 | } |
179 | } |
153 | }; |
180 | }; |
154 | |
181 | |
155 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
182 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
… | |
… | |
165 | void execute (io_watcher &w, short revents) |
192 | void execute (io_watcher &w, short revents) |
166 | { |
193 | { |
167 | invoke ("urxvt::iow", newSViow (this), revents); |
194 | invoke ("urxvt::iow", newSViow (this), revents); |
168 | } |
195 | } |
169 | }; |
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 | |
170 | |
367 | |
171 | ///////////////////////////////////////////////////////////////////////////// |
368 | ///////////////////////////////////////////////////////////////////////////// |
172 | |
369 | |
173 | struct rxvt_perl_interp rxvt_perl; |
370 | struct rxvt_perl_interp rxvt_perl; |
174 | |
371 | |
… | |
… | |
213 | } |
410 | } |
214 | |
411 | |
215 | bool |
412 | bool |
216 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
413 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
217 | { |
414 | { |
218 | if (!perl |
415 | if (!perl) |
219 | || (!should_invoke [htype] && htype != HOOK_INIT && htype != HOOK_DESTROY)) |
|
|
220 | return false; |
416 | return false; |
221 | |
417 | |
222 | if (htype == HOOK_INIT) // first hook ever called |
418 | if (htype == HOOK_INIT) // first hook ever called |
|
|
419 | { |
223 | 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; |
224 | |
443 | |
225 | dSP; |
444 | dSP; |
226 | va_list ap; |
445 | va_list ap; |
227 | |
446 | |
228 | va_start (ap, htype); |
447 | va_start (ap, htype); |
… | |
… | |
246 | |
465 | |
247 | case DT_LONG: |
466 | case DT_LONG: |
248 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
249 | break; |
468 | break; |
250 | |
469 | |
251 | case DT_STRING: |
470 | case DT_STR: |
252 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
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 | break; |
|
|
491 | |
|
|
492 | case DT_XEVENT: |
|
|
493 | { |
|
|
494 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
495 | HV *hv = newHV (); |
|
|
496 | |
|
|
497 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
498 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
499 | # undef set |
|
|
500 | |
|
|
501 | setiv (type, xe->type); |
|
|
502 | setiv (send_event, xe->xany.send_event); |
|
|
503 | setiv (serial, xe->xany.serial); |
|
|
504 | |
|
|
505 | switch (xe->type) |
|
|
506 | { |
|
|
507 | case KeyPress: |
|
|
508 | case KeyRelease: |
|
|
509 | case ButtonPress: |
|
|
510 | case ButtonRelease: |
|
|
511 | case MotionNotify: |
|
|
512 | setiv (time, xe->xmotion.time); |
|
|
513 | setiv (x, xe->xmotion.x); |
|
|
514 | setiv (y, xe->xmotion.y); |
|
|
515 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
516 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
517 | setiv (x_root, xe->xmotion.x_root); |
|
|
518 | setiv (y_root, xe->xmotion.y_root); |
|
|
519 | setiv (state, xe->xmotion.state); |
|
|
520 | break; |
|
|
521 | } |
|
|
522 | |
|
|
523 | switch (xe->type) |
|
|
524 | { |
|
|
525 | case KeyPress: |
|
|
526 | case KeyRelease: |
|
|
527 | setiv (keycode, xe->xkey.keycode); |
|
|
528 | break; |
|
|
529 | |
|
|
530 | case ButtonPress: |
|
|
531 | case ButtonRelease: |
|
|
532 | setiv (button, xe->xbutton.button); |
|
|
533 | break; |
|
|
534 | |
|
|
535 | case MotionNotify: |
|
|
536 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
537 | break; |
|
|
538 | } |
|
|
539 | |
|
|
540 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
541 | } |
253 | break; |
542 | break; |
254 | |
543 | |
255 | case DT_END: |
544 | case DT_END: |
256 | { |
545 | { |
257 | va_end (ap); |
546 | va_end (ap); |
… | |
… | |
273 | if (SvTRUE (ERRSV)) |
562 | if (SvTRUE (ERRSV)) |
274 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
563 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
275 | |
564 | |
276 | if (htype == HOOK_DESTROY) |
565 | if (htype == HOOK_DESTROY) |
277 | { |
566 | { |
278 | // TODO: clear magic |
|
|
279 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
567 | clearSVptr ((SV *)term->self); |
280 | SvREFCNT_dec ((SV *)term->self); |
568 | SvREFCNT_dec ((SV *)term->self); |
281 | } |
569 | } |
282 | |
570 | |
283 | return count; |
571 | return count; |
284 | } |
572 | } |
… | |
… | |
295 | |
583 | |
296 | PROTOTYPES: ENABLE |
584 | PROTOTYPES: ENABLE |
297 | |
585 | |
298 | BOOT: |
586 | BOOT: |
299 | { |
587 | { |
300 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
|
|
301 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); |
588 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
302 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
589 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
303 | set_hookname (INIT); |
590 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
304 | set_hookname (RESET); |
591 | # include "hookinc.h" |
305 | set_hookname (START); |
592 | # undef def |
306 | set_hookname (DESTROY); |
|
|
307 | set_hookname (SEL_BEGIN); |
|
|
308 | set_hookname (SEL_EXTEND); |
|
|
309 | set_hookname (SEL_MAKE); |
|
|
310 | set_hookname (SEL_GRAB); |
|
|
311 | set_hookname (FOCUS_IN); |
|
|
312 | set_hookname (FOCUS_OUT); |
|
|
313 | set_hookname (VIEW_CHANGE); |
|
|
314 | set_hookname (SCROLL_BACK); |
|
|
315 | set_hookname (TTY_ACTIVITY); |
|
|
316 | set_hookname (REFRESH_BEGIN); |
|
|
317 | set_hookname (REFRESH_END); |
|
|
318 | set_hookname (KEYBOARD_COMMAND); |
|
|
319 | |
593 | |
320 | export_const (DEFAULT_RSTYLE); |
594 | export_const (DEFAULT_RSTYLE); |
321 | export_const (OVERLAY_RSTYLE); |
595 | export_const (OVERLAY_RSTYLE); |
322 | export_const (RS_Bold); |
596 | export_const (RS_Bold); |
323 | export_const (RS_Italic); |
597 | export_const (RS_Italic); |
… | |
… | |
326 | export_const (RS_Uline); |
600 | export_const (RS_Uline); |
327 | |
601 | |
328 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
602 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
329 | } |
603 | } |
330 | |
604 | |
|
|
605 | SV * |
|
|
606 | new (...) |
|
|
607 | CODE: |
|
|
608 | { |
|
|
609 | stringvec *argv = new stringvec; |
|
|
610 | bool success; |
|
|
611 | |
|
|
612 | for (int i = 0; i < items ;i++) |
|
|
613 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
614 | |
|
|
615 | rxvt_term *term = new rxvt_term; |
|
|
616 | |
|
|
617 | term->argv = argv; |
|
|
618 | |
|
|
619 | try |
|
|
620 | { |
|
|
621 | if (!term->init (argv->size (), argv->begin ())) |
|
|
622 | term = 0; |
|
|
623 | } |
|
|
624 | catch (const class rxvt_failure_exception &e) |
|
|
625 | { |
|
|
626 | term->destroy (); |
|
|
627 | croak ("exception caught while initializing new terminal instance"); |
|
|
628 | } |
|
|
629 | |
|
|
630 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
|
|
631 | } |
|
|
632 | OUTPUT: |
|
|
633 | RETVAL |
|
|
634 | |
331 | void |
635 | void |
332 | set_should_invoke (int htype, int value) |
636 | set_should_invoke (int htype, int value) |
333 | CODE: |
637 | CODE: |
334 | rxvt_perl.should_invoke [htype] = value; |
638 | rxvt_perl.should_invoke [htype] = value; |
335 | |
639 | |
… | |
… | |
397 | } |
701 | } |
398 | OUTPUT: |
702 | OUTPUT: |
399 | RETVAL |
703 | RETVAL |
400 | |
704 | |
401 | MODULE = urxvt PACKAGE = urxvt::term |
705 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
706 | |
|
|
707 | void |
|
|
708 | rxvt_term::destroy () |
|
|
709 | |
|
|
710 | void |
|
|
711 | rxvt_term::grab (int eventtime) |
|
|
712 | CODE: |
|
|
713 | { |
|
|
714 | return; |
|
|
715 | XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
716 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
717 | GrabModeAsync, GrabModeAsync, None, None, eventtime); |
|
|
718 | XGrabKeyboard (THIS->display->display, THIS->vt, 0, GrabModeAsync, GrabModeAsync, eventtime); |
|
|
719 | } |
402 | |
720 | |
403 | int |
721 | int |
404 | rxvt_term::strwidth (SV *str) |
722 | rxvt_term::strwidth (SV *str) |
405 | CODE: |
723 | CODE: |
406 | { |
724 | { |
… | |
… | |
442 | |
760 | |
443 | rxvt_push_locale (THIS->locale); |
761 | rxvt_push_locale (THIS->locale); |
444 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
762 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
445 | rxvt_pop_locale (); |
763 | rxvt_pop_locale (); |
446 | |
764 | |
447 | char *str = rxvt_wcstoutf8 (wstr); |
765 | RETVAL = wcs2sv (wstr); |
448 | free (wstr); |
766 | free (wstr); |
449 | |
|
|
450 | RETVAL = newSVpv (str, 0); |
|
|
451 | SvUTF8_on (RETVAL); |
|
|
452 | free (str); |
|
|
453 | } |
767 | } |
454 | OUTPUT: |
768 | OUTPUT: |
455 | RETVAL |
769 | RETVAL |
456 | |
770 | |
|
|
771 | # very portable, especially on objects as opposed to pods |
|
|
772 | #define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0) |
|
|
773 | |
|
|
774 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
775 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
776 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
777 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
778 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
779 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
780 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
781 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
782 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
783 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
784 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
785 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
|
|
786 | |
457 | int |
787 | int |
|
|
788 | rxvt_term::width () |
|
|
789 | ALIAS: |
|
|
790 | width = TERM_OFFSET_width |
|
|
791 | height = TERM_OFFSET_height |
|
|
792 | fwidth = TERM_OFFSET_fwidth |
|
|
793 | fheight = TERM_OFFSET_fheight |
|
|
794 | fbase = TERM_OFFSET_fbase |
|
|
795 | nrow = TERM_OFFSET_nrow |
|
|
796 | ncol = TERM_OFFSET_ncol |
|
|
797 | focus = TERM_OFFSET_focus |
|
|
798 | mapped = TERM_OFFSET_mapped |
|
|
799 | saveLines = TERM_OFFSET_saveLines |
|
|
800 | total_rows = TERM_OFFSET_total_rows |
|
|
801 | nsaved = TERM_OFFSET_nsaved |
|
|
802 | CODE: |
|
|
803 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
804 | OUTPUT: |
|
|
805 | RETVAL |
|
|
806 | |
|
|
807 | U32 |
|
|
808 | rxvt_term::parent () |
|
|
809 | CODE: |
|
|
810 | RETVAL = (U32)THIS->parent [0]; |
|
|
811 | OUTPUT: |
|
|
812 | RETVAL |
|
|
813 | |
|
|
814 | U32 |
458 | rxvt_term::nsaved () |
815 | rxvt_term::vt () |
459 | CODE: |
816 | CODE: |
|
|
817 | RETVAL = (U32)THIS->vt; |
|
|
818 | OUTPUT: |
|
|
819 | RETVAL |
|
|
820 | |
|
|
821 | U32 |
|
|
822 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
823 | CODE: |
|
|
824 | { |
460 | RETVAL = THIS->nsaved; |
825 | RETVAL = THIS->rstyle; |
|
|
826 | THIS->rstyle = new_rstyle; |
|
|
827 | } |
461 | OUTPUT: |
828 | OUTPUT: |
462 | RETVAL |
829 | RETVAL |
463 | |
830 | |
464 | int |
831 | int |
465 | rxvt_term::view_start (int newval = -1) |
832 | rxvt_term::view_start (int newval = -1) |
466 | CODE: |
833 | CODE: |
467 | { |
834 | { |
… | |
… | |
474 | } |
841 | } |
475 | } |
842 | } |
476 | OUTPUT: |
843 | OUTPUT: |
477 | RETVAL |
844 | RETVAL |
478 | |
845 | |
479 | int |
|
|
480 | rxvt_term::nrow () |
|
|
481 | CODE: |
|
|
482 | RETVAL = THIS->nrow; |
|
|
483 | OUTPUT: |
|
|
484 | RETVAL |
|
|
485 | |
|
|
486 | int |
|
|
487 | rxvt_term::ncol () |
|
|
488 | CODE: |
|
|
489 | RETVAL = THIS->ncol; |
|
|
490 | OUTPUT: |
|
|
491 | RETVAL |
|
|
492 | |
|
|
493 | void |
846 | void |
494 | rxvt_term::want_refresh () |
847 | rxvt_term::want_refresh () |
495 | CODE: |
848 | CODE: |
496 | THIS->want_refresh = 1; |
849 | THIS->want_refresh = 1; |
497 | |
850 | |
498 | void |
851 | void |
499 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
852 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
500 | PPCODE: |
853 | PPCODE: |
501 | { |
854 | { |
502 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
855 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
503 | croak ("row_number number of out range"); |
856 | XSRETURN_EMPTY; |
504 | |
857 | |
505 | line_t &l = ROW(row_number); |
858 | line_t &l = ROW(row_number); |
506 | |
859 | |
507 | if (GIMME_V != G_VOID) |
860 | if (GIMME_V != G_VOID) |
508 | { |
861 | { |
509 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
862 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
510 | |
863 | |
511 | for (int col = 0; col <THIS->ncol; col++) |
864 | for (int col = 0; col < THIS->ncol; col++) |
512 | wstr [col] = l.t [col]; |
865 | wstr [col] = l.t [col]; |
513 | |
866 | |
514 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
|
|
515 | free (wstr); |
|
|
516 | |
|
|
517 | SV *sv = newSVpv (str, 0); |
|
|
518 | SvUTF8_on (sv); |
|
|
519 | XPUSHs (sv_2mortal (sv)); |
867 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
520 | free (str); |
868 | |
|
|
869 | delete [] wstr; |
521 | } |
870 | } |
522 | |
871 | |
523 | if (new_text) |
872 | if (new_text) |
524 | { |
873 | { |
525 | STRLEN slen; |
|
|
526 | char *str = SvPVutf8 (new_text, slen); |
874 | wchar_t *wstr = sv2wcs (new_text); |
527 | wchar_t *wstr = rxvt_utf8towcs (str, slen); |
|
|
528 | |
875 | |
529 | int len = wcslen (wstr); |
876 | int len = min (wcslen (wstr) - start_ofs, max_len); |
530 | |
877 | |
531 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
878 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
532 | { |
879 | { |
533 | free (wstr); |
880 | free (wstr); |
534 | croak ("new_text extends beyond horizontal margins"); |
881 | croak ("new_text extends beyond horizontal margins"); |
535 | } |
882 | } |
536 | |
883 | |
537 | for (int col = start_col; col < start_col + len; col++) |
884 | for (int col = start_col; col < start_col + len; col++) |
538 | { |
885 | { |
539 | l.t [col] = wstr [col - start_col]; |
886 | l.t [col] = wstr [start_ofs + col - start_col]; |
540 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
887 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
541 | } |
888 | } |
542 | |
889 | |
543 | free (wstr); |
890 | free (wstr); |
544 | } |
891 | } |
545 | } |
892 | } |
546 | |
893 | |
547 | void |
894 | void |
548 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
895 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
549 | PPCODE: |
896 | PPCODE: |
550 | { |
897 | { |
551 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
898 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
552 | croak ("row_number number of out range"); |
899 | XSRETURN_EMPTY; |
553 | |
900 | |
554 | line_t &l = ROW(row_number); |
901 | line_t &l = ROW(row_number); |
555 | |
902 | |
556 | if (GIMME_V != G_VOID) |
903 | if (GIMME_V != G_VOID) |
557 | { |
904 | { |
… | |
… | |
568 | { |
915 | { |
569 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
916 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
570 | croak ("new_rend must be arrayref"); |
917 | croak ("new_rend must be arrayref"); |
571 | |
918 | |
572 | AV *av = (AV *)SvRV (new_rend); |
919 | AV *av = (AV *)SvRV (new_rend); |
573 | int len = av_len (av) + 1; |
920 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
574 | |
921 | |
575 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
922 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
576 | croak ("new_rend array extends beyond horizontal margins"); |
923 | croak ("new_rend array extends beyond horizontal margins"); |
577 | |
924 | |
578 | for (int col = start_col; col < start_col + len; col++) |
925 | for (int col = start_col; col < start_col + len; col++) |
579 | { |
926 | { |
580 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
927 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
581 | |
928 | |
582 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
929 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
583 | } |
930 | } |
584 | } |
931 | } |
585 | } |
932 | } |
586 | |
933 | |
587 | int |
934 | int |
588 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
935 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
589 | CODE: |
936 | CODE: |
590 | { |
937 | { |
591 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
938 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
592 | croak ("row_number number of out range"); |
939 | XSRETURN_EMPTY; |
593 | |
940 | |
594 | line_t &l = ROW(row_number); |
941 | line_t &l = ROW(row_number); |
595 | RETVAL = l.l; |
942 | RETVAL = l.l; |
596 | |
943 | |
597 | if (new_length >= -1) |
944 | if (new_length >= 0) |
598 | l.l = new_length; |
945 | l.l = new_length; |
599 | } |
946 | } |
600 | OUTPUT: |
947 | OUTPUT: |
601 | RETVAL |
948 | RETVAL |
602 | |
949 | |
|
|
950 | bool |
|
|
951 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
|
|
952 | CODE: |
|
|
953 | { |
|
|
954 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
955 | XSRETURN_EMPTY; |
|
|
956 | |
|
|
957 | line_t &l = ROW(row_number); |
|
|
958 | RETVAL = l.is_longer (); |
|
|
959 | |
|
|
960 | if (new_is_longer >= 0) |
|
|
961 | l.is_longer (new_is_longer); |
|
|
962 | } |
|
|
963 | OUTPUT: |
|
|
964 | RETVAL |
|
|
965 | |
603 | SV * |
966 | SV * |
604 | rxvt_term::special_encode (SV *str) |
967 | rxvt_term::special_encode (SV *string) |
605 | CODE: |
968 | CODE: |
606 | abort ();//TODO |
969 | { |
|
|
970 | wchar_t *wstr = sv2wcs (string); |
|
|
971 | int wlen = wcslen (wstr); |
|
|
972 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
973 | |
|
|
974 | rxvt_push_locale (THIS->locale); |
|
|
975 | |
|
|
976 | wchar_t *r = rstr; |
|
|
977 | for (wchar_t *s = wstr; *s; s++) |
|
|
978 | if (wcwidth (*s) == 0) |
|
|
979 | { |
|
|
980 | if (r == rstr) |
|
|
981 | croak ("leading combining character unencodable"); |
|
|
982 | |
|
|
983 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
984 | if (n == NOCHAR) |
|
|
985 | n = rxvt_composite.compose (r[-1], *s); |
|
|
986 | |
|
|
987 | r[-1] = n; |
|
|
988 | } |
|
|
989 | #if !UNICODE_3 |
|
|
990 | else if (*s >= 0x10000) |
|
|
991 | *r++ = rxvt_composite.compose (*s); |
|
|
992 | #endif |
|
|
993 | else |
|
|
994 | *r++ = *s; |
|
|
995 | |
|
|
996 | rxvt_pop_locale (); |
|
|
997 | |
|
|
998 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
999 | |
|
|
1000 | delete [] rstr; |
|
|
1001 | } |
|
|
1002 | OUTPUT: |
|
|
1003 | RETVAL |
607 | |
1004 | |
608 | SV * |
1005 | SV * |
609 | rxvt_term::special_decode (SV *str) |
1006 | rxvt_term::special_decode (SV *text) |
610 | CODE: |
1007 | CODE: |
611 | abort ();//TODO |
1008 | { |
|
|
1009 | wchar_t *wstr = sv2wcs (text); |
|
|
1010 | int wlen = wcslen (wstr); |
|
|
1011 | int dlen = 0; |
|
|
1012 | |
|
|
1013 | // find length |
|
|
1014 | for (wchar_t *s = wstr; *s; s++) |
|
|
1015 | if (*s == NOCHAR) |
|
|
1016 | ; |
|
|
1017 | else if (IS_COMPOSE (*s)) |
|
|
1018 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1019 | else |
|
|
1020 | dlen++; |
|
|
1021 | |
|
|
1022 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1023 | |
|
|
1024 | // decode |
|
|
1025 | wchar_t *r = rstr; |
|
|
1026 | for (wchar_t *s = wstr; *s; s++) |
|
|
1027 | if (*s == NOCHAR) |
|
|
1028 | ; |
|
|
1029 | else if (IS_COMPOSE (*s)) |
|
|
1030 | r += rxvt_composite.expand (*s, r); |
|
|
1031 | else |
|
|
1032 | *r++ = *s; |
|
|
1033 | |
|
|
1034 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1035 | |
|
|
1036 | delete [] rstr; |
|
|
1037 | } |
|
|
1038 | OUTPUT: |
|
|
1039 | RETVAL |
612 | |
1040 | |
613 | void |
1041 | void |
614 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1042 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
615 | PPCODE: |
1043 | PPCODE: |
616 | { |
1044 | { |
617 | struct resval { const char *name; int value; } rslist [] = { |
1045 | struct resval { const char *name; int value; } rslist [] = { |
618 | # define Rs_def(name) { # name, Rs_ ## name }, |
1046 | # define def(name) { # name, Rs_ ## name }, |
619 | # define Rs_reserve(name,count) |
1047 | # define reserve(name,count) |
620 | # include "rsinc.h" |
1048 | # include "rsinc.h" |
621 | # undef Rs_def |
1049 | # undef def |
622 | # undef Rs_reserve |
1050 | # undef reserve |
623 | }; |
1051 | }; |
624 | |
1052 | |
625 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1053 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
626 | |
1054 | |
627 | do { |
1055 | do { |
… | |
… | |
649 | THIS->rs [index] = 0; |
1077 | THIS->rs [index] = 0; |
650 | } |
1078 | } |
651 | } |
1079 | } |
652 | |
1080 | |
653 | void |
1081 | void |
654 | rxvt_term::selection_mark (...) |
1082 | rxvt_term::cur (...) |
655 | PROTOTYPE: $;$$ |
1083 | PROTOTYPE: $;$$ |
656 | ALIAS: |
1084 | ALIAS: |
|
|
1085 | screen_cur = 0 |
657 | selection_beg = 1 |
1086 | selection_beg = 1 |
658 | selection_end = 2 |
1087 | selection_end = 2 |
|
|
1088 | selection_mark = 3 |
659 | PPCODE: |
1089 | PPCODE: |
660 | { |
1090 | { |
661 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1091 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1092 | : ix == 1 ? THIS->selection.beg |
662 | : ix == 2 ? THIS->selection.end |
1093 | : ix == 2 ? THIS->selection.end |
663 | : THIS->selection.mark; |
1094 | : THIS->selection.mark; |
664 | |
1095 | |
665 | if (GIMME_V != G_VOID) |
1096 | if (GIMME_V != G_VOID) |
666 | { |
1097 | { |
667 | EXTEND (SP, 2); |
1098 | EXTEND (SP, 2); |
668 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1099 | PUSHs (sv_2mortal (newSViv (rc.row))); |
669 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1100 | PUSHs (sv_2mortal (newSViv (rc.col))); |
670 | } |
1101 | } |
671 | |
1102 | |
672 | if (items == 3) |
1103 | if (items == 3) |
673 | { |
1104 | { |
674 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1105 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
675 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1106 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
676 | |
1107 | |
677 | if (ix) |
1108 | if (ix) |
678 | THIS->want_refresh = 1; |
1109 | THIS->want_refresh = 1; |
679 | } |
1110 | } |
680 | } |
1111 | } |
681 | |
1112 | |
682 | int |
1113 | int |
683 | rxvt_term::selection_grab (int eventtime) |
1114 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
684 | |
1115 | |
685 | void |
1116 | void |
686 | rxvt_term::selection (SV *newtext = 0) |
1117 | rxvt_term::selection (SV *newtext = 0) |
687 | PPCODE: |
1118 | PPCODE: |
688 | { |
1119 | { |
689 | if (GIMME_V != G_VOID) |
1120 | if (GIMME_V != G_VOID) |
690 | { |
1121 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
691 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
692 | SV *sv = newSVpv (sel, 0); |
|
|
693 | SvUTF8_on (sv); |
|
|
694 | free (sel); |
|
|
695 | XPUSHs (sv_2mortal (sv)); |
|
|
696 | } |
|
|
697 | |
1122 | |
698 | if (newtext) |
1123 | if (newtext) |
699 | { |
1124 | { |
700 | free (THIS->selection.text); |
1125 | free (THIS->selection.text); |
701 | |
1126 | |
702 | THIS->selection.text = sv2wcs (newtext); |
1127 | THIS->selection.text = sv2wcs (newtext); |
703 | THIS->selection.len = wcslen (THIS->selection.text); |
1128 | THIS->selection.len = wcslen (THIS->selection.text); |
704 | } |
1129 | } |
705 | } |
1130 | } |
706 | |
|
|
707 | void |
|
|
708 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
|
|
709 | |
1131 | |
710 | void |
1132 | void |
711 | rxvt_term::scr_overlay_off () |
1133 | rxvt_term::scr_add_lines (SV *string) |
712 | |
|
|
713 | void |
|
|
714 | rxvt_term::scr_overlay_set_char (int x, int y, U32 text, U32 rend = OVERLAY_RSTYLE) |
|
|
715 | CODE: |
1134 | CODE: |
716 | THIS->scr_overlay_set (x, y, text, rend); |
|
|
717 | |
|
|
718 | void |
|
|
719 | rxvt_term::scr_overlay_set (int x, int y, SV *text) |
|
|
720 | CODE: |
|
|
721 | { |
1135 | { |
722 | wchar_t *wtext = sv2wcs (text); |
1136 | wchar_t *wstr = sv2wcs (string); |
723 | THIS->scr_overlay_set (x, y, wtext); |
1137 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
724 | free (wtext); |
1138 | free (wstr); |
725 | } |
1139 | } |
726 | |
1140 | |
727 | void |
1141 | void |
728 | rxvt_term::tt_write (SV *octets) |
1142 | rxvt_term::tt_write (SV *octets) |
729 | INIT: |
1143 | INIT: |
730 | STRLEN len; |
1144 | STRLEN len; |
731 | char *str = SvPVbyte (octets, len); |
1145 | char *str = SvPVbyte (octets, len); |
732 | C_ARGS: |
1146 | C_ARGS: |
733 | (unsigned char *)str, len |
1147 | str, len |
|
|
1148 | |
|
|
1149 | void |
|
|
1150 | rxvt_term::cmd_parse (SV *octets) |
|
|
1151 | CODE: |
|
|
1152 | { |
|
|
1153 | STRLEN len; |
|
|
1154 | char *str = SvPVbyte (octets, len); |
|
|
1155 | |
|
|
1156 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1157 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1158 | |
|
|
1159 | THIS->cmdbuf_ptr = str; |
|
|
1160 | THIS->cmdbuf_endp = str + len; |
|
|
1161 | |
|
|
1162 | rxvt_push_locale (THIS->locale); |
|
|
1163 | THIS->cmd_parse (); |
|
|
1164 | rxvt_pop_locale (); |
|
|
1165 | |
|
|
1166 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1167 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1168 | } |
|
|
1169 | |
|
|
1170 | SV * |
|
|
1171 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
|
|
1172 | CODE: |
|
|
1173 | { |
|
|
1174 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
|
|
1175 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
|
|
1176 | o->self = (HV *)SvRV (RETVAL); |
|
|
1177 | } |
|
|
1178 | OUTPUT: |
|
|
1179 | RETVAL |
|
|
1180 | |
|
|
1181 | MODULE = urxvt PACKAGE = urxvt::overlay |
|
|
1182 | |
|
|
1183 | void |
|
|
1184 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
|
|
1185 | |
|
|
1186 | void |
|
|
1187 | overlay::show () |
|
|
1188 | |
|
|
1189 | void |
|
|
1190 | overlay::hide () |
|
|
1191 | |
|
|
1192 | void |
|
|
1193 | overlay::DESTROY () |
734 | |
1194 | |
735 | MODULE = urxvt PACKAGE = urxvt::timer |
1195 | MODULE = urxvt PACKAGE = urxvt::timer |
736 | |
1196 | |
737 | SV * |
1197 | SV * |
738 | timer::new () |
1198 | timer::new () |
739 | CODE: |
1199 | CODE: |
740 | timer *w = new timer; |
1200 | timer *w = new timer; |
|
|
1201 | w->start (NOW); |
741 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
1202 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
742 | w->self = (HV *)SvRV (RETVAL); |
1203 | w->self = (HV *)SvRV (RETVAL); |
743 | OUTPUT: |
1204 | OUTPUT: |
744 | RETVAL |
1205 | RETVAL |
745 | |
1206 | |
… | |
… | |
753 | |
1214 | |
754 | NV |
1215 | NV |
755 | timer::at () |
1216 | timer::at () |
756 | CODE: |
1217 | CODE: |
757 | RETVAL = THIS->at; |
1218 | RETVAL = THIS->at; |
|
|
1219 | OUTPUT: |
|
|
1220 | RETVAL |
|
|
1221 | |
|
|
1222 | timer * |
|
|
1223 | timer::interval (NV interval) |
|
|
1224 | CODE: |
|
|
1225 | THIS->interval = interval; |
|
|
1226 | RETVAL = THIS; |
758 | OUTPUT: |
1227 | OUTPUT: |
759 | RETVAL |
1228 | RETVAL |
760 | |
1229 | |
761 | timer * |
1230 | timer * |
762 | timer::set (NV tstamp) |
1231 | timer::set (NV tstamp) |