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