Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interactive console programming for c/c++?

So I've written a small program which takes in commands by the users, and then displays the output (after connecting to a server). It's an interactive console of sorts.

However, after using the mongodb and redis command-line clients (which work interactively on the console/terminal), it seems that there must be a library somewhere which provides functionalities such as recording user inputs, accepting up/down keypresses to browse through command history, as well as tab completion framework (not sure how that one would work, but yeah).

What's an ideal library to use for such a thing?

like image 646
kamziro Avatar asked Sep 24 '11 05:09

kamziro


1 Answers

The readline library is a common choice: http://www.gnu.org/s/readline

If you are more ambitious, ncurses gives you more control, but has less functionality to begin with and a steeper learning curve.

Edit: icktoofay mentioned that readline is licensed under the GPL. If this is a problem for your software, tecla is an alternative licensed under an X11 style license, so it can be used in proprietary projects.

like image 134
regality Avatar answered Oct 13 '22 17:10

regality