|
-
February 29th, 2008, 04:29 PM
#1
Autocompletion for a CLI application
Hello,
I'm programming a CLI application and I would like to add the autocompletion feature.
I have all the valid commands in a hash table and I would like to display the available options when a user presses the TAB key when typing an incomplete command.
Ex: sc(hit the TAB key) --> scanf
The same functionality as in a linux shell.
The problem is when I do a (cin >> cmd) I have to press the enter key to read that line and I would like to display the options only by pressing the TAB key.
I tried the ncurses library but I would like to do that with standard C++ w/o any external library.
Somebody with a good idea?
-
March 1st, 2008, 02:53 AM
#2
Re: Autocompletion for a CLI application
Try using getc instead of cin >> cmd.
-
March 1st, 2008, 08:28 AM
#3
Re: Autocompletion for a CLI application
Use an existing library - either GNU readline http://tiswww.case.edu/php/chet/readline/rltop.html (GPL2) or editline http://www.thrysoee.dk/editline/ (BSD) depending on licensing tastes.
-
March 1st, 2008, 08:51 PM
#4
Re: Autocompletion for a CLI application
Ok, thanks for the hint on the readline library, I think it's what I was looking for.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|