Next: 8.14 Pads Up: 8 Character Cell Graphics Previous: 8.12 Cursor and Window

# 8.13 Scrolling

- `int scrollok(win, bf)`
  If TRUE, the text in the window `win` will be scrolled up one line when the cursor is on the lower right corner and a character is typed (or newline). If FALSE, the cursor is left in the same position.

  When turned on the contents of a window can be scrolled with the following functions. (Note: It would be also scrolled, if you print a new line in the last line of the window. So, be careful with scrollok(...) or you will get unreasonable results.)

- `int scroll(win)`
  This function will scroll up the window (and the lines in the data structure) one line.
- `int scrl(n)`
  `int wscrl(win, n)`
  These functions will scroll the window or `win` up or down depending on the value of the integer `n`. If `n` is positive the window will be scrolled up `n` lines, otherwise if `n` is negative the window will be scrolled down `n` lines.
- `int setscrreg(t, b)`
  `int wsetscrreg(win, t, b)`
  Set a software scrolling region.

The following code should explain how to get the effect of scrolling a text on the screen. Look also in .c in the example directory.

We have a window with 18 lines and 66 columns and want to scroll a text in it. S[] is a character array with the text. Max_s is the number of the last line in s[]. Clear_line will print blank characters from the current cursor position up to the end of the line using the current attributes from the window (not A_NORMAL as clrtoeol does). Beg is the last line from s[] currently shown on the screen. Scroll is an enumerate to tell the function what to do, show the NEXT or PREVious line from the text.

Next: 8.14 Pads Up: 8 Character Cell Graphics Previous: 8.12 Cursor and Window