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.208 by root, Tue Jun 5 22:23:07 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;
1269 $proxy->enable ($name => $ref); 1303 $proxy->enable ($name => $ref);
1270 } 1304 }
1271 } 1305 }
1272} 1306}
1273 1307
1308sub 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
1316sub 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
1274=item $term = new urxvt::term $envhashref, $rxvtname, [arg...] 1351=item $term = new urxvt::term $envhashref, $rxvtname, [arg...]
1275 1352
1276Creates a new terminal, very similar as if you had started it with system 1353Creates a new terminal, very similar as if you had started it with system
1277C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like 1354C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like
1278hash which defines the environment of the new terminal. 1355hash which defines the environment of the new terminal.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines