/[Term-Shelly]/trunk/foo.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/foo.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Mon Jun 25 08:16:44 2007 UTC revision 5 by dpavlin, Mon Jun 25 08:32:23 2007 UTC
# Line 7  my @WORDS = qw(hello how are you today f Line 7  my @WORDS = qw(hello how are you today f
7    
8  my $sh = Term::Shelly->new();  my $sh = Term::Shelly->new();
9    
10    if (0) {
11  $sh->out(  $sh->out(
12  "This is a demo of Term::Shelly. It is designed to show you some of the  "This is a demo of Term::Shelly. It is designed to show you some of the
13  features of it. For this demo there is only a short number of features  features of it. For this demo there is only a short number of features
# Line 19  completion system. The following words c Line 20  completion system. The following words c
20  " . join(" ", @WORDS)."  " . join(" ", @WORDS)."
21  Commands must start with a / (forward slash) and be at the beginning of  Commands must start with a / (forward slash) and be at the beginning of
22  the line.");  the line.");
23    }
24    
25  $sh->{"completion_function"} = \&completer;  $sh->{"completion_function"} = \&completer;
26    $sh->prompt("Foo> ");
27    
28    $sh->out("Welcome!");
29    
30  while (1) {  while (1) {
31          $sh->do_one_loop();          $sh->do_one_loop();
# Line 41  sub completer { Line 45  sub completer {
45                  $word = substr($curword,1);                  $word = substr($curword,1);
46                  @matches = map { "/$_" } grep(m/^\Q$word\E/i, @COMMANDS);                  @matches = map { "/$_" } grep(m/^\Q$word\E/i, @COMMANDS);
47          } else {          } else {
48                  @matches = grep(m/\Q$curword\E/i, @WORDS);                  @matches = grep(m/^\Q$curword\E/i, @WORDS);
49          }          }
50    
51          return @matches;          return @matches;

Legend:
Removed from v.4  
changed lines
  Added in v.5

  ViewVC Help
Powered by ViewVC 1.1.26