… | |
… | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
31 | #include <cstddef> |
31 | #include <cstddef> |
32 | #include <cstdarg> |
32 | #include <cstdarg> |
33 | |
33 | |
|
|
34 | #include "unistd.h" |
|
|
35 | |
34 | #include "iom.h" |
36 | #include "iom.h" |
35 | #include "rxvt.h" |
37 | #include "rxvt.h" |
36 | #include "keyboard.h" |
38 | #include "keyboard.h" |
37 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
38 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
39 | |
41 | |
40 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
41 | |
43 | |
42 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
44 | #ifdef HAVE_SCROLLBARS |
43 | # define GRAB_CURSOR THIS->leftptr_cursor |
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
44 | #else |
46 | #else |
45 | # define GRAB_CURSOR None |
47 | # define GRAB_CURSOR None |
46 | #endif |
48 | #endif |
47 | |
49 | |
48 | #undef LINENO |
50 | #undef LINENO |
49 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
50 | #undef ROW |
52 | #undef ROW |
51 | #define ROW(n) THIS->row_buf [LINENO (n)] |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
52 | |
54 | |
|
|
55 | #define ENABLE_PERL_FRILLS 1 |
|
|
56 | |
53 | ///////////////////////////////////////////////////////////////////////////// |
57 | ///////////////////////////////////////////////////////////////////////////// |
54 | |
|
|
55 | static SV * |
|
|
56 | taint (SV *sv) |
|
|
57 | { |
|
|
58 | SvTAINT (sv); |
|
|
59 | return sv; |
|
|
60 | } |
|
|
61 | |
|
|
62 | static SV * |
|
|
63 | taint_if (SV *sv, SV *src) |
|
|
64 | { |
|
|
65 | if (SvTAINTED (src)) |
|
|
66 | SvTAINT (sv); |
|
|
67 | |
|
|
68 | return sv; |
|
|
69 | } |
|
|
70 | |
58 | |
71 | static wchar_t * |
59 | static wchar_t * |
72 | sv2wcs (SV *sv) |
60 | sv2wcs (SV *sv) |
73 | { |
61 | { |
74 | STRLEN len; |
62 | STRLEN len; |
… | |
… | |
345 | for (int y = ov_h; y--; ) |
333 | for (int y = ov_h; y--; ) |
346 | { |
334 | { |
347 | text_t *t1 = text [y]; |
335 | text_t *t1 = text [y]; |
348 | rend_t *r1 = rend [y]; |
336 | rend_t *r1 = rend [y]; |
349 | |
337 | |
350 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
338 | text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x; |
351 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
339 | rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x; |
352 | |
340 | |
353 | for (int x = ov_w; x--; ) |
341 | for (int x = ov_w; x--; ) |
354 | { |
342 | { |
355 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
343 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
356 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
344 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
… | |
… | |
393 | |
381 | |
394 | struct rxvt_perl_interp rxvt_perl; |
382 | struct rxvt_perl_interp rxvt_perl; |
395 | |
383 | |
396 | static PerlInterpreter *perl; |
384 | static PerlInterpreter *perl; |
397 | |
385 | |
398 | rxvt_perl_interp::rxvt_perl_interp () |
|
|
399 | { |
|
|
400 | } |
|
|
401 | |
|
|
402 | rxvt_perl_interp::~rxvt_perl_interp () |
386 | rxvt_perl_interp::~rxvt_perl_interp () |
403 | { |
387 | { |
404 | if (perl) |
388 | if (perl) |
405 | { |
389 | { |
406 | perl_destruct (perl); |
390 | perl_destruct (perl); |
407 | perl_free (perl); |
391 | perl_free (perl); |
408 | } |
392 | } |
409 | } |
393 | } |
410 | |
394 | |
411 | void |
395 | void |
412 | rxvt_perl_interp::init () |
396 | rxvt_perl_interp::init (rxvt_term *term) |
413 | { |
397 | { |
414 | if (!perl) |
398 | if (!perl) |
415 | { |
399 | { |
|
|
400 | rxvt_push_locale (""); // perl init destroys current locale |
|
|
401 | |
|
|
402 | perl_environ = rxvt_environ; |
|
|
403 | swap (perl_environ, environ); |
|
|
404 | |
416 | char *argv[] = { |
405 | char *argv[] = { |
417 | "", |
406 | "", |
418 | "-T", |
407 | "-e" |
419 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
408 | "BEGIN {" |
|
|
409 | " urxvt->bootstrap;" |
|
|
410 | " unshift @INC, '" LIBDIR "';" |
|
|
411 | "}" |
|
|
412 | "" |
|
|
413 | "use urxvt;" |
420 | }; |
414 | }; |
421 | |
415 | |
422 | perl = perl_alloc (); |
416 | perl = perl_alloc (); |
423 | perl_construct (perl); |
417 | perl_construct (perl); |
424 | |
418 | |
425 | if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) |
419 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
426 | || perl_run (perl)) |
420 | || perl_run (perl)) |
427 | { |
421 | { |
428 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
422 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
429 | |
423 | |
430 | perl_destruct (perl); |
424 | perl_destruct (perl); |
431 | perl_free (perl); |
425 | perl_free (perl); |
432 | perl = 0; |
426 | perl = 0; |
433 | } |
427 | } |
|
|
428 | |
|
|
429 | swap (perl_environ, environ); |
|
|
430 | |
|
|
431 | rxvt_pop_locale (); |
|
|
432 | } |
|
|
433 | |
|
|
434 | if (perl) |
|
|
435 | { |
|
|
436 | // runs outside of perls ENV |
|
|
437 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
438 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
434 | } |
439 | } |
435 | } |
440 | } |
436 | |
441 | |
437 | static void |
442 | static void |
438 | ungrab (rxvt_term *THIS) |
443 | ungrab (rxvt_term *THIS) |
… | |
… | |
443 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
448 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
444 | THIS->perl.grabtime = 0; |
449 | THIS->perl.grabtime = 0; |
445 | } |
450 | } |
446 | } |
451 | } |
447 | |
452 | |
|
|
453 | static void |
|
|
454 | swap_overlays (rxvt_term *term) |
|
|
455 | { |
|
|
456 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
457 | |
|
|
458 | if (HvKEYS (hv)) |
|
|
459 | { |
|
|
460 | hv_iterinit (hv); |
|
|
461 | |
|
|
462 | while (HE *he = hv_iternext (hv)) |
|
|
463 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
464 | } |
|
|
465 | } |
|
|
466 | |
448 | bool |
467 | bool |
449 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
468 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
450 | { |
469 | { |
451 | if (!perl) |
470 | if (!perl || !term->perl.self) |
452 | return false; |
471 | return false; |
453 | |
472 | |
454 | if (htype == HOOK_INIT) // first hook ever called |
473 | // pre-handling of some events |
|
|
474 | if (htype == HOOK_REFRESH_END) |
|
|
475 | swap_overlays (term); |
|
|
476 | |
|
|
477 | swap (perl_environ, environ); |
|
|
478 | |
|
|
479 | bool event_consumed; |
|
|
480 | |
|
|
481 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
|
|
482 | || term->perl.should_invoke [htype]) |
|
|
483 | try |
455 | { |
484 | { |
456 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
485 | dSP; |
457 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
486 | va_list ap; |
|
|
487 | |
|
|
488 | va_start (ap, htype); |
|
|
489 | |
|
|
490 | ENTER; |
|
|
491 | SAVETMPS; |
|
|
492 | |
|
|
493 | PUSHMARK (SP); |
|
|
494 | |
|
|
495 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
496 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
497 | |
|
|
498 | for (;;) { |
|
|
499 | data_type dt = (data_type)va_arg (ap, int); |
|
|
500 | |
|
|
501 | switch (dt) |
|
|
502 | { |
|
|
503 | case DT_INT: |
|
|
504 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
505 | break; |
|
|
506 | |
|
|
507 | case DT_LONG: |
|
|
508 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
509 | break; |
|
|
510 | |
|
|
511 | case DT_STR: |
|
|
512 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
513 | break; |
|
|
514 | |
|
|
515 | case DT_STR_LEN: |
|
|
516 | { |
|
|
517 | char *str = va_arg (ap, char *); |
|
|
518 | int len = va_arg (ap, int); |
|
|
519 | |
|
|
520 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
521 | } |
|
|
522 | break; |
|
|
523 | |
|
|
524 | case DT_WCS_LEN: |
|
|
525 | { |
|
|
526 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
527 | int wlen = va_arg (ap, int); |
|
|
528 | |
|
|
529 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
530 | } |
|
|
531 | break; |
|
|
532 | |
|
|
533 | case DT_XEVENT: |
|
|
534 | { |
|
|
535 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
536 | HV *hv = newHV (); |
|
|
537 | |
|
|
538 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
539 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
540 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
|
|
541 | # undef set |
|
|
542 | |
|
|
543 | setiv (type, xe->type); |
|
|
544 | setiv (send_event, xe->xany.send_event); |
|
|
545 | setiv (serial, xe->xany.serial); |
|
|
546 | |
|
|
547 | switch (xe->type) |
|
|
548 | { |
|
|
549 | case KeyPress: |
|
|
550 | case KeyRelease: |
|
|
551 | case ButtonPress: |
|
|
552 | case ButtonRelease: |
|
|
553 | case MotionNotify: |
|
|
554 | setuv (window, xe->xmotion.window); |
|
|
555 | setuv (root, xe->xmotion.root); |
|
|
556 | setuv (subwindow, xe->xmotion.subwindow); |
|
|
557 | setuv (time, xe->xmotion.time); |
|
|
558 | setiv (x, xe->xmotion.x); |
|
|
559 | setiv (y, xe->xmotion.y); |
|
|
560 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
561 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
562 | setiv (x_root, xe->xmotion.x_root); |
|
|
563 | setiv (y_root, xe->xmotion.y_root); |
|
|
564 | setuv (state, xe->xmotion.state); |
|
|
565 | |
|
|
566 | switch (xe->type) |
|
|
567 | { |
|
|
568 | case KeyPress: |
|
|
569 | case KeyRelease: |
|
|
570 | setuv (keycode, xe->xkey.keycode); |
|
|
571 | break; |
|
|
572 | |
|
|
573 | case ButtonPress: |
|
|
574 | case ButtonRelease: |
|
|
575 | setuv (button, xe->xbutton.button); |
|
|
576 | break; |
|
|
577 | |
|
|
578 | case MotionNotify: |
|
|
579 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
580 | break; |
|
|
581 | } |
|
|
582 | |
|
|
583 | break; |
|
|
584 | |
|
|
585 | case MapNotify: |
|
|
586 | case UnmapNotify: |
|
|
587 | case ConfigureNotify: |
|
|
588 | setuv (event, xe->xconfigure.event); |
|
|
589 | setuv (window, xe->xconfigure.window); |
|
|
590 | |
|
|
591 | switch (xe->type) |
|
|
592 | { |
|
|
593 | case ConfigureNotify: |
|
|
594 | setiv (x, xe->xconfigure.x); |
|
|
595 | setiv (y, xe->xconfigure.y); |
|
|
596 | setiv (width, xe->xconfigure.width); |
|
|
597 | setiv (height, xe->xconfigure.height); |
|
|
598 | setuv (above, xe->xconfigure.above); |
|
|
599 | break; |
|
|
600 | } |
|
|
601 | |
|
|
602 | break; |
|
|
603 | } |
|
|
604 | |
|
|
605 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
606 | } |
|
|
607 | break; |
|
|
608 | |
|
|
609 | case DT_END: |
|
|
610 | goto call; |
|
|
611 | |
|
|
612 | default: |
|
|
613 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
614 | } |
|
|
615 | } |
|
|
616 | |
|
|
617 | call: |
|
|
618 | va_end (ap); |
|
|
619 | |
|
|
620 | PUTBACK; |
|
|
621 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
622 | SPAGAIN; |
|
|
623 | |
|
|
624 | if (count) |
|
|
625 | { |
|
|
626 | SV *status = POPs; |
|
|
627 | count = SvTRUE (status); |
|
|
628 | } |
|
|
629 | |
|
|
630 | PUTBACK; |
|
|
631 | FREETMPS; |
|
|
632 | LEAVE; |
|
|
633 | |
|
|
634 | if (SvTRUE (ERRSV)) |
|
|
635 | { |
|
|
636 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
637 | ungrab (term); // better lose the grab than the session |
|
|
638 | } |
|
|
639 | |
|
|
640 | event_consumed = !!count; |
458 | } |
641 | } |
459 | else if (!term->perl.self) |
642 | catch (...) |
460 | return false; // perl not initialized for this instance |
643 | { |
|
|
644 | swap (perl_environ, environ); |
|
|
645 | throw; |
|
|
646 | } |
|
|
647 | else |
|
|
648 | event_consumed = false; |
|
|
649 | |
|
|
650 | // post-handling of some events |
|
|
651 | if (htype == HOOK_REFRESH_BEGIN) |
|
|
652 | swap_overlays (term); |
461 | else if (htype == HOOK_DESTROY) |
653 | else if (htype == HOOK_DESTROY) |
462 | { |
654 | { |
463 | // handled later |
655 | clearSVptr ((SV *)term->perl.self); |
|
|
656 | SvREFCNT_dec ((SV *)term->perl.self); |
464 | } |
657 | } |
465 | else |
|
|
466 | { |
|
|
467 | if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
468 | { |
|
|
469 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
470 | |
658 | |
471 | if (HvKEYS (hv)) |
659 | swap (perl_environ, environ); |
472 | { |
|
|
473 | hv_iterinit (hv); |
|
|
474 | |
660 | |
475 | while (HE *he = hv_iternext (hv)) |
661 | return event_consumed; |
476 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
477 | } |
|
|
478 | |
|
|
479 | } |
|
|
480 | |
|
|
481 | if (!should_invoke [htype]) |
|
|
482 | return false; |
|
|
483 | } |
|
|
484 | |
|
|
485 | dSP; |
|
|
486 | va_list ap; |
|
|
487 | |
|
|
488 | va_start (ap, htype); |
|
|
489 | |
|
|
490 | ENTER; |
|
|
491 | SAVETMPS; |
|
|
492 | |
|
|
493 | PUSHMARK (SP); |
|
|
494 | |
|
|
495 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
496 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
497 | |
|
|
498 | for (;;) { |
|
|
499 | data_type dt = (data_type)va_arg (ap, int); |
|
|
500 | |
|
|
501 | switch (dt) |
|
|
502 | { |
|
|
503 | case DT_INT: |
|
|
504 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
505 | break; |
|
|
506 | |
|
|
507 | case DT_LONG: |
|
|
508 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
509 | break; |
|
|
510 | |
|
|
511 | case DT_STR: |
|
|
512 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
|
|
513 | break; |
|
|
514 | |
|
|
515 | case DT_STR_LEN: |
|
|
516 | { |
|
|
517 | char *str = va_arg (ap, char *); |
|
|
518 | int len = va_arg (ap, int); |
|
|
519 | |
|
|
520 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
|
|
521 | } |
|
|
522 | break; |
|
|
523 | |
|
|
524 | case DT_WCS_LEN: |
|
|
525 | { |
|
|
526 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
527 | int wlen = va_arg (ap, int); |
|
|
528 | |
|
|
529 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
|
|
530 | } |
|
|
531 | break; |
|
|
532 | |
|
|
533 | case DT_XEVENT: |
|
|
534 | { |
|
|
535 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
536 | HV *hv = newHV (); |
|
|
537 | |
|
|
538 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
539 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
540 | # undef set |
|
|
541 | |
|
|
542 | setiv (type, xe->type); |
|
|
543 | setiv (send_event, xe->xany.send_event); |
|
|
544 | setiv (serial, xe->xany.serial); |
|
|
545 | |
|
|
546 | switch (xe->type) |
|
|
547 | { |
|
|
548 | case KeyPress: |
|
|
549 | case KeyRelease: |
|
|
550 | case ButtonPress: |
|
|
551 | case ButtonRelease: |
|
|
552 | case MotionNotify: |
|
|
553 | setiv (time, xe->xmotion.time); |
|
|
554 | setiv (x, xe->xmotion.x); |
|
|
555 | setiv (y, xe->xmotion.y); |
|
|
556 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
557 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
558 | setiv (x_root, xe->xmotion.x_root); |
|
|
559 | setiv (y_root, xe->xmotion.y_root); |
|
|
560 | setiv (state, xe->xmotion.state); |
|
|
561 | break; |
|
|
562 | } |
|
|
563 | |
|
|
564 | switch (xe->type) |
|
|
565 | { |
|
|
566 | case KeyPress: |
|
|
567 | case KeyRelease: |
|
|
568 | setiv (keycode, xe->xkey.keycode); |
|
|
569 | break; |
|
|
570 | |
|
|
571 | case ButtonPress: |
|
|
572 | case ButtonRelease: |
|
|
573 | setiv (button, xe->xbutton.button); |
|
|
574 | break; |
|
|
575 | |
|
|
576 | case MotionNotify: |
|
|
577 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
578 | break; |
|
|
579 | } |
|
|
580 | |
|
|
581 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
582 | } |
|
|
583 | break; |
|
|
584 | |
|
|
585 | case DT_END: |
|
|
586 | { |
|
|
587 | va_end (ap); |
|
|
588 | |
|
|
589 | PUTBACK; |
|
|
590 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
591 | SPAGAIN; |
|
|
592 | |
|
|
593 | if (count) |
|
|
594 | { |
|
|
595 | SV *status = POPs; |
|
|
596 | count = SvTRUE (status); |
|
|
597 | } |
|
|
598 | |
|
|
599 | PUTBACK; |
|
|
600 | FREETMPS; |
|
|
601 | LEAVE; |
|
|
602 | |
|
|
603 | if (SvTRUE (ERRSV)) |
|
|
604 | { |
|
|
605 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
606 | ungrab (term); // better lose the grab than the session |
|
|
607 | } |
|
|
608 | |
|
|
609 | if (htype == HOOK_DESTROY) |
|
|
610 | { |
|
|
611 | clearSVptr ((SV *)term->perl.self); |
|
|
612 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
613 | } |
|
|
614 | |
|
|
615 | return count; |
|
|
616 | } |
|
|
617 | |
|
|
618 | default: |
|
|
619 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
620 | } |
|
|
621 | } |
|
|
622 | } |
662 | } |
623 | |
663 | |
624 | ///////////////////////////////////////////////////////////////////////////// |
664 | ///////////////////////////////////////////////////////////////////////////// |
625 | |
665 | |
626 | MODULE = urxvt PACKAGE = urxvt |
666 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
645 | # include "optinc.h" |
685 | # include "optinc.h" |
646 | # undef nodef |
686 | # undef nodef |
647 | # undef def |
687 | # undef def |
648 | |
688 | |
649 | HV *stash = gv_stashpv ("urxvt", 1); |
689 | HV *stash = gv_stashpv ("urxvt", 1); |
650 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
690 | struct { |
|
|
691 | const char *name; |
|
|
692 | IV iv; |
|
|
693 | } *civ, const_iv[] = { |
|
|
694 | # define const_iv(name) { # name, (IV)name } |
651 | export_const_iv (DEFAULT_RSTYLE); |
695 | const_iv (DEFAULT_RSTYLE), |
652 | export_const_iv (OVERLAY_RSTYLE); |
696 | const_iv (OVERLAY_RSTYLE), |
653 | export_const_iv (RS_Bold); |
697 | const_iv (RS_Bold), |
654 | export_const_iv (RS_Italic); |
698 | const_iv (RS_Italic), |
655 | export_const_iv (RS_Blink); |
699 | const_iv (RS_Blink), |
656 | export_const_iv (RS_RVid); |
700 | const_iv (RS_RVid), |
657 | export_const_iv (RS_Uline); |
701 | const_iv (RS_Uline), |
658 | |
702 | |
659 | export_const_iv (CurrentTime); |
703 | const_iv (CurrentTime), |
660 | export_const_iv (ShiftMask); |
704 | const_iv (ShiftMask), |
661 | export_const_iv (LockMask); |
705 | const_iv (LockMask), |
662 | export_const_iv (ControlMask); |
706 | const_iv (ControlMask), |
663 | export_const_iv (Mod1Mask); |
707 | const_iv (Mod1Mask), |
664 | export_const_iv (Mod2Mask); |
708 | const_iv (Mod2Mask), |
665 | export_const_iv (Mod3Mask); |
709 | const_iv (Mod3Mask), |
666 | export_const_iv (Mod4Mask); |
710 | const_iv (Mod4Mask), |
667 | export_const_iv (Mod5Mask); |
711 | const_iv (Mod5Mask), |
668 | export_const_iv (Button1Mask); |
712 | const_iv (Button1Mask), |
669 | export_const_iv (Button2Mask); |
713 | const_iv (Button2Mask), |
670 | export_const_iv (Button3Mask); |
714 | const_iv (Button3Mask), |
671 | export_const_iv (Button4Mask); |
715 | const_iv (Button4Mask), |
672 | export_const_iv (Button5Mask); |
716 | const_iv (Button5Mask), |
673 | export_const_iv (AnyModifier); |
717 | const_iv (AnyModifier), |
674 | |
718 | |
675 | export_const_iv (EVENT_NONE); |
719 | const_iv (EVENT_NONE), |
676 | export_const_iv (EVENT_READ); |
720 | const_iv (EVENT_READ), |
677 | export_const_iv (EVENT_WRITE); |
721 | const_iv (EVENT_WRITE), |
678 | } |
|
|
679 | |
722 | |
680 | SV * |
723 | const_iv (NoEventMask), |
681 | new (...) |
724 | const_iv (KeyPressMask), |
682 | CODE: |
725 | const_iv (KeyReleaseMask), |
683 | { |
726 | const_iv (ButtonPressMask), |
684 | stringvec *argv = new stringvec; |
727 | const_iv (ButtonReleaseMask), |
685 | bool success; |
728 | const_iv (EnterWindowMask), |
|
|
729 | const_iv (LeaveWindowMask), |
|
|
730 | const_iv (PointerMotionMask), |
|
|
731 | const_iv (PointerMotionHintMask), |
|
|
732 | const_iv (Button1MotionMask), |
|
|
733 | const_iv (Button2MotionMask), |
|
|
734 | const_iv (Button3MotionMask), |
|
|
735 | const_iv (Button4MotionMask), |
|
|
736 | const_iv (Button5MotionMask), |
|
|
737 | const_iv (ButtonMotionMask), |
|
|
738 | const_iv (KeymapStateMask), |
|
|
739 | const_iv (ExposureMask), |
|
|
740 | const_iv (VisibilityChangeMask), |
|
|
741 | const_iv (StructureNotifyMask), |
|
|
742 | const_iv (ResizeRedirectMask), |
|
|
743 | const_iv (SubstructureNotifyMask), |
|
|
744 | const_iv (SubstructureRedirectMask), |
|
|
745 | const_iv (FocusChangeMask), |
|
|
746 | const_iv (PropertyChangeMask), |
|
|
747 | const_iv (ColormapChangeMask), |
|
|
748 | const_iv (OwnerGrabButtonMask), |
686 | |
749 | |
687 | for (int i = 0; i < items ;i++) |
750 | const_iv (KeyPress), |
688 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
751 | const_iv (KeyRelease), |
|
|
752 | const_iv (ButtonPress), |
|
|
753 | const_iv (ButtonRelease), |
|
|
754 | const_iv (MotionNotify), |
|
|
755 | const_iv (EnterNotify), |
|
|
756 | const_iv (LeaveNotify), |
|
|
757 | const_iv (FocusIn), |
|
|
758 | const_iv (FocusOut), |
|
|
759 | const_iv (KeymapNotify), |
|
|
760 | const_iv (Expose), |
|
|
761 | const_iv (GraphicsExpose), |
|
|
762 | const_iv (NoExpose), |
|
|
763 | const_iv (VisibilityNotify), |
|
|
764 | const_iv (CreateNotify), |
|
|
765 | const_iv (DestroyNotify), |
|
|
766 | const_iv (UnmapNotify), |
|
|
767 | const_iv (MapNotify), |
|
|
768 | const_iv (MapRequest), |
|
|
769 | const_iv (ReparentNotify), |
|
|
770 | const_iv (ConfigureNotify), |
|
|
771 | const_iv (ConfigureRequest), |
|
|
772 | const_iv (GravityNotify), |
|
|
773 | const_iv (ResizeRequest), |
|
|
774 | const_iv (CirculateNotify), |
|
|
775 | const_iv (CirculateRequest), |
|
|
776 | const_iv (PropertyNotify), |
|
|
777 | const_iv (SelectionClear), |
|
|
778 | const_iv (SelectionRequest), |
|
|
779 | const_iv (SelectionNotify), |
|
|
780 | const_iv (ColormapNotify), |
|
|
781 | const_iv (ClientMessage), |
|
|
782 | const_iv (MappingNotify), |
|
|
783 | }; |
689 | |
784 | |
690 | rxvt_term *term = new rxvt_term; |
785 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
691 | |
786 | civ-- > const_iv; ) |
692 | term->argv = argv; |
787 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
693 | |
|
|
694 | try |
|
|
695 | { |
|
|
696 | if (!term->init (argv->size (), argv->begin ())) |
|
|
697 | term = 0; |
|
|
698 | } |
|
|
699 | catch (const class rxvt_failure_exception &e) |
|
|
700 | { |
|
|
701 | term->destroy (); |
|
|
702 | croak ("exception caught while initializing new terminal instance"); |
|
|
703 | } |
|
|
704 | |
|
|
705 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
|
|
706 | } |
788 | } |
707 | OUTPUT: |
|
|
708 | RETVAL |
|
|
709 | |
|
|
710 | void |
|
|
711 | set_should_invoke (int htype, int value) |
|
|
712 | CODE: |
|
|
713 | rxvt_perl.should_invoke [htype] = value; |
|
|
714 | |
789 | |
715 | void |
790 | void |
716 | warn (const char *msg) |
791 | warn (const char *msg) |
717 | CODE: |
792 | CODE: |
718 | rxvt_warn ("%s", msg); |
793 | rxvt_warn ("%s", msg); |
… | |
… | |
720 | void |
795 | void |
721 | fatal (const char *msg) |
796 | fatal (const char *msg) |
722 | CODE: |
797 | CODE: |
723 | rxvt_fatal ("%s", msg); |
798 | rxvt_fatal ("%s", msg); |
724 | |
799 | |
725 | SV * |
800 | void |
726 | untaint (SV *sv) |
801 | _exit (int status) |
727 | CODE: |
|
|
728 | RETVAL = newSVsv (sv); |
|
|
729 | SvTAINTED_off (RETVAL); |
|
|
730 | OUTPUT: |
|
|
731 | RETVAL |
|
|
732 | |
|
|
733 | bool |
|
|
734 | safe () |
|
|
735 | CODE: |
|
|
736 | RETVAL = !rxvt_tainted (); |
|
|
737 | OUTPUT: |
|
|
738 | RETVAL |
|
|
739 | |
802 | |
740 | NV |
803 | NV |
741 | NOW () |
804 | NOW () |
742 | CODE: |
805 | CODE: |
743 | RETVAL = NOW; |
806 | RETVAL = NOW; |
… | |
… | |
792 | OUTPUT: |
855 | OUTPUT: |
793 | RETVAL |
856 | RETVAL |
794 | |
857 | |
795 | MODULE = urxvt PACKAGE = urxvt::term |
858 | MODULE = urxvt PACKAGE = urxvt::term |
796 | |
859 | |
|
|
860 | SV * |
|
|
861 | _new (...) |
|
|
862 | CODE: |
|
|
863 | { |
|
|
864 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
865 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
866 | |
|
|
867 | rxvt_term *term = new rxvt_term; |
|
|
868 | |
|
|
869 | term->argv = new stringvec; |
|
|
870 | term->envv = new stringvec; |
|
|
871 | |
|
|
872 | for (int i = 1; i < items; i++) |
|
|
873 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
874 | |
|
|
875 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
876 | for (int i = av_len (envv) + 1; i--; ) |
|
|
877 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
|
|
878 | |
|
|
879 | term->envv->push_back (0); |
|
|
880 | |
|
|
881 | bool success; |
|
|
882 | |
|
|
883 | try |
|
|
884 | { |
|
|
885 | success = term->init (term->argv->size (), term->argv->begin ()); |
|
|
886 | } |
|
|
887 | catch (const class rxvt_failure_exception &e) |
|
|
888 | { |
|
|
889 | success = false; |
|
|
890 | } |
|
|
891 | |
|
|
892 | if (!success) |
|
|
893 | { |
|
|
894 | term->destroy (); |
|
|
895 | croak ("error while initializing new terminal instance"); |
|
|
896 | } |
|
|
897 | |
|
|
898 | RETVAL = term && term->perl.self |
|
|
899 | ? newSVterm (term) : &PL_sv_undef; |
|
|
900 | } |
|
|
901 | OUTPUT: |
|
|
902 | RETVAL |
|
|
903 | |
797 | void |
904 | void |
798 | rxvt_term::destroy () |
905 | rxvt_term::destroy () |
|
|
906 | |
|
|
907 | #if ENABLE_PERL_FRILLS |
|
|
908 | |
|
|
909 | void |
|
|
910 | rxvt_term::XListProperties (U32 window) |
|
|
911 | PPCODE: |
|
|
912 | { |
|
|
913 | int count; |
|
|
914 | Atom *props = XListProperties (THIS->display->display, (Window)window, &count); |
|
|
915 | |
|
|
916 | EXTEND (SP, count); |
|
|
917 | while (count--) |
|
|
918 | PUSHs (newSVuv ((U32)props [count])); |
|
|
919 | |
|
|
920 | XFree (props); |
|
|
921 | } |
|
|
922 | |
|
|
923 | void |
|
|
924 | rxvt_term::XGetWindowProperty (U32 window, U32 property) |
|
|
925 | PPCODE: |
|
|
926 | { |
|
|
927 | Atom type; |
|
|
928 | int format; |
|
|
929 | unsigned long nitems; |
|
|
930 | unsigned long bytes_after; |
|
|
931 | unsigned char *prop; |
|
|
932 | XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
933 | 0, 1<<30, 0, AnyPropertyType, |
|
|
934 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
935 | if (type != None) |
|
|
936 | { |
|
|
937 | EXTEND (SP, 3); |
|
|
938 | PUSHs (newSVuv ((U32)type)); |
|
|
939 | PUSHs (newSViv (format)); |
|
|
940 | PUSHs (newSVpvn ((char *)prop, nitems * format / 8)); |
|
|
941 | XFree (prop); |
|
|
942 | } |
|
|
943 | } |
|
|
944 | |
|
|
945 | void |
|
|
946 | rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data) |
|
|
947 | CODE: |
|
|
948 | { |
|
|
949 | STRLEN len; |
|
|
950 | char *data_ = SvPVbyte (data, len); |
|
|
951 | |
|
|
952 | XChangeProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
953 | type, format, PropModeReplace, |
|
|
954 | (unsigned char *)data, len * 8 / format); |
|
|
955 | } |
|
|
956 | |
|
|
957 | void |
|
|
958 | rxvt_term::XDeleteProperty (U32 window, U32 property) |
|
|
959 | CODE: |
|
|
960 | XDeleteProperty (THIS->display->display, (Window)window, (Atom)property); |
|
|
961 | |
|
|
962 | U32 |
|
|
963 | rxvt_term::DefaultRootWindow () |
|
|
964 | CODE: |
|
|
965 | RETVAL = (U32)THIS->display->root; |
|
|
966 | OUTPUT: |
|
|
967 | RETVAL |
|
|
968 | |
|
|
969 | U32 |
|
|
970 | rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height) |
|
|
971 | CODE: |
|
|
972 | RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent, |
|
|
973 | x, y, width, height, 0, |
|
|
974 | THIS->pix_colors_focused[Color_border], |
|
|
975 | THIS->pix_colors_focused[Color_border]); |
|
|
976 | OUTPUT: |
|
|
977 | RETVAL |
|
|
978 | |
|
|
979 | void |
|
|
980 | rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0) |
|
|
981 | CODE: |
|
|
982 | XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y); |
|
|
983 | |
|
|
984 | void |
|
|
985 | rxvt_term::XMapWindow (U32 window) |
|
|
986 | CODE: |
|
|
987 | XMapWindow (THIS->display->display, (Window)window); |
|
|
988 | |
|
|
989 | void |
|
|
990 | rxvt_term::XUnmapWindow (U32 window) |
|
|
991 | CODE: |
|
|
992 | XUnmapWindow (THIS->display->display, (Window)window); |
|
|
993 | |
|
|
994 | #endif |
|
|
995 | |
|
|
996 | void |
|
|
997 | rxvt_term::set_should_invoke (int htype, int inc) |
|
|
998 | CODE: |
|
|
999 | THIS->perl.should_invoke [htype] += inc; |
799 | |
1000 | |
800 | void |
1001 | void |
801 | rxvt_term::grab_button (int button, U32 modifiers) |
1002 | rxvt_term::grab_button (int button, U32 modifiers) |
802 | CODE: |
1003 | CODE: |
803 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1004 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
… | |
… | |
871 | char *mbstr = rxvt_wcstombs (wstr); |
1072 | char *mbstr = rxvt_wcstombs (wstr); |
872 | rxvt_pop_locale (); |
1073 | rxvt_pop_locale (); |
873 | |
1074 | |
874 | free (wstr); |
1075 | free (wstr); |
875 | |
1076 | |
876 | RETVAL = taint_if (newSVpv (mbstr, 0), str); |
1077 | RETVAL = newSVpv (mbstr, 0); |
877 | free (mbstr); |
1078 | free (mbstr); |
878 | } |
1079 | } |
879 | OUTPUT: |
1080 | OUTPUT: |
880 | RETVAL |
1081 | RETVAL |
881 | |
1082 | |
… | |
… | |
888 | |
1089 | |
889 | rxvt_push_locale (THIS->locale); |
1090 | rxvt_push_locale (THIS->locale); |
890 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
1091 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
891 | rxvt_pop_locale (); |
1092 | rxvt_pop_locale (); |
892 | |
1093 | |
893 | RETVAL = taint_if (wcs2sv (wstr), octets); |
1094 | RETVAL = wcs2sv (wstr); |
894 | free (wstr); |
1095 | free (wstr); |
895 | } |
1096 | } |
896 | OUTPUT: |
1097 | OUTPUT: |
897 | RETVAL |
1098 | RETVAL |
898 | |
1099 | |
… | |
… | |
907 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1108 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
908 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1109 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
909 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1110 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
910 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1111 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
911 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1112 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
912 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
1113 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
913 | |
1114 | |
914 | int |
1115 | int |
915 | rxvt_term::width () |
1116 | rxvt_term::width () |
916 | ALIAS: |
1117 | ALIAS: |
917 | width = TERM_OFFSET_width |
1118 | width = TERM_OFFSET_width |
… | |
… | |
923 | ncol = TERM_OFFSET_ncol |
1124 | ncol = TERM_OFFSET_ncol |
924 | focus = TERM_OFFSET_focus |
1125 | focus = TERM_OFFSET_focus |
925 | mapped = TERM_OFFSET_mapped |
1126 | mapped = TERM_OFFSET_mapped |
926 | saveLines = TERM_OFFSET_saveLines |
1127 | saveLines = TERM_OFFSET_saveLines |
927 | total_rows = TERM_OFFSET_total_rows |
1128 | total_rows = TERM_OFFSET_total_rows |
928 | nsaved = TERM_OFFSET_nsaved |
1129 | top_row = TERM_OFFSET_top_row |
929 | CODE: |
1130 | CODE: |
930 | RETVAL = *(int *)((char *)THIS + ix); |
1131 | RETVAL = *(int *)((char *)THIS + ix); |
931 | OUTPUT: |
1132 | OUTPUT: |
932 | RETVAL |
1133 | RETVAL |
933 | |
1134 | |
… | |
… | |
959 | case 1: RETVAL = THIS->locale; break; |
1160 | case 1: RETVAL = THIS->locale; break; |
960 | } |
1161 | } |
961 | OUTPUT: |
1162 | OUTPUT: |
962 | RETVAL |
1163 | RETVAL |
963 | |
1164 | |
|
|
1165 | SV * |
|
|
1166 | rxvt_term::_env () |
|
|
1167 | CODE: |
|
|
1168 | { |
|
|
1169 | if (THIS->envv) |
|
|
1170 | { |
|
|
1171 | AV *av = newAV (); |
|
|
1172 | |
|
|
1173 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
|
|
1174 | if (*i) |
|
|
1175 | av_push (av, newSVpv (*i, 0)); |
|
|
1176 | |
|
|
1177 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1178 | } |
|
|
1179 | else |
|
|
1180 | RETVAL = &PL_sv_undef; |
|
|
1181 | } |
|
|
1182 | OUTPUT: |
|
|
1183 | RETVAL |
|
|
1184 | |
964 | int |
1185 | int |
965 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1186 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
966 | CODE: |
1187 | CODE: |
967 | RETVAL = THIS->pty_ev.events; |
1188 | RETVAL = THIS->pty_ev.events; |
968 | if (events != EVENT_UNDEF) |
1189 | if (events != EVENT_UNDEF) |
… | |
… | |
982 | CODE: |
1203 | CODE: |
983 | RETVAL = (U32)THIS->vt; |
1204 | RETVAL = (U32)THIS->vt; |
984 | OUTPUT: |
1205 | OUTPUT: |
985 | RETVAL |
1206 | RETVAL |
986 | |
1207 | |
|
|
1208 | void |
|
|
1209 | rxvt_term::vt_emask_add (U32 emask) |
|
|
1210 | CODE: |
|
|
1211 | THIS->vt_emask_perl |= emask; |
|
|
1212 | THIS->vt_select_input (); |
|
|
1213 | |
987 | U32 |
1214 | U32 |
988 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
1215 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
989 | CODE: |
1216 | CODE: |
990 | { |
|
|
991 | RETVAL = THIS->rstyle; |
1217 | RETVAL = THIS->rstyle; |
992 | THIS->rstyle = new_rstyle; |
1218 | THIS->rstyle = new_rstyle; |
993 | } |
|
|
994 | OUTPUT: |
1219 | OUTPUT: |
995 | RETVAL |
1220 | RETVAL |
996 | |
1221 | |
997 | int |
1222 | int |
998 | rxvt_term::view_start (int newval = -1) |
1223 | rxvt_term::view_start (int newval = 1) |
|
|
1224 | PROTOTYPE: $;$ |
999 | CODE: |
1225 | CODE: |
1000 | { |
1226 | { |
1001 | RETVAL = THIS->view_start; |
1227 | RETVAL = THIS->view_start; |
1002 | |
1228 | |
1003 | if (newval >= 0) |
1229 | if (newval <= 0) |
1004 | { |
1230 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1005 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
1006 | THIS->scr_changeview (RETVAL); |
|
|
1007 | } |
|
|
1008 | } |
1231 | } |
1009 | OUTPUT: |
1232 | OUTPUT: |
1010 | RETVAL |
1233 | RETVAL |
1011 | |
1234 | |
1012 | void |
1235 | void |
… | |
… | |
1016 | |
1239 | |
1017 | void |
1240 | void |
1018 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1241 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1019 | PPCODE: |
1242 | PPCODE: |
1020 | { |
1243 | { |
1021 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1244 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1022 | XSRETURN_EMPTY; |
1245 | XSRETURN_EMPTY; |
1023 | |
1246 | |
1024 | line_t &l = ROW(row_number); |
1247 | line_t &l = ROW(row_number); |
1025 | |
1248 | |
1026 | if (GIMME_V != G_VOID) |
1249 | if (GIMME_V != G_VOID) |
… | |
… | |
1028 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
1251 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
1029 | |
1252 | |
1030 | for (int col = 0; col < THIS->ncol; col++) |
1253 | for (int col = 0; col < THIS->ncol; col++) |
1031 | wstr [col] = l.t [col]; |
1254 | wstr [col] = l.t [col]; |
1032 | |
1255 | |
1033 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); |
1256 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
1034 | |
1257 | |
1035 | delete [] wstr; |
1258 | delete [] wstr; |
1036 | } |
1259 | } |
1037 | |
1260 | |
1038 | if (new_text) |
1261 | if (new_text) |
… | |
… | |
1059 | |
1282 | |
1060 | void |
1283 | void |
1061 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1284 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1062 | PPCODE: |
1285 | PPCODE: |
1063 | { |
1286 | { |
1064 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1287 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1065 | XSRETURN_EMPTY; |
1288 | XSRETURN_EMPTY; |
1066 | |
1289 | |
1067 | line_t &l = ROW(row_number); |
1290 | line_t &l = ROW(row_number); |
1068 | |
1291 | |
1069 | if (GIMME_V != G_VOID) |
1292 | if (GIMME_V != G_VOID) |
… | |
… | |
1099 | |
1322 | |
1100 | int |
1323 | int |
1101 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1324 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1102 | CODE: |
1325 | CODE: |
1103 | { |
1326 | { |
1104 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1327 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1105 | XSRETURN_EMPTY; |
1328 | XSRETURN_EMPTY; |
1106 | |
1329 | |
1107 | line_t &l = ROW(row_number); |
1330 | line_t &l = ROW(row_number); |
1108 | RETVAL = l.l; |
1331 | RETVAL = l.l; |
1109 | |
1332 | |
… | |
… | |
1115 | |
1338 | |
1116 | bool |
1339 | bool |
1117 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1340 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1118 | CODE: |
1341 | CODE: |
1119 | { |
1342 | { |
1120 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1343 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1121 | XSRETURN_EMPTY; |
1344 | XSRETURN_EMPTY; |
1122 | |
1345 | |
1123 | line_t &l = ROW(row_number); |
1346 | line_t &l = ROW(row_number); |
1124 | RETVAL = l.is_longer (); |
1347 | RETVAL = l.is_longer (); |
1125 | |
1348 | |
… | |
… | |
1159 | else |
1382 | else |
1160 | *r++ = *s; |
1383 | *r++ = *s; |
1161 | |
1384 | |
1162 | rxvt_pop_locale (); |
1385 | rxvt_pop_locale (); |
1163 | |
1386 | |
1164 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); |
1387 | RETVAL = wcs2sv (rstr, r - rstr); |
1165 | |
1388 | |
1166 | delete [] rstr; |
1389 | delete [] rstr; |
1167 | } |
1390 | } |
1168 | OUTPUT: |
1391 | OUTPUT: |
1169 | RETVAL |
1392 | RETVAL |
… | |
… | |
1195 | else if (IS_COMPOSE (*s)) |
1418 | else if (IS_COMPOSE (*s)) |
1196 | r += rxvt_composite.expand (*s, r); |
1419 | r += rxvt_composite.expand (*s, r); |
1197 | else |
1420 | else |
1198 | *r++ = *s; |
1421 | *r++ = *s; |
1199 | |
1422 | |
1200 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); |
1423 | RETVAL = wcs2sv (rstr, r - rstr); |
1201 | |
1424 | |
1202 | delete [] rstr; |
1425 | delete [] rstr; |
1203 | } |
1426 | } |
1204 | OUTPUT: |
1427 | OUTPUT: |
1205 | RETVAL |
1428 | RETVAL |
… | |
… | |
1227 | |
1450 | |
1228 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1451 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1229 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1452 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1230 | |
1453 | |
1231 | if (GIMME_V != G_VOID) |
1454 | if (GIMME_V != G_VOID) |
1232 | XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); |
1455 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
1233 | |
1456 | |
1234 | if (newval) |
1457 | if (newval) |
1235 | { |
1458 | { |
1236 | if (SvOK (newval)) |
1459 | if (SvOK (newval)) |
1237 | { |
1460 | { |
… | |
… | |
1242 | else |
1465 | else |
1243 | THIS->rs [index] = 0; |
1466 | THIS->rs [index] = 0; |
1244 | } |
1467 | } |
1245 | } |
1468 | } |
1246 | |
1469 | |
|
|
1470 | const char * |
|
|
1471 | rxvt_term::x_resource (const char *name) |
|
|
1472 | |
1247 | bool |
1473 | bool |
1248 | rxvt_term::option (U32 optval, int set = -1) |
1474 | rxvt_term::option (U32 optval, int set = -1) |
1249 | CODE: |
1475 | CODE: |
1250 | { |
1476 | { |
1251 | RETVAL = THIS->options & optval; |
1477 | RETVAL = THIS->options & optval; |
… | |
… | |
1310 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1536 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1311 | } |
1537 | } |
1312 | |
1538 | |
1313 | if (items == 3) |
1539 | if (items == 3) |
1314 | { |
1540 | { |
1315 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1541 | rc.row = SvIV (ST (1)); |
1316 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1542 | rc.col = SvIV (ST (2)); |
|
|
1543 | |
|
|
1544 | if (ix == 2 && rc.col == 0) |
|
|
1545 | { |
|
|
1546 | rc.row--; |
|
|
1547 | rc.col = THIS->ncol; |
|
|
1548 | } |
|
|
1549 | |
|
|
1550 | clamp_it (rc.col, 0, THIS->ncol); |
|
|
1551 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1317 | |
1552 | |
1318 | if (ix) |
1553 | if (ix) |
1319 | THIS->want_refresh = 1; |
1554 | THIS->want_refresh = 1; |
1320 | } |
1555 | } |
1321 | } |
1556 | } |
… | |
… | |
1325 | CODE: |
1560 | CODE: |
1326 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1561 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1327 | OUTPUT: |
1562 | OUTPUT: |
1328 | RETVAL |
1563 | RETVAL |
1329 | |
1564 | |
|
|
1565 | #void |
|
|
1566 | #rxvt_term::selection_clear () |
|
|
1567 | |
|
|
1568 | void |
|
|
1569 | rxvt_term::selection_make (U32 eventtime, bool rect = false) |
|
|
1570 | CODE: |
|
|
1571 | THIS->selection.op = SELECTION_CONT; |
|
|
1572 | THIS->selection.rect = rect; |
|
|
1573 | THIS->selection_make (eventtime); |
|
|
1574 | |
1330 | int |
1575 | int |
1331 | rxvt_term::selection_grab (U32 eventtime) |
1576 | rxvt_term::selection_grab (U32 eventtime) |
1332 | |
1577 | |
1333 | void |
1578 | void |
1334 | rxvt_term::selection (SV *newtext = 0) |
1579 | rxvt_term::selection (SV *newtext = 0) |
1335 | PPCODE: |
1580 | PPCODE: |
1336 | { |
1581 | { |
1337 | if (GIMME_V != G_VOID) |
1582 | if (GIMME_V != G_VOID) |
1338 | XPUSHs (THIS->selection.text |
1583 | XPUSHs (THIS->selection.text |
1339 | ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) |
1584 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1340 | : &PL_sv_undef); |
1585 | : &PL_sv_undef); |
1341 | |
1586 | |
1342 | if (newtext) |
1587 | if (newtext) |
1343 | { |
1588 | { |
1344 | free (THIS->selection.text); |
1589 | free (THIS->selection.text); |