curs_window(3X) | Library calls | curs_window(3X) |
newwin, delwin, mvwin, subwin, derwin, mvderwin, dupwin, wsyncup, syncok, wcursyncup, wsyncdown - create and manipulate curses windows
#include <ncurses/curses.h>
WINDOW *newwin(
int nlines, int ncols,
int begin_y, int begin_x); int delwin(WINDOW *win); int mvwin(WINDOW *win, int y, int x); WINDOW *subwin(WINDOW *orig,
int nlines, int ncols,
int begin_y, int begin_x); WINDOW *derwin(WINDOW *orig,
int nlines, int ncols,
int begin_y, int begin_x); int mvderwin(WINDOW *win, int par_y, int par_x); WINDOW *dupwin(WINDOW *win); void wsyncup(WINDOW *win); int syncok(WINDOW *win, bool bf); void wcursyncup(WINDOW *win); void wsyncdown(WINDOW *win);
Calling newwin creates and returns a pointer to a new window with the given number of lines and columns. The upper left-hand corner of the window is at
If either nlines or ncols is zero, they default to
A new full-screen window is created by calling newwin(0,0,0,0).
Regardless of the function used for creating a new window (e.g., newwin, subwin, derwin, newpad), rather than a duplicate (with dupwin), all of the window modes are initialized to the default values. These functions set window modes after a window is created:
idcok idlok immedok keypad leaveok nodelay scrollok setscrreg syncok wbkgdset wbkgrndset and wtimeout.
Calling delwin deletes the named window, freeing all memory associated with it (it does not actually erase the window's screen image). Subwindows must be deleted before the main window can be deleted.
Calling mvwin moves the window so that the upper left-hand corner is at position (x, y). If the move would cause the window to be off the screen, it is an error and the window is not moved. Moving subwindows is allowed, but should be avoided.
Calling subwin creates and returns a pointer to a new window with the given number of lines, nlines, and columns, ncols. The window is at position (begin_y, begin_x) on the screen. The subwindow shares memory with the window orig, its ancestor, so that changes made to one window will affect both windows. When using this routine, it is necessary to call touchwin or touchline on orig before calling wrefresh on the subwindow.
Calling derwin is the same as calling subwin, except that begin_y and begin_x are relative to the origin of the window orig rather than the screen. There is no difference between the subwindows and the derived windows.
Calling mvderwin moves a derived window (or subwindow) inside its parent window. The screen-relative parameters of the window are not changed. This routine is used to display different parts of the parent window at the same physical position on the screen.
Calling dupwin creates an exact duplicate of the window win.
Calling wsyncup touches all locations in ancestors of win that are changed in win. If syncok is called with second argument TRUE then wsyncup is called automatically whenever there is a change in the window.
The wsyncdown routine touches each location in win that has been touched in any of its ancestor windows. This routine is called by wrefresh, so it should almost never be necessary to call it manually.
The routine wcursyncup updates the current cursor position of all the ancestors of the window to reflect the current cursor position of the window.
Routines that return an integer return the integer ERR upon failure and OK (SVr4 only specifies "an integer value other than ERR") upon successful completion.
Routines that return pointers return NULL on error.
X/Open defines no error conditions. In this implementation
The functions which return a window pointer may also fail if there is insufficient memory for its data structures. Any of these functions will fail if the screen has not been initialized, i.e., with initscr or newterm.
If many small changes are made to the window, the wsyncup option could degrade performance.
Note that syncok may be a macro.
X/Open Curses, Issue 4 describes these functions.
X/Open Curses states regarding delwin:
The subwindow functions subwin, derwin, mvderwin, wsyncup, wsyncdown, wcursyncup, and syncok are flaky, incompletely implemented, and not well tested.
System V's curses documentation is unclear about what wsyncup and wsyncdown actually do. It seems to imply that they are supposed to touch only those lines that are affected by changes to a window's ancestors. The language here, and behavior of ncurses, is patterned on the X/Open Curses standard; this approach may result in slower updates.
curses(3X), curs_initscr(3X), curs_refresh(3X), curs_touch(3X), curs_variables(3X)
2024-04-20 | ncurses 6.5 |