OK - there's your answer. It's the program's fault
Think about it: who's supposed to "remember" the text that scrolls off the screen?
If it's an X terminal with scrollbars, it's the "xterm" executable that buffers the unseen text. Similarly, "less", "vi", "emacs" et al each have their own strategies for saving, displaying and retrieving text.
It sounds like all your program does is "read" and "scroll". You can probably scroll forward just because the text that comes next is still waiting to be read. But you can't scroll backward - because the program never saved (and cannot retrieve) what it already read.
I'd forget the ANSI character sequences, if you have any choice in the matter.
Two better alternatives:
1. Use your program in conjunction with an external scrolling tool (like "less")
2. Use a more robust screen control library (like "
ncurses").