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 | |
… | |
… | |
212 | { |
414 | { |
213 | if (!perl) |
415 | if (!perl) |
214 | return false; |
416 | return false; |
215 | |
417 | |
216 | if (htype == HOOK_INIT) // first hook ever called |
418 | if (htype == HOOK_INIT) // first hook ever called |
|
|
419 | { |
217 | 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 |
218 | else if (htype == HOOK_DESTROY) |
425 | else if (htype == HOOK_DESTROY) |
219 | { |
426 | { |
220 | // TODO: clear magic |
427 | // handled later |
221 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
|
|
222 | SvREFCNT_dec ((SV *)term->self); |
|
|
223 | } |
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)); |
224 | |
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 | } |
225 | if (!should_invoke [htype]) |
441 | else if (!should_invoke [htype]) |
226 | return false; |
442 | return false; |
227 | |
443 | |
228 | dSP; |
444 | dSP; |
229 | va_list ap; |
445 | va_list ap; |
230 | |
446 | |
231 | va_start (ap, htype); |
447 | va_start (ap, htype); |
232 | |
448 | |
… | |
… | |
249 | |
465 | |
250 | case DT_LONG: |
466 | case DT_LONG: |
251 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
252 | break; |
468 | break; |
253 | |
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 | 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 | } |
|
|
542 | break; |
|
|
543 | |
254 | case DT_END: |
544 | case DT_END: |
255 | { |
545 | { |
256 | va_end (ap); |
546 | va_end (ap); |
257 | |
547 | |
258 | PUTBACK; |
548 | PUTBACK; |
… | |
… | |
270 | LEAVE; |
560 | LEAVE; |
271 | |
561 | |
272 | if (SvTRUE (ERRSV)) |
562 | if (SvTRUE (ERRSV)) |
273 | 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)); |
274 | |
564 | |
|
|
565 | if (htype == HOOK_DESTROY) |
|
|
566 | { |
|
|
567 | clearSVptr ((SV *)term->self); |
|
|
568 | SvREFCNT_dec ((SV *)term->self); |
|
|
569 | } |
|
|
570 | |
275 | return count; |
571 | return count; |
276 | } |
572 | } |
277 | |
573 | |
278 | default: |
574 | default: |
279 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
575 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
… | |
… | |
287 | |
583 | |
288 | PROTOTYPES: ENABLE |
584 | PROTOTYPES: ENABLE |
289 | |
585 | |
290 | BOOT: |
586 | BOOT: |
291 | { |
587 | { |
292 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
588 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
293 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
589 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
294 | set_hookname (LOAD); |
590 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
295 | set_hookname (INIT); |
591 | # include "hookinc.h" |
296 | set_hookname (RESET); |
592 | # undef def |
297 | set_hookname (START); |
593 | |
298 | set_hookname (DESTROY); |
594 | export_const (DEFAULT_RSTYLE); |
299 | set_hookname (SEL_BEGIN); |
595 | export_const (OVERLAY_RSTYLE); |
300 | set_hookname (SEL_EXTEND); |
596 | export_const (RS_Bold); |
301 | set_hookname (SEL_MAKE); |
597 | export_const (RS_Italic); |
302 | set_hookname (SEL_GRAB); |
598 | export_const (RS_Blink); |
303 | set_hookname (FOCUS_IN); |
599 | export_const (RS_RVid); |
304 | set_hookname (FOCUS_OUT); |
600 | 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 | |
601 | |
311 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
602 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
312 | } |
603 | } |
313 | |
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 | |
314 | void |
635 | void |
315 | set_should_invoke (int htype, int value) |
636 | set_should_invoke (int htype, int value) |
316 | CODE: |
637 | CODE: |
317 | rxvt_perl.should_invoke [htype] = value; |
638 | rxvt_perl.should_invoke [htype] = value; |
318 | |
639 | |
… | |
… | |
323 | |
644 | |
324 | void |
645 | void |
325 | fatal (const char *msg) |
646 | fatal (const char *msg) |
326 | CODE: |
647 | CODE: |
327 | rxvt_fatal ("%s", msg); |
648 | rxvt_fatal ("%s", msg); |
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 | |
649 | |
340 | NV |
650 | NV |
341 | NOW () |
651 | NOW () |
342 | CODE: |
652 | CODE: |
343 | RETVAL = NOW; |
653 | RETVAL = NOW; |
344 | OUTPUT: |
654 | OUTPUT: |
345 | RETVAL |
655 | RETVAL |
346 | |
656 | |
|
|
657 | int |
|
|
658 | GET_BASEFG (int rend) |
|
|
659 | CODE: |
|
|
660 | RETVAL = GET_BASEFG (rend); |
|
|
661 | OUTPUT: |
|
|
662 | RETVAL |
|
|
663 | |
|
|
664 | int |
|
|
665 | GET_BASEBG (int rend) |
|
|
666 | CODE: |
|
|
667 | RETVAL = GET_BASEBG (rend); |
|
|
668 | OUTPUT: |
|
|
669 | RETVAL |
|
|
670 | |
|
|
671 | int |
|
|
672 | SET_FGCOLOR (int rend, int new_color) |
|
|
673 | CODE: |
|
|
674 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
675 | OUTPUT: |
|
|
676 | RETVAL |
|
|
677 | |
|
|
678 | int |
|
|
679 | SET_BGCOLOR (int rend, int new_color) |
|
|
680 | CODE: |
|
|
681 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
682 | OUTPUT: |
|
|
683 | RETVAL |
|
|
684 | |
|
|
685 | int |
|
|
686 | GET_CUSTOM (int rend) |
|
|
687 | CODE: |
|
|
688 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
689 | OUTPUT: |
|
|
690 | RETVAL |
|
|
691 | |
|
|
692 | int |
|
|
693 | SET_CUSTOM (int rend, int new_value) |
|
|
694 | CODE: |
|
|
695 | { |
|
|
696 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
697 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
698 | |
|
|
699 | RETVAL = (rend & ~RS_customMask) |
|
|
700 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
701 | } |
|
|
702 | OUTPUT: |
|
|
703 | RETVAL |
|
|
704 | |
347 | MODULE = urxvt PACKAGE = urxvt::term |
705 | MODULE = urxvt PACKAGE = urxvt::term |
348 | |
706 | |
349 | void |
707 | void |
350 | rxvt_term::selection_mark (...) |
708 | rxvt_term::destroy () |
|
|
709 | |
|
|
710 | int |
|
|
711 | rxvt_term::strwidth (SV *str) |
|
|
712 | CODE: |
|
|
713 | { |
|
|
714 | wchar_t *wstr = sv2wcs (str); |
|
|
715 | |
|
|
716 | rxvt_push_locale (THIS->locale); |
|
|
717 | RETVAL = wcswidth (wstr, wcslen (wstr)); |
|
|
718 | rxvt_pop_locale (); |
|
|
719 | |
|
|
720 | free (wstr); |
|
|
721 | } |
|
|
722 | OUTPUT: |
|
|
723 | RETVAL |
|
|
724 | |
|
|
725 | SV * |
|
|
726 | rxvt_term::locale_encode (SV *str) |
|
|
727 | CODE: |
|
|
728 | { |
|
|
729 | wchar_t *wstr = sv2wcs (str); |
|
|
730 | |
|
|
731 | rxvt_push_locale (THIS->locale); |
|
|
732 | char *mbstr = rxvt_wcstombs (wstr); |
|
|
733 | rxvt_pop_locale (); |
|
|
734 | |
|
|
735 | free (wstr); |
|
|
736 | |
|
|
737 | RETVAL = newSVpv (mbstr, 0); |
|
|
738 | free (mbstr); |
|
|
739 | } |
|
|
740 | OUTPUT: |
|
|
741 | RETVAL |
|
|
742 | |
|
|
743 | SV * |
|
|
744 | rxvt_term::locale_decode (SV *octets) |
|
|
745 | CODE: |
|
|
746 | { |
|
|
747 | STRLEN len; |
|
|
748 | char *data = SvPVbyte (octets, len); |
|
|
749 | |
|
|
750 | rxvt_push_locale (THIS->locale); |
|
|
751 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
|
|
752 | rxvt_pop_locale (); |
|
|
753 | |
|
|
754 | RETVAL = wcs2sv (wstr); |
|
|
755 | free (wstr); |
|
|
756 | } |
|
|
757 | OUTPUT: |
|
|
758 | RETVAL |
|
|
759 | |
|
|
760 | # very portable, especially on objects as opposed to pods |
|
|
761 | #define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0) |
|
|
762 | |
|
|
763 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
764 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
765 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
766 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
767 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
768 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
769 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
770 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
771 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
772 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
773 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
774 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
|
|
775 | |
|
|
776 | int |
|
|
777 | rxvt_term::width () |
|
|
778 | ALIAS: |
|
|
779 | width = TERM_OFFSET_width |
|
|
780 | height = TERM_OFFSET_height |
|
|
781 | fwidth = TERM_OFFSET_fwidth |
|
|
782 | fheight = TERM_OFFSET_fheight |
|
|
783 | fbase = TERM_OFFSET_fbase |
|
|
784 | nrow = TERM_OFFSET_nrow |
|
|
785 | ncol = TERM_OFFSET_ncol |
|
|
786 | focus = TERM_OFFSET_focus |
|
|
787 | mapped = TERM_OFFSET_mapped |
|
|
788 | saveLines = TERM_OFFSET_saveLines |
|
|
789 | total_rows = TERM_OFFSET_total_rows |
|
|
790 | nsaved = TERM_OFFSET_nsaved |
|
|
791 | CODE: |
|
|
792 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
793 | OUTPUT: |
|
|
794 | RETVAL |
|
|
795 | |
|
|
796 | U32 |
|
|
797 | rxvt_term::parent () |
|
|
798 | CODE: |
|
|
799 | RETVAL = (U32)THIS->parent [0]; |
|
|
800 | OUTPUT: |
|
|
801 | RETVAL |
|
|
802 | |
|
|
803 | U32 |
|
|
804 | rxvt_term::vt () |
|
|
805 | CODE: |
|
|
806 | RETVAL = (U32)THIS->vt; |
|
|
807 | OUTPUT: |
|
|
808 | RETVAL |
|
|
809 | |
|
|
810 | U32 |
|
|
811 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
812 | CODE: |
|
|
813 | { |
|
|
814 | RETVAL = THIS->rstyle; |
|
|
815 | THIS->rstyle = new_rstyle; |
|
|
816 | } |
|
|
817 | OUTPUT: |
|
|
818 | RETVAL |
|
|
819 | |
|
|
820 | int |
|
|
821 | rxvt_term::view_start (int newval = -1) |
|
|
822 | CODE: |
|
|
823 | { |
|
|
824 | RETVAL = THIS->view_start; |
|
|
825 | |
|
|
826 | if (newval >= 0) |
|
|
827 | { |
|
|
828 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
829 | THIS->scr_changeview (RETVAL); |
|
|
830 | } |
|
|
831 | } |
|
|
832 | OUTPUT: |
|
|
833 | RETVAL |
|
|
834 | |
|
|
835 | void |
|
|
836 | rxvt_term::want_refresh () |
|
|
837 | CODE: |
|
|
838 | THIS->want_refresh = 1; |
|
|
839 | |
|
|
840 | void |
|
|
841 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
|
|
842 | PPCODE: |
|
|
843 | { |
|
|
844 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
845 | XSRETURN_EMPTY; |
|
|
846 | |
|
|
847 | line_t &l = ROW(row_number); |
|
|
848 | |
|
|
849 | if (GIMME_V != G_VOID) |
|
|
850 | { |
|
|
851 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
|
|
852 | |
|
|
853 | for (int col = 0; col < THIS->ncol; col++) |
|
|
854 | wstr [col] = l.t [col]; |
|
|
855 | |
|
|
856 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
|
|
857 | |
|
|
858 | delete [] wstr; |
|
|
859 | } |
|
|
860 | |
|
|
861 | if (new_text) |
|
|
862 | { |
|
|
863 | wchar_t *wstr = sv2wcs (new_text); |
|
|
864 | |
|
|
865 | int len = min (wcslen (wstr) - start_ofs, max_len); |
|
|
866 | |
|
|
867 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
868 | { |
|
|
869 | free (wstr); |
|
|
870 | croak ("new_text extends beyond horizontal margins"); |
|
|
871 | } |
|
|
872 | |
|
|
873 | for (int col = start_col; col < start_col + len; col++) |
|
|
874 | { |
|
|
875 | l.t [col] = wstr [start_ofs + col - start_col]; |
|
|
876 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
|
|
877 | } |
|
|
878 | |
|
|
879 | free (wstr); |
|
|
880 | } |
|
|
881 | } |
|
|
882 | |
|
|
883 | void |
|
|
884 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
|
|
885 | PPCODE: |
|
|
886 | { |
|
|
887 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
888 | XSRETURN_EMPTY; |
|
|
889 | |
|
|
890 | line_t &l = ROW(row_number); |
|
|
891 | |
|
|
892 | if (GIMME_V != G_VOID) |
|
|
893 | { |
|
|
894 | AV *av = newAV (); |
|
|
895 | |
|
|
896 | av_extend (av, THIS->ncol - 1); |
|
|
897 | for (int col = 0; col < THIS->ncol; col++) |
|
|
898 | av_store (av, col, newSViv (l.r [col])); |
|
|
899 | |
|
|
900 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
901 | } |
|
|
902 | |
|
|
903 | if (new_rend) |
|
|
904 | { |
|
|
905 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
|
|
906 | croak ("new_rend must be arrayref"); |
|
|
907 | |
|
|
908 | AV *av = (AV *)SvRV (new_rend); |
|
|
909 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
|
|
910 | |
|
|
911 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
912 | croak ("new_rend array extends beyond horizontal margins"); |
|
|
913 | |
|
|
914 | for (int col = start_col; col < start_col + len; col++) |
|
|
915 | { |
|
|
916 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
|
|
917 | |
|
|
918 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
|
|
919 | } |
|
|
920 | } |
|
|
921 | } |
|
|
922 | |
|
|
923 | int |
|
|
924 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
|
|
925 | CODE: |
|
|
926 | { |
|
|
927 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
928 | XSRETURN_EMPTY; |
|
|
929 | |
|
|
930 | line_t &l = ROW(row_number); |
|
|
931 | RETVAL = l.l; |
|
|
932 | |
|
|
933 | if (new_length >= 0) |
|
|
934 | l.l = new_length; |
|
|
935 | } |
|
|
936 | OUTPUT: |
|
|
937 | RETVAL |
|
|
938 | |
|
|
939 | bool |
|
|
940 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
|
|
941 | CODE: |
|
|
942 | { |
|
|
943 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
944 | XSRETURN_EMPTY; |
|
|
945 | |
|
|
946 | line_t &l = ROW(row_number); |
|
|
947 | RETVAL = l.is_longer (); |
|
|
948 | |
|
|
949 | if (new_is_longer >= 0) |
|
|
950 | l.is_longer (new_is_longer); |
|
|
951 | } |
|
|
952 | OUTPUT: |
|
|
953 | RETVAL |
|
|
954 | |
|
|
955 | SV * |
|
|
956 | rxvt_term::special_encode (SV *string) |
|
|
957 | CODE: |
|
|
958 | { |
|
|
959 | wchar_t *wstr = sv2wcs (string); |
|
|
960 | int wlen = wcslen (wstr); |
|
|
961 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
962 | |
|
|
963 | rxvt_push_locale (THIS->locale); |
|
|
964 | |
|
|
965 | wchar_t *r = rstr; |
|
|
966 | for (wchar_t *s = wstr; *s; s++) |
|
|
967 | if (wcwidth (*s) == 0) |
|
|
968 | { |
|
|
969 | if (r == rstr) |
|
|
970 | croak ("leading combining character unencodable"); |
|
|
971 | |
|
|
972 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
973 | if (n == NOCHAR) |
|
|
974 | n = rxvt_composite.compose (r[-1], *s); |
|
|
975 | |
|
|
976 | r[-1] = n; |
|
|
977 | } |
|
|
978 | #if !UNICODE_3 |
|
|
979 | else if (*s >= 0x10000) |
|
|
980 | *r++ = rxvt_composite.compose (*s); |
|
|
981 | #endif |
|
|
982 | else |
|
|
983 | *r++ = *s; |
|
|
984 | |
|
|
985 | rxvt_pop_locale (); |
|
|
986 | |
|
|
987 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
988 | |
|
|
989 | delete [] rstr; |
|
|
990 | } |
|
|
991 | OUTPUT: |
|
|
992 | RETVAL |
|
|
993 | |
|
|
994 | SV * |
|
|
995 | rxvt_term::special_decode (SV *text) |
|
|
996 | CODE: |
|
|
997 | { |
|
|
998 | wchar_t *wstr = sv2wcs (text); |
|
|
999 | int wlen = wcslen (wstr); |
|
|
1000 | int dlen = 0; |
|
|
1001 | |
|
|
1002 | // find length |
|
|
1003 | for (wchar_t *s = wstr; *s; s++) |
|
|
1004 | if (*s == NOCHAR) |
|
|
1005 | ; |
|
|
1006 | else if (IS_COMPOSE (*s)) |
|
|
1007 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1008 | else |
|
|
1009 | dlen++; |
|
|
1010 | |
|
|
1011 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1012 | |
|
|
1013 | // decode |
|
|
1014 | wchar_t *r = rstr; |
|
|
1015 | for (wchar_t *s = wstr; *s; s++) |
|
|
1016 | if (*s == NOCHAR) |
|
|
1017 | ; |
|
|
1018 | else if (IS_COMPOSE (*s)) |
|
|
1019 | r += rxvt_composite.expand (*s, r); |
|
|
1020 | else |
|
|
1021 | *r++ = *s; |
|
|
1022 | |
|
|
1023 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1024 | |
|
|
1025 | delete [] rstr; |
|
|
1026 | } |
|
|
1027 | OUTPUT: |
|
|
1028 | RETVAL |
|
|
1029 | |
|
|
1030 | void |
|
|
1031 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
|
|
1032 | PPCODE: |
|
|
1033 | { |
|
|
1034 | struct resval { const char *name; int value; } rslist [] = { |
|
|
1035 | # define def(name) { # name, Rs_ ## name }, |
|
|
1036 | # define reserve(name,count) |
|
|
1037 | # include "rsinc.h" |
|
|
1038 | # undef def |
|
|
1039 | # undef reserve |
|
|
1040 | }; |
|
|
1041 | |
|
|
1042 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
|
|
1043 | |
|
|
1044 | do { |
|
|
1045 | if (rs-- == rslist) |
|
|
1046 | croak ("no such resource '%s', requested", name); |
|
|
1047 | } while (strcmp (name, rs->name)); |
|
|
1048 | |
|
|
1049 | index += rs->value; |
|
|
1050 | |
|
|
1051 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
|
|
1052 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
|
|
1053 | |
|
|
1054 | if (GIMME_V != G_VOID) |
|
|
1055 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
|
|
1056 | |
|
|
1057 | if (newval) |
|
|
1058 | { |
|
|
1059 | if (SvOK (newval)) |
|
|
1060 | { |
|
|
1061 | char *str = strdup (SvPVbyte_nolen (newval)); |
|
|
1062 | THIS->rs [index] = str; |
|
|
1063 | THIS->allocated.push_back (str); |
|
|
1064 | } |
|
|
1065 | else |
|
|
1066 | THIS->rs [index] = 0; |
|
|
1067 | } |
|
|
1068 | } |
|
|
1069 | |
|
|
1070 | void |
|
|
1071 | rxvt_term::cur (...) |
351 | PROTOTYPE: $;$$ |
1072 | PROTOTYPE: $;$$ |
352 | ALIAS: |
1073 | ALIAS: |
|
|
1074 | screen_cur = 0 |
353 | selection_beg = 1 |
1075 | selection_beg = 1 |
354 | selection_end = 2 |
1076 | selection_end = 2 |
|
|
1077 | selection_mark = 3 |
355 | PPCODE: |
1078 | PPCODE: |
356 | { |
1079 | { |
357 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1080 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1081 | : ix == 1 ? THIS->selection.beg |
358 | : ix == 2 ? THIS->selection.end |
1082 | : ix == 2 ? THIS->selection.end |
359 | : THIS->selection.mark; |
1083 | : THIS->selection.mark; |
360 | |
1084 | |
361 | if (GIMME_V != G_VOID) |
1085 | if (GIMME_V != G_VOID) |
362 | { |
1086 | { |
363 | EXTEND (SP, 2); |
1087 | EXTEND (SP, 2); |
364 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1088 | PUSHs (sv_2mortal (newSViv (rc.row))); |
365 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1089 | PUSHs (sv_2mortal (newSViv (rc.col))); |
366 | } |
1090 | } |
367 | |
1091 | |
368 | if (items == 3) |
1092 | if (items == 3) |
369 | { |
1093 | { |
370 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1094 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
371 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1095 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
372 | |
1096 | |
373 | if (ix) |
1097 | if (ix) |
374 | THIS->want_refresh = 1; |
1098 | THIS->want_refresh = 1; |
375 | } |
1099 | } |
376 | } |
1100 | } |
377 | |
1101 | |
378 | int |
1102 | int |
379 | rxvt_term::selection_grab (int eventtime) |
1103 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
380 | |
1104 | |
381 | void |
1105 | void |
382 | rxvt_term::selection (SV *newtext = 0) |
1106 | rxvt_term::selection (SV *newtext = 0) |
383 | PPCODE: |
1107 | PPCODE: |
384 | { |
1108 | { |
385 | if (GIMME_V != G_VOID) |
1109 | if (GIMME_V != G_VOID) |
386 | { |
1110 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
387 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
388 | SV *sv = newSVpv (sel, 0); |
|
|
389 | SvUTF8_on (sv); |
|
|
390 | free (sel); |
|
|
391 | XPUSHs (sv_2mortal (sv)); |
|
|
392 | } |
|
|
393 | |
1111 | |
394 | if (newtext) |
1112 | if (newtext) |
395 | { |
1113 | { |
396 | free (THIS->selection.text); |
1114 | free (THIS->selection.text); |
397 | |
1115 | |
398 | THIS->selection.text = sv2wcs (newtext); |
1116 | THIS->selection.text = sv2wcs (newtext); |
399 | THIS->selection.len = wcslen (THIS->selection.text); |
1117 | THIS->selection.len = wcslen (THIS->selection.text); |
400 | } |
1118 | } |
401 | } |
1119 | } |
402 | |
|
|
403 | void |
|
|
404 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
|
|
405 | |
1120 | |
406 | void |
1121 | void |
407 | rxvt_term::scr_overlay_off () |
1122 | rxvt_term::scr_add_lines (SV *string) |
408 | |
|
|
409 | void |
|
|
410 | rxvt_term::scr_overlay_set_char (int x, int y, U32 text, U32 rend = OVERLAY_RSTYLE) |
|
|
411 | CODE: |
1123 | CODE: |
412 | THIS->scr_overlay_set (x, y, text, rend); |
|
|
413 | |
|
|
414 | void |
|
|
415 | rxvt_term::scr_overlay_set (int x, int y, SV *text) |
|
|
416 | CODE: |
|
|
417 | { |
1124 | { |
418 | wchar_t *wtext = sv2wcs (text); |
1125 | wchar_t *wstr = sv2wcs (string); |
419 | THIS->scr_overlay_set (x, y, wtext); |
1126 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
420 | free (wtext); |
1127 | free (wstr); |
421 | } |
1128 | } |
|
|
1129 | |
|
|
1130 | void |
|
|
1131 | rxvt_term::tt_write (SV *octets) |
|
|
1132 | INIT: |
|
|
1133 | STRLEN len; |
|
|
1134 | char *str = SvPVbyte (octets, len); |
|
|
1135 | C_ARGS: |
|
|
1136 | str, len |
|
|
1137 | |
|
|
1138 | void |
|
|
1139 | rxvt_term::cmd_parse (SV *octets) |
|
|
1140 | CODE: |
|
|
1141 | { |
|
|
1142 | STRLEN len; |
|
|
1143 | char *str = SvPVbyte (octets, len); |
|
|
1144 | |
|
|
1145 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1146 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1147 | |
|
|
1148 | THIS->cmdbuf_ptr = str; |
|
|
1149 | THIS->cmdbuf_endp = str + len; |
|
|
1150 | |
|
|
1151 | THIS->cmd_parse (); |
|
|
1152 | |
|
|
1153 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1154 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1155 | } |
|
|
1156 | |
|
|
1157 | SV * |
|
|
1158 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
|
|
1159 | CODE: |
|
|
1160 | { |
|
|
1161 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
|
|
1162 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
|
|
1163 | o->self = (HV *)SvRV (RETVAL); |
|
|
1164 | } |
|
|
1165 | OUTPUT: |
|
|
1166 | RETVAL |
|
|
1167 | |
|
|
1168 | MODULE = urxvt PACKAGE = urxvt::overlay |
|
|
1169 | |
|
|
1170 | void |
|
|
1171 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
|
|
1172 | |
|
|
1173 | void |
|
|
1174 | overlay::show () |
|
|
1175 | |
|
|
1176 | void |
|
|
1177 | overlay::hide () |
|
|
1178 | |
|
|
1179 | void |
|
|
1180 | overlay::DESTROY () |
422 | |
1181 | |
423 | MODULE = urxvt PACKAGE = urxvt::timer |
1182 | MODULE = urxvt PACKAGE = urxvt::timer |
424 | |
1183 | |
425 | SV * |
1184 | SV * |
426 | timer::new () |
1185 | timer::new () |
427 | CODE: |
1186 | CODE: |
428 | timer *w = new timer; |
1187 | timer *w = new timer; |
|
|
1188 | w->start (NOW); |
429 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
1189 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
430 | w->self = (HV *)SvRV (RETVAL); |
1190 | w->self = (HV *)SvRV (RETVAL); |
431 | OUTPUT: |
1191 | OUTPUT: |
432 | RETVAL |
1192 | RETVAL |
433 | |
1193 | |
… | |
… | |
441 | |
1201 | |
442 | NV |
1202 | NV |
443 | timer::at () |
1203 | timer::at () |
444 | CODE: |
1204 | CODE: |
445 | RETVAL = THIS->at; |
1205 | RETVAL = THIS->at; |
|
|
1206 | OUTPUT: |
|
|
1207 | RETVAL |
|
|
1208 | |
|
|
1209 | timer * |
|
|
1210 | timer::interval (NV interval) |
|
|
1211 | CODE: |
|
|
1212 | THIS->interval = interval; |
|
|
1213 | RETVAL = THIS; |
446 | OUTPUT: |
1214 | OUTPUT: |
447 | RETVAL |
1215 | RETVAL |
448 | |
1216 | |
449 | timer * |
1217 | timer * |
450 | timer::set (NV tstamp) |
1218 | timer::set (NV tstamp) |