Morning all !!
I'v written a shell program (a perl script that opens a shell and the user can explore menus there). I'm currently using Term::ReadLine for tab completion of commands in the shell. The tab completion is using a predefined array of words to be completed as the module requires, I define it as follows in the begining of my script:
my $term = new Term::ReadLine 'Command Line Interface';
my $attribs = $term->Attribs;
$attribs->{completion_entry_function} = $attribs->{'list_completion_fu
+nction'};
$attribs->{completion_word} = \@commands; # array of supported comma
+nds
My problem is that my prompt is built like a tree, a user can get down on the tree and his promp is changes accordingly, for example:
Main>
Main> nfs # user enters the nfs menu
Main/NFS> # new prompt
The thing is that the array of words to be completed is containg (at the moment) all the commands that can be typed in my shell, no matter what menu the user is in, so pressing
tab twice on any menu will give the list of all word in the array and not only the relevant for each menu.
is there a way to handle this more efficiently or I'll have to maintain commands array for each menu I'm in?
Hotshot
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.