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.204 by sf-exg, Mon Dec 5 12:52:57 2011 UTC vs.
Revision 1.209 by root, Tue Jun 5 22:38:17 2012 UTC

943 }; 943 };
944} 944}
945 945
946no warnings 'utf8'; 946no warnings 'utf8';
947 947
948sub resource {
949 my ($term, $name, $isarg, $flag, $value) = @_;
950
951 $term->scan_meta;
952
953 warn "resourece<@_>\n";#d#
954
955 0
956}
957
958sub usage {
959 my ($term, $usage_type) = @_;
960
961 $term->scan_meta;
962
963 my $r = $term->{meta}{resource};
964
965 for my $regex (sort keys %$r) {
966 my ($ext, $type, $desc) = @{ $r->{$regex} };
967
968 $desc .= " (-pe $ext)";
969
970 if ($usage_type == 1) {
971 if ($type eq "boolean") {
972 urxvt::log sprintf " -%-20.20s %s\n", "/+$regex", $desc;
973 } else {
974 urxvt::log sprintf " -%-20.20s %s\n", "$regex $type", $desc;
975 }
976 } else {
977 urxvt::log sprintf " %-19.19s %s\n", "$regex:", $type;
978 }
979 }
980}
981
948my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; 982my $verbosity = $ENV{URXVT_PERL_VERBOSITY};
949 983
950sub verbose { 984sub verbose {
951 my ($level, $msg) = @_; 985 my ($level, $msg) = @_;
952 warn "$msg\n" if $level <= $verbosity; 986 warn "$msg\n" if $level <= $verbosity;
988sub invoke { 1022sub invoke {
989 local $TERM = shift; 1023 local $TERM = shift;
990 my $htype = shift; 1024 my $htype = shift;
991 1025
992 if ($htype == 0) { # INIT 1026 if ($htype == 0) { # INIT
993 my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$ENV{HOME}/.urxvt/ext", "$LIBDIR/perl"); 1027 my @dirs = $TERM->perl_libdirs;
994 1028
995 my %ext_arg; 1029 my %ext_arg;
996 1030
997 { 1031 {
998 my @init = @TERM_INIT; 1032 my @init = @TERM_INIT;
1159=head2 The C<urxvt::anyevent> Class 1193=head2 The C<urxvt::anyevent> Class
1160 1194
1161The sole purpose of this class is to deliver an interface to the 1195The sole purpose of this class is to deliver an interface to the
1162C<AnyEvent> module - any module using it will work inside urxvt without 1196C<AnyEvent> module - any module using it will work inside urxvt without
1163further programming. The only exception is that you cannot wait on 1197further programming. The only exception is that you cannot wait on
1164condition variables, but non-blocking condvar use is ok. What this means 1198condition variables, but non-blocking condvar use is ok.
1165is that you cannot use blocking APIs, but the non-blocking variant should 1199
1166work. 1200In practical terms this means is that you cannot use blocking APIs, but
1201the non-blocking variant should work.
1167 1202
1168=cut 1203=cut
1169 1204
1170our $VERSION = '5.23'; 1205our $VERSION = '5.23';
1171 1206
1265 $self->{_pkg}{$pkg} = $proxy; 1300 $self->{_pkg}{$pkg} = $proxy;
1266 1301
1267 for my $name (@HOOKNAME) { 1302 for my $name (@HOOKNAME) {
1268 if (my $ref = $pkg->can ("on_" . lc $name)) { 1303 if (my $ref = $pkg->can ("on_" . lc $name)) {
1269 $proxy->enable ($name => $ref); 1304 $proxy->enable ($name => $ref);
1305 }
1306 }
1307}
1308
1309sub perl_libdirs {
1310 map { split /:/ }
1311 $_[0]->resource ("perl_lib"),
1312 $ENV{URXVT_PERL_LIB},
1313 "$ENV{HOME}/.urxvt/ext",
1314 "$LIBDIR/perl"
1315}
1316
1317sub scan_meta {
1318 my ($self) = @_;
1319 my @libdirs = perl_libdirs $self;
1320
1321 return if $self->{meta_libdirs} eq join "\x00", @libdirs;
1322
1323 my %meta;
1324
1325 $self->{meta_libdirs} = join "\x00", @libdirs;
1326 $self->{meta} = \%meta;
1327
1328 for my $dir (reverse @libdirs) {
1329 opendir my $fh, $dir
1330 or next;
1331 for my $ext (readdir $fh) {
1332 $ext ne "."
1333 and $ext ne ".."
1334 and open my $fh, "<", "$dir/$ext"
1335 or next;
1336
1337 while (<$fh>) {
1338 if (/^#:META:RESOURCE:(.*)/) {
1339 my ($regex, $type, $desc) = split /:/, $1;
1340 $regex =~ s/\$\$/$ext/g; # $$ in regex == extension name
1341 $meta{resource}{$regex} = [$ext, $type, $desc];
1342 } elsif (/^\s*(?:#|$)/) {
1343 # skip other comments and empty lines
1344 } else {
1345 last; # stop parsing on first non-empty non-comment line
1346 }
1347 }
1270 } 1348 }
1271 } 1349 }
1272} 1350}
1273 1351
1274=item $term = new urxvt::term $envhashref, $rxvtname, [arg...] 1352=item $term = new urxvt::term $envhashref, $rxvtname, [arg...]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines