Good day,
I am writing a simple CLI (command-line interface) application that provides a simple prompt that can accept strings from the user, validates them, and performs certain actions based on input. Fairly straightforward.
I am looking for a platform independent, NON-GPL/LGPL means (or, at least something that works for POSIX compliant OS’s, like Linux, BSD, etc), so I can use the up/down arrows keys to scroll back and forth throughout the history of previously typed commands in my CLI application, and have them appear in the input line.
The goal is to effectively mimic the history feature found in BASH and most other shells. I would like to just use the up/down keys and have them detected. I’m assuming I would need to use interrupts or some specialized library for this; I would really like to just do this with standard ANSI C though, and must avoid any third party libraries entirely.
If you insist on doing it yourself, then there’s not much we can say other than “do it yourself;” it’s not horribly complex but it’s not a morning’s work, either.
You should very seriously consider using GNU
readline, which is what everybody else (includingbash) uses. It does all this and more and does it well.