curs_touch(3X)

✨ curs_touch β€” the manual page for curs_touch(3X) ✨

okay bestie, sit down, hydrate, because we're talking about curs_touch(3X), a genuine library call from the ncurses girlies πŸ’… and honestly? it's giving "who touched my window" in the best way possible.


🌸 NAME 🌸

touchwin, touchline, untouchwin, wtouchln, is_linetouched, is_wintouched β€” the whole squad that controls terminal output refresh in a curses window 🫢


✨ SYNOPSIS ✨

#include <curses.h>

int touchline(WINDOW *win, int start, int count);

int touchwin(WINDOW *win);
int wtouchln(WINDOW *win, int y, int n, int changed);

int untouchwin(WINDOW *win);

bool is_linetouched(WINDOW *win, int line);
bool is_wintouched(WINDOW *win);

πŸ’– DESCRIPTION πŸ’–

so here's the tea, bestie β˜•

The touchwin and touchline routines throw away all optimization information about which parts of the window have been touched, by pretending that the entire window has been drawn on. iconic behavior, honestly. this is sometimes necessary when you're using overlapping windows, because a change to one window affects the other window, but the records of which lines have been changed in the other window do not reflect the change. rude of them, but okay.

The touchline routine only pretends that count lines have been changed, beginning with line start. a little more chill, a little more precise πŸŽ€

The untouchwin routine marks all lines in the window as unchanged since the last call to wrefresh. it's the "no thoughts, head empty, nothing happened here" of curses functions.

The wtouchln routine makes n lines in the window, starting at line y, look as if they have (changed=1) or have not (changed=0) been changed since the last call to wrefresh. you're literally gaslighting the window, and it's working ✨

The is_linetouched and is_wintouched routines return TRUE if the specified line/window was modified since the last call to wrefresh; otherwise they return FALSE. and plot twist β€” is_linetouched also returns ERR if line is not valid for the given window. drama! πŸ’€


πŸ”₯ RETURN VALUE πŸ”₯

Functions returning integers return ERR upon failure and OK upon success. the classic duo. the Sam and Frodo of curses.

In ncurses, specifically:

  • is_linetouched
    • returns ERR if the window pointer is null, or if the line number is outside the window boundaries.
    • The constant ERR is distinct from TRUE and FALSE, which are the normal return values of this function. Because the function returns a bool, returning ERR (which is neither TRUE nor FALSE) may not be supported by the compiler. so like… that's a whole situation 🫠
    • To provide error-checking and also match the X/Open function prototype, the ERR is provided by a macro named is_linetouched. The actual function returns FALSE when it detects an error. sneaky but slay.
  • wtouchln
    • returns ERR if the window pointer is null, or if the line number is outside the window boundaries.

πŸ¦‹ NOTES πŸ¦‹

All of these functions except wtouchln may be implemented as macros. so don't come for them if they're not "real" functions, bestie, that's just how they roll πŸ’…


🌈 PORTABILITY 🌈

X/Open Curses Issue 4 describes these functions. It specifies no error conditions for them. so like, do what you want, I guess πŸ’œ

SVr4 describes a successful return value β€” except where "otherwise noted" β€” as "an integer value other than ERR".

SVr4 does not check win to ensure that it is not a null pointer. not it being reckless 😭


πŸ‘‘ HISTORY πŸ‘‘

  • SVr2 (1984) introduced touchwin. a legend was born πŸŽ€
  • SVr3 (1987) added touchline. SVr3.1 later that year supplied is_linetouched, is_wintouched, untouchwin, and wtouchln. the whole crew assembled ✨

πŸ“ SEE ALSO πŸ“

  • curses(3X)
  • curs_refresh(3X)
  • curs_variables(3X)

and that's the whole page, bestie!! this was curs_touch(3X) from ncurses 6.6, dated 2025-01-18 🫢 go forth and touch your windows (affectionately), you absolute main character πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from