curs_scroll(3X)
β¨ curs_scroll β scroll, scrl, wscrl β¨
okay bestie, so this is a page from the ncurses library calls era, and it's literally all about making a curses window do the little scroll-y thing π
πΈ NAME πΈ
scroll, scrl, wscrl β the trio that scrolls a curses window up or down, no cap
π SYNOPSIS π
#include <curses.h>
int scroll(WINDOW * win);
int scrl(int n);
int wscrl(WINDOW * win, int n);
π DESCRIPTION π
So scroll does the most: it scrolls the window you hand it up by one single line. Translated into math-girl terms: every visible line we might number i becomes line i-1. iconic.
Then wscrl and scrl are the flexible ones β they scroll the window you specify, or stdscr respectively, and they go up or down depending on the sign of n:
- For positive n, line i+n becomes i (that's scrolling up);
- For negative n, line i-n becomes i (that's scrolling down).
A line that scrolls past the window boundaries? Gone. Poof. disappears. And curses fills the new line popping up on the opposite boundary with the background character β go check bkgd(3X) for that (and if you're on the wide-character API, it's bkgrnd(3X) for you π«Ά).
Now here's a cute little optimization moment: if the scrolling region of the window happens to be the entire screen, the physical screen may get scrolled at the same time β peep curscr(3X) for the deets.
The cursor does not move. periodt. π
Also, these functions literally do nothing unless scrolling is enabled for the window via scrollok(3X). So if you forgot that, you're gonna be sitting there likeβ¦ why is nothing happening π
π RETURN VALUE π
They return ERR when it goes wrong and OK when it goes right. simple as that π
In ncurses, they return ERR if:
- the curses screen has not been initialized,
- (for the functions that take a
WINDOWpointer argument) win is a null pointer, or - scrolling is not enabled in the window (as by
scrollok(3X)).
π¦ NOTES π¦
scroll and scrl may be implemented as macros. sneaky but valid.
And here's the quirky lore: unusually, there is no wscroll function. scroll just behaves like you'd expect wscroll to, accepting a WINDOW pointer argument. the main character energy of it all.
β PORTABILITY β
X/Open Curses Issue 4 describes these functions. It specifies no error conditions for them, so do with that what you will.
SVr4 describes a successful return value only as "an integer value other than ERR". sooo vague bestie.
SVr4 says that the optimization of physically scrolling immediately if the scroll region is the entire screen "is" performed β not "may be" performed. ncurses deliberately does not guarantee that this occurs, to leave open the possibility of better optimization of multiple scroll actions on the next update. it's giving strategic.
Neither SVr4 curses nor X/Open Curses specify whether these functions zero the attributes or the color pair identifier of the background character. In ncurses, they do not. okay? okay. π
π HISTORY π
- 4BSD (1980) introduced
scroll, defining it as a function. - SVr3.1 (1987) added
scrlandwscrl, redefiningscrollas a macro wrapping the latter.
π SEE ALSO π
curses(3X)curs_outopts(3X)
and that's the whole page, bestie π«Ά this was ncurses 6.6, dated 2025-04-05, and it lives at the curs_scroll(3X) address β no cap, go scroll something β¨
π¦ where this page comes from
- alpine 3.24: ncurses-doc 6.6_p20260516-r0 Β· X11
- arch rolling: ncurses 6.6-2 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- Copyright 2018-2024,2025 Thomas E. Dickey
- Copyright 1998-2006,2010 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms