--- rxvt-unicode/src/urxvt.pm 2011/12/02 09:03:43 1.203 +++ rxvt-unicode/src/urxvt.pm 2012/06/05 22:38:17 1.209 @@ -945,6 +945,40 @@ no warnings 'utf8'; +sub resource { + my ($term, $name, $isarg, $flag, $value) = @_; + + $term->scan_meta; + + warn "resourece<@_>\n";#d# + + 0 +} + +sub usage { + my ($term, $usage_type) = @_; + + $term->scan_meta; + + my $r = $term->{meta}{resource}; + + for my $regex (sort keys %$r) { + my ($ext, $type, $desc) = @{ $r->{$regex} }; + + $desc .= " (-pe $ext)"; + + if ($usage_type == 1) { + if ($type eq "boolean") { + urxvt::log sprintf " -%-20.20s %s\n", "/+$regex", $desc; + } else { + urxvt::log sprintf " -%-20.20s %s\n", "$regex $type", $desc; + } + } else { + urxvt::log sprintf " %-19.19s %s\n", "$regex:", $type; + } + } +} + my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; sub verbose { @@ -990,7 +1024,7 @@ my $htype = shift; if ($htype == 0) { # INIT - my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$ENV{HOME}/.urxvt/ext", "$LIBDIR/perl"); + my @dirs = $TERM->perl_libdirs; my %ext_arg; @@ -1161,9 +1195,10 @@ The sole purpose of this class is to deliver an interface to the C module - any module using it will work inside urxvt without further programming. The only exception is that you cannot wait on -condition variables, but non-blocking condvar use is ok. What this means -is that you cannot use blocking APIs, but the non-blocking variant should -work. +condition variables, but non-blocking condvar use is ok. + +In practical terms this means is that you cannot use blocking APIs, but +the non-blocking variant should work. =cut @@ -1271,6 +1306,49 @@ } } +sub perl_libdirs { + map { split /:/ } + $_[0]->resource ("perl_lib"), + $ENV{URXVT_PERL_LIB}, + "$ENV{HOME}/.urxvt/ext", + "$LIBDIR/perl" +} + +sub scan_meta { + my ($self) = @_; + my @libdirs = perl_libdirs $self; + + return if $self->{meta_libdirs} eq join "\x00", @libdirs; + + my %meta; + + $self->{meta_libdirs} = join "\x00", @libdirs; + $self->{meta} = \%meta; + + for my $dir (reverse @libdirs) { + opendir my $fh, $dir + or next; + for my $ext (readdir $fh) { + $ext ne "." + and $ext ne ".." + and open my $fh, "<", "$dir/$ext" + or next; + + while (<$fh>) { + if (/^#:META:RESOURCE:(.*)/) { + my ($regex, $type, $desc) = split /:/, $1; + $regex =~ s/\$\$/$ext/g; # $$ in regex == extension name + $meta{resource}{$regex} = [$ext, $type, $desc]; + } elsif (/^\s*(?:#|$)/) { + # skip other comments and empty lines + } else { + last; # stop parsing on first non-empty non-comment line + } + } + } + } +} + =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] Creates a new terminal, very similar as if you had started it with system @@ -1631,6 +1709,10 @@ $term->vt_emask_add (urxvt::PointerMotionMask); +=item $term->set_urgency ($set) + +Enable/disable the urgency hint on the toplevel window. + =item $term->focus_in =item $term->focus_out