curs_border(3X)
π curs_border β the manual page, but make it cute π
okay so bestie, this is curs_border(3X), a Library call from the ncurses crew, and it's literally all about drawing borders and lines in a curses window of characters. like, boxes. pretty lines. the whole aesthetic. π
β¨ NAME β¨
border, wborder, box, hline, whline, vline, wvline, mvhline, mvwhline, mvvline, mvwvline β draw borders and lines in a curses window of characters π
πΈ SYNOPSIS πΈ
#include <curses.h>
int border(chtype ls, chtype rs, chtype ts, chtype bs,
chtype tl, chtype tr, chtype bl, chtype br);
int wborder(WINDOW *win, chtype ls, chtype rs,
chtype ts, chtype bs, chtype tl, chtype tr,
chtype bl, chtype br);
int box(WINDOW *win, chtype verch, chtype horch);
int hline(chtype ch, int n);
int whline(WINDOW *win, chtype ch, int n);
int mvhline(int y, int x, chtype ch, int n);
int mvwhline(WINDOW *win, int y, int x, chtype ch, int n);
int vline(chtype ch, int n);
int wvline(WINDOW *win, chtype ch, int n);
int mvvline(int y, int x, chtype ch, int n);
int mvwvline(WINDOW *win, int y, int x, chtype ch, int n);
π¦ DESCRIPTION π¦
okay so wborder and border draw a box at the edges of the window you picked, or of stdscr respectively (that's the glow-up difference between them π«). each chtype argument is a specific geometric component of the border, like a little puzzle piece:
lsβ left side,rsβ right side,tsβ top side,bsβ bottom side,tlβ top left-hand corner,trβ top right-hand corner,blβ bottom left-hand corner, andbrβ bottom right-hand corner.
and here's the tea: if any chtype argument is 0, curses just goes "say less" and uses forms-drawing characters instead (peep addch(3X)), in this exact correspondence:
ACS_VLINE,ACS_VLINE,ACS_HLINE,ACS_HLINE,ACS_ULCORNER,ACS_URCORNER,ACS_LLCORNER, andACS_LRCORNER.
ngl box(win, verch, horch) is just shorthand for:
wborder(win, verch, verch, horch, horch, 0, 0, 0, 0)
iconic, right? π
so whline draws a horizontal line of ch going left to right, and wvline does a vertical one going top to bottom. they stop once n characters have been drawn, or the moment they hit the boundary of win β whichever comes first, bestie, they know when to stop. π
and the way that these functions do not update the cursor position (beyond any motion directed by their mv variants) β yeah, cursor stays put. ncurses(3X) is where the variants of these functions get described, iykyk.
β RETURN VALUE β
these functions return OK on success and ERR on failure. simple as that, periodt.
in ncurses:
- these functions fail if the screen is not initialized; and
- functions taking a
WINDOWpointer argument fail ifwinis a null pointer. π
and the functions prefixed with mv? they first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. so don't be sending them off-grid fr fr.
π NOTES π
unusually β and honestly this is a lil quirky of the codebase β there is no wbox function. like, at all. box just behaves as one would expect wbox to, accepting a WINDOW pointer argument. main character energy, honestly. π
also: border, box, hline, mvhline, mvwhline, vline, mvvline, and mvwvline may be implemented as macros. so no, you can't always take their address, bestie. π
and one more thing: borders drawn by these functions are interior borders.
π PORTABILITY π
these functions are described in X/Open Curses Issue 4. it specifies no error conditions for them. wild, right?
SVr4 documentation says these functions return OK "or a non-negative integer if immedok() is set" β and that's referring to the return value from wrefresh, which in SVr4 returns a count of characters written to the window if its immedok property is set. in ncurses, it does not. so yeah, don't count on that one. π
and the history lesson: BSD curses drew boxes with horch in every character cell of the top and bottom lines of the window, whereas SVr3.1 and later curses used the default corner characters β because its box wrapped wborder. glow-up behavior, honestly. β¨
π§ HISTORY π§
4BSD (1980) introduced box, defining it as a function.
SVr3.1 (1987) added whline and wvline and their variants, as well as border and wborder, redefining box as a macro wrapping the latter. we love an evolution arc. π
π SEE ALSO π
curses(3X), curs_outopts(3X)
and that's the whole page, bestie!! π«Ά this was ncurses 6.6, dated 2025-10-20, brought to you by the curs_border(3X) manual page. go draw some boxes, slay, and remember: interior borders only, no wbox, no cap. πβ¨πΈ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 2018-2024,2025 Thomas E. Dickey
- Copyright 1998-2007,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