… | |
… | |
342 | |
342 | |
343 | =item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, |
343 | =item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, |
344 | Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask, |
344 | Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask, |
345 | Button4Mask, Button5Mask, AnyModifier |
345 | Button4Mask, Button5Mask, AnyModifier |
346 | |
346 | |
347 | Various constants for use in X events. |
347 | Various constants for use in X calls and event processing. |
348 | |
348 | |
349 | =back |
349 | =back |
350 | |
350 | |
351 | =head2 RENDITION |
351 | =head2 RENDITION |
352 | |
352 | |
… | |
… | |
407 | use utf8; |
407 | use utf8; |
408 | use strict; |
408 | use strict; |
409 | use Scalar::Util (); |
409 | use Scalar::Util (); |
410 | use List::Util (); |
410 | use List::Util (); |
411 | |
411 | |
|
|
412 | our $VERSION = 1; |
412 | our $TERM; |
413 | our $TERM; |
413 | our @HOOKNAME; |
414 | our @HOOKNAME; |
414 | our %OPTION; |
415 | our %OPTION; |
415 | our $LIBDIR; |
416 | our $LIBDIR; |
416 | |
417 | |
… | |
… | |
469 | my $source = "package $pkg; use strict; use utf8;\n" |
470 | my $source = "package $pkg; use strict; use utf8;\n" |
470 | . "use base urxvt::term::proxy::;\n" |
471 | . "use base urxvt::term::proxy::;\n" |
471 | . "#line 1 \"$path\"\n{\n" |
472 | . "#line 1 \"$path\"\n{\n" |
472 | . (do { local $/; <$fh> }) |
473 | . (do { local $/; <$fh> }) |
473 | . "\n};\n1"; |
474 | . "\n};\n1"; |
|
|
475 | |
|
|
476 | $source =~ /(.*)/s and $source = $1; # untaint |
474 | |
477 | |
475 | eval $source or die "$path: $@"; |
478 | eval $source or die "$path: $@"; |
476 | |
479 | |
477 | $pkg |
480 | $pkg |
478 | } |
481 | } |
… | |
… | |
507 | register_package extension_package $files[0]; |
510 | register_package extension_package $files[0]; |
508 | } else { |
511 | } else { |
509 | warn "perl extension '$ext' not found in perl library search path\n"; |
512 | warn "perl extension '$ext' not found in perl library search path\n"; |
510 | } |
513 | } |
511 | } |
514 | } |
|
|
515 | |
|
|
516 | eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("perl_eval"); |
|
|
517 | warn $@ if $@; |
512 | } |
518 | } |
513 | |
519 | |
514 | $retval = undef; |
520 | $retval = undef; |
515 | |
521 | |
516 | if (my $cb = $TERM->{_hook}[$htype]) { |
522 | if (my $cb = $TERM->{_hook}[$htype]) { |
… | |
… | |
528 | $proxy |
534 | $proxy |
529 | }, |
535 | }, |
530 | @_, |
536 | @_, |
531 | ) and last; |
537 | ) and last; |
532 | }; |
538 | }; |
533 | warn $@ if $@;#d# |
539 | if ($@) { |
|
|
540 | $TERM->ungrab; # better to lose the grab than the session |
|
|
541 | warn $@; |
|
|
542 | } |
534 | } |
543 | } |
535 | } |
544 | } |
536 | |
545 | |
537 | if ($htype == 1) { # DESTROY |
546 | if ($htype == 1) { # DESTROY |
538 | # remove hooks if unused |
547 | # remove hooks if unused |
… | |
… | |
551 | } |
560 | } |
552 | |
561 | |
553 | $retval |
562 | $retval |
554 | } |
563 | } |
555 | |
564 | |
|
|
565 | # urxvt::term::proxy |
|
|
566 | |
556 | sub urxvt::term::proxy::AUTOLOAD { |
567 | sub urxvt::term::proxy::AUTOLOAD { |
557 | $urxvt::term::proxy::AUTOLOAD =~ /:([^:]+)$/ |
568 | $urxvt::term::proxy::AUTOLOAD =~ /:([^:]+)$/ |
558 | or die "FATAL: \$AUTOLOAD '$urxvt::term::proxy::AUTOLOAD' unparsable"; |
569 | or die "FATAL: \$AUTOLOAD '$urxvt::term::proxy::AUTOLOAD' unparsable"; |
559 | |
570 | |
560 | eval qq{ |
571 | eval qq{ |
… | |
… | |
566 | } or die "FATAL: unable to compile method forwarder: $@"; |
577 | } or die "FATAL: unable to compile method forwarder: $@"; |
567 | |
578 | |
568 | goto &$urxvt::term::proxy::AUTOLOAD; |
579 | goto &$urxvt::term::proxy::AUTOLOAD; |
569 | } |
580 | } |
570 | |
581 | |
|
|
582 | sub urxvt::term::proxy::DESTROY { |
|
|
583 | # nop |
|
|
584 | } |
|
|
585 | |
|
|
586 | # urxvt::destroy_hook |
|
|
587 | |
571 | sub urxvt::destroy_hook::DESTROY { |
588 | sub urxvt::destroy_hook::DESTROY { |
572 | ${$_[0]}->(); |
589 | ${$_[0]}->(); |
573 | } |
590 | } |
574 | |
591 | |
575 | sub urxvt::destroy_hook(&) { |
592 | sub urxvt::destroy_hook(&) { |
576 | bless \shift, urxvt::destroy_hook:: |
593 | bless \shift, urxvt::destroy_hook:: |
577 | } |
594 | } |
|
|
595 | |
|
|
596 | package urxvt::anyevent; |
|
|
597 | |
|
|
598 | =head2 The C<urxvt::anyevent> Class |
|
|
599 | |
|
|
600 | The sole purpose of this class is to deliver an interface to the |
|
|
601 | C<AnyEvent> module - any module using it will work inside urxvt without |
|
|
602 | further work. The only exception is that you cannot wait on condition |
|
|
603 | variables, but non-blocking condvar use is ok. What this means is that you |
|
|
604 | cannot use blocking APIs, but the non-blocking variant should work. |
|
|
605 | |
|
|
606 | =cut |
|
|
607 | |
|
|
608 | our $VERSION = 1; |
|
|
609 | |
|
|
610 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
|
|
611 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
|
|
612 | |
|
|
613 | sub timer { |
|
|
614 | my ($class, %arg) = @_; |
|
|
615 | |
|
|
616 | my $cb = $arg{cb}; |
|
|
617 | |
|
|
618 | urxvt::timer |
|
|
619 | ->new |
|
|
620 | ->start (urxvt::NOW + $arg{after}) |
|
|
621 | ->cb (sub { |
|
|
622 | $_[0]->stop; # need to cancel manually |
|
|
623 | $cb->(); |
|
|
624 | }) |
|
|
625 | } |
|
|
626 | |
|
|
627 | sub io { |
|
|
628 | my ($class, %arg) = @_; |
|
|
629 | |
|
|
630 | my $cb = $arg{cb}; |
|
|
631 | |
|
|
632 | bless [$arg{fh}, urxvt::iow |
|
|
633 | ->new |
|
|
634 | ->fd (fileno $arg{fh}) |
|
|
635 | ->events (($arg{poll} =~ /r/ ? 1 : 0) |
|
|
636 | | ($arg{poll} =~ /w/ ? 2 : 0)) |
|
|
637 | ->start |
|
|
638 | ->cb (sub { |
|
|
639 | $cb->(($_[1] & 1 ? 'r' : '') |
|
|
640 | . ($_[1] & 2 ? 'w' : '')); |
|
|
641 | })], |
|
|
642 | urxvt::anyevent:: |
|
|
643 | } |
|
|
644 | |
|
|
645 | sub DESTROY { |
|
|
646 | $_[0][1]->stop; |
|
|
647 | } |
|
|
648 | |
|
|
649 | sub condvar { |
|
|
650 | bless \my $flag, urxvt::anyevent::condvar:: |
|
|
651 | } |
|
|
652 | |
|
|
653 | sub urxvt::anyevent::condvar::broadcast { |
|
|
654 | ${$_[0]}++; |
|
|
655 | } |
|
|
656 | |
|
|
657 | sub urxvt::anyevent::condvar::wait { |
|
|
658 | unless (${$_[0]}) { |
|
|
659 | require Carp; |
|
|
660 | Carp::croak ("AnyEvent->condvar blocking wait unsupported in urxvt, use a non-blocking API"); |
|
|
661 | } |
|
|
662 | } |
|
|
663 | |
|
|
664 | package urxvt::term; |
578 | |
665 | |
579 | =head2 The C<urxvt::term> Class |
666 | =head2 The C<urxvt::term> Class |
580 | |
667 | |
581 | =over 4 |
668 | =over 4 |
582 | |
669 | |
… | |
… | |
634 | shade term_name title transparent transparent_all tripleclickwords |
721 | shade term_name title transparent transparent_all tripleclickwords |
635 | utmpInhibit visualBell |
722 | utmpInhibit visualBell |
636 | |
723 | |
637 | =cut |
724 | =cut |
638 | |
725 | |
639 | sub urxvt::term::resource($$;$) { |
726 | sub resource($$;$) { |
640 | my ($self, $name) = (shift, shift); |
727 | my ($self, $name) = (shift, shift); |
641 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
728 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
642 | &urxvt::term::_resource |
729 | &urxvt::term::_resource |
643 | } |
730 | } |
644 | |
731 | |
… | |
… | |
731 | C<$event> I<must> be the event causing the menu to pop up (a button event, |
818 | C<$event> I<must> be the event causing the menu to pop up (a button event, |
732 | currently). |
819 | currently). |
733 | |
820 | |
734 | =cut |
821 | =cut |
735 | |
822 | |
736 | sub urxvt::term::popup { |
823 | sub popup { |
737 | my ($self, $event) = @_; |
824 | my ($self, $event) = @_; |
738 | |
825 | |
739 | $self->grab ($event->{time}, 1) |
826 | $self->grab ($event->{time}, 1) |
740 | or return; |
827 | or return; |
741 | |
828 | |
… | |
… | |
931 | |
1018 | |
932 | =back |
1019 | =back |
933 | |
1020 | |
934 | =cut |
1021 | =cut |
935 | |
1022 | |
936 | sub urxvt::term::line { |
1023 | sub line { |
937 | my ($self, $row) = @_; |
1024 | my ($self, $row) = @_; |
938 | |
1025 | |
939 | my $maxrow = $self->nrow - 1; |
1026 | my $maxrow = $self->nrow - 1; |
940 | |
1027 | |
941 | my ($beg, $end) = ($row, $row); |
1028 | my ($beg, $end) = ($row, $row); |
… | |
… | |
1019 | Converts rxvt-unicodes text reprsentation into a perl string. See |
1106 | Converts rxvt-unicodes text reprsentation into a perl string. See |
1020 | C<< $term->ROW_t >> for details. |
1107 | C<< $term->ROW_t >> for details. |
1021 | |
1108 | |
1022 | =back |
1109 | =back |
1023 | |
1110 | |
|
|
1111 | =cut |
|
|
1112 | |
|
|
1113 | package urxvt::popup; |
|
|
1114 | |
1024 | =head2 The C<urxvt::popup> Class |
1115 | =head2 The C<urxvt::popup> Class |
1025 | |
1116 | |
1026 | =over 4 |
1117 | =over 4 |
1027 | |
1118 | |
1028 | =cut |
1119 | =cut |
1029 | |
|
|
1030 | package urxvt::popup; |
|
|
1031 | |
1120 | |
1032 | sub add_item { |
1121 | sub add_item { |
1033 | my ($self, $item) = @_; |
1122 | my ($self, $item) = @_; |
1034 | |
1123 | |
1035 | $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal}; |
1124 | $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal}; |
… | |
… | |
1075 | |
1164 | |
1076 | my $item; $item = { |
1165 | my $item; $item = { |
1077 | type => "button", |
1166 | type => "button", |
1078 | text => " $text", |
1167 | text => " $text", |
1079 | value => $value, |
1168 | value => $value, |
1080 | render => sub { ($item->{value} ? "* " : " ") . $text }, |
1169 | render => sub { ($_[0]{value} ? "* " : " ") . $text }, |
1081 | activate => sub { $cb->($item->{value} = !$item->{value}); }, |
1170 | activate => sub { $cb->($_[0]{value} = !$_[0]{value}); }, |
1082 | }; |
1171 | }; |
1083 | |
1172 | |
1084 | $self->add_item ($item); |
1173 | $self->add_item ($item); |
1085 | } |
1174 | } |
1086 | |
1175 | |
… | |
… | |
1096 | } |
1185 | } |
1097 | |
1186 | |
1098 | sub DESTROY { |
1187 | sub DESTROY { |
1099 | my ($self) = @_; |
1188 | my ($self) = @_; |
1100 | |
1189 | |
|
|
1190 | delete $self->{term}{_destroy}{$self}; |
1101 | $self->{term}->ungrab; |
1191 | $self->{term}->ungrab; |
1102 | } |
1192 | } |
1103 | |
1193 | |
1104 | =head2 The C<urxvt::timer> Class |
1194 | =head2 The C<urxvt::timer> Class |
1105 | |
1195 | |
… | |
… | |
1209 | This variable controls the verbosity level of the perl extension. Higher |
1299 | This variable controls the verbosity level of the perl extension. Higher |
1210 | numbers indicate more verbose output. |
1300 | numbers indicate more verbose output. |
1211 | |
1301 | |
1212 | =over 4 |
1302 | =over 4 |
1213 | |
1303 | |
1214 | =item =0 - only fatal messages |
1304 | =item == 0 - fatal messages |
1215 | |
1305 | |
1216 | =item =3 - script loading and management |
1306 | =item >= 3 - script loading and management |
1217 | |
1307 | |
1218 | =item =10 - all events received |
1308 | =item >=10 - all events received |
1219 | |
1309 | |
1220 | =back |
1310 | =back |
1221 | |
1311 | |
1222 | =head1 AUTHOR |
1312 | =head1 AUTHOR |
1223 | |
1313 | |