I am writing a program that's similar to a shell. Once started up, there's a prompt and you enter in some app-specific commands.

So far this works just fine. However, I want to add support for command history like in Bash, so the user could hit the up or down arrow and see previously entered commands.

I have included the ncurses library, and I have done a simple hello world test with getch() to make sure the up and down arrows are reported correctly.

The thing that's bothering me is that it seems to be a requirement that I call initscr() which will clear the screen in order for me to use getch().

OKAY SO THE QUESTION IS:

Does anybody know a way to use ncurses getch() function without calling initscr() first? If not, can I make it not clear the screen? Basically, I'm looking to have getch() act the same as getchar(), if that makes sense.

Thanks in advance!

EDIT: I think the best example of this is how Python runs in interactive mode.