delch(3NCURSES)

πŸ’– delch β€” bestie edition πŸ’–

okay so this is a page from the ncurses library manual, section 3, and it's all about four little functions that delete a character from a curses window. their names are delch, wdelch, mvdelch, and mvwdelch. yes they're basically the same function wearing four different outfits, and yes we're gonna talk about all four. πŸŽ€


✨ NAME ✨

delch, wdelch, mvdelch, mvwdelch β€” delete a character from a curses window. that's it. that's the whole vibe. πŸ¦‹


✨ SYNOPSIS ✨

#include <curses.h>

int delch(void);
int wdelch(WINDOW * win);
int mvdelch(int y, int x);
int mvwdelch(WINDOW * win, int y, int x);

like. look at them. four lil guys. same energy, different arguments. πŸ’…


✨ DESCRIPTION ✨

so wdelch is the one that does the actual work, and here's what it does: it deletes the character sitting at the cursor position in win. πŸ’€

then it does the shuffle β€” it takes every character to the right of the cursor on the same line and moves them all one position to the left. and the rightmost position on that line? it gets its contents replaced with the window's background character. for the deets on that, go read bkgd(3NCURSES) β€” and if you're a wide-character API girlie, you want bkgrnd(3NCURSES) instead. 🫢

and here's the part that's lowkey iconic: the cursor position does not change (after moving to (y, x), if you specified that). it just stays put, unbothered, moisturised, in its lane. ✨

oh and also β€” ncurses(3NCURSES) is where you go to read about the variants of this function, so keep that in your back pocket. πŸ“š


✨ RETURN VALUE ✨

these functions return OK when everything slays, and ERR when it does not. 😭

in ncurses specifically, these functions fail if:

  • the curses screen has not been initialized, or
  • (for the functions that take a WINDOW pointer argument) win is a null pointer.

and the ones with the mv prefix? they do cursor movement first, and they fail if the position (y, x) is outside the window boundaries. so like, you can't just wander off the edge of the window bestie, it's not gonna happen. 🚫


✨ NOTES ✨

  • delch, mvdelch, and mvwdelch may be implemented as macros. so like, they might not be real functions at all. jumpscare. πŸ’€
  • a terminal's delete_character (dch1) capability is not necessarily employed. so don't just assume the terminal is doing the deleting, okay? that's not guaranteed. πŸ™ˆ

✨ PORTABILITY ✨

X/Open Curses Issue 4 describes these functions β€” but it specifies no error conditions for them. so like, it's giving "we documented them and then said nothing else." πŸ‘‘

and SVr4? it describes a successful return value only as "an integer value other than ERR". that's the whole description. an integer. other than ERR. the bar is on the floor fr fr. 😭


✨ HISTORY ✨

SVr2, way back in 1984, introduced wdelch. so this function is literally older than basically everything. a true elder. respect the elders. 🫑


✨ SEE ALSO ✨

  • ncurses(3NCURSES)

and that's the whole page bestie!! no cap, every flag, every caveat, every 1984 factoid β€” all of it, preserved, untouched, exactly as the ancestors wrote it. 🧚

this was the delch(3NCURSES) page from ncurses 6.6, dated 2025-04-05. mwah. πŸ’…βœ¨πŸ’–
πŸ“¦ where this page comes from