… | |
… | |
946 | no warnings 'utf8'; |
946 | no warnings 'utf8'; |
947 | |
947 | |
948 | sub resource { |
948 | sub resource { |
949 | my ($term, $name, $isarg, $flag, $value) = @_; |
949 | my ($term, $name, $isarg, $flag, $value) = @_; |
950 | |
950 | |
|
|
951 | $term->scan_meta; |
|
|
952 | |
951 | warn "resourece<@_>\n";#d# |
953 | warn "resourece<@_>\n";#d# |
952 | |
954 | |
953 | 0 |
955 | 0 |
|
|
956 | } |
|
|
957 | |
|
|
958 | sub 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 | } |
954 | } |
980 | } |
955 | |
981 | |
956 | my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; |
982 | my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; |
957 | |
983 | |
958 | sub verbose { |
984 | sub verbose { |
… | |
… | |
996 | sub invoke { |
1022 | sub invoke { |
997 | local $TERM = shift; |
1023 | local $TERM = shift; |
998 | my $htype = shift; |
1024 | my $htype = shift; |
999 | |
1025 | |
1000 | if ($htype == 0) { # INIT |
1026 | if ($htype == 0) { # INIT |
1001 | my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$ENV{HOME}/.urxvt/ext", "$LIBDIR/perl"); |
1027 | my @dirs = $TERM->perl_libdirs; |
1002 | |
1028 | |
1003 | my %ext_arg; |
1029 | my %ext_arg; |
1004 | |
1030 | |
1005 | { |
1031 | { |
1006 | my @init = @TERM_INIT; |
1032 | my @init = @TERM_INIT; |
… | |
… | |
1167 | =head2 The C<urxvt::anyevent> Class |
1193 | =head2 The C<urxvt::anyevent> Class |
1168 | |
1194 | |
1169 | The sole purpose of this class is to deliver an interface to the |
1195 | The sole purpose of this class is to deliver an interface to the |
1170 | C<AnyEvent> module - any module using it will work inside urxvt without |
1196 | C<AnyEvent> module - any module using it will work inside urxvt without |
1171 | further programming. The only exception is that you cannot wait on |
1197 | further programming. The only exception is that you cannot wait on |
1172 | condition variables, but non-blocking condvar use is ok. What this means |
1198 | condition variables, but non-blocking condvar use is ok. |
1173 | is that you cannot use blocking APIs, but the non-blocking variant should |
1199 | |
1174 | work. |
1200 | In practical terms this means is that you cannot use blocking APIs, but |
|
|
1201 | the non-blocking variant should work. |
1175 | |
1202 | |
1176 | =cut |
1203 | =cut |
1177 | |
1204 | |
1178 | our $VERSION = '5.23'; |
1205 | our $VERSION = '5.23'; |
1179 | |
1206 | |
… | |
… | |
1273 | $self->{_pkg}{$pkg} = $proxy; |
1300 | $self->{_pkg}{$pkg} = $proxy; |
1274 | |
1301 | |
1275 | for my $name (@HOOKNAME) { |
1302 | for my $name (@HOOKNAME) { |
1276 | if (my $ref = $pkg->can ("on_" . lc $name)) { |
1303 | if (my $ref = $pkg->can ("on_" . lc $name)) { |
1277 | $proxy->enable ($name => $ref); |
1304 | $proxy->enable ($name => $ref); |
|
|
1305 | } |
|
|
1306 | } |
|
|
1307 | } |
|
|
1308 | |
|
|
1309 | sub 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 | |
|
|
1317 | sub 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 | } |
1278 | } |
1348 | } |
1279 | } |
1349 | } |
1280 | } |
1350 | } |
1281 | |
1351 | |
1282 | =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] |
1352 | =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] |