I'm developing a Linux console app, the normal sort of thing: output a prompt, read the user's input line, action it, repeat. However, I want to offer a line input facility like that of the Linux shell, with access to previously-typed input lines, as well as the normal editing of input. In other words, keys like BACKSPACE, DELETE, etc. all do what you would expect, and ENTER delivers the complete line of input to my program, all as normal, BUT the up-arrow key replaces the current input line with the previous one (from my program's input, not from the shell's history)
The shell obviously has all the code for this, and it's a non-trivial job to replicate it, so I wondered whether it is possible to tap into that code, assuming it lives in a library. Anybody ever done that, or have any other suggestions as to an easy way to achieve what I want?