… | |
… | |
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 | { |
… | |
… | |
56 | //TODO: use magic |
61 | //TODO: use magic |
57 | static SV * |
62 | static SV * |
58 | newSVptr (void *ptr, const char *klass) |
63 | newSVptr (void *ptr, const char *klass) |
59 | { |
64 | { |
60 | HV *hv = newHV (); |
65 | HV *hv = newHV (); |
61 | hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); |
66 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
62 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
67 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
68 | } |
|
|
69 | |
|
|
70 | static void |
|
|
71 | clearSVptr (SV *sv) |
|
|
72 | { |
|
|
73 | if (SvROK (sv)) |
|
|
74 | sv = SvRV (sv); |
|
|
75 | |
|
|
76 | hv_clear ((HV *)sv); |
|
|
77 | sv_unmagic (sv, PERL_MAGIC_ext); |
63 | } |
78 | } |
64 | |
79 | |
65 | static long |
80 | static long |
66 | SvPTR (SV *sv, const char *klass) |
81 | SvPTR (SV *sv, const char *klass) |
67 | { |
82 | { |
68 | if (!sv_derived_from (sv, klass)) |
83 | if (!sv_derived_from (sv, klass)) |
69 | croak ("object of type %s expected", klass); |
84 | croak ("object of type %s expected", klass); |
70 | |
85 | |
71 | IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); |
86 | MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
72 | |
87 | |
73 | if (!iv) |
88 | if (!mg) |
74 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
89 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
75 | |
90 | |
76 | return (long)iv; |
91 | return (long)mg->mg_ptr; |
77 | } |
92 | } |
78 | |
93 | |
79 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
94 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
80 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
95 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
81 | |
96 | |
… | |
… | |
134 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
149 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
135 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
150 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
136 | |
151 | |
137 | struct timer : time_watcher, perl_watcher |
152 | struct timer : time_watcher, perl_watcher |
138 | { |
153 | { |
|
|
154 | tstamp interval; |
|
|
155 | |
139 | timer () |
156 | timer () |
140 | : time_watcher (this, &timer::execute) |
157 | : time_watcher (this, &timer::execute) |
141 | { |
158 | { |
142 | } |
159 | } |
143 | |
160 | |
144 | void execute (time_watcher &w) |
161 | void execute (time_watcher &w) |
145 | { |
162 | { |
|
|
163 | if (interval) |
|
|
164 | start (at + interval); |
|
|
165 | |
146 | invoke ("urxvt::timer", newSVtimer (this)); |
166 | invoke ("urxvt::timer", newSVtimer (this)); |
147 | } |
167 | } |
148 | }; |
168 | }; |
149 | |
169 | |
150 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
170 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
… | |
… | |
160 | void execute (io_watcher &w, short revents) |
180 | void execute (io_watcher &w, short revents) |
161 | { |
181 | { |
162 | invoke ("urxvt::iow", newSViow (this), revents); |
182 | invoke ("urxvt::iow", newSViow (this), revents); |
163 | } |
183 | } |
164 | }; |
184 | }; |
|
|
185 | |
|
|
186 | ///////////////////////////////////////////////////////////////////////////// |
|
|
187 | |
|
|
188 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
|
|
189 | |
|
|
190 | struct overlay { |
|
|
191 | HV *self; |
|
|
192 | rxvt_term *THIS; |
|
|
193 | int x, y, w, h; |
|
|
194 | int border; |
|
|
195 | text_t **text; |
|
|
196 | rend_t **rend; |
|
|
197 | |
|
|
198 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
|
|
199 | ~overlay (); |
|
|
200 | |
|
|
201 | void show (); |
|
|
202 | void hide (); |
|
|
203 | |
|
|
204 | void swap (); |
|
|
205 | |
|
|
206 | void set (int x, int y, SV *str, SV *rend); |
|
|
207 | }; |
|
|
208 | |
|
|
209 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
|
|
210 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) |
|
|
211 | { |
|
|
212 | if (border == 2) |
|
|
213 | { |
|
|
214 | w += 2; |
|
|
215 | h += 2; |
|
|
216 | } |
|
|
217 | |
|
|
218 | text = new text_t *[h]; |
|
|
219 | rend = new rend_t *[h]; |
|
|
220 | |
|
|
221 | for (int y = 0; y < h; y++) |
|
|
222 | { |
|
|
223 | text_t *tp = text[y] = new text_t[w]; |
|
|
224 | rend_t *rp = rend[y] = new rend_t[w]; |
|
|
225 | |
|
|
226 | text_t t0, t1, t2; |
|
|
227 | rend_t r = rstyle; |
|
|
228 | |
|
|
229 | if (border == 2) |
|
|
230 | { |
|
|
231 | if (y == 0) |
|
|
232 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
|
|
233 | else if (y < h - 1) |
|
|
234 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
|
|
235 | else |
|
|
236 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
|
|
237 | |
|
|
238 | *tp++ = t0; |
|
|
239 | *rp++ = r; |
|
|
240 | |
|
|
241 | for (int x = w - 2; x-- > 0; ) |
|
|
242 | { |
|
|
243 | *tp++ = t1; |
|
|
244 | *rp++ = r; |
|
|
245 | } |
|
|
246 | |
|
|
247 | *tp = t2; |
|
|
248 | *rp = r; |
|
|
249 | } |
|
|
250 | else |
|
|
251 | for (int x = w; x-- > 0; ) |
|
|
252 | { |
|
|
253 | *tp++ = 0x0020; |
|
|
254 | *rp++ = r; |
|
|
255 | } |
|
|
256 | } |
|
|
257 | |
|
|
258 | show (); |
|
|
259 | THIS->want_refresh = 1; |
|
|
260 | } |
|
|
261 | |
|
|
262 | overlay::~overlay () |
|
|
263 | { |
|
|
264 | hide (); |
|
|
265 | |
|
|
266 | for (int y = h; y--; ) |
|
|
267 | { |
|
|
268 | delete [] text[y]; |
|
|
269 | delete [] rend[y]; |
|
|
270 | } |
|
|
271 | |
|
|
272 | delete [] text; |
|
|
273 | delete [] rend; |
|
|
274 | |
|
|
275 | THIS->want_refresh = 1; |
|
|
276 | } |
|
|
277 | |
|
|
278 | void |
|
|
279 | overlay::show () |
|
|
280 | { |
|
|
281 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
282 | |
|
|
283 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
|
|
284 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
|
|
285 | } |
|
|
286 | |
|
|
287 | void |
|
|
288 | overlay::hide () |
|
|
289 | { |
|
|
290 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); |
|
|
291 | |
|
|
292 | if (ovs) |
|
|
293 | { |
|
|
294 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
295 | |
|
|
296 | HV *hv = (HV *)SvRV (*ovs); |
|
|
297 | hv_delete (hv, key, 32, G_DISCARD); |
|
|
298 | } |
|
|
299 | } |
|
|
300 | |
|
|
301 | void overlay::swap () |
|
|
302 | { |
|
|
303 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
|
|
304 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
|
|
305 | |
|
|
306 | int ov_w = min (w, THIS->ncol - ov_x); |
|
|
307 | int ov_h = min (h, THIS->nrow - ov_y); |
|
|
308 | |
|
|
309 | for (int y = ov_h; y--; ) |
|
|
310 | { |
|
|
311 | text_t *t1 = text [y]; |
|
|
312 | rend_t *r1 = rend [y]; |
|
|
313 | |
|
|
314 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
|
|
315 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
|
|
316 | |
|
|
317 | for (int x = ov_w; x--; ) |
|
|
318 | { |
|
|
319 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
|
|
320 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
|
|
321 | } |
|
|
322 | } |
|
|
323 | |
|
|
324 | } |
|
|
325 | |
|
|
326 | void overlay::set (int x, int y, SV *text, SV *rend) |
|
|
327 | { |
|
|
328 | x += border; |
|
|
329 | y += border; |
|
|
330 | |
|
|
331 | if (!IN_RANGE_EXC (y, 0, h - border)) |
|
|
332 | return; |
|
|
333 | |
|
|
334 | wchar_t *wtext = sv2wcs (text); |
|
|
335 | |
|
|
336 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
|
|
337 | this->text [y][x + col] = wtext [col]; |
|
|
338 | |
|
|
339 | free (wtext); |
|
|
340 | |
|
|
341 | if (rend) |
|
|
342 | { |
|
|
343 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
|
|
344 | croak ("rend must be arrayref"); |
|
|
345 | |
|
|
346 | AV *av = (AV *)SvRV (rend); |
|
|
347 | |
|
|
348 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
|
|
349 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
|
|
350 | } |
|
|
351 | |
|
|
352 | THIS->want_refresh = 1; |
|
|
353 | } |
|
|
354 | |
165 | |
355 | |
166 | ///////////////////////////////////////////////////////////////////////////// |
356 | ///////////////////////////////////////////////////////////////////////////// |
167 | |
357 | |
168 | struct rxvt_perl_interp rxvt_perl; |
358 | struct rxvt_perl_interp rxvt_perl; |
169 | |
359 | |
… | |
… | |
208 | } |
398 | } |
209 | |
399 | |
210 | bool |
400 | bool |
211 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
401 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
212 | { |
402 | { |
213 | // INIT and DESTROY must be requested by the runtime |
403 | if (!perl) |
214 | |
|
|
215 | if (!perl || !should_invoke [htype]) |
|
|
216 | return false; |
404 | return false; |
217 | |
405 | |
218 | if (htype == HOOK_INIT) // first hook ever called |
406 | if (htype == HOOK_INIT) // first hook ever called |
|
|
407 | { |
219 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
408 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
409 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
|
|
410 | } |
|
|
411 | else if (!term->self) |
|
|
412 | return false; // perl not initialized for this instance |
|
|
413 | else if (htype == HOOK_DESTROY) |
|
|
414 | { |
|
|
415 | // handled later |
|
|
416 | } |
|
|
417 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
418 | { |
|
|
419 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
|
|
420 | |
|
|
421 | if (HvKEYS (hv)) |
|
|
422 | { |
|
|
423 | hv_iterinit (hv); |
|
|
424 | |
|
|
425 | while (HE *he = hv_iternext (hv)) |
|
|
426 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
427 | } |
|
|
428 | } |
|
|
429 | else if (!should_invoke [htype]) |
|
|
430 | return false; |
220 | |
431 | |
221 | dSP; |
432 | dSP; |
222 | va_list ap; |
433 | va_list ap; |
223 | |
434 | |
224 | va_start (ap, htype); |
435 | va_start (ap, htype); |
… | |
… | |
242 | |
453 | |
243 | case DT_LONG: |
454 | case DT_LONG: |
244 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
455 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
245 | break; |
456 | break; |
246 | |
457 | |
|
|
458 | case DT_STRING: |
|
|
459 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
460 | break; |
|
|
461 | |
247 | case DT_END: |
462 | case DT_END: |
248 | { |
463 | { |
249 | va_end (ap); |
464 | va_end (ap); |
250 | |
465 | |
251 | PUTBACK; |
466 | PUTBACK; |
… | |
… | |
265 | if (SvTRUE (ERRSV)) |
480 | if (SvTRUE (ERRSV)) |
266 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
481 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
267 | |
482 | |
268 | if (htype == HOOK_DESTROY) |
483 | if (htype == HOOK_DESTROY) |
269 | { |
484 | { |
270 | // TODO: clear magic |
|
|
271 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
485 | clearSVptr ((SV *)term->self); |
272 | SvREFCNT_dec ((SV *)term->self); |
486 | SvREFCNT_dec ((SV *)term->self); |
273 | } |
487 | } |
274 | |
488 | |
275 | return count; |
489 | return count; |
276 | } |
490 | } |
… | |
… | |
288 | PROTOTYPES: ENABLE |
502 | PROTOTYPES: ENABLE |
289 | |
503 | |
290 | BOOT: |
504 | BOOT: |
291 | { |
505 | { |
292 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
506 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
|
|
507 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); |
293 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
508 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
294 | set_hookname (LOAD); |
|
|
295 | set_hookname (INIT); |
509 | set_hookname (INIT); |
296 | set_hookname (RESET); |
510 | set_hookname (RESET); |
297 | set_hookname (START); |
511 | set_hookname (START); |
298 | set_hookname (DESTROY); |
512 | set_hookname (DESTROY); |
299 | set_hookname (SEL_BEGIN); |
513 | set_hookname (SEL_BEGIN); |
… | |
… | |
305 | set_hookname (VIEW_CHANGE); |
519 | set_hookname (VIEW_CHANGE); |
306 | set_hookname (SCROLL_BACK); |
520 | set_hookname (SCROLL_BACK); |
307 | set_hookname (TTY_ACTIVITY); |
521 | set_hookname (TTY_ACTIVITY); |
308 | set_hookname (REFRESH_BEGIN); |
522 | set_hookname (REFRESH_BEGIN); |
309 | set_hookname (REFRESH_END); |
523 | set_hookname (REFRESH_END); |
|
|
524 | set_hookname (KEYBOARD_COMMAND); |
|
|
525 | |
|
|
526 | export_const (DEFAULT_RSTYLE); |
|
|
527 | export_const (OVERLAY_RSTYLE); |
|
|
528 | export_const (RS_Bold); |
|
|
529 | export_const (RS_Italic); |
|
|
530 | export_const (RS_Blink); |
|
|
531 | export_const (RS_RVid); |
|
|
532 | export_const (RS_Uline); |
310 | |
533 | |
311 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
534 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
312 | } |
535 | } |
313 | |
536 | |
314 | void |
537 | void |
… | |
… | |
329 | NV |
552 | NV |
330 | NOW () |
553 | NOW () |
331 | CODE: |
554 | CODE: |
332 | RETVAL = NOW; |
555 | RETVAL = NOW; |
333 | OUTPUT: |
556 | OUTPUT: |
|
|
557 | RETVAL |
|
|
558 | |
|
|
559 | int |
|
|
560 | GET_BASEFG (int rend) |
|
|
561 | CODE: |
|
|
562 | RETVAL = GET_BASEFG (rend); |
|
|
563 | OUTPUT: |
|
|
564 | RETVAL |
|
|
565 | |
|
|
566 | int |
|
|
567 | GET_BASEBG (int rend) |
|
|
568 | CODE: |
|
|
569 | RETVAL = GET_BASEBG (rend); |
|
|
570 | OUTPUT: |
|
|
571 | RETVAL |
|
|
572 | |
|
|
573 | int |
|
|
574 | SET_FGCOLOR (int rend, int new_color) |
|
|
575 | CODE: |
|
|
576 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
577 | OUTPUT: |
|
|
578 | RETVAL |
|
|
579 | |
|
|
580 | int |
|
|
581 | SET_BGCOLOR (int rend, int new_color) |
|
|
582 | CODE: |
|
|
583 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
584 | OUTPUT: |
|
|
585 | RETVAL |
|
|
586 | |
|
|
587 | int |
|
|
588 | GET_CUSTOM (int rend) |
|
|
589 | CODE: |
|
|
590 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
591 | OUTPUT: |
|
|
592 | RETVAL |
|
|
593 | |
|
|
594 | int |
|
|
595 | SET_CUSTOM (int rend, int new_value) |
|
|
596 | CODE: |
|
|
597 | { |
|
|
598 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
599 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
600 | |
|
|
601 | RETVAL = (rend & ~RS_customMask) |
|
|
602 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
603 | } |
|
|
604 | OUTPUT: |
334 | RETVAL |
605 | RETVAL |
335 | |
606 | |
336 | MODULE = urxvt PACKAGE = urxvt::term |
607 | MODULE = urxvt PACKAGE = urxvt::term |
337 | |
608 | |
338 | int |
609 | int |
… | |
… | |
386 | SvUTF8_on (RETVAL); |
657 | SvUTF8_on (RETVAL); |
387 | free (str); |
658 | free (str); |
388 | } |
659 | } |
389 | OUTPUT: |
660 | OUTPUT: |
390 | RETVAL |
661 | RETVAL |
|
|
662 | |
|
|
663 | int |
|
|
664 | rxvt_term::nsaved () |
|
|
665 | CODE: |
|
|
666 | RETVAL = THIS->nsaved; |
|
|
667 | OUTPUT: |
|
|
668 | RETVAL |
|
|
669 | |
|
|
670 | int |
|
|
671 | rxvt_term::view_start (int newval = -1) |
|
|
672 | CODE: |
|
|
673 | { |
|
|
674 | RETVAL = THIS->view_start; |
|
|
675 | |
|
|
676 | if (newval >= 0) |
|
|
677 | { |
|
|
678 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
679 | THIS->scr_changeview (RETVAL); |
|
|
680 | } |
|
|
681 | } |
|
|
682 | OUTPUT: |
|
|
683 | RETVAL |
|
|
684 | |
|
|
685 | int |
|
|
686 | rxvt_term::nrow () |
|
|
687 | CODE: |
|
|
688 | RETVAL = THIS->nrow; |
|
|
689 | OUTPUT: |
|
|
690 | RETVAL |
|
|
691 | |
|
|
692 | int |
|
|
693 | rxvt_term::ncol () |
|
|
694 | CODE: |
|
|
695 | RETVAL = THIS->ncol; |
|
|
696 | OUTPUT: |
|
|
697 | RETVAL |
|
|
698 | |
|
|
699 | void |
|
|
700 | rxvt_term::want_refresh () |
|
|
701 | CODE: |
|
|
702 | THIS->want_refresh = 1; |
|
|
703 | |
|
|
704 | void |
|
|
705 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
|
|
706 | PPCODE: |
|
|
707 | { |
|
|
708 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
709 | XSRETURN_EMPTY; |
|
|
710 | |
|
|
711 | line_t &l = ROW(row_number); |
|
|
712 | |
|
|
713 | if (GIMME_V != G_VOID) |
|
|
714 | { |
|
|
715 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
|
|
716 | |
|
|
717 | for (int col = 0; col <THIS->ncol; col++) |
|
|
718 | wstr [col] = l.t [col]; |
|
|
719 | |
|
|
720 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
|
|
721 | free (wstr); |
|
|
722 | |
|
|
723 | SV *sv = newSVpv (str, 0); |
|
|
724 | SvUTF8_on (sv); |
|
|
725 | XPUSHs (sv_2mortal (sv)); |
|
|
726 | free (str); |
|
|
727 | } |
|
|
728 | |
|
|
729 | if (new_text) |
|
|
730 | { |
|
|
731 | wchar_t *wstr = sv2wcs (new_text); |
|
|
732 | |
|
|
733 | int len = wcslen (wstr); |
|
|
734 | |
|
|
735 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
736 | { |
|
|
737 | free (wstr); |
|
|
738 | croak ("new_text extends beyond horizontal margins"); |
|
|
739 | } |
|
|
740 | |
|
|
741 | for (int col = start_col; col < start_col + len; col++) |
|
|
742 | { |
|
|
743 | l.t [col] = wstr [col - start_col]; |
|
|
744 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
|
|
745 | } |
|
|
746 | |
|
|
747 | free (wstr); |
|
|
748 | } |
|
|
749 | } |
|
|
750 | |
|
|
751 | void |
|
|
752 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
|
|
753 | PPCODE: |
|
|
754 | { |
|
|
755 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
756 | XSRETURN_EMPTY; |
|
|
757 | |
|
|
758 | line_t &l = ROW(row_number); |
|
|
759 | |
|
|
760 | if (GIMME_V != G_VOID) |
|
|
761 | { |
|
|
762 | AV *av = newAV (); |
|
|
763 | |
|
|
764 | av_extend (av, THIS->ncol - 1); |
|
|
765 | for (int col = 0; col < THIS->ncol; col++) |
|
|
766 | av_store (av, col, newSViv (l.r [col])); |
|
|
767 | |
|
|
768 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
769 | } |
|
|
770 | |
|
|
771 | if (new_rend) |
|
|
772 | { |
|
|
773 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
|
|
774 | croak ("new_rend must be arrayref"); |
|
|
775 | |
|
|
776 | AV *av = (AV *)SvRV (new_rend); |
|
|
777 | int len = av_len (av) + 1; |
|
|
778 | |
|
|
779 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
780 | croak ("new_rend array extends beyond horizontal margins"); |
|
|
781 | |
|
|
782 | for (int col = start_col; col < start_col + len; col++) |
|
|
783 | { |
|
|
784 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
|
|
785 | |
|
|
786 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
|
|
787 | } |
|
|
788 | } |
|
|
789 | } |
|
|
790 | |
|
|
791 | int |
|
|
792 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
|
|
793 | CODE: |
|
|
794 | { |
|
|
795 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
796 | XSRETURN_EMPTY; |
|
|
797 | |
|
|
798 | line_t &l = ROW(row_number); |
|
|
799 | RETVAL = l.l < 0 ? THIS->ncol : l.l; |
|
|
800 | |
|
|
801 | if (new_length >= -1) |
|
|
802 | l.l = new_length; |
|
|
803 | } |
|
|
804 | OUTPUT: |
|
|
805 | RETVAL |
|
|
806 | |
|
|
807 | bool |
|
|
808 | rxvt_term::ROW_is_longer (int row_number) |
|
|
809 | CODE: |
|
|
810 | { |
|
|
811 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
812 | XSRETURN_EMPTY; |
|
|
813 | |
|
|
814 | line_t &l = ROW(row_number); |
|
|
815 | RETVAL = l.l < 0; |
|
|
816 | } |
|
|
817 | OUTPUT: |
|
|
818 | RETVAL |
|
|
819 | |
|
|
820 | SV * |
|
|
821 | rxvt_term::special_encode (SV *str) |
|
|
822 | CODE: |
|
|
823 | abort ();//TODO |
|
|
824 | |
|
|
825 | SV * |
|
|
826 | rxvt_term::special_decode (SV *str) |
|
|
827 | CODE: |
|
|
828 | abort ();//TODO |
391 | |
829 | |
392 | void |
830 | void |
393 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
831 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
394 | PPCODE: |
832 | PPCODE: |
395 | { |
833 | { |
… | |
… | |
457 | THIS->want_refresh = 1; |
895 | THIS->want_refresh = 1; |
458 | } |
896 | } |
459 | } |
897 | } |
460 | |
898 | |
461 | int |
899 | int |
462 | rxvt_term::selection_grab (int eventtime) |
900 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
463 | |
901 | |
464 | void |
902 | void |
465 | rxvt_term::selection (SV *newtext = 0) |
903 | rxvt_term::selection (SV *newtext = 0) |
466 | PPCODE: |
904 | PPCODE: |
467 | { |
905 | { |
… | |
… | |
482 | THIS->selection.len = wcslen (THIS->selection.text); |
920 | THIS->selection.len = wcslen (THIS->selection.text); |
483 | } |
921 | } |
484 | } |
922 | } |
485 | |
923 | |
486 | void |
924 | void |
487 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
|
|
488 | |
|
|
489 | void |
|
|
490 | rxvt_term::scr_overlay_off () |
|
|
491 | |
|
|
492 | void |
|
|
493 | rxvt_term::scr_overlay_set_char (int x, int y, U32 text, U32 rend = OVERLAY_RSTYLE) |
|
|
494 | 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 | { |
|
|
501 | wchar_t *wtext = sv2wcs (text); |
|
|
502 | THIS->scr_overlay_set (x, y, wtext); |
|
|
503 | free (wtext); |
|
|
504 | } |
|
|
505 | |
|
|
506 | void |
|
|
507 | rxvt_term::tt_write (SV *octets) |
925 | rxvt_term::tt_write (SV *octets) |
508 | INIT: |
926 | INIT: |
509 | STRLEN len; |
927 | STRLEN len; |
510 | char *str = SvPVbyte (octets, len); |
928 | char *str = SvPVbyte (octets, len); |
511 | C_ARGS: |
929 | C_ARGS: |
512 | (unsigned char *)str, len |
930 | (unsigned char *)str, len |
513 | |
931 | |
|
|
932 | SV * |
|
|
933 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
|
|
934 | CODE: |
|
|
935 | { |
|
|
936 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
|
|
937 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
|
|
938 | o->self = (HV *)SvRV (RETVAL); |
|
|
939 | } |
|
|
940 | OUTPUT: |
|
|
941 | RETVAL |
|
|
942 | |
|
|
943 | MODULE = urxvt PACKAGE = urxvt::overlay |
|
|
944 | |
|
|
945 | void |
|
|
946 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
|
|
947 | |
|
|
948 | void |
|
|
949 | overlay::show () |
|
|
950 | |
|
|
951 | void |
|
|
952 | overlay::hide () |
|
|
953 | |
|
|
954 | void |
|
|
955 | overlay::DESTROY () |
|
|
956 | |
514 | MODULE = urxvt PACKAGE = urxvt::timer |
957 | MODULE = urxvt PACKAGE = urxvt::timer |
515 | |
958 | |
516 | SV * |
959 | SV * |
517 | timer::new () |
960 | timer::new () |
518 | CODE: |
961 | CODE: |
519 | timer *w = new timer; |
962 | timer *w = new timer; |
|
|
963 | w->start (NOW); |
520 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
964 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
521 | w->self = (HV *)SvRV (RETVAL); |
965 | w->self = (HV *)SvRV (RETVAL); |
522 | OUTPUT: |
966 | OUTPUT: |
523 | RETVAL |
967 | RETVAL |
524 | |
968 | |
… | |
… | |
532 | |
976 | |
533 | NV |
977 | NV |
534 | timer::at () |
978 | timer::at () |
535 | CODE: |
979 | CODE: |
536 | RETVAL = THIS->at; |
980 | RETVAL = THIS->at; |
|
|
981 | OUTPUT: |
|
|
982 | RETVAL |
|
|
983 | |
|
|
984 | timer * |
|
|
985 | timer::interval (NV interval) |
|
|
986 | CODE: |
|
|
987 | THIS->interval = interval; |
|
|
988 | RETVAL = THIS; |
537 | OUTPUT: |
989 | OUTPUT: |
538 | RETVAL |
990 | RETVAL |
539 | |
991 | |
540 | timer * |
992 | timer * |
541 | timer::set (NV tstamp) |
993 | timer::set (NV tstamp) |