scroll(3NCURSES)
π scroll β bestie edition π
okay so this is scroll(3NCURSES), straight out of the ncurses library calls squad β¨ it's the whole scroll / scrl / wscrl situation and honestly it's giving "tiny function, big drama" energy π
πΈ NAME πΈ
scroll, scrl, wscrl β scroll a curses window π¦
β¨ SYNOPSIS β¨
#include <curses.h>
int scroll(WINDOW * win);
int scrl(int n);
int wscrl(WINDOW * win, int n);
π DESCRIPTION π
okay so scroll scrolls the window you hand it up by one line. like, every visible line we might number i becomes line i-1. the way that works is so simple but so iconic fr fr π
and then wscrl and scrl scroll the specified window, or stdscr respectively, up or down depending on the sign of n. lowkey the sign is doing all the work here:
- 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 beyond the window boundaries justβ¦ disappears π gone, not coming back. and curses populates a new one emerging at the opposite boundary with the background character; check bkgd(3NCURSES) for that (and if you're on the wide-character API, bkgrnd(3NCURSES), iykyk).
as an optimization, if the scrolling region of the window is the entire screen, the physical screen may be scrolled at the same time; peep curscr(3NCURSES) for that whole situation.
also: the cursor does not move. periodt. and these functions perform no operation unless scrolling is enabled for the window via scrollok(3NCURSES). so if you forgot that call, you're just gonna sit there scrolling nothing and wondering why π«Ά
π₯ RETURN VALUE π₯
these functions return ERR upon failure and OK upon success. no in-between, no vibes, just those two.
in ncurses, they return ERR if:
- the curses screen has not been initialized,
- (for functions taking a
WINDOWpointer argument) win is a null pointer, or - scrolling is not enabled in the window (as by
scrollok(3NCURSES)).
π¦ NOTES π¦
scroll and scrl may be implemented as macros. sneaky little macros, we love them, we fear them π
and unusually, there is no wscroll function. not a thing. scroll behaves as one would expect wscroll to, accepting a WINDOW pointer argument. so like, it's the w-version, just without the w. main character behavior honestly π
π PORTABILITY π
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. so likeβ¦ do with that what you will π
SVr4 describes a successful return value only as βan integer value other than ERRβ. iconic, unhelpful, we stan.
SVr4 indicates 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. so basically ncurses is playing the long game π
and neither SVr4 curses nor X/Open Curses specify whether these functions zero the attributes or color pair identifier of the background character. in ncurses, they do not. noted, bestie, noted.
π HISTORY π
4BSD (1980) introduced scroll, defining it as a function.
SVr3.1 (1987) added scrl and wscrl, redefining scroll as a macro wrapping the latter. the glow-up arc we didn't know we needed β¨
π SEE ALSO π
ncurses(3NCURSES)outopts(3NCURSES)
okay that's the whole page!! this was ncurses 6.6, dated 2025-04-05, and honestly scrolling has never looked this good. go enable scrollok(3NCURSES) and slay πππ¦β¨
π¦ where this page comes from
- ubuntu resolute: ncurses-doc 6.6+20251231-1 Β· MIT/X11
- ubuntu stonking: ncurses-doc 6.6+20260608-2 Β· MIT/X11
- 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