hello monks!

as I mentioned before I'm writing a shell problem with tab completion capabilities using Term::ReadLine. my code is something like that:
use Term::ReadLine; my $term = new Term::ReadLine 'Command Line Interface'; my $attribs = $term->Attribs; $attribs->{completion_entry_function} = $attribs->{'list_completion_fu +nction'}; $attribs->{attempted_completion_function} = \&tabCompletionFunction; sub tabCompletionFunction { my ($text, $line, $start, $end) = @_; if ($somthing) { &printSomething(); print "\nPrompt> $line"; $attribs->{completion_word} = []; } else { # other thing $attribs->{completion_word} = &getTabCompletionArray($node); # g +et completions array } return $term->completion_matches($text, $attribs->{list_completion_f +unction}); }
The above function is suppose to get the array for the tab completion in case 'other thing' happens. if 'something' happens I want to print something and return the prompt with no completion (therefore $atrribs->{completion_word} is set to an empty array).
the problem is that if 'somthing' happens then the function printSomething() is called and the print in the next line (print "\nPrompt> $line";) is not printed to screen, it is printed only the next time the user presses the tab key. a little testing reveals that if I'll add "\n" after printing the prompt line, this line will be printed on the right tab pressing, but then the user will enter his input on an empty line and not in the same line of the prompt. I'v tried everything already and couldn't find a solution, anyone?

Thanks in advance

Hotshot

In reply to problem with tab completion 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.