Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Term::ReadLine

by hotshot (Prior)
on Dec 10, 2002 at 17:25 UTC ( [id://218845]=perlquestion: print w/replies, xml ) Need Help??

hotshot has asked for the wisdom of the Perl Monks concerning the following question:

hello monks

I'm using Term::TeadLine in my shell program for some purposes. One of them is the tab completion. my shell have menus so for example:
# if I write main > one two # I should get new prompt main\one\two >
I manage to do so by:
my $term = new Term::ReadLine 'Command Line Interface'; my $attribs = $term->Attribs; $attribs->{attempted_completion_function} = \&tabCompletionFunction; sub tabCompletionFunction { my ($text, $line, $start, $end) = @_; my @tmp = split(/\s+/, $line); unshift(@tmp, @prompt); # the completion should be relative to cur +rent prompt $attribs->{completion_word} = &getTabCompletionArray(\@tmp); return $term->completion_matches($text, $attribs->{list_completion_f +unction}); }
each time the tab button will be pressed, the completion will be made relatively to the current prompt and the info in the input buffer in $line.

This works perfectly except the case when I enter in the command line a char that no word in the completion array starts with, for example when the array is:
$completionsArray = qw(one two three four); # found by &getTabComple +tionArray
and the input is:
current prompt > xdd
what I should expect is that no completion should be preformed, but what actually happens is that if in the current directory (where my shell program runs from) theres a file/directory that starts with xdd, the completion will be made. I guess it uses the defaultfile_completion_function, but I specified list_completion_function intentionaly so this won't happen, Anyone knows why this happens and how can I fix that not to show anything if no matches in the completion array?


Hotshot

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://218845]
Approved by valdez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found