… | |
… | |
470 | my $source = "package $pkg; use strict; use utf8;\n" |
470 | my $source = "package $pkg; use strict; use utf8;\n" |
471 | . "use base urxvt::term::proxy::;\n" |
471 | . "use base urxvt::term::proxy::;\n" |
472 | . "#line 1 \"$path\"\n{\n" |
472 | . "#line 1 \"$path\"\n{\n" |
473 | . (do { local $/; <$fh> }) |
473 | . (do { local $/; <$fh> }) |
474 | . "\n};\n1"; |
474 | . "\n};\n1"; |
|
|
475 | |
|
|
476 | $source =~ /(.*)/s and $source = $1; # untaint |
475 | |
477 | |
476 | eval $source or die "$path: $@"; |
478 | eval $source or die "$path: $@"; |
477 | |
479 | |
478 | $pkg |
480 | $pkg |
479 | } |
481 | } |
… | |
… | |
532 | $proxy |
534 | $proxy |
533 | }, |
535 | }, |
534 | @_, |
536 | @_, |
535 | ) and last; |
537 | ) and last; |
536 | }; |
538 | }; |
537 | warn $@ if $@;#d# |
539 | if ($@) { |
|
|
540 | $TERM->ungrab; # better to lose the grab than the session |
|
|
541 | warn $@; |
|
|
542 | } |
538 | } |
543 | } |
539 | } |
544 | } |
540 | |
545 | |
541 | if ($htype == 1) { # DESTROY |
546 | if ($htype == 1) { # DESTROY |
542 | # remove hooks if unused |
547 | # remove hooks if unused |
… | |
… | |
572 | } or die "FATAL: unable to compile method forwarder: $@"; |
577 | } or die "FATAL: unable to compile method forwarder: $@"; |
573 | |
578 | |
574 | goto &$urxvt::term::proxy::AUTOLOAD; |
579 | goto &$urxvt::term::proxy::AUTOLOAD; |
575 | } |
580 | } |
576 | |
581 | |
|
|
582 | sub urxvt::term::proxy::DESTROY { |
|
|
583 | # nop |
|
|
584 | } |
|
|
585 | |
577 | # urxvt::destroy_hook |
586 | # urxvt::destroy_hook |
578 | |
587 | |
579 | sub urxvt::destroy_hook::DESTROY { |
588 | sub urxvt::destroy_hook::DESTROY { |
580 | ${$_[0]}->(); |
589 | ${$_[0]}->(); |
581 | } |
590 | } |
582 | |
591 | |
583 | sub urxvt::destroy_hook(&) { |
592 | sub urxvt::destroy_hook(&) { |
584 | bless \shift, urxvt::destroy_hook:: |
593 | bless \shift, urxvt::destroy_hook:: |
585 | } |
594 | } |
586 | |
595 | |
587 | # urxvt::anyevent |
|
|
588 | |
|
|
589 | package urxvt::anyevent; |
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 |
590 | |
607 | |
591 | our $VERSION = 1; |
608 | our $VERSION = 1; |
592 | |
609 | |
593 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
610 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
594 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
611 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
… | |
… | |
1147 | |
1164 | |
1148 | my $item; $item = { |
1165 | my $item; $item = { |
1149 | type => "button", |
1166 | type => "button", |
1150 | text => " $text", |
1167 | text => " $text", |
1151 | value => $value, |
1168 | value => $value, |
1152 | render => sub { ($item->{value} ? "* " : " ") . $text }, |
1169 | render => sub { ($_[0]{value} ? "* " : " ") . $text }, |
1153 | activate => sub { $cb->($item->{value} = !$item->{value}); }, |
1170 | activate => sub { $cb->($_[0]{value} = !$_[0]{value}); }, |
1154 | }; |
1171 | }; |
1155 | |
1172 | |
1156 | $self->add_item ($item); |
1173 | $self->add_item ($item); |
1157 | } |
1174 | } |
1158 | |
1175 | |
… | |
… | |
1168 | } |
1185 | } |
1169 | |
1186 | |
1170 | sub DESTROY { |
1187 | sub DESTROY { |
1171 | my ($self) = @_; |
1188 | my ($self) = @_; |
1172 | |
1189 | |
|
|
1190 | delete $self->{term}{_destroy}{$self}; |
1173 | $self->{term}->ungrab; |
1191 | $self->{term}->ungrab; |
1174 | } |
1192 | } |
1175 | |
1193 | |
1176 | =head2 The C<urxvt::timer> Class |
1194 | =head2 The C<urxvt::timer> Class |
1177 | |
1195 | |
… | |
… | |
1281 | This variable controls the verbosity level of the perl extension. Higher |
1299 | This variable controls the verbosity level of the perl extension. Higher |
1282 | numbers indicate more verbose output. |
1300 | numbers indicate more verbose output. |
1283 | |
1301 | |
1284 | =over 4 |
1302 | =over 4 |
1285 | |
1303 | |
1286 | =item =0 - only fatal messages |
1304 | =item == 0 - fatal messages |
1287 | |
1305 | |
1288 | =item =3 - script loading and management |
1306 | =item >= 3 - script loading and management |
1289 | |
1307 | |
1290 | =item =10 - all events received |
1308 | =item >=10 - all events received |
1291 | |
1309 | |
1292 | =back |
1310 | =back |
1293 | |
1311 | |
1294 | =head1 AUTHOR |
1312 | =head1 AUTHOR |
1295 | |
1313 | |