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. How
Curses wants to fully control the screen, and to optimize writes to the screen, especially over slow serial lines. To do this, it needs to know what is on the screen, and the only reasonable way to do that with most terminals is to start from an empty screen and keep track of what you write to the terminal.
Thus, I suspect (n)curses is the wrong tool for your shell. You probably need to go down a step on the abstraction layer and use terminfo and non-blocking reads from the terminal (standard input) instead.
(This is not very helpful. Sorry.)
Here is another discussion about this. The provided solutions are:
Of course there is the third option to get the ncurses source code and modify it so it doesn't clear the screen anymore.
You could just call your program from whithin rlwrap and have the functionality without the pain...
Have you considered the simple expedient of creating a custom terminfo or termcap entry lacking a sequence to clear the screen and then switching your terminal setting to that right before running your program? You could also just use newterm() and set_term() in ncurses. This used to be easier with termcap, since you could include another terminal and override some of its capabilities.
It might be simpler to use an interface like readline() rather than resorting to full-blown ncurses.