--- rxvt-unicode/src/urxvt.pm 2006/01/08 01:59:29 1.54 +++ rxvt-unicode/src/urxvt.pm 2006/01/08 05:50:27 1.55 @@ -344,7 +344,7 @@ Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask, AnyModifier -Various constants for use in X events. +Various constants for use in X calls and event processing. =back @@ -409,6 +409,7 @@ use Scalar::Util (); use List::Util (); +our $VERSION = 1; our $TERM; our @HOOKNAME; our %OPTION; @@ -509,6 +510,9 @@ warn "perl extension '$ext' not found in perl library search path\n"; } } + + eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("perl_eval"); + warn $@ if $@; } $retval = undef; @@ -553,6 +557,8 @@ $retval } +# urxvt::term::proxy + sub urxvt::term::proxy::AUTOLOAD { $urxvt::term::proxy::AUTOLOAD =~ /:([^:]+)$/ or die "FATAL: \$AUTOLOAD '$urxvt::term::proxy::AUTOLOAD' unparsable"; @@ -568,6 +574,8 @@ goto &$urxvt::term::proxy::AUTOLOAD; } +# urxvt::destroy_hook + sub urxvt::destroy_hook::DESTROY { ${$_[0]}->(); } @@ -576,6 +584,68 @@ bless \shift, urxvt::destroy_hook:: } +# urxvt::anyevent + +package urxvt::anyevent; + +our $VERSION = 1; + +$INC{"urxvt/anyevent.pm"} = 1; # mark us as there +push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; + +sub timer { + my ($class, %arg) = @_; + + my $cb = $arg{cb}; + + urxvt::timer + ->new + ->start (urxvt::NOW + $arg{after}) + ->cb (sub { + $_[0]->stop; # need to cancel manually + $cb->(); + }) +} + +sub io { + my ($class, %arg) = @_; + + my $cb = $arg{cb}; + + bless [$arg{fh}, urxvt::iow + ->new + ->fd (fileno $arg{fh}) + ->events (($arg{poll} =~ /r/ ? 1 : 0) + | ($arg{poll} =~ /w/ ? 2 : 0)) + ->start + ->cb (sub { + $cb->(($_[1] & 1 ? 'r' : '') + . ($_[1] & 2 ? 'w' : '')); + })], + urxvt::anyevent:: +} + +sub DESTROY { + $_[0][1]->stop; +} + +sub condvar { + bless \my $flag, urxvt::anyevent::condvar:: +} + +sub urxvt::anyevent::condvar::broadcast { + ${$_[0]}++; +} + +sub urxvt::anyevent::condvar::wait { + unless (${$_[0]}) { + require Carp; + Carp::croak ("AnyEvent->condvar blocking wait unsupported in urxvt, use a non-blocking API"); + } +} + +package urxvt::term; + =head2 The C Class =over 4 @@ -636,7 +706,7 @@ =cut -sub urxvt::term::resource($$;$) { +sub resource($$;$) { my ($self, $name) = (shift, shift); unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); &urxvt::term::_resource @@ -733,7 +803,7 @@ =cut -sub urxvt::term::popup { +sub popup { my ($self, $event) = @_; $self->grab ($event->{time}, 1) @@ -933,7 +1003,7 @@ =cut -sub urxvt::term::line { +sub line { my ($self, $row) = @_; my $maxrow = $self->nrow - 1; @@ -1021,14 +1091,16 @@ =back +=cut + +package urxvt::popup; + =head2 The C Class =over 4 =cut -package urxvt::popup; - sub add_item { my ($self, $item) = @_;