… | |
… | |
943 | }; |
943 | }; |
944 | } |
944 | } |
945 | |
945 | |
946 | no warnings 'utf8'; |
946 | no warnings 'utf8'; |
947 | |
947 | |
948 | sub perl_libdirs { |
|
|
949 | map { split /:/ } |
|
|
950 | $_[0]->resource ("perl_lib"), |
|
|
951 | $ENV{URXVT_PERL_LIB}, |
|
|
952 | "$ENV{HOME}/.urxvt/ext", |
|
|
953 | "$LIBDIR/perl" |
|
|
954 | } |
|
|
955 | |
|
|
956 | our %META; # meta header information from scripts |
|
|
957 | our %SCAN; # which dirs already scanned |
|
|
958 | |
|
|
959 | sub resource { |
948 | sub resource { |
960 | my ($term, $name, $isarg, $flag, $value) = @_; |
949 | my ($term, $name, $isarg, $flag, $value) = @_; |
961 | |
950 | |
962 | for my $dir (perl_libdirs $term) { |
951 | $term->scan_meta; |
|
|
952 | |
|
|
953 | warn "resourece<@_>\n";#d# |
|
|
954 | |
|
|
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 | } |
963 | } |
979 | } |
964 | |
|
|
965 | warn "resourece<@_>\n";#d# |
|
|
966 | |
|
|
967 | 0 |
|
|
968 | } |
980 | } |
969 | |
981 | |
970 | my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; |
982 | my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; |
971 | |
983 | |
972 | sub verbose { |
984 | sub verbose { |
… | |
… | |
1010 | sub invoke { |
1022 | sub invoke { |
1011 | local $TERM = shift; |
1023 | local $TERM = shift; |
1012 | my $htype = shift; |
1024 | my $htype = shift; |
1013 | |
1025 | |
1014 | if ($htype == 0) { # INIT |
1026 | if ($htype == 0) { # INIT |
1015 | my @dirs = perl_libdirs $TERM; |
1027 | my @dirs = $TERM->perl_libdirs; |
1016 | |
1028 | |
1017 | my %ext_arg; |
1029 | my %ext_arg; |
1018 | |
1030 | |
1019 | { |
1031 | { |
1020 | my @init = @TERM_INIT; |
1032 | my @init = @TERM_INIT; |
… | |
… | |
1291 | $proxy->enable ($name => $ref); |
1303 | $proxy->enable ($name => $ref); |
1292 | } |
1304 | } |
1293 | } |
1305 | } |
1294 | } |
1306 | } |
1295 | |
1307 | |
|
|
1308 | sub perl_libdirs { |
|
|
1309 | map { split /:/ } |
|
|
1310 | $_[0]->resource ("perl_lib"), |
|
|
1311 | $ENV{URXVT_PERL_LIB}, |
|
|
1312 | "$ENV{HOME}/.urxvt/ext", |
|
|
1313 | "$LIBDIR/perl" |
|
|
1314 | } |
|
|
1315 | |
|
|
1316 | sub scan_meta { |
|
|
1317 | my ($self) = @_; |
|
|
1318 | my @libdirs = perl_libdirs $self; |
|
|
1319 | |
|
|
1320 | return if $self->{meta_libdirs} eq join "\x00", @libdirs; |
|
|
1321 | |
|
|
1322 | my %meta; |
|
|
1323 | |
|
|
1324 | $self->{meta_libdirs} = join "\x00", @libdirs; |
|
|
1325 | $self->{meta} = \%meta; |
|
|
1326 | |
|
|
1327 | for my $dir (reverse @libdirs) { |
|
|
1328 | opendir my $fh, $dir |
|
|
1329 | or next; |
|
|
1330 | for my $ext (readdir $fh) { |
|
|
1331 | $ext ne "." |
|
|
1332 | and $ext ne ".." |
|
|
1333 | and open my $fh, "<", "$dir/$ext" |
|
|
1334 | or next; |
|
|
1335 | |
|
|
1336 | while (<$fh>) { |
|
|
1337 | if (/^#:META:RESOURCE:(.*)/) { |
|
|
1338 | my ($regex, $type, $desc) = split /:/, $1; |
|
|
1339 | $regex =~ s/\$\$/$ext/g; # $$ in regex == extension name |
|
|
1340 | $meta{resource}{$regex} = [$ext, $type, $desc]; |
|
|
1341 | } elsif (/^\s*(?:#|$)/) { |
|
|
1342 | # skip other comments and empty lines |
|
|
1343 | } else { |
|
|
1344 | last; # stop parsing on first non-empty non-comment line |
|
|
1345 | } |
|
|
1346 | } |
|
|
1347 | } |
|
|
1348 | } |
|
|
1349 | } |
|
|
1350 | |
1296 | =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] |
1351 | =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] |
1297 | |
1352 | |
1298 | Creates a new terminal, very similar as if you had started it with system |
1353 | Creates a new terminal, very similar as if you had started it with system |
1299 | C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like |
1354 | C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like |
1300 | hash which defines the environment of the new terminal. |
1355 | hash which defines the environment of the new terminal. |