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

In reply to Term::ReadLine by hotshot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.