Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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?
Posted

1 solution

The GNU shell (bash) uses the GNU Readline Library[^].
 
Share this answer
 
Comments
old_hacker 24-Feb-11 3:48am    
Many thanks, markkuk, that's just what I was looking for (with no success, despite a lot of Web searching)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900