diff options
Diffstat (limited to 'gmi.pl')
-rwxr-xr-x | gmi.pl | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -10,7 +10,7 @@ use bytes; use feature qw(refaliasing); no warnings qw(experimental::refaliasing); -our $VERSION = 'v0.0.17'; +our $VERSION = 'v0.0.18'; # TODO: # back() only works once; should fix this @@ -23,6 +23,8 @@ require Text::Wrapper; # CPAN use Term::ReadKey; # CPAN use Term::ANSIColor; # Core use Path::Naive qw(normalize_path); # CPAN +use Text::ParseWords; # Core +use Term::ReadLine; # CPAN use Smart::Comments; # CPAN my $wrapper = Text::Wrapper->new(columns=>70, body_start=>''); @@ -87,18 +89,24 @@ my %commands = ( 'exit' => [sub {exit 0;}, "This exits the program with a status code of 0."], ); -print "Type 'cmds' to see available commands.\n"; -while () { +my $term=new Term::ReadLine "hmm, what goes here?"; +my @completions = keys %commands; +my $OUT = $term->OUT || \*STDOUT; - $prompt = "$current_url > "; - print "$prompt"; - chomp(my $input = <STDIN>); +$term->Attribs->{'do_expand'}=1; +$term->Attribs->{'completion_entry_function'} = $term->Attribs->{'list_completion_function'}; +$term->Attribs->{'completion_word'} = \@completions; +$term->ornaments(0); + +$prompt = "$current_url > "; - # ## $input - if ($input) { - my ($command, $detail) = split(/\s/, $input); +print "Press <tab><tab> to see available commands.\n"; +while ( defined ($_ = $term->readline($prompt)) ) { + if ($_) { + my ($command, $detail) = split(/\s/, $_); do_command(\$command, \$detail); } + $prompt = "$current_url > "; } sub do_command { @@ -150,7 +158,7 @@ sub url { # ## $url # relative movement - if ($mode eq 1) { + if ($mode and $mode eq 1) { if (!$current_url) {print "Relative movement impossible: no current URL.\n"; return 1;} my $c_url = parse_url($current_url); |