- Add autocompletion for parameter names and values
authorRalf Ertzinger <sun@ryoko-darknet.camperquake.de>
Sun, 7 Dec 2008 22:34:02 +0000 (23:34 +0100)
committerRalf Ertzinger <sun@ryoko-darknet.camperquake.de>
Sun, 7 Dec 2008 22:34:02 +0000 (23:34 +0100)
videosite.pl
videosite/Base.pm

index 54a1280..bf14b95 100644 (file)
@@ -455,8 +455,28 @@ sub sig_complete {
         foreach (@grabbers, @getters) {
             push(@matches, $_->{'NAME'}) if $_->{'NAME'} =~ m|^$word|;
         };
+    } elsif ($linestart =~ m|^/videosite set (\w+)$|) {
+        my $module = $1;
+
+        foreach my $p (@getters, @grabbers) {
+            if ($p->{'NAME'} eq $module) {
+                @matches = $p->getparamlist($word);
+                last;
+            }
+        }
+    } elsif ($linestart =~ m|/videosite set (\w+) (\w+)$|) {
+        my $module = $1;
+        my $param = $2;
+
+        foreach my $p (@getters, @grabbers) {
+            if ($p->{'NAME'} eq $module) {
+                @matches = $p->getparamvalues($param, $word);
+                last;
+            }
+        }
     }
 
+
     push(@{$complist}, sort @matches);
     ${$want_space} = 0;
 
index 697bcfb..f0fa439 100644 (file)
@@ -111,6 +111,30 @@ sub getconfstr {
     return $s;
 }
 
+# Return a list of the parameters supported by the module
+# Does not return the 'enabled' parameter
+sub getparamlist {
+    my $self = shift;
+    my $word = shift;
+
+    return grep {$_ ne 'enabled' && /^$word/} keys %{$self->{'_PARAMS'}};
+}
+
+# Return a list of valid parameter values, if the parameter has
+# such a list.
+sub getparamvalues {
+    my $self = shift;
+    my $param = shift;
+    my $word = shift;
+
+    unless(exists($self->{'_PARAMS'}->{$param}->[2])) {
+        return ();
+    } else {
+        return grep {/^$word/} keys %{$self->{'_PARAMS'}->{$param}->[2]};
+    }
+}
+
+
 sub gethelpstr {
     my $self = shift;
     my $s = 'Help for ' . $self->{'NAME'} . ":\n";