--- rxvt-unicode/src/urxvt.pm 2011/11/20 10:58:58 1.200 +++ rxvt-unicode/src/urxvt.pm 2012/06/05 22:38:17 1.209 @@ -448,6 +448,12 @@ Either binary data or - more common - a text string encoded in a locale-specific way. +=item $keysym + +an integer that is a valid X11 keysym code. You can convert a string +into a keysym and viceversa by using C and +C. + =back =head2 Extension Objects @@ -668,6 +674,13 @@ The event is simply the action string. This interface is assumed to change slightly in the future. +=item on_register_command $term, $keysym, $modifiermask, $string + +Called after parsing a keysym resource but before registering the +associated binding. If this hook returns TRUE the binding is not +registered. It can be used to modify a binding by calling +C. + =item on_resize_all_windows $term, $new_width, $new_height Called just after the new window size has been calculated, but before @@ -932,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 { @@ -977,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; @@ -1148,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 @@ -1258,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 @@ -1384,11 +1475,18 @@ only one resource database per display, and later invocations might return the wrong resources. -=item $success = $term->parse_keysym ($keysym_spec, $command_string) +=item $success = $term->parse_keysym ($key, $octets) -Adds a keymap translation exactly as specified via a resource. See the +Adds a key binding exactly as specified via a resource. See the C resource in the @@RXVT_NAME@@(1) manpage. +=item $term->register_command ($keysym, $modifiermask, $string) + +Adds a key binding. This is a lower level api compared to +C, as it expects a parsed key description, and can be +used only inside either the C hook, to add a binding, or the +C hook, to modify a parsed binding. + =item $rend = $term->rstyle ([$new_rstyle]) Return and optionally change the current rendition. Text that is output by @@ -1611,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 @@ -1936,6 +2038,10 @@ =item $term->XChangeInput ($window, $add_events[, $del_events]) +=item $keysym = $term->XStringToKeysym ($string) + +=item $string = $term->XKeysymToString ($keysym) + Various X or X-related functions. The C<$term> object only serves as the source of the display, otherwise those functions map more-or-less directly onto the X functions of the same name.