curs_outopts(3X)
π curs_outopts β setting your window's whole output vibe β¨
okay bestie, so this is a library calls page from the curses(3X) manual, and it's literally all about the little switches that decide how your window puts stuff on the screen. no cap, these are the personality settings for your WINDOW. π«Ά
πΈ NAME πΈ
clearok, idcok, idlok, immedok, leaveok, scrollok, setscrreg, wsetscrreg β literally just "set curses output options," that's the whole gig β¨
π SYNOPSIS π
okay here's the lineup, copy-paste ready:
#include <curses.h>
int clearok(WINDOW * win, bool bf);
void idcok(WINDOW * win, bool bf);
int idlok(WINDOW * win, bool bf);
void immedok(WINDOW * win, bool bf);
int leaveok(WINDOW * win, bool bf);
int scrollok(WINDOW * win, bool bf);
int setscrreg(int top, int bot);
int wsetscrreg(WINDOW * win, int top, int bot);
π DESCRIPTION π
so these functions configure properties of curses windows that affect their manner of output. the boolean-valued properties start out FALSE unless it says otherwise down there. and like, endwin(3X) resets any terminal modes that correspond to these properties, so an application does not need to restore their initial values. slay, one less thing to worry about π
β¨ clearok
setting win's clearok property to TRUE makes the next wrefresh call on it clear the terminal screen and redraw it entirely. this property is useful to restore the contents of the screen (maybe because another process wrote to the terminal, rude π), or in some cases to achieve a more pleasing visual effect. if win is curscr (see curs_variables(3X)), then the next wrefresh call on any window causes the terminal screen to clear and redraw as above. wrefresh resets this property to FALSE. it's giving "start over, fresh face" β¨
π¦ idcok
(this property defaults TRUE, bestie, so it's already on π
) setting win's idcok property to FALSE prevents curses from using the insert/delete character capabilities of terminal types that possess them according to the terminfo database.
πΈ idlok
setting win's idlok property to TRUE causes curses to consider using the insert/delete line capabilities of terminal types that possess them according to the terminfo database. enable this option if the application explicitly requires these operations, like a full-screen text editor might. otherwise the results may be visually annoying to the user π. so like, don't just turn it on for fun, okay?
π immedok
if immedok is called with TRUE as the second argument, changes to the window image β like those caused by waddch, wclrtobot, or wscrl β automatically cause a call to wrefresh. setting a window's immedok property may degrade performance considerably if writes are frequent π. calling immedok with FALSE as the second argument restores the default behavior, deferring screen updates until a refresh is needed or explicitly directed by the application. no cap, it's convenient but it's expensive, so use it with intention.
π leaveok
normally, curses leaves the hardware cursor at the library's cursor location of the window being refreshed. the leaveok option allows the cursor to be left wherever the update happens to leave it. it's useful for applications that do not employ a visible cursor, since it reduces the need for cursor motions. main character energy: no cursor needed π
β scrollok
the scrollok option controls what happens when a window's cursor moves off the edge of the window or scrolling region, as a result of either:
- writing a newline anywhere on its bottom line, or
- writing a character that advances the cursor to the last position on its bottom line.
if disabled (bf is FALSE), curses leaves the cursor on the bottom line of the window. if enabled (bf is TRUE), curses scrolls the window up one line. (to get the physical scrolling effect on the terminal, the application must also enable idlok. two switches, one vibe.)
π setscrreg, wsetscrreg
the wsetscrreg and setscrreg functions allow the application to set a software scrolling region in the specified window or stdscr, respectively. the top and bot parameters are the line numbers of the top and bottom margin of the scrolling region. if this option and scrollok are enabled, an attempt to move off the bottom margin line causes all lines in the scrolling region to scroll one line in the direction of the first line. only the text of the window is scrolled. (this process has nothing to do with the scrolling region capability of the terminal, as found in the DEC VT100. like, different thing entirely, don't get it twisted π«Ά) if idlok is enabled and the terminal has either a scrolling region or insert/delete line capability, they will probably be used by the output routines.
π RETURN VALUE π
the functions setscrreg and wsetscrreg return OK upon success and ERR upon failure. all other routines that return an integer always return OK. periodt.
in ncurses, these functions fail if:
- the curses screen has not been initialized,
- (for functions taking a
WINDOWpointer argument)winis a null pointer, or - (for
setscrregandwsetscrreg) the function is passed arguments describing a scrolling region with limits that extend outside the window boundaries.
π§ NOTES π§
clearok, leaveok, scrollok, idcok, and setscrreg may be implemented as macros. iykyk, so don't go taking their addresses or anything weird.
unlike the other functions described by this page, setscrreg does not accept a pointer-to-WINDOW parameter, but operates on stdscr. use wsetscrreg to configure the scrolling region of a selected window.
historically, applications used idcok(FALSE) to accommodate the "magic cookie" feature of some terminal types; see subsection "Highlighting, Underlining, and Visible Bells" of terminfo(5). when updating a line, the presence of character cells with magic cookies in them made the curses library's computations of characters to be rewritten inaccurate. a better solution is to indicate the magic_cookie_glitch (xmc) capability in the terminal's type description. the way that magic cookies messed up the math... π
immedok is useful for windows that are used as terminal emulators.
π PORTABILITY π
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them.
some historic curses implementations, as an undocumented feature, did the equivalent of "clearok(..., 1)" when touchwin(stdstr) or clear(stdstr) were used. this trick does not work with ncurses. π
early System V curses implementations specified that with scrollok enabled, any window modification triggering a scroll also forced a physical refresh. X/Open Curses does not require this, and ncurses avoids doing so to better optimize vertical motions upon a wrefresh.
X/Open Curses does not mention that the cursor should be made invisible as a side effect of leaveok. SVr4 curses documentation notes this behavior, but the code neglects to implement it. use curs_set(3X) to make the cursor invisible. fr fr, do it yourself.
π HISTORY π
- 4BSD (1980) introduced
clearok,leaveok, andscrollok. - SVr2 (1984) supplied
idlok,setscrreg, andwsetscrreg. - SVr3.1 (1987) implemented
idcokandimmedok. - ncurses formerly treated
nlandnonlas both input and output options, but no longer; seecurs_inopts(3X).
π₯ SEE ALSO π₯
curses(3X), curs_addch(3X), curs_clear(3X), curs_initscr(3X), curs_refresh(3X), curs_scroll(3X), curs_variables(3X)
and that's the whole page bestie π this was ncurses 6.6, dated 2025-11-11, from the curs_outopts(3X) manual. go forth and configure your windows, you absolute icon πβ¨
π¦ 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-2016,2017 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms