ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/urxvt.pm
(Generate patch)

Comparing rxvt-unicode/src/urxvt.pm (file contents):
Revision 1.176 by root, Sat Jul 18 05:59:49 2009 UTC vs.
Revision 1.179 by root, Sat Dec 26 09:23:53 2009 UTC

1124is that you cannot use blocking APIs, but the non-blocking variant should 1124is that you cannot use blocking APIs, but the non-blocking variant should
1125work. 1125work.
1126 1126
1127=cut 1127=cut
1128 1128
1129our $VERSION = '3.4'; 1129our $VERSION = '5.23';
1130 1130
1131$INC{"urxvt/anyevent.pm"} = 1; # mark us as there 1131$INC{"urxvt/anyevent.pm"} = 1; # mark us as there
1132push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; 1132push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::];
1133 1133
1134sub timer { 1134sub timer {
1136 1136
1137 my $cb = $arg{cb}; 1137 my $cb = $arg{cb};
1138 1138
1139 urxvt::timer 1139 urxvt::timer
1140 ->new 1140 ->new
1141 ->after ($arg{after}) 1141 ->after ($arg{after}, $arg{interval})
1142 ->interval ($arg{interval}) 1142 ->cb ($arg{interval} ? $cb : sub {
1143 ->start
1144 ->cb (sub {
1145 #TODO interval?
1146 $_[0]->stop; # need to cancel manually 1143 $_[0]->stop; # need to cancel manually
1147 $cb->(); 1144 $cb->();
1148 }) 1145 })
1149} 1146}
1150 1147
1155 my $fd = fileno $arg{fh}; 1152 my $fd = fileno $arg{fh};
1156 defined $fd or $fd = $arg{fh}; 1153 defined $fd or $fd = $arg{fh};
1157 1154
1158 bless [$arg{fh}, urxvt::iow 1155 bless [$arg{fh}, urxvt::iow
1159 ->new 1156 ->new
1160 ->fd (defined fileno $arg{fh}) 1157 ->fd ($fd)
1161 ->events (($arg{poll} =~ /r/ ? 1 : 0) 1158 ->events (($arg{poll} =~ /r/ ? 1 : 0)
1162 | ($arg{poll} =~ /w/ ? 2 : 0)) 1159 | ($arg{poll} =~ /w/ ? 2 : 0))
1163 ->start 1160 ->start
1164 ->cb ($cb) 1161 ->cb ($cb)
1165 ], urxvt::anyevent:: 1162 ], urxvt::anyevent::
1171 my $cb = $arg{cb}; 1168 my $cb = $arg{cb};
1172 1169
1173 urxvt::iw 1170 urxvt::iw
1174 ->new 1171 ->new
1175 ->start 1172 ->start
1176 ->cb (sub { 1173 ->cb ($cb)
1177 #TODO really cancel?
1178 $_[0]->stop; # need to cancel manually
1179 $cb->();
1180 })
1181} 1174}
1182 1175
1183sub child { 1176sub child {
1184 my ($class, %arg) = @_; 1177 my ($class, %arg) = @_;
1185 1178
1187 1180
1188 urxvt::pw 1181 urxvt::pw
1189 ->new 1182 ->new
1190 ->start ($arg{pid}) 1183 ->start ($arg{pid})
1191 ->cb (sub { 1184 ->cb (sub {
1192 #TODO really cancel?
1193 $_[0]->stop; # need to cancel manually 1185 $_[0]->stop; # need to cancel manually
1194 $cb->($_[0]->rpid, $_[0]->rstatus); 1186 $cb->($_[0]->rpid, $_[0]->rstatus);
1195 }) 1187 })
1196} 1188}
1197 1189
2061 2053
2062=item $timer = $timer->cb (sub { my ($timer) = @_; ... }) 2054=item $timer = $timer->cb (sub { my ($timer) = @_; ... })
2063 2055
2064Set the callback to be called when the timer triggers. 2056Set the callback to be called when the timer triggers.
2065 2057
2066=item $tstamp = $timer->at
2067
2068Return the time this watcher will fire next.
2069
2070=item $timer = $timer->set ($tstamp) 2058=item $timer = $timer->set ($tstamp[, $interval])
2071 2059
2072Set the time the event is generated to $tstamp. 2060Set the time the event is generated to $tstamp (and optionally specifies a
2061new $interval).
2073 2062
2074=item $timer = $timer->interval ($interval) 2063=item $timer = $timer->interval ($interval)
2075 2064
2076Normally (and when C<$interval> is C<0>), the timer will automatically 2065By default (and when C<$interval> is C<0>), the timer will automatically
2077stop after it has fired once. If C<$interval> is non-zero, then the timer 2066stop after it has fired once. If C<$interval> is non-zero, then the timer
2078is automatically rescheduled at the given intervals. 2067is automatically rescheduled at the given intervals.
2079 2068
2080=item $timer = $timer->start 2069=item $timer = $timer->start
2081 2070
2082Start the timer. 2071Start the timer.
2083 2072
2084=item $timer = $timer->start ($tstamp) 2073=item $timer = $timer->start ($tstamp[, $interval])
2085 2074
2086Set the event trigger time to C<$tstamp> and start the timer. 2075Set the event trigger time to C<$tstamp> and start the timer. Optionally
2076also replaces the interval.
2087 2077
2088=item $timer = $timer->after ($delay) 2078=item $timer = $timer->after ($delay[, $interval])
2089 2079
2090Like C<start>, but sets the expiry timer to c<urxvt::NOW + $delay>. 2080Like C<start>, but sets the expiry timer to c<urxvt::NOW + $delay>.
2091 2081
2092=item $timer = $timer->stop 2082=item $timer = $timer->stop
2093 2083

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines