*** empty log message ***
authorroot <root>
Mon, 9 Jan 2006 20:00:31 +0000 (20:00 +0000)
committerroot <root>
Mon, 9 Jan 2006 20:00:31 +0000 (20:00 +0000)
src/urxvt.pm

index 8d040c8..798bc1a 100644 (file)
@@ -447,23 +447,6 @@ sub verbose {
    warn "$msg\n" if $level <= $verbosity;
 }
 
-# find on_xxx subs in the package and register them
-# as hooks
-sub register_package($) {
-   my ($pkg) = @_;
-
-   for my $htype (0.. $#HOOKNAME) {
-      my $name = $HOOKNAME[$htype];
-
-      my $ref = $pkg->can ("on_" . lc $name)
-         or next;
-
-      $TERM->{_hook}[$htype]{$pkg} = $ref;
-      $hook_count[$htype]++
-         or set_should_invoke $htype, 1;
-   }
-}
-
 my $extension_pkg = "extension0000";
 my %extension_pkg;
 
@@ -501,23 +484,25 @@ sub invoke {
    if ($htype == 0) { # INIT
       my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl");
       
-      my %want_ext;
+      my %ext_arg;
 
       for (map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2) {
          if ($_ eq "default") {
-            $want_ext{$_}++ for qw(selection option-popup selection-popup);
+            $ext_arg{$_} ||= [] for qw(selection option-popup selection-popup);
          } elsif (/^-(.*)$/) {
-            delete $want_ext{$1};
+            delete $ext_arg{$1};
+         } elsif (/^([^<]+)<(.*)>$/) {
+            push @{ $ext_arg{$1} }, $2;
          } else {
-            $want_ext{$_}++;
+            $ext_arg{$_} ||= [];
          }
       }
 
-      for my $ext (keys %want_ext) {
+      while (my ($ext, $argv) = each %ext_arg) {
          my @files = grep -f $_, map "$_/$ext", @dirs;
 
          if (@files) {
-            register_package extension_package $files[0];
+            $TERM->register_package (extension_package $files[0], $argv);
          } else {
             warn "perl extension '$ext' not found in perl library search path\n";
          }
@@ -536,16 +521,9 @@ sub invoke {
       keys %$cb;
 
       while (my ($pkg, $cb) = each %$cb) {
-         eval {
-            $retval = $cb->(
-               $TERM->{_pkg}{$pkg} ||= do {
-                  my $proxy = bless { }, $pkg;
-                  Scalar::Util::weaken ($proxy->{term} = $TERM);
-                  $proxy
-               },
-               @_,
-            ) and last;
-         };
+         $retval = eval { $cb->($TERM->{_pkg}{$pkg}, @_) }
+            and last;
+
          if ($@) {
             $TERM->ungrab; # better to lose the grab than the session
             warn $@;
@@ -677,6 +655,30 @@ package urxvt::term;
 
 =over 4
 
+=cut
+
+# find on_xxx subs in the package and register them
+# as hooks
+sub register_package {
+   my ($self, $pkg, $argv) = @_;
+
+   my $proxy = bless { argv => $argv }, $pkg;
+   Scalar::Util::weaken ($proxy->{term} = $TERM);
+
+   $self->{_pkg}{$pkg} = $proxy;
+
+   for my $htype (0.. $#HOOKNAME) {
+      my $name = $HOOKNAME[$htype];
+
+      my $ref = $pkg->can ("on_" . lc $name)
+         or next;
+
+      $self->{_hook}[$htype]{$pkg} = $ref;
+      $hook_count[$htype]++
+         or urxvt::set_should_invoke $htype, 1;
+   }
+}
+
 =item $term->destroy
 
 Destroy the terminal object (close the window, free resources etc.).
@@ -1178,7 +1180,7 @@ sub add_item {
 sub add_separator {
    my ($self, $sep) = @_;
 
-   $sep ||= "";
+   $sep ||= "=";
 
    $self->add_item ({
       rend => { normal => "\x1b[0;30;47m", hover => "\x1b[0;30;47m", active => "\x1b[0;30;47m" },