Curses variadic functions


The bindings for printw, wprintw, mvprintw and mvwprintw each accept one integer formatting argument. Their existing stack effects are preserved, and the integer is passed through the C variadic ABI. The format string must describe that argument, for example %d.

Declare a typed alias when a format needs a different argument list. Put the ellipsis immediately after the named format parameter:
USING: alien.c-types alien.syntax curses.ffi ; LIBRARY: curses FUNCTION-ALIAS: wprintw-values int wprintw ( WINDOW* win, c-string fmt, ... c-string text, double value, int count ) ! win "%s=%.2f/%d" "value" 1.25 7 wprintw-values FUNCTION-ALIAS: wprintw-literal int wprintw ( WINDOW* win, c-string fmt, ... )

Types after the ellipsis describe the arguments for that alias; they do not make its Factor stack effect dynamic. Use a separate alias for each required signature. A float tail undergoes the C default promotion to double, and narrow integer tails promote to int.

The tparm binding instantiates an ncurses terminfo capability with nine long parameters. Pass zero for unused parameters. For a shorter parameter list, or capabilities that require strings, declare the matching types explicitly:
FUNCTION-ALIAS: tparm-position c-string tparm ( c-string capability, ... long row, long column ) FUNCTION-ALIAS: tparm-text c-string tparm ( c-string capability, ... c-string text )

The capability expression determines the argument types; printf format strings and terminfo expressions use different syntax. The returned string is copied into a Factor string. Initialize terminfo with a curses screen before using capabilities.

The vw_printw and legacy vwprintw functions take an existing va_list as an ordinary named parameter. They do not receive an ellipsis argument list.

Reference: https://invisible-island.net/ncurses/man/curs_printw.3x.html and https://invisible-island.net/ncurses/man/curs_terminfo.3x.html.