Interactive console programming for c/c++?

≡放荡痞女 提交于 2019-12-07 01:19:52

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7537288/interactive-console-programming-for-c-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!