user3091673
user3091673

Reputation:

ncurses scroll text contents of window

I'm looking for definitive answers about scrolling methods in a window or pad using ncurses.

I would like to display a stdout stream which quickly fills the number of available lines on the screen and starts to overflow. Using stdio the terminal simply scrolls the contents. But with ncurses as far as I understand the output is only limited to the screen area. Is this entirely accurate?

Is the usual approach then to put the entire contents of stdout into a buffer and then read specific parts of the buffer into a ncurses window or pad? Which other methods are there to scroll text using ncurses?

Upvotes: 5

Views: 5787

Answers (2)

Amir Forsati
Amir Forsati

Reputation: 5988

Use scrollok like:

scrollok(win, TRUE);

Upvotes: 1

Thomas Dickey
Thomas Dickey

Reputation: 54668

You may have overlooked scrollok:

The scrollok option controls what happens when the cursor of a window is moved off the edge of the window or scrolling region, either as a result of a newline action on the bottom line, or typing the last character of the last line. If disabled, (bf is FALSE), the cursor is left on the bottom line. If enabled, (bf is TRUE), the window is scrolled up one line (Note that to get the physical scrolling effect on the terminal, it is also necessary to call idlok).

Using that, you can write to any window, and have it scroll up—just like stdio.

Further reading:

Upvotes: 4

Related Questions