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" |
36 | #include "rxvtperl.h" |
37 | #include "rxvtperl.h" |
37 | |
38 | |
38 | #include "perlxsi.c" |
39 | #include "perlxsi.c" |
39 | |
40 | |
|
|
41 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
|
|
42 | # define GRAB_CURSOR THIS->leftptr_cursor |
|
|
43 | #else |
|
|
44 | # define GRAB_CURSOR None |
|
|
45 | #endif |
|
|
46 | |
40 | #undef LINENO |
47 | #undef LINENO |
41 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
48 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
42 | #undef ROW |
49 | #undef ROW |
43 | #define ROW(n) THIS->row_buf [LINENO (n)] |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
44 | |
51 | |
45 | ///////////////////////////////////////////////////////////////////////////// |
52 | ///////////////////////////////////////////////////////////////////////////// |
46 | |
53 | |
|
|
54 | static SV * |
|
|
55 | taint (SV *sv) |
|
|
56 | { |
|
|
57 | SvTAINT (sv); |
|
|
58 | return sv; |
|
|
59 | } |
|
|
60 | |
|
|
61 | static SV * |
|
|
62 | taint_if (SV *sv, SV *src) |
|
|
63 | { |
|
|
64 | if (SvTAINTED (src)) |
|
|
65 | SvTAINT (sv); |
|
|
66 | |
|
|
67 | return sv; |
|
|
68 | } |
|
|
69 | |
47 | static wchar_t * |
70 | static wchar_t * |
48 | sv2wcs (SV *sv) |
71 | sv2wcs (SV *sv) |
49 | { |
72 | { |
50 | STRLEN len; |
73 | STRLEN len; |
51 | char *str = SvPVutf8 (sv, len); |
74 | char *str = SvPVutf8 (sv, len); |
52 | return rxvt_utf8towcs (str, len); |
75 | return rxvt_utf8towcs (str, len); |
53 | } |
76 | } |
54 | |
77 | |
55 | static SV * |
78 | static SV * |
|
|
79 | wcs2sv (wchar_t *wstr, int len = -1) |
|
|
80 | { |
|
|
81 | char *str = rxvt_wcstoutf8 (wstr, len); |
|
|
82 | |
|
|
83 | SV *sv = newSVpv (str, 0); |
|
|
84 | SvUTF8_on (sv); |
|
|
85 | free (str); |
|
|
86 | |
|
|
87 | return sv; |
|
|
88 | } |
|
|
89 | |
|
|
90 | static SV * |
56 | new_ref (HV *hv, const char *klass) |
91 | new_ref (HV *hv, const char *klass) |
57 | { |
92 | { |
58 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
93 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
59 | } |
94 | } |
60 | |
95 | |
… | |
… | |
89 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
124 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
90 | |
125 | |
91 | return (long)mg->mg_ptr; |
126 | return (long)mg->mg_ptr; |
92 | } |
127 | } |
93 | |
128 | |
94 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
129 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
95 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
130 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
96 | |
131 | |
97 | ///////////////////////////////////////////////////////////////////////////// |
132 | ///////////////////////////////////////////////////////////////////////////// |
98 | |
133 | |
99 | struct perl_watcher |
134 | struct perl_watcher |
… | |
… | |
215 | h += 2; |
250 | h += 2; |
216 | } |
251 | } |
217 | |
252 | |
218 | text = new text_t *[h]; |
253 | text = new text_t *[h]; |
219 | rend = new rend_t *[h]; |
254 | rend = new rend_t *[h]; |
220 | |
255 | |
221 | for (int y = 0; y < h; y++) |
256 | for (int y = 0; y < h; y++) |
222 | { |
257 | { |
223 | text_t *tp = text[y] = new text_t[w]; |
258 | text_t *tp = text[y] = new text_t[w]; |
224 | rend_t *rp = rend[y] = new rend_t[w]; |
259 | rend_t *rp = rend[y] = new rend_t[w]; |
225 | |
260 | |
226 | text_t t0, t1, t2; |
261 | text_t t0, t1, t2; |
227 | rend_t r = rstyle; |
262 | rend_t r = rstyle; |
228 | |
263 | |
229 | if (border == 2) |
264 | if (border == 2) |
230 | { |
265 | { |
231 | if (y == 0) |
266 | if (y == 0) |
232 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
267 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
233 | else if (y < h - 1) |
268 | else if (y < h - 1) |
234 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
269 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
235 | else |
270 | else |
236 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
271 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
237 | |
272 | |
238 | *tp++ = t0; |
273 | *tp++ = t0; |
239 | *rp++ = r; |
274 | *rp++ = r; |
240 | |
275 | |
241 | for (int x = w - 2; x-- > 0; ) |
276 | for (int x = w - 2; x-- > 0; ) |
242 | { |
277 | { |
243 | *tp++ = t1; |
278 | *tp++ = t1; |
244 | *rp++ = r; |
279 | *rp++ = r; |
245 | } |
280 | } |
246 | |
281 | |
247 | *tp = t2; |
282 | *tp = t2; |
248 | *rp = r; |
283 | *rp = r; |
249 | } |
284 | } |
250 | else |
285 | else |
251 | for (int x = w; x-- > 0; ) |
286 | for (int x = w; x-- > 0; ) |
252 | { |
287 | { |
253 | *tp++ = 0x0020; |
288 | *tp++ = 0x0020; |
254 | *rp++ = r; |
289 | *rp++ = r; |
255 | } |
290 | } |
256 | } |
291 | } |
257 | |
292 | |
258 | show (); |
293 | show (); |
259 | THIS->want_refresh = 1; |
294 | THIS->want_refresh = 1; |
260 | } |
295 | } |
261 | |
296 | |
… | |
… | |
278 | void |
313 | void |
279 | overlay::show () |
314 | overlay::show () |
280 | { |
315 | { |
281 | char key[33]; sprintf (key, "%32lx", (long)this); |
316 | char key[33]; sprintf (key, "%32lx", (long)this); |
282 | |
317 | |
283 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
318 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
284 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
319 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
285 | } |
320 | } |
286 | |
321 | |
287 | void |
322 | void |
288 | overlay::hide () |
323 | overlay::hide () |
289 | { |
324 | { |
290 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); |
325 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
291 | |
326 | |
292 | if (ovs) |
327 | if (ovs) |
293 | { |
328 | { |
294 | char key[33]; sprintf (key, "%32lx", (long)this); |
329 | char key[33]; sprintf (key, "%32lx", (long)this); |
295 | |
330 | |
… | |
… | |
308 | |
343 | |
309 | for (int y = ov_h; y--; ) |
344 | for (int y = ov_h; y--; ) |
310 | { |
345 | { |
311 | text_t *t1 = text [y]; |
346 | text_t *t1 = text [y]; |
312 | rend_t *r1 = rend [y]; |
347 | rend_t *r1 = rend [y]; |
313 | |
348 | |
314 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
349 | 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; |
350 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
316 | |
351 | |
317 | for (int x = ov_w; x--; ) |
352 | for (int x = ov_w; x--; ) |
318 | { |
353 | { |
319 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
354 | 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)); |
355 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
321 | } |
356 | } |
322 | } |
357 | } |
323 | |
358 | |
… | |
… | |
333 | |
368 | |
334 | wchar_t *wtext = sv2wcs (text); |
369 | wchar_t *wtext = sv2wcs (text); |
335 | |
370 | |
336 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
371 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
337 | this->text [y][x + col] = wtext [col]; |
372 | this->text [y][x + col] = wtext [col]; |
338 | |
373 | |
339 | free (wtext); |
374 | free (wtext); |
340 | |
375 | |
341 | if (rend) |
376 | if (rend) |
342 | { |
377 | { |
343 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
378 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
… | |
… | |
377 | { |
412 | { |
378 | if (!perl) |
413 | if (!perl) |
379 | { |
414 | { |
380 | char *argv[] = { |
415 | char *argv[] = { |
381 | "", |
416 | "", |
|
|
417 | "-T", |
382 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
418 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
383 | }; |
419 | }; |
384 | |
420 | |
385 | perl = perl_alloc (); |
421 | perl = perl_alloc (); |
386 | perl_construct (perl); |
422 | perl_construct (perl); |
387 | |
423 | |
388 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
424 | if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) |
389 | || perl_run (perl)) |
425 | || perl_run (perl)) |
390 | { |
426 | { |
391 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
427 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
392 | |
428 | |
393 | perl_destruct (perl); |
429 | perl_destruct (perl); |
… | |
… | |
400 | bool |
436 | bool |
401 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
437 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
402 | { |
438 | { |
403 | if (!perl) |
439 | if (!perl) |
404 | return false; |
440 | return false; |
405 | |
441 | |
406 | if (htype == HOOK_INIT) // first hook ever called |
442 | if (htype == HOOK_INIT) // first hook ever called |
407 | { |
443 | { |
408 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
444 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
409 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
445 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
410 | } |
446 | } |
411 | else if (!term->self) |
447 | else if (!term->perl.self) |
412 | return false; // perl not initialized for this instance |
448 | return false; // perl not initialized for this instance |
413 | else if (htype == HOOK_DESTROY) |
449 | else if (htype == HOOK_DESTROY) |
414 | { |
450 | { |
415 | // handled later |
451 | // handled later |
416 | } |
452 | } |
417 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
453 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
418 | { |
454 | { |
419 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
455 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
420 | |
456 | |
421 | if (HvKEYS (hv)) |
457 | if (HvKEYS (hv)) |
422 | { |
458 | { |
423 | hv_iterinit (hv); |
459 | hv_iterinit (hv); |
424 | |
460 | |
… | |
… | |
453 | |
489 | |
454 | case DT_LONG: |
490 | case DT_LONG: |
455 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
491 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
456 | break; |
492 | break; |
457 | |
493 | |
458 | case DT_STRING: |
494 | case DT_STR: |
459 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
495 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
|
|
496 | break; |
|
|
497 | |
|
|
498 | case DT_STR_LEN: |
|
|
499 | { |
|
|
500 | char *str = va_arg (ap, char *); |
|
|
501 | int len = va_arg (ap, int); |
|
|
502 | |
|
|
503 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
|
|
504 | } |
|
|
505 | break; |
|
|
506 | |
|
|
507 | case DT_WCS_LEN: |
|
|
508 | { |
|
|
509 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
510 | int wlen = va_arg (ap, int); |
|
|
511 | |
|
|
512 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
|
|
513 | } |
|
|
514 | break; |
|
|
515 | |
|
|
516 | case DT_XEVENT: |
|
|
517 | { |
|
|
518 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
519 | HV *hv = newHV (); |
|
|
520 | |
|
|
521 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
522 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
523 | # undef set |
|
|
524 | |
|
|
525 | setiv (type, xe->type); |
|
|
526 | setiv (send_event, xe->xany.send_event); |
|
|
527 | setiv (serial, xe->xany.serial); |
|
|
528 | |
|
|
529 | switch (xe->type) |
|
|
530 | { |
|
|
531 | case KeyPress: |
|
|
532 | case KeyRelease: |
|
|
533 | case ButtonPress: |
|
|
534 | case ButtonRelease: |
|
|
535 | case MotionNotify: |
|
|
536 | setiv (time, xe->xmotion.time); |
|
|
537 | setiv (x, xe->xmotion.x); |
|
|
538 | setiv (y, xe->xmotion.y); |
|
|
539 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
540 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
541 | setiv (x_root, xe->xmotion.x_root); |
|
|
542 | setiv (y_root, xe->xmotion.y_root); |
|
|
543 | setiv (state, xe->xmotion.state); |
|
|
544 | break; |
|
|
545 | } |
|
|
546 | |
|
|
547 | switch (xe->type) |
|
|
548 | { |
|
|
549 | case KeyPress: |
|
|
550 | case KeyRelease: |
|
|
551 | setiv (keycode, xe->xkey.keycode); |
|
|
552 | break; |
|
|
553 | |
|
|
554 | case ButtonPress: |
|
|
555 | case ButtonRelease: |
|
|
556 | setiv (button, xe->xbutton.button); |
|
|
557 | break; |
|
|
558 | |
|
|
559 | case MotionNotify: |
|
|
560 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
561 | break; |
|
|
562 | } |
|
|
563 | |
|
|
564 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
565 | } |
460 | break; |
566 | break; |
461 | |
567 | |
462 | case DT_END: |
568 | case DT_END: |
463 | { |
569 | { |
464 | va_end (ap); |
570 | va_end (ap); |
… | |
… | |
480 | if (SvTRUE (ERRSV)) |
586 | if (SvTRUE (ERRSV)) |
481 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
587 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
482 | |
588 | |
483 | if (htype == HOOK_DESTROY) |
589 | if (htype == HOOK_DESTROY) |
484 | { |
590 | { |
485 | clearSVptr ((SV *)term->self); |
591 | clearSVptr ((SV *)term->perl.self); |
486 | SvREFCNT_dec ((SV *)term->self); |
592 | SvREFCNT_dec ((SV *)term->perl.self); |
487 | } |
593 | } |
488 | |
594 | |
489 | return count; |
595 | return count; |
490 | } |
596 | } |
491 | |
597 | |
… | |
… | |
501 | |
607 | |
502 | PROTOTYPES: ENABLE |
608 | PROTOTYPES: ENABLE |
503 | |
609 | |
504 | BOOT: |
610 | BOOT: |
505 | { |
611 | { |
506 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
612 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
613 | |
507 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
614 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
508 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
615 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
509 | # include "hookinc.h" |
616 | # include "hookinc.h" |
510 | # undef def |
617 | # undef def |
511 | |
618 | |
|
|
619 | HV *option = get_hv ("urxvt::OPTION", 1); |
|
|
620 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
|
|
621 | # define nodef(name) |
|
|
622 | # include "optinc.h" |
|
|
623 | # undef nodef |
|
|
624 | # undef def |
|
|
625 | |
|
|
626 | HV *stash = gv_stashpv ("urxvt", 1); |
|
|
627 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
512 | export_const (DEFAULT_RSTYLE); |
628 | export_const_iv (DEFAULT_RSTYLE); |
513 | export_const (OVERLAY_RSTYLE); |
629 | export_const_iv (OVERLAY_RSTYLE); |
514 | export_const (RS_Bold); |
630 | export_const_iv (RS_Bold); |
515 | export_const (RS_Italic); |
631 | export_const_iv (RS_Italic); |
516 | export_const (RS_Blink); |
632 | export_const_iv (RS_Blink); |
517 | export_const (RS_RVid); |
633 | export_const_iv (RS_RVid); |
518 | export_const (RS_Uline); |
634 | export_const_iv (RS_Uline); |
519 | |
635 | |
520 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
636 | export_const_iv (CurrentTime); |
|
|
637 | export_const_iv (ShiftMask); |
|
|
638 | export_const_iv (LockMask); |
|
|
639 | export_const_iv (ControlMask); |
|
|
640 | export_const_iv (Mod1Mask); |
|
|
641 | export_const_iv (Mod2Mask); |
|
|
642 | export_const_iv (Mod3Mask); |
|
|
643 | export_const_iv (Mod4Mask); |
|
|
644 | export_const_iv (Mod5Mask); |
|
|
645 | export_const_iv (Button1Mask); |
|
|
646 | export_const_iv (Button2Mask); |
|
|
647 | export_const_iv (Button3Mask); |
|
|
648 | export_const_iv (Button4Mask); |
|
|
649 | export_const_iv (Button5Mask); |
|
|
650 | export_const_iv (AnyModifier); |
521 | } |
651 | } |
|
|
652 | |
|
|
653 | SV * |
|
|
654 | new (...) |
|
|
655 | CODE: |
|
|
656 | { |
|
|
657 | stringvec *argv = new stringvec; |
|
|
658 | bool success; |
|
|
659 | |
|
|
660 | for (int i = 0; i < items ;i++) |
|
|
661 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
662 | |
|
|
663 | rxvt_term *term = new rxvt_term; |
|
|
664 | |
|
|
665 | term->argv = argv; |
|
|
666 | |
|
|
667 | try |
|
|
668 | { |
|
|
669 | if (!term->init (argv->size (), argv->begin ())) |
|
|
670 | term = 0; |
|
|
671 | } |
|
|
672 | catch (const class rxvt_failure_exception &e) |
|
|
673 | { |
|
|
674 | term->destroy (); |
|
|
675 | croak ("exception caught while initializing new terminal instance"); |
|
|
676 | } |
|
|
677 | |
|
|
678 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
|
|
679 | } |
|
|
680 | OUTPUT: |
|
|
681 | RETVAL |
522 | |
682 | |
523 | void |
683 | void |
524 | set_should_invoke (int htype, int value) |
684 | set_should_invoke (int htype, int value) |
525 | CODE: |
685 | CODE: |
526 | rxvt_perl.should_invoke [htype] = value; |
686 | rxvt_perl.should_invoke [htype] = value; |
… | |
… | |
589 | } |
749 | } |
590 | OUTPUT: |
750 | OUTPUT: |
591 | RETVAL |
751 | RETVAL |
592 | |
752 | |
593 | MODULE = urxvt PACKAGE = urxvt::term |
753 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
754 | |
|
|
755 | void |
|
|
756 | rxvt_term::destroy () |
|
|
757 | |
|
|
758 | void |
|
|
759 | rxvt_term::grab_button (int button, U32 modifiers) |
|
|
760 | CODE: |
|
|
761 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
|
|
762 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
763 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
764 | |
|
|
765 | bool |
|
|
766 | rxvt_term::grab (U32 eventtime, int sync = 0) |
|
|
767 | CODE: |
|
|
768 | { |
|
|
769 | int mode = sync ? GrabModeSync : GrabModeAsync; |
|
|
770 | |
|
|
771 | THIS->perl.grabtime = 0; |
|
|
772 | |
|
|
773 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
774 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
775 | mode, mode, None, GRAB_CURSOR, eventtime)) |
|
|
776 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
|
|
777 | THIS->perl.grabtime = eventtime; |
|
|
778 | else |
|
|
779 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
780 | |
|
|
781 | RETVAL = !!THIS->perl.grabtime; |
|
|
782 | } |
|
|
783 | OUTPUT: |
|
|
784 | RETVAL |
|
|
785 | |
|
|
786 | void |
|
|
787 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
|
|
788 | CODE: |
|
|
789 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
|
|
790 | |
|
|
791 | void |
|
|
792 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
|
|
793 | CODE: |
|
|
794 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
|
|
795 | |
|
|
796 | void |
|
|
797 | rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) |
|
|
798 | CODE: |
|
|
799 | XAllowEvents (THIS->display->display, ReplayPointer, eventtime); |
|
|
800 | XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); |
|
|
801 | |
|
|
802 | void |
|
|
803 | rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) |
|
|
804 | CODE: |
|
|
805 | THIS->perl.grabtime = 0; |
|
|
806 | XUngrabKeyboard (THIS->display->display, eventtime); |
|
|
807 | XUngrabPointer (THIS->display->display, eventtime); |
594 | |
808 | |
595 | int |
809 | int |
596 | rxvt_term::strwidth (SV *str) |
810 | rxvt_term::strwidth (SV *str) |
597 | CODE: |
811 | CODE: |
598 | { |
812 | { |
… | |
… | |
617 | char *mbstr = rxvt_wcstombs (wstr); |
831 | char *mbstr = rxvt_wcstombs (wstr); |
618 | rxvt_pop_locale (); |
832 | rxvt_pop_locale (); |
619 | |
833 | |
620 | free (wstr); |
834 | free (wstr); |
621 | |
835 | |
622 | RETVAL = newSVpv (mbstr, 0); |
836 | RETVAL = taint_if (newSVpv (mbstr, 0), str); |
623 | free (mbstr); |
837 | free (mbstr); |
624 | } |
838 | } |
625 | OUTPUT: |
839 | OUTPUT: |
626 | RETVAL |
840 | RETVAL |
627 | |
841 | |
… | |
… | |
634 | |
848 | |
635 | rxvt_push_locale (THIS->locale); |
849 | rxvt_push_locale (THIS->locale); |
636 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
850 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
637 | rxvt_pop_locale (); |
851 | rxvt_pop_locale (); |
638 | |
852 | |
639 | char *str = rxvt_wcstoutf8 (wstr); |
853 | RETVAL = taint_if (wcs2sv (wstr), octets); |
640 | free (wstr); |
854 | free (wstr); |
641 | |
|
|
642 | RETVAL = newSVpv (str, 0); |
|
|
643 | SvUTF8_on (RETVAL); |
|
|
644 | free (str); |
|
|
645 | } |
855 | } |
646 | OUTPUT: |
856 | OUTPUT: |
647 | RETVAL |
857 | RETVAL |
648 | |
858 | |
|
|
859 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
|
|
860 | |
|
|
861 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
862 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
863 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
864 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
865 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
866 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
867 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
868 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
869 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
870 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
871 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
872 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
|
|
873 | |
649 | int |
874 | int |
|
|
875 | rxvt_term::width () |
|
|
876 | ALIAS: |
|
|
877 | width = TERM_OFFSET_width |
|
|
878 | height = TERM_OFFSET_height |
|
|
879 | fwidth = TERM_OFFSET_fwidth |
|
|
880 | fheight = TERM_OFFSET_fheight |
|
|
881 | fbase = TERM_OFFSET_fbase |
|
|
882 | nrow = TERM_OFFSET_nrow |
|
|
883 | ncol = TERM_OFFSET_ncol |
|
|
884 | focus = TERM_OFFSET_focus |
|
|
885 | mapped = TERM_OFFSET_mapped |
|
|
886 | saveLines = TERM_OFFSET_saveLines |
|
|
887 | total_rows = TERM_OFFSET_total_rows |
|
|
888 | nsaved = TERM_OFFSET_nsaved |
|
|
889 | CODE: |
|
|
890 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
891 | OUTPUT: |
|
|
892 | RETVAL |
|
|
893 | |
|
|
894 | unsigned int |
|
|
895 | rxvt_term::ModLevel3Mask () |
|
|
896 | ALIAS: |
|
|
897 | ModLevel3Mask = 0 |
|
|
898 | ModMetaMask = 1 |
|
|
899 | ModNumLockMask = 2 |
|
|
900 | CODE: |
|
|
901 | switch (ix) |
|
|
902 | { |
|
|
903 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
|
|
904 | case 1: RETVAL = THIS->ModMetaMask; break; |
|
|
905 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
906 | } |
|
|
907 | OUTPUT: |
|
|
908 | RETVAL |
|
|
909 | |
|
|
910 | U32 |
|
|
911 | rxvt_term::parent () |
|
|
912 | CODE: |
|
|
913 | RETVAL = (U32)THIS->parent [0]; |
|
|
914 | OUTPUT: |
|
|
915 | RETVAL |
|
|
916 | |
|
|
917 | U32 |
650 | rxvt_term::nsaved () |
918 | rxvt_term::vt () |
651 | CODE: |
919 | CODE: |
|
|
920 | RETVAL = (U32)THIS->vt; |
|
|
921 | OUTPUT: |
|
|
922 | RETVAL |
|
|
923 | |
|
|
924 | U32 |
|
|
925 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
926 | CODE: |
|
|
927 | { |
652 | RETVAL = THIS->nsaved; |
928 | RETVAL = THIS->rstyle; |
|
|
929 | THIS->rstyle = new_rstyle; |
|
|
930 | } |
653 | OUTPUT: |
931 | OUTPUT: |
654 | RETVAL |
932 | RETVAL |
655 | |
933 | |
656 | int |
934 | int |
657 | rxvt_term::view_start (int newval = -1) |
935 | rxvt_term::view_start (int newval = -1) |
658 | CODE: |
936 | CODE: |
659 | { |
937 | { |
… | |
… | |
666 | } |
944 | } |
667 | } |
945 | } |
668 | OUTPUT: |
946 | OUTPUT: |
669 | RETVAL |
947 | RETVAL |
670 | |
948 | |
671 | int |
|
|
672 | rxvt_term::nrow () |
|
|
673 | CODE: |
|
|
674 | RETVAL = THIS->nrow; |
|
|
675 | OUTPUT: |
|
|
676 | RETVAL |
|
|
677 | |
|
|
678 | int |
|
|
679 | rxvt_term::ncol () |
|
|
680 | CODE: |
|
|
681 | RETVAL = THIS->ncol; |
|
|
682 | OUTPUT: |
|
|
683 | RETVAL |
|
|
684 | |
|
|
685 | void |
949 | void |
686 | rxvt_term::want_refresh () |
950 | rxvt_term::want_refresh () |
687 | CODE: |
951 | CODE: |
688 | THIS->want_refresh = 1; |
952 | THIS->want_refresh = 1; |
689 | |
953 | |
690 | void |
954 | void |
691 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
955 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
692 | PPCODE: |
956 | PPCODE: |
693 | { |
957 | { |
694 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
958 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
695 | XSRETURN_EMPTY; |
959 | XSRETURN_EMPTY; |
696 | |
960 | |
… | |
… | |
698 | |
962 | |
699 | if (GIMME_V != G_VOID) |
963 | if (GIMME_V != G_VOID) |
700 | { |
964 | { |
701 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
965 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
702 | |
966 | |
703 | for (int col = 0; col <THIS->ncol; col++) |
967 | for (int col = 0; col < THIS->ncol; col++) |
704 | wstr [col] = l.t [col]; |
968 | wstr [col] = l.t [col]; |
705 | |
969 | |
706 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
970 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); |
707 | free (wstr); |
|
|
708 | |
971 | |
709 | SV *sv = newSVpv (str, 0); |
972 | delete [] wstr; |
710 | SvUTF8_on (sv); |
|
|
711 | XPUSHs (sv_2mortal (sv)); |
|
|
712 | free (str); |
|
|
713 | } |
973 | } |
714 | |
974 | |
715 | if (new_text) |
975 | if (new_text) |
716 | { |
976 | { |
717 | wchar_t *wstr = sv2wcs (new_text); |
977 | wchar_t *wstr = sv2wcs (new_text); |
718 | |
978 | |
719 | int len = wcslen (wstr); |
979 | int len = min (wcslen (wstr) - start_ofs, max_len); |
720 | |
980 | |
721 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
981 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
722 | { |
982 | { |
723 | free (wstr); |
983 | free (wstr); |
724 | croak ("new_text extends beyond horizontal margins"); |
984 | croak ("new_text extends beyond horizontal margins"); |
725 | } |
985 | } |
726 | |
986 | |
727 | for (int col = start_col; col < start_col + len; col++) |
987 | for (int col = start_col; col < start_col + len; col++) |
728 | { |
988 | { |
729 | l.t [col] = wstr [col - start_col]; |
989 | l.t [col] = wstr [start_ofs + col - start_col]; |
730 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
990 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
731 | } |
991 | } |
732 | |
992 | |
733 | free (wstr); |
993 | free (wstr); |
734 | } |
994 | } |
735 | } |
995 | } |
736 | |
996 | |
737 | void |
997 | void |
738 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
998 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
739 | PPCODE: |
999 | PPCODE: |
740 | { |
1000 | { |
741 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1001 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
742 | XSRETURN_EMPTY; |
1002 | XSRETURN_EMPTY; |
743 | |
1003 | |
… | |
… | |
758 | { |
1018 | { |
759 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1019 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
760 | croak ("new_rend must be arrayref"); |
1020 | croak ("new_rend must be arrayref"); |
761 | |
1021 | |
762 | AV *av = (AV *)SvRV (new_rend); |
1022 | AV *av = (AV *)SvRV (new_rend); |
763 | int len = av_len (av) + 1; |
1023 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
764 | |
1024 | |
765 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1025 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
766 | croak ("new_rend array extends beyond horizontal margins"); |
1026 | croak ("new_rend array extends beyond horizontal margins"); |
767 | |
1027 | |
768 | for (int col = start_col; col < start_col + len; col++) |
1028 | for (int col = start_col; col < start_col + len; col++) |
769 | { |
1029 | { |
770 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
1030 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
771 | |
1031 | |
772 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
1032 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
773 | } |
1033 | } |
774 | } |
1034 | } |
775 | } |
1035 | } |
776 | |
1036 | |
777 | int |
1037 | int |
778 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
1038 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
779 | CODE: |
1039 | CODE: |
780 | { |
1040 | { |
781 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1041 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
782 | XSRETURN_EMPTY; |
1042 | XSRETURN_EMPTY; |
783 | |
1043 | |
784 | line_t &l = ROW(row_number); |
1044 | line_t &l = ROW(row_number); |
785 | RETVAL = l.l < 0 ? THIS->ncol : l.l; |
1045 | RETVAL = l.l; |
786 | |
1046 | |
787 | if (new_length >= -1) |
1047 | if (new_length >= 0) |
788 | l.l = new_length; |
1048 | l.l = new_length; |
789 | } |
1049 | } |
790 | OUTPUT: |
1050 | OUTPUT: |
791 | RETVAL |
1051 | RETVAL |
792 | |
1052 | |
793 | bool |
1053 | bool |
794 | rxvt_term::ROW_is_longer (int row_number) |
1054 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
795 | CODE: |
1055 | CODE: |
796 | { |
1056 | { |
797 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1057 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
798 | XSRETURN_EMPTY; |
1058 | XSRETURN_EMPTY; |
799 | |
1059 | |
800 | line_t &l = ROW(row_number); |
1060 | line_t &l = ROW(row_number); |
801 | RETVAL = l.l < 0; |
1061 | RETVAL = l.is_longer (); |
|
|
1062 | |
|
|
1063 | if (new_is_longer >= 0) |
|
|
1064 | l.is_longer (new_is_longer); |
802 | } |
1065 | } |
803 | OUTPUT: |
1066 | OUTPUT: |
804 | RETVAL |
1067 | RETVAL |
805 | |
1068 | |
806 | SV * |
1069 | SV * |
807 | rxvt_term::special_encode (SV *str) |
1070 | rxvt_term::special_encode (SV *string) |
808 | CODE: |
1071 | CODE: |
809 | abort ();//TODO |
1072 | { |
|
|
1073 | wchar_t *wstr = sv2wcs (string); |
|
|
1074 | int wlen = wcslen (wstr); |
|
|
1075 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
1076 | |
|
|
1077 | rxvt_push_locale (THIS->locale); |
|
|
1078 | |
|
|
1079 | wchar_t *r = rstr; |
|
|
1080 | for (wchar_t *s = wstr; *s; s++) |
|
|
1081 | if (wcwidth (*s) == 0) |
|
|
1082 | { |
|
|
1083 | if (r == rstr) |
|
|
1084 | croak ("leading combining character unencodable"); |
|
|
1085 | |
|
|
1086 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
1087 | if (n == NOCHAR) |
|
|
1088 | n = rxvt_composite.compose (r[-1], *s); |
|
|
1089 | |
|
|
1090 | r[-1] = n; |
|
|
1091 | } |
|
|
1092 | #if !UNICODE_3 |
|
|
1093 | else if (*s >= 0x10000) |
|
|
1094 | *r++ = rxvt_composite.compose (*s); |
|
|
1095 | #endif |
|
|
1096 | else |
|
|
1097 | *r++ = *s; |
|
|
1098 | |
|
|
1099 | rxvt_pop_locale (); |
|
|
1100 | |
|
|
1101 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); |
|
|
1102 | |
|
|
1103 | delete [] rstr; |
|
|
1104 | } |
|
|
1105 | OUTPUT: |
|
|
1106 | RETVAL |
810 | |
1107 | |
811 | SV * |
1108 | SV * |
812 | rxvt_term::special_decode (SV *str) |
1109 | rxvt_term::special_decode (SV *text) |
813 | CODE: |
1110 | CODE: |
814 | abort ();//TODO |
1111 | { |
|
|
1112 | wchar_t *wstr = sv2wcs (text); |
|
|
1113 | int wlen = wcslen (wstr); |
|
|
1114 | int dlen = 0; |
|
|
1115 | |
|
|
1116 | // find length |
|
|
1117 | for (wchar_t *s = wstr; *s; s++) |
|
|
1118 | if (*s == NOCHAR) |
|
|
1119 | ; |
|
|
1120 | else if (IS_COMPOSE (*s)) |
|
|
1121 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1122 | else |
|
|
1123 | dlen++; |
|
|
1124 | |
|
|
1125 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1126 | |
|
|
1127 | // decode |
|
|
1128 | wchar_t *r = rstr; |
|
|
1129 | for (wchar_t *s = wstr; *s; s++) |
|
|
1130 | if (*s == NOCHAR) |
|
|
1131 | ; |
|
|
1132 | else if (IS_COMPOSE (*s)) |
|
|
1133 | r += rxvt_composite.expand (*s, r); |
|
|
1134 | else |
|
|
1135 | *r++ = *s; |
|
|
1136 | |
|
|
1137 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); |
|
|
1138 | |
|
|
1139 | delete [] rstr; |
|
|
1140 | } |
|
|
1141 | OUTPUT: |
|
|
1142 | RETVAL |
815 | |
1143 | |
816 | void |
1144 | void |
817 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1145 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
818 | PPCODE: |
1146 | PPCODE: |
819 | { |
1147 | { |
… | |
… | |
836 | |
1164 | |
837 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1165 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
838 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1166 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
839 | |
1167 | |
840 | if (GIMME_V != G_VOID) |
1168 | if (GIMME_V != G_VOID) |
841 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
1169 | XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); |
842 | |
1170 | |
843 | if (newval) |
1171 | if (newval) |
844 | { |
1172 | { |
845 | if (SvOK (newval)) |
1173 | if (SvOK (newval)) |
846 | { |
1174 | { |
… | |
… | |
851 | else |
1179 | else |
852 | THIS->rs [index] = 0; |
1180 | THIS->rs [index] = 0; |
853 | } |
1181 | } |
854 | } |
1182 | } |
855 | |
1183 | |
|
|
1184 | bool |
|
|
1185 | rxvt_term::option (U32 optval, int set = -1) |
|
|
1186 | CODE: |
|
|
1187 | { |
|
|
1188 | RETVAL = THIS->options & optval; |
|
|
1189 | |
|
|
1190 | if (set >= 0) |
|
|
1191 | { |
|
|
1192 | if (set) |
|
|
1193 | THIS->options |= optval; |
|
|
1194 | else |
|
|
1195 | THIS->options &= ~optval; |
|
|
1196 | |
|
|
1197 | switch (optval) |
|
|
1198 | { |
|
|
1199 | case Opt_skipBuiltinGlyphs: |
|
|
1200 | THIS->set_fonts (); |
|
|
1201 | THIS->scr_remap_chars (); |
|
|
1202 | THIS->scr_touch (true); |
|
|
1203 | THIS->want_refresh = 1; |
|
|
1204 | break; |
|
|
1205 | |
|
|
1206 | case Opt_cursorUnderline: |
|
|
1207 | THIS->want_refresh = 1; |
|
|
1208 | break; |
|
|
1209 | |
|
|
1210 | # case Opt_scrollBar_floating: |
|
|
1211 | # case Opt_scrollBar_right: |
|
|
1212 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
|
|
1213 | # break; |
|
|
1214 | } |
|
|
1215 | } |
|
|
1216 | } |
|
|
1217 | OUTPUT: |
|
|
1218 | RETVAL |
|
|
1219 | |
856 | void |
1220 | void |
857 | rxvt_term::selection_mark (...) |
1221 | rxvt_term::cur (...) |
858 | PROTOTYPE: $;$$ |
1222 | PROTOTYPE: $;$$ |
859 | ALIAS: |
1223 | ALIAS: |
|
|
1224 | screen_cur = 0 |
860 | selection_beg = 1 |
1225 | selection_beg = 1 |
861 | selection_end = 2 |
1226 | selection_end = 2 |
|
|
1227 | selection_mark = 3 |
862 | PPCODE: |
1228 | PPCODE: |
863 | { |
1229 | { |
864 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1230 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1231 | : ix == 1 ? THIS->selection.beg |
865 | : ix == 2 ? THIS->selection.end |
1232 | : ix == 2 ? THIS->selection.end |
866 | : THIS->selection.mark; |
1233 | : THIS->selection.mark; |
867 | |
1234 | |
868 | if (GIMME_V != G_VOID) |
1235 | if (GIMME_V != G_VOID) |
869 | { |
1236 | { |
870 | EXTEND (SP, 2); |
1237 | EXTEND (SP, 2); |
871 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1238 | PUSHs (sv_2mortal (newSViv (rc.row))); |
872 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1239 | PUSHs (sv_2mortal (newSViv (rc.col))); |
873 | } |
1240 | } |
874 | |
1241 | |
875 | if (items == 3) |
1242 | if (items == 3) |
876 | { |
1243 | { |
877 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1244 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
878 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1245 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
879 | |
1246 | |
880 | if (ix) |
1247 | if (ix) |
881 | THIS->want_refresh = 1; |
1248 | THIS->want_refresh = 1; |
882 | } |
1249 | } |
883 | } |
1250 | } |
884 | |
1251 | |
885 | int |
1252 | int |
886 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
1253 | rxvt_term::selection_grab (U32 eventtime) |
887 | |
1254 | |
888 | void |
1255 | void |
889 | rxvt_term::selection (SV *newtext = 0) |
1256 | rxvt_term::selection (SV *newtext = 0) |
890 | PPCODE: |
1257 | PPCODE: |
891 | { |
1258 | { |
892 | if (GIMME_V != G_VOID) |
1259 | if (GIMME_V != G_VOID) |
893 | { |
1260 | XPUSHs (taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))); |
894 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
895 | SV *sv = newSVpv (sel, 0); |
|
|
896 | SvUTF8_on (sv); |
|
|
897 | free (sel); |
|
|
898 | XPUSHs (sv_2mortal (sv)); |
|
|
899 | } |
|
|
900 | |
1261 | |
901 | if (newtext) |
1262 | if (newtext) |
902 | { |
1263 | { |
903 | free (THIS->selection.text); |
1264 | free (THIS->selection.text); |
904 | |
1265 | |
905 | THIS->selection.text = sv2wcs (newtext); |
1266 | THIS->selection.text = sv2wcs (newtext); |
906 | THIS->selection.len = wcslen (THIS->selection.text); |
1267 | THIS->selection.len = wcslen (THIS->selection.text); |
907 | } |
1268 | } |
908 | } |
1269 | } |
909 | |
1270 | |
|
|
1271 | void |
|
|
1272 | rxvt_term::scr_add_lines (SV *string) |
|
|
1273 | CODE: |
|
|
1274 | { |
|
|
1275 | wchar_t *wstr = sv2wcs (string); |
|
|
1276 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
|
|
1277 | free (wstr); |
|
|
1278 | } |
|
|
1279 | |
910 | void |
1280 | void |
911 | rxvt_term::tt_write (SV *octets) |
1281 | rxvt_term::tt_write (SV *octets) |
912 | INIT: |
1282 | INIT: |
913 | STRLEN len; |
1283 | STRLEN len; |
914 | char *str = SvPVbyte (octets, len); |
1284 | char *str = SvPVbyte (octets, len); |
915 | C_ARGS: |
1285 | C_ARGS: |
916 | (unsigned char *)str, len |
1286 | str, len |
|
|
1287 | |
|
|
1288 | void |
|
|
1289 | rxvt_term::cmd_parse (SV *octets) |
|
|
1290 | CODE: |
|
|
1291 | { |
|
|
1292 | STRLEN len; |
|
|
1293 | char *str = SvPVbyte (octets, len); |
|
|
1294 | |
|
|
1295 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1296 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1297 | |
|
|
1298 | THIS->cmdbuf_ptr = str; |
|
|
1299 | THIS->cmdbuf_endp = str + len; |
|
|
1300 | |
|
|
1301 | rxvt_push_locale (THIS->locale); |
|
|
1302 | THIS->cmd_parse (); |
|
|
1303 | rxvt_pop_locale (); |
|
|
1304 | |
|
|
1305 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1306 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1307 | } |
917 | |
1308 | |
918 | SV * |
1309 | SV * |
919 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
1310 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
920 | CODE: |
1311 | CODE: |
921 | { |
1312 | { |