How can I write a command line shell to capture 'UP' key to get historic input?
c, c++, command-line, shell
Solution
There is a `readline` function that supports history and line editing, etc.
In basic mode it does reading of line, etc. If you want to add hooks, you can make it expand commands when pressing `tab` or similar.
This is what your typical shell in Linux uses.
Documentation here: http://web.mit.edu/gnu/doc/html/rlman_2.html
An example here: http://www.delorie.com/gnu/docs/readline/rlman_48.html
Main project page: http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
Problem
I want to write a command line shell for a background program, and in witch I can type some commands. I want to add a feature like the bash (or other shell-like) ---'UP' key to get the historic input. How can I capture the 'UP' key was pressed? If I just use `std::getline(std::cin, line)` I can't get the 'UP' key or other function key, ie. Ctrl+w to delete a word of the input line.