What is the recommended way to implement text scrolling in ncurses?

Viewed 6285

I am trying to implement an ncurses app with text scrolling like less. What is the recommended way to do this?

Here's what I know:

  1. You can use scroll to move the text buffer up or down by 1 row. However, you'll end up with one blank line at the top if you scroll down, or at the bottom if you scroll up, which you'll have to repaint yourself.
  2. Ncurses does wordwrap for you, which messes up my math when I have to determine what line I have to repaint in step 1.

I guess I could re-implement wordwrap myself and keep an array of all the post-wrapped lines, but this seems like a common problem, so there might be a better way.

3 Answers
Related