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. |
… | |
… | |
26 | #include <XSUB.h> |
26 | #include <XSUB.h> |
27 | #undef line_t |
27 | #undef line_t |
28 | |
28 | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
|
|
31 | #include <cstddef> |
31 | #include <cstdarg> |
32 | #include <cstdarg> |
32 | |
33 | |
33 | #include "rxvt.h" |
34 | #include "rxvt.h" |
34 | #include "iom.h" |
35 | #include "iom.h" |
35 | #include "rxvtutil.h" |
36 | #include "rxvtutil.h" |
… | |
… | |
51 | char *str = SvPVutf8 (sv, len); |
52 | char *str = SvPVutf8 (sv, len); |
52 | return rxvt_utf8towcs (str, len); |
53 | return rxvt_utf8towcs (str, len); |
53 | } |
54 | } |
54 | |
55 | |
55 | static SV * |
56 | static SV * |
|
|
57 | wcs2sv (wchar_t *wstr, int len = -1) |
|
|
58 | { |
|
|
59 | char *str = rxvt_wcstoutf8 (wstr, len); |
|
|
60 | |
|
|
61 | SV *sv = newSVpv (str, 0); |
|
|
62 | SvUTF8_on (sv); |
|
|
63 | free (str); |
|
|
64 | |
|
|
65 | return sv; |
|
|
66 | } |
|
|
67 | |
|
|
68 | static SV * |
56 | new_ref (HV *hv, const char *klass) |
69 | new_ref (HV *hv, const char *klass) |
57 | { |
70 | { |
58 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
71 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
59 | } |
72 | } |
60 | |
73 | |
61 | //TODO: use magic |
74 | //TODO: use magic |
62 | static SV * |
75 | static SV * |
63 | newSVptr (void *ptr, const char *klass) |
76 | newSVptr (void *ptr, const char *klass) |
64 | { |
77 | { |
65 | HV *hv = newHV (); |
78 | HV *hv = newHV (); |
66 | hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); |
79 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
67 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
80 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
81 | } |
|
|
82 | |
|
|
83 | static void |
|
|
84 | clearSVptr (SV *sv) |
|
|
85 | { |
|
|
86 | if (SvROK (sv)) |
|
|
87 | sv = SvRV (sv); |
|
|
88 | |
|
|
89 | hv_clear ((HV *)sv); |
|
|
90 | sv_unmagic (sv, PERL_MAGIC_ext); |
68 | } |
91 | } |
69 | |
92 | |
70 | static long |
93 | static long |
71 | SvPTR (SV *sv, const char *klass) |
94 | SvPTR (SV *sv, const char *klass) |
72 | { |
95 | { |
73 | if (!sv_derived_from (sv, klass)) |
96 | if (!sv_derived_from (sv, klass)) |
74 | croak ("object of type %s expected", klass); |
97 | croak ("object of type %s expected", klass); |
75 | |
98 | |
76 | IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); |
99 | MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
77 | |
100 | |
78 | if (!iv) |
101 | if (!mg) |
79 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
102 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
80 | |
103 | |
81 | return (long)iv; |
104 | return (long)mg->mg_ptr; |
82 | } |
105 | } |
83 | |
106 | |
84 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
107 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
85 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
108 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
86 | |
109 | |
87 | ///////////////////////////////////////////////////////////////////////////// |
110 | ///////////////////////////////////////////////////////////////////////////// |
88 | |
111 | |
89 | struct perl_watcher |
112 | struct perl_watcher |
… | |
… | |
186 | rend_t **rend; |
209 | rend_t **rend; |
187 | |
210 | |
188 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
211 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
189 | ~overlay (); |
212 | ~overlay (); |
190 | |
213 | |
|
|
214 | void show (); |
|
|
215 | void hide (); |
|
|
216 | |
191 | void swap (); |
217 | void swap (); |
192 | |
218 | |
193 | void set (int x, int y, SV *str, SV *rend); |
219 | void set (int x, int y, SV *str, SV *rend); |
194 | }; |
220 | }; |
195 | |
221 | |
… | |
… | |
202 | h += 2; |
228 | h += 2; |
203 | } |
229 | } |
204 | |
230 | |
205 | text = new text_t *[h]; |
231 | text = new text_t *[h]; |
206 | rend = new rend_t *[h]; |
232 | rend = new rend_t *[h]; |
207 | |
233 | |
208 | for (int y = 0; y < h; y++) |
234 | for (int y = 0; y < h; y++) |
209 | { |
235 | { |
210 | text_t *tp = text[y] = new text_t[w]; |
236 | text_t *tp = text[y] = new text_t[w]; |
211 | rend_t *rp = rend[y] = new rend_t[w]; |
237 | rend_t *rp = rend[y] = new rend_t[w]; |
212 | |
238 | |
213 | text_t t0, t1, t2; |
239 | text_t t0, t1, t2; |
214 | rend_t r = rstyle; |
240 | rend_t r = rstyle; |
215 | |
241 | |
216 | if (border == 2) |
242 | if (border == 2) |
217 | { |
243 | { |
218 | if (y == 0) |
244 | if (y == 0) |
219 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
245 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
220 | else if (y < h - 1) |
246 | else if (y < h - 1) |
221 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
247 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
222 | else |
248 | else |
223 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
249 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
224 | |
250 | |
225 | *tp++ = t0; |
251 | *tp++ = t0; |
226 | *rp++ = r; |
252 | *rp++ = r; |
227 | |
253 | |
228 | for (int x = w - 2; x-- > 0; ) |
254 | for (int x = w - 2; x-- > 0; ) |
229 | { |
255 | { |
230 | *tp++ = t1; |
256 | *tp++ = t1; |
231 | *rp++ = r; |
257 | *rp++ = r; |
232 | } |
258 | } |
233 | |
259 | |
234 | *tp = t2; |
260 | *tp = t2; |
235 | *rp = r; |
261 | *rp = r; |
236 | } |
262 | } |
237 | else |
263 | else |
238 | for (int x = w; x-- > 0; ) |
264 | for (int x = w; x-- > 0; ) |
239 | { |
265 | { |
240 | *tp++ = 0x0020; |
266 | *tp++ = 0x0020; |
241 | *rp++ = r; |
267 | *rp++ = r; |
242 | } |
268 | } |
243 | } |
269 | } |
244 | |
270 | |
|
|
271 | show (); |
245 | THIS->want_refresh = 1; |
272 | THIS->want_refresh = 1; |
246 | } |
273 | } |
247 | |
274 | |
248 | overlay::~overlay () |
275 | overlay::~overlay () |
249 | { |
276 | { |
|
|
277 | hide (); |
|
|
278 | |
250 | for (int y = h; y--; ) |
279 | for (int y = h; y--; ) |
251 | { |
280 | { |
252 | delete [] text[y]; |
281 | delete [] text[y]; |
253 | delete [] rend[y]; |
282 | delete [] rend[y]; |
254 | } |
283 | } |
… | |
… | |
257 | delete [] rend; |
286 | delete [] rend; |
258 | |
287 | |
259 | THIS->want_refresh = 1; |
288 | THIS->want_refresh = 1; |
260 | } |
289 | } |
261 | |
290 | |
|
|
291 | void |
|
|
292 | overlay::show () |
|
|
293 | { |
|
|
294 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
295 | |
|
|
296 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
|
|
297 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
|
|
298 | } |
|
|
299 | |
|
|
300 | void |
|
|
301 | overlay::hide () |
|
|
302 | { |
|
|
303 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
|
|
304 | |
|
|
305 | if (ovs) |
|
|
306 | { |
|
|
307 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
308 | |
|
|
309 | HV *hv = (HV *)SvRV (*ovs); |
|
|
310 | hv_delete (hv, key, 32, G_DISCARD); |
|
|
311 | } |
|
|
312 | } |
|
|
313 | |
262 | void overlay::swap () |
314 | void overlay::swap () |
263 | { |
315 | { |
264 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
316 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
265 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
317 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
266 | |
318 | |
… | |
… | |
269 | |
321 | |
270 | for (int y = ov_h; y--; ) |
322 | for (int y = ov_h; y--; ) |
271 | { |
323 | { |
272 | text_t *t1 = text [y]; |
324 | text_t *t1 = text [y]; |
273 | rend_t *r1 = rend [y]; |
325 | rend_t *r1 = rend [y]; |
274 | |
326 | |
275 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
327 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
276 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
328 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
277 | |
329 | |
278 | for (int x = ov_w; x--; ) |
330 | for (int x = ov_w; x--; ) |
279 | { |
331 | { |
280 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
332 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
281 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
333 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
282 | } |
334 | } |
283 | } |
335 | } |
284 | |
336 | |
… | |
… | |
294 | |
346 | |
295 | wchar_t *wtext = sv2wcs (text); |
347 | wchar_t *wtext = sv2wcs (text); |
296 | |
348 | |
297 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
349 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
298 | this->text [y][x + col] = wtext [col]; |
350 | this->text [y][x + col] = wtext [col]; |
299 | |
351 | |
300 | free (wtext); |
352 | free (wtext); |
301 | |
353 | |
302 | if (rend) |
354 | if (rend) |
303 | { |
355 | { |
304 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
356 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
… | |
… | |
361 | bool |
413 | bool |
362 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
414 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
363 | { |
415 | { |
364 | if (!perl) |
416 | if (!perl) |
365 | return false; |
417 | return false; |
366 | |
418 | |
367 | if (htype == HOOK_INIT) // first hook ever called |
419 | if (htype == HOOK_INIT) // first hook ever called |
368 | { |
420 | { |
369 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
421 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
370 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
422 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
371 | } |
423 | } |
|
|
424 | else if (!term->perl.self) |
|
|
425 | return false; // perl not initialized for this instance |
372 | else if (htype == HOOK_DESTROY) |
426 | else if (htype == HOOK_DESTROY) |
373 | { |
427 | { |
374 | // handled later |
428 | // handled later |
375 | } |
429 | } |
376 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
430 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
377 | { |
431 | { |
378 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
432 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
379 | |
433 | |
380 | if (HvKEYS (hv)) |
434 | if (HvKEYS (hv)) |
381 | { |
435 | { |
382 | hv_iterinit (hv); |
436 | hv_iterinit (hv); |
383 | |
437 | |
… | |
… | |
412 | |
466 | |
413 | case DT_LONG: |
467 | case DT_LONG: |
414 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
468 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
415 | break; |
469 | break; |
416 | |
470 | |
417 | case DT_STRING: |
471 | case DT_STR: |
418 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
472 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
473 | break; |
|
|
474 | |
|
|
475 | case DT_STR_LEN: |
|
|
476 | { |
|
|
477 | char *str = va_arg (ap, char *); |
|
|
478 | int len = va_arg (ap, int); |
|
|
479 | |
|
|
480 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
481 | } |
|
|
482 | break; |
|
|
483 | |
|
|
484 | case DT_WCS_LEN: |
|
|
485 | { |
|
|
486 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
487 | int wlen = va_arg (ap, int); |
|
|
488 | |
|
|
489 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
490 | } |
|
|
491 | break; |
|
|
492 | |
|
|
493 | case DT_XEVENT: |
|
|
494 | { |
|
|
495 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
496 | HV *hv = newHV (); |
|
|
497 | |
|
|
498 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
499 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
500 | # undef set |
|
|
501 | |
|
|
502 | setiv (type, xe->type); |
|
|
503 | setiv (send_event, xe->xany.send_event); |
|
|
504 | setiv (serial, xe->xany.serial); |
|
|
505 | |
|
|
506 | switch (xe->type) |
|
|
507 | { |
|
|
508 | case KeyPress: |
|
|
509 | case KeyRelease: |
|
|
510 | case ButtonPress: |
|
|
511 | case ButtonRelease: |
|
|
512 | case MotionNotify: |
|
|
513 | setiv (time, xe->xmotion.time); |
|
|
514 | setiv (x, xe->xmotion.x); |
|
|
515 | setiv (y, xe->xmotion.y); |
|
|
516 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
517 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
518 | setiv (x_root, xe->xmotion.x_root); |
|
|
519 | setiv (y_root, xe->xmotion.y_root); |
|
|
520 | setiv (state, xe->xmotion.state); |
|
|
521 | break; |
|
|
522 | } |
|
|
523 | |
|
|
524 | switch (xe->type) |
|
|
525 | { |
|
|
526 | case KeyPress: |
|
|
527 | case KeyRelease: |
|
|
528 | setiv (keycode, xe->xkey.keycode); |
|
|
529 | break; |
|
|
530 | |
|
|
531 | case ButtonPress: |
|
|
532 | case ButtonRelease: |
|
|
533 | setiv (button, xe->xbutton.button); |
|
|
534 | break; |
|
|
535 | |
|
|
536 | case MotionNotify: |
|
|
537 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
538 | break; |
|
|
539 | } |
|
|
540 | |
|
|
541 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
542 | } |
419 | break; |
543 | break; |
420 | |
544 | |
421 | case DT_END: |
545 | case DT_END: |
422 | { |
546 | { |
423 | va_end (ap); |
547 | va_end (ap); |
… | |
… | |
439 | if (SvTRUE (ERRSV)) |
563 | if (SvTRUE (ERRSV)) |
440 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
564 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
441 | |
565 | |
442 | if (htype == HOOK_DESTROY) |
566 | if (htype == HOOK_DESTROY) |
443 | { |
567 | { |
444 | // TODO: clear magic |
|
|
445 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
568 | clearSVptr ((SV *)term->perl.self); |
446 | SvREFCNT_dec ((SV *)term->self); |
569 | SvREFCNT_dec ((SV *)term->perl.self); |
447 | } |
570 | } |
448 | |
571 | |
449 | return count; |
572 | return count; |
450 | } |
573 | } |
451 | |
574 | |
… | |
… | |
461 | |
584 | |
462 | PROTOTYPES: ENABLE |
585 | PROTOTYPES: ENABLE |
463 | |
586 | |
464 | BOOT: |
587 | BOOT: |
465 | { |
588 | { |
466 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
589 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
467 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); |
590 | |
468 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
591 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
469 | set_hookname (INIT); |
592 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
470 | set_hookname (RESET); |
593 | # include "hookinc.h" |
471 | set_hookname (START); |
594 | # undef def |
472 | set_hookname (DESTROY); |
|
|
473 | set_hookname (SEL_BEGIN); |
|
|
474 | set_hookname (SEL_EXTEND); |
|
|
475 | set_hookname (SEL_MAKE); |
|
|
476 | set_hookname (SEL_GRAB); |
|
|
477 | set_hookname (FOCUS_IN); |
|
|
478 | set_hookname (FOCUS_OUT); |
|
|
479 | set_hookname (VIEW_CHANGE); |
|
|
480 | set_hookname (SCROLL_BACK); |
|
|
481 | set_hookname (TTY_ACTIVITY); |
|
|
482 | set_hookname (REFRESH_BEGIN); |
|
|
483 | set_hookname (REFRESH_END); |
|
|
484 | set_hookname (KEYBOARD_COMMAND); |
|
|
485 | |
595 | |
|
|
596 | HV *option = get_hv ("urxvt::OPTION", 1); |
|
|
597 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
|
|
598 | # define nodef(name) |
|
|
599 | # include "optinc.h" |
|
|
600 | # undef nodef |
|
|
601 | # undef def |
|
|
602 | |
|
|
603 | HV *stash = gv_stashpv ("urxvt", 1); |
|
|
604 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
486 | export_const (DEFAULT_RSTYLE); |
605 | export_const_iv (DEFAULT_RSTYLE); |
487 | export_const (OVERLAY_RSTYLE); |
606 | export_const_iv (OVERLAY_RSTYLE); |
488 | export_const (RS_Bold); |
607 | export_const_iv (RS_Bold); |
489 | export_const (RS_Italic); |
608 | export_const_iv (RS_Italic); |
490 | export_const (RS_Blink); |
609 | export_const_iv (RS_Blink); |
491 | export_const (RS_RVid); |
610 | export_const_iv (RS_RVid); |
492 | export_const (RS_Uline); |
611 | export_const_iv (RS_Uline); |
493 | |
612 | |
494 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
613 | export_const_iv (CurrentTime); |
|
|
614 | export_const_iv (ShiftMask); |
|
|
615 | export_const_iv (LockMask); |
|
|
616 | export_const_iv (ControlMask); |
|
|
617 | export_const_iv (Mod1Mask); |
|
|
618 | export_const_iv (Mod2Mask); |
|
|
619 | export_const_iv (Mod3Mask); |
|
|
620 | export_const_iv (Mod4Mask); |
|
|
621 | export_const_iv (Mod5Mask); |
|
|
622 | export_const_iv (Button1Mask); |
|
|
623 | export_const_iv (Button2Mask); |
|
|
624 | export_const_iv (Button3Mask); |
|
|
625 | export_const_iv (Button4Mask); |
|
|
626 | export_const_iv (Button5Mask); |
|
|
627 | export_const_iv (AnyModifier); |
495 | } |
628 | } |
|
|
629 | |
|
|
630 | SV * |
|
|
631 | new (...) |
|
|
632 | CODE: |
|
|
633 | { |
|
|
634 | stringvec *argv = new stringvec; |
|
|
635 | bool success; |
|
|
636 | |
|
|
637 | for (int i = 0; i < items ;i++) |
|
|
638 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
639 | |
|
|
640 | rxvt_term *term = new rxvt_term; |
|
|
641 | |
|
|
642 | term->argv = argv; |
|
|
643 | |
|
|
644 | try |
|
|
645 | { |
|
|
646 | if (!term->init (argv->size (), argv->begin ())) |
|
|
647 | term = 0; |
|
|
648 | } |
|
|
649 | catch (const class rxvt_failure_exception &e) |
|
|
650 | { |
|
|
651 | term->destroy (); |
|
|
652 | croak ("exception caught while initializing new terminal instance"); |
|
|
653 | } |
|
|
654 | |
|
|
655 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
|
|
656 | } |
|
|
657 | OUTPUT: |
|
|
658 | RETVAL |
496 | |
659 | |
497 | void |
660 | void |
498 | set_should_invoke (int htype, int value) |
661 | set_should_invoke (int htype, int value) |
499 | CODE: |
662 | CODE: |
500 | rxvt_perl.should_invoke [htype] = value; |
663 | rxvt_perl.should_invoke [htype] = value; |
… | |
… | |
563 | } |
726 | } |
564 | OUTPUT: |
727 | OUTPUT: |
565 | RETVAL |
728 | RETVAL |
566 | |
729 | |
567 | MODULE = urxvt PACKAGE = urxvt::term |
730 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
731 | |
|
|
732 | void |
|
|
733 | rxvt_term::destroy () |
|
|
734 | |
|
|
735 | void |
|
|
736 | rxvt_term::grab_button (int button, U32 modifiers) |
|
|
737 | CODE: |
|
|
738 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
|
|
739 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
740 | GrabModeSync, GrabModeSync, None, None); |
|
|
741 | |
|
|
742 | bool |
|
|
743 | rxvt_term::grab (U32 eventtime, int sync = 0) |
|
|
744 | CODE: |
|
|
745 | { |
|
|
746 | int mode = sync ? GrabModeSync : GrabModeAsync; |
|
|
747 | |
|
|
748 | THIS->perl.grabtime = 0; |
|
|
749 | |
|
|
750 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
751 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
752 | mode, mode, None, None, eventtime)) |
|
|
753 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
|
|
754 | THIS->perl.grabtime = eventtime; |
|
|
755 | else |
|
|
756 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
757 | |
|
|
758 | RETVAL = !!THIS->perl.grabtime; |
|
|
759 | } |
|
|
760 | OUTPUT: |
|
|
761 | RETVAL |
|
|
762 | |
|
|
763 | void |
|
|
764 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
|
|
765 | CODE: |
|
|
766 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
|
|
767 | |
|
|
768 | void |
|
|
769 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
|
|
770 | CODE: |
|
|
771 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
|
|
772 | |
|
|
773 | void |
|
|
774 | rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) |
|
|
775 | CODE: |
|
|
776 | XAllowEvents (THIS->display->display, ReplayPointer, eventtime); |
|
|
777 | XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); |
|
|
778 | |
|
|
779 | void |
|
|
780 | rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) |
|
|
781 | CODE: |
|
|
782 | THIS->perl.grabtime = 0; |
|
|
783 | XUngrabKeyboard (THIS->display->display, eventtime); |
|
|
784 | XUngrabPointer (THIS->display->display, eventtime); |
568 | |
785 | |
569 | int |
786 | int |
570 | rxvt_term::strwidth (SV *str) |
787 | rxvt_term::strwidth (SV *str) |
571 | CODE: |
788 | CODE: |
572 | { |
789 | { |
… | |
… | |
608 | |
825 | |
609 | rxvt_push_locale (THIS->locale); |
826 | rxvt_push_locale (THIS->locale); |
610 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
827 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
611 | rxvt_pop_locale (); |
828 | rxvt_pop_locale (); |
612 | |
829 | |
613 | char *str = rxvt_wcstoutf8 (wstr); |
830 | RETVAL = wcs2sv (wstr); |
614 | free (wstr); |
831 | free (wstr); |
615 | |
|
|
616 | RETVAL = newSVpv (str, 0); |
|
|
617 | SvUTF8_on (RETVAL); |
|
|
618 | free (str); |
|
|
619 | } |
832 | } |
620 | OUTPUT: |
833 | OUTPUT: |
621 | RETVAL |
834 | RETVAL |
622 | |
835 | |
|
|
836 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
|
|
837 | |
|
|
838 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
839 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
840 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
841 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
842 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
843 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
844 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
845 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
846 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
847 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
848 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
849 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
|
|
850 | |
623 | int |
851 | int |
|
|
852 | rxvt_term::width () |
|
|
853 | ALIAS: |
|
|
854 | width = TERM_OFFSET_width |
|
|
855 | height = TERM_OFFSET_height |
|
|
856 | fwidth = TERM_OFFSET_fwidth |
|
|
857 | fheight = TERM_OFFSET_fheight |
|
|
858 | fbase = TERM_OFFSET_fbase |
|
|
859 | nrow = TERM_OFFSET_nrow |
|
|
860 | ncol = TERM_OFFSET_ncol |
|
|
861 | focus = TERM_OFFSET_focus |
|
|
862 | mapped = TERM_OFFSET_mapped |
|
|
863 | saveLines = TERM_OFFSET_saveLines |
|
|
864 | total_rows = TERM_OFFSET_total_rows |
|
|
865 | nsaved = TERM_OFFSET_nsaved |
|
|
866 | CODE: |
|
|
867 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
868 | OUTPUT: |
|
|
869 | RETVAL |
|
|
870 | |
|
|
871 | unsigned int |
|
|
872 | rxvt_term::ModLevel3Mask () |
|
|
873 | ALIAS: |
|
|
874 | ModLevel3Mask = 0 |
|
|
875 | ModMetaMask = 1 |
|
|
876 | ModNumLockMask = 2 |
|
|
877 | CODE: |
|
|
878 | switch (ix) |
|
|
879 | { |
|
|
880 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
|
|
881 | case 1: RETVAL = THIS->ModMetaMask; break; |
|
|
882 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
883 | } |
|
|
884 | OUTPUT: |
|
|
885 | RETVAL |
|
|
886 | |
|
|
887 | U32 |
|
|
888 | rxvt_term::parent () |
|
|
889 | CODE: |
|
|
890 | RETVAL = (U32)THIS->parent [0]; |
|
|
891 | OUTPUT: |
|
|
892 | RETVAL |
|
|
893 | |
|
|
894 | U32 |
624 | rxvt_term::nsaved () |
895 | rxvt_term::vt () |
625 | CODE: |
896 | CODE: |
|
|
897 | RETVAL = (U32)THIS->vt; |
|
|
898 | OUTPUT: |
|
|
899 | RETVAL |
|
|
900 | |
|
|
901 | U32 |
|
|
902 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
903 | CODE: |
|
|
904 | { |
626 | RETVAL = THIS->nsaved; |
905 | RETVAL = THIS->rstyle; |
|
|
906 | THIS->rstyle = new_rstyle; |
|
|
907 | } |
627 | OUTPUT: |
908 | OUTPUT: |
628 | RETVAL |
909 | RETVAL |
629 | |
910 | |
630 | int |
911 | int |
631 | rxvt_term::view_start (int newval = -1) |
912 | rxvt_term::view_start (int newval = -1) |
632 | CODE: |
913 | CODE: |
633 | { |
914 | { |
… | |
… | |
640 | } |
921 | } |
641 | } |
922 | } |
642 | OUTPUT: |
923 | OUTPUT: |
643 | RETVAL |
924 | RETVAL |
644 | |
925 | |
645 | int |
|
|
646 | rxvt_term::nrow () |
|
|
647 | CODE: |
|
|
648 | RETVAL = THIS->nrow; |
|
|
649 | OUTPUT: |
|
|
650 | RETVAL |
|
|
651 | |
|
|
652 | int |
|
|
653 | rxvt_term::ncol () |
|
|
654 | CODE: |
|
|
655 | RETVAL = THIS->ncol; |
|
|
656 | OUTPUT: |
|
|
657 | RETVAL |
|
|
658 | |
|
|
659 | void |
926 | void |
660 | rxvt_term::want_refresh () |
927 | rxvt_term::want_refresh () |
661 | CODE: |
928 | CODE: |
662 | THIS->want_refresh = 1; |
929 | THIS->want_refresh = 1; |
663 | |
930 | |
664 | void |
931 | void |
665 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
932 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
666 | PPCODE: |
933 | PPCODE: |
667 | { |
934 | { |
668 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
935 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
669 | croak ("row_number number of out range"); |
936 | XSRETURN_EMPTY; |
670 | |
937 | |
671 | line_t &l = ROW(row_number); |
938 | line_t &l = ROW(row_number); |
672 | |
939 | |
673 | if (GIMME_V != G_VOID) |
940 | if (GIMME_V != G_VOID) |
674 | { |
941 | { |
675 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
942 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
676 | |
943 | |
677 | for (int col = 0; col <THIS->ncol; col++) |
944 | for (int col = 0; col < THIS->ncol; col++) |
678 | wstr [col] = l.t [col]; |
945 | wstr [col] = l.t [col]; |
679 | |
946 | |
680 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
|
|
681 | free (wstr); |
|
|
682 | |
|
|
683 | SV *sv = newSVpv (str, 0); |
|
|
684 | SvUTF8_on (sv); |
|
|
685 | XPUSHs (sv_2mortal (sv)); |
947 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
686 | free (str); |
948 | |
|
|
949 | delete [] wstr; |
687 | } |
950 | } |
688 | |
951 | |
689 | if (new_text) |
952 | if (new_text) |
690 | { |
953 | { |
691 | wchar_t *wstr = sv2wcs (new_text); |
954 | wchar_t *wstr = sv2wcs (new_text); |
692 | |
955 | |
693 | int len = wcslen (wstr); |
956 | int len = min (wcslen (wstr) - start_ofs, max_len); |
694 | |
957 | |
695 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
958 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
696 | { |
959 | { |
697 | free (wstr); |
960 | free (wstr); |
698 | croak ("new_text extends beyond horizontal margins"); |
961 | croak ("new_text extends beyond horizontal margins"); |
699 | } |
962 | } |
700 | |
963 | |
701 | for (int col = start_col; col < start_col + len; col++) |
964 | for (int col = start_col; col < start_col + len; col++) |
702 | { |
965 | { |
703 | l.t [col] = wstr [col - start_col]; |
966 | l.t [col] = wstr [start_ofs + col - start_col]; |
704 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
967 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
705 | } |
968 | } |
706 | |
969 | |
707 | free (wstr); |
970 | free (wstr); |
708 | } |
971 | } |
709 | } |
972 | } |
710 | |
973 | |
711 | void |
974 | void |
712 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
975 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
713 | PPCODE: |
976 | PPCODE: |
714 | { |
977 | { |
715 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
978 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
716 | croak ("row_number number of out range"); |
979 | XSRETURN_EMPTY; |
717 | |
980 | |
718 | line_t &l = ROW(row_number); |
981 | line_t &l = ROW(row_number); |
719 | |
982 | |
720 | if (GIMME_V != G_VOID) |
983 | if (GIMME_V != G_VOID) |
721 | { |
984 | { |
… | |
… | |
732 | { |
995 | { |
733 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
996 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
734 | croak ("new_rend must be arrayref"); |
997 | croak ("new_rend must be arrayref"); |
735 | |
998 | |
736 | AV *av = (AV *)SvRV (new_rend); |
999 | AV *av = (AV *)SvRV (new_rend); |
737 | int len = av_len (av) + 1; |
1000 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
738 | |
1001 | |
739 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1002 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
740 | croak ("new_rend array extends beyond horizontal margins"); |
1003 | croak ("new_rend array extends beyond horizontal margins"); |
741 | |
1004 | |
742 | for (int col = start_col; col < start_col + len; col++) |
1005 | for (int col = start_col; col < start_col + len; col++) |
743 | { |
1006 | { |
744 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
1007 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
745 | |
1008 | |
746 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
1009 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
747 | } |
1010 | } |
748 | } |
1011 | } |
749 | } |
1012 | } |
750 | |
1013 | |
751 | int |
1014 | int |
752 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
1015 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
753 | CODE: |
1016 | CODE: |
754 | { |
1017 | { |
755 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1018 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
756 | croak ("row_number number of out range"); |
1019 | XSRETURN_EMPTY; |
757 | |
1020 | |
758 | line_t &l = ROW(row_number); |
1021 | line_t &l = ROW(row_number); |
759 | RETVAL = l.l; |
1022 | RETVAL = l.l; |
760 | |
1023 | |
761 | if (new_length >= -1) |
1024 | if (new_length >= 0) |
762 | l.l = new_length; |
1025 | l.l = new_length; |
763 | } |
1026 | } |
764 | OUTPUT: |
1027 | OUTPUT: |
765 | RETVAL |
1028 | RETVAL |
766 | |
1029 | |
|
|
1030 | bool |
|
|
1031 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
|
|
1032 | CODE: |
|
|
1033 | { |
|
|
1034 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
1035 | XSRETURN_EMPTY; |
|
|
1036 | |
|
|
1037 | line_t &l = ROW(row_number); |
|
|
1038 | RETVAL = l.is_longer (); |
|
|
1039 | |
|
|
1040 | if (new_is_longer >= 0) |
|
|
1041 | l.is_longer (new_is_longer); |
|
|
1042 | } |
|
|
1043 | OUTPUT: |
|
|
1044 | RETVAL |
|
|
1045 | |
767 | SV * |
1046 | SV * |
768 | rxvt_term::special_encode (SV *str) |
1047 | rxvt_term::special_encode (SV *string) |
769 | CODE: |
1048 | CODE: |
770 | abort ();//TODO |
1049 | { |
|
|
1050 | wchar_t *wstr = sv2wcs (string); |
|
|
1051 | int wlen = wcslen (wstr); |
|
|
1052 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
1053 | |
|
|
1054 | rxvt_push_locale (THIS->locale); |
|
|
1055 | |
|
|
1056 | wchar_t *r = rstr; |
|
|
1057 | for (wchar_t *s = wstr; *s; s++) |
|
|
1058 | if (wcwidth (*s) == 0) |
|
|
1059 | { |
|
|
1060 | if (r == rstr) |
|
|
1061 | croak ("leading combining character unencodable"); |
|
|
1062 | |
|
|
1063 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
1064 | if (n == NOCHAR) |
|
|
1065 | n = rxvt_composite.compose (r[-1], *s); |
|
|
1066 | |
|
|
1067 | r[-1] = n; |
|
|
1068 | } |
|
|
1069 | #if !UNICODE_3 |
|
|
1070 | else if (*s >= 0x10000) |
|
|
1071 | *r++ = rxvt_composite.compose (*s); |
|
|
1072 | #endif |
|
|
1073 | else |
|
|
1074 | *r++ = *s; |
|
|
1075 | |
|
|
1076 | rxvt_pop_locale (); |
|
|
1077 | |
|
|
1078 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1079 | |
|
|
1080 | delete [] rstr; |
|
|
1081 | } |
|
|
1082 | OUTPUT: |
|
|
1083 | RETVAL |
771 | |
1084 | |
772 | SV * |
1085 | SV * |
773 | rxvt_term::special_decode (SV *str) |
1086 | rxvt_term::special_decode (SV *text) |
774 | CODE: |
1087 | CODE: |
775 | abort ();//TODO |
1088 | { |
|
|
1089 | wchar_t *wstr = sv2wcs (text); |
|
|
1090 | int wlen = wcslen (wstr); |
|
|
1091 | int dlen = 0; |
|
|
1092 | |
|
|
1093 | // find length |
|
|
1094 | for (wchar_t *s = wstr; *s; s++) |
|
|
1095 | if (*s == NOCHAR) |
|
|
1096 | ; |
|
|
1097 | else if (IS_COMPOSE (*s)) |
|
|
1098 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1099 | else |
|
|
1100 | dlen++; |
|
|
1101 | |
|
|
1102 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1103 | |
|
|
1104 | // decode |
|
|
1105 | wchar_t *r = rstr; |
|
|
1106 | for (wchar_t *s = wstr; *s; s++) |
|
|
1107 | if (*s == NOCHAR) |
|
|
1108 | ; |
|
|
1109 | else if (IS_COMPOSE (*s)) |
|
|
1110 | r += rxvt_composite.expand (*s, r); |
|
|
1111 | else |
|
|
1112 | *r++ = *s; |
|
|
1113 | |
|
|
1114 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1115 | |
|
|
1116 | delete [] rstr; |
|
|
1117 | } |
|
|
1118 | OUTPUT: |
|
|
1119 | RETVAL |
776 | |
1120 | |
777 | void |
1121 | void |
778 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1122 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
779 | PPCODE: |
1123 | PPCODE: |
780 | { |
1124 | { |
781 | struct resval { const char *name; int value; } rslist [] = { |
1125 | struct resval { const char *name; int value; } rslist [] = { |
782 | # define Rs_def(name) { # name, Rs_ ## name }, |
1126 | # define def(name) { # name, Rs_ ## name }, |
783 | # define Rs_reserve(name,count) |
1127 | # define reserve(name,count) |
784 | # include "rsinc.h" |
1128 | # include "rsinc.h" |
785 | # undef Rs_def |
1129 | # undef def |
786 | # undef Rs_reserve |
1130 | # undef reserve |
787 | }; |
1131 | }; |
788 | |
1132 | |
789 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1133 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
790 | |
1134 | |
791 | do { |
1135 | do { |
… | |
… | |
812 | else |
1156 | else |
813 | THIS->rs [index] = 0; |
1157 | THIS->rs [index] = 0; |
814 | } |
1158 | } |
815 | } |
1159 | } |
816 | |
1160 | |
|
|
1161 | bool |
|
|
1162 | rxvt_term::option (U32 optval, int set = -1) |
|
|
1163 | CODE: |
|
|
1164 | { |
|
|
1165 | RETVAL = THIS->options & optval; |
|
|
1166 | |
|
|
1167 | if (set >= 0) |
|
|
1168 | { |
|
|
1169 | if (set) |
|
|
1170 | THIS->options |= optval; |
|
|
1171 | else |
|
|
1172 | THIS->options &= ~optval; |
|
|
1173 | |
|
|
1174 | switch (optval) |
|
|
1175 | { |
|
|
1176 | case Opt_skipBuiltinGlyphs: |
|
|
1177 | THIS->set_fonts (); |
|
|
1178 | THIS->scr_remap_chars (); |
|
|
1179 | THIS->scr_touch (true); |
|
|
1180 | THIS->want_refresh = 1; |
|
|
1181 | break; |
|
|
1182 | |
|
|
1183 | case Opt_cursorUnderline: |
|
|
1184 | THIS->want_refresh = 1; |
|
|
1185 | break; |
|
|
1186 | |
|
|
1187 | # case Opt_scrollBar_floating: |
|
|
1188 | # case Opt_scrollBar_right: |
|
|
1189 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
|
|
1190 | # break; |
|
|
1191 | } |
|
|
1192 | } |
|
|
1193 | } |
|
|
1194 | OUTPUT: |
|
|
1195 | RETVAL |
|
|
1196 | |
817 | void |
1197 | void |
818 | rxvt_term::selection_mark (...) |
1198 | rxvt_term::cur (...) |
819 | PROTOTYPE: $;$$ |
1199 | PROTOTYPE: $;$$ |
820 | ALIAS: |
1200 | ALIAS: |
|
|
1201 | screen_cur = 0 |
821 | selection_beg = 1 |
1202 | selection_beg = 1 |
822 | selection_end = 2 |
1203 | selection_end = 2 |
|
|
1204 | selection_mark = 3 |
823 | PPCODE: |
1205 | PPCODE: |
824 | { |
1206 | { |
825 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1207 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1208 | : ix == 1 ? THIS->selection.beg |
826 | : ix == 2 ? THIS->selection.end |
1209 | : ix == 2 ? THIS->selection.end |
827 | : THIS->selection.mark; |
1210 | : THIS->selection.mark; |
828 | |
1211 | |
829 | if (GIMME_V != G_VOID) |
1212 | if (GIMME_V != G_VOID) |
830 | { |
1213 | { |
831 | EXTEND (SP, 2); |
1214 | EXTEND (SP, 2); |
832 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1215 | PUSHs (sv_2mortal (newSViv (rc.row))); |
833 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1216 | PUSHs (sv_2mortal (newSViv (rc.col))); |
834 | } |
1217 | } |
835 | |
1218 | |
836 | if (items == 3) |
1219 | if (items == 3) |
837 | { |
1220 | { |
838 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1221 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
839 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1222 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
840 | |
1223 | |
841 | if (ix) |
1224 | if (ix) |
842 | THIS->want_refresh = 1; |
1225 | THIS->want_refresh = 1; |
843 | } |
1226 | } |
844 | } |
1227 | } |
845 | |
1228 | |
846 | int |
1229 | int |
847 | rxvt_term::selection_grab (int eventtime) |
1230 | rxvt_term::selection_grab (U32 eventtime) |
848 | |
1231 | |
849 | void |
1232 | void |
850 | rxvt_term::selection (SV *newtext = 0) |
1233 | rxvt_term::selection (SV *newtext = 0) |
851 | PPCODE: |
1234 | PPCODE: |
852 | { |
1235 | { |
853 | if (GIMME_V != G_VOID) |
1236 | if (GIMME_V != G_VOID) |
854 | { |
1237 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
855 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
856 | SV *sv = newSVpv (sel, 0); |
|
|
857 | SvUTF8_on (sv); |
|
|
858 | free (sel); |
|
|
859 | XPUSHs (sv_2mortal (sv)); |
|
|
860 | } |
|
|
861 | |
1238 | |
862 | if (newtext) |
1239 | if (newtext) |
863 | { |
1240 | { |
864 | free (THIS->selection.text); |
1241 | free (THIS->selection.text); |
865 | |
1242 | |
866 | THIS->selection.text = sv2wcs (newtext); |
1243 | THIS->selection.text = sv2wcs (newtext); |
867 | THIS->selection.len = wcslen (THIS->selection.text); |
1244 | THIS->selection.len = wcslen (THIS->selection.text); |
868 | } |
1245 | } |
869 | } |
1246 | } |
870 | |
1247 | |
|
|
1248 | void |
|
|
1249 | rxvt_term::scr_add_lines (SV *string) |
|
|
1250 | CODE: |
|
|
1251 | { |
|
|
1252 | wchar_t *wstr = sv2wcs (string); |
|
|
1253 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
|
|
1254 | free (wstr); |
|
|
1255 | } |
|
|
1256 | |
871 | void |
1257 | void |
872 | rxvt_term::tt_write (SV *octets) |
1258 | rxvt_term::tt_write (SV *octets) |
873 | INIT: |
1259 | INIT: |
874 | STRLEN len; |
1260 | STRLEN len; |
875 | char *str = SvPVbyte (octets, len); |
1261 | char *str = SvPVbyte (octets, len); |
876 | C_ARGS: |
1262 | C_ARGS: |
877 | (unsigned char *)str, len |
1263 | str, len |
|
|
1264 | |
|
|
1265 | void |
|
|
1266 | rxvt_term::cmd_parse (SV *octets) |
|
|
1267 | CODE: |
|
|
1268 | { |
|
|
1269 | STRLEN len; |
|
|
1270 | char *str = SvPVbyte (octets, len); |
|
|
1271 | |
|
|
1272 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1273 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1274 | |
|
|
1275 | THIS->cmdbuf_ptr = str; |
|
|
1276 | THIS->cmdbuf_endp = str + len; |
|
|
1277 | |
|
|
1278 | rxvt_push_locale (THIS->locale); |
|
|
1279 | THIS->cmd_parse (); |
|
|
1280 | rxvt_pop_locale (); |
|
|
1281 | |
|
|
1282 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1283 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1284 | } |
878 | |
1285 | |
879 | SV * |
1286 | SV * |
880 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
1287 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
881 | CODE: |
1288 | CODE: |
882 | { |
1289 | { |
883 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
1290 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
884 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
1291 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
885 | o->self = (HV *)SvRV (RETVAL); |
1292 | o->self = (HV *)SvRV (RETVAL); |
886 | |
|
|
887 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
|
|
888 | char key[33]; sprintf (key, "%32lx", (long)o); |
|
|
889 | hv_store (hv, key, 32, newSViv ((long)o), 0); |
|
|
890 | } |
1293 | } |
891 | OUTPUT: |
1294 | OUTPUT: |
892 | RETVAL |
1295 | RETVAL |
893 | |
1296 | |
894 | MODULE = urxvt PACKAGE = urxvt::overlay |
1297 | MODULE = urxvt PACKAGE = urxvt::overlay |
895 | |
1298 | |
896 | void |
1299 | void |
897 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
1300 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
898 | |
1301 | |
899 | void |
1302 | void |
|
|
1303 | overlay::show () |
|
|
1304 | |
|
|
1305 | void |
|
|
1306 | overlay::hide () |
|
|
1307 | |
|
|
1308 | void |
900 | overlay::DESTROY () |
1309 | overlay::DESTROY () |
901 | CODE: |
|
|
902 | { |
|
|
903 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->THIS->self), "_overlay", 8, 0); |
|
|
904 | if (ovs) |
|
|
905 | { |
|
|
906 | HV *hv = (HV *)SvRV (*ovs); |
|
|
907 | char key[33]; sprintf (key, "%32lx", (long)THIS); |
|
|
908 | hv_delete (hv, key, 32, G_DISCARD); |
|
|
909 | } |
|
|
910 | |
|
|
911 | delete THIS; |
|
|
912 | } |
|
|
913 | |
1310 | |
914 | MODULE = urxvt PACKAGE = urxvt::timer |
1311 | MODULE = urxvt PACKAGE = urxvt::timer |
915 | |
1312 | |
916 | SV * |
1313 | SV * |
917 | timer::new () |
1314 | timer::new () |