Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

How could I work on an auto-complete feature?

So I was thinking of it today, my program requires user input from a list and I got a thought from Linux how you press tab it auto completes to whatever command it is closest too.


My thought was something like this

Code
#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::cin;

int main()
{
string sInput;
cout << "Enter the input";
cin >> sInput;
/*If it is an exact input as in it fits the following if statements it goes and does that.*/

/*However, if it doesn't it loads PDCurses or a similar library that allows "console" manipulation so it lists them then I can press up or down to choose the closest one judging by what the first few characters are. */
}

Yeah shit syntax and such, but idgaf. I am just stuck how I would set up like a Linux auto-completion feature. Without criticizing me to much how would I do this or can you point me somewhere?
[Image: 3.gif]
If your trying to implement this on a Linux console then you'll have to look at the ncurses library so that you can grab keystrokes and display output.
Nah sadly I am using crappy pdcurses for Windows for the time being.
[Image: 3.gif]
(Sep 3, 2013 03:23 AM)Terry A. Davis Wrote:  Nah sadly I am using crappy pdcurses for Windows for the time being.

Did you try looking at Window's conio functionality?
The other problem is that as far as I'm aware cin is a blocking functions. You'll have to use non blocking input or multiple threads.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by lucienhfMar 22, 2024 03:06 AM 4 241 Mar 22, 2024 03:06 AM
Last Post: lucienhf
[C] by Sir BillyAug 26, 2019 06:33 PM 1 149 Aug 26, 2019 06:33 PM
Last Post: YouthInAsia
[Python] by L33TPr0xYDec 1, 2015 11:54 AM 1 116 Dec 1, 2015 11:54 AM
Last Post: alexis