Window creation subroutines.
Curses Library (libcurses.a)
#include <curses.h>
WINDOW *derwin(WINDOW *orig,
int nlines,
int ncols,
int begin_y,
int begin_x);
WINDOW *newwin(int nlines,
int ncols,
int begin_y,
int begin_x);
WINDOW *subwin(WINDOW *orig,
int nlines,
int ncols,
int begin_y,
int begin_x);
The derwin subroutine is the same as the subwin subroutine except that begin_y and begin_x are relative to the origin of the window orig rather than absolute screen positions.
The newwin subroutine creates a new window with nlines lines and ncols columns, positioned so that the origin is at (begin_y, begin_x). If nlines is zero, it defaults to LINES - begin_y; if ncols is zero, it defaults to COLS - begin_x.
The subwin subroutine creates a new window with nlines lines and ncols columns, positioned so that the origin is at (begin_y, begin_x). (This position is an absolute screen position, not a position relative to the window orig.) If any part of the new window is outside orig, the subroutine fails and the window is not created.
Item | Description |
---|---|
ncols | |
nlines | |
begin_y | |
begin_x |
Upon successful completion, these subroutines return a pointer to the new window. Otherwise, they return a null pointer.
For the derwin and newwin subroutines:
WINDOW *my_window;
my_window = newwin(5, 10, 20, 30);
my_window is
now a window 5 lines deep, 10 columns wide, starting
at the coordinates y = 20, x = 30. That is, the
upper left corner is at coordinates y = 20, x = 30,
and the lower right corner is at coordinates y = 24, x = 39.WINDOW *my_window;
my_window = newwin(5, 0, 20, 30);
my_window is
now a window 5 lines deep, extending all the way to the right
side of the terminal, starting at the coordinates y = 20,
x = 30. The upper left corner is at coordinates y = 20,
x = 30, and the lower right corner is at coordinates y = 24,
x = lastcolumn.WINDOW *my_window;
my_window = newwin(0, 0, 0, 0);
my_window is
now a screen that is a window that fills the entire terminal's display.For the subwin subroutine:
WINDOW *my_window, *my_sub_window;
my_window = newwin (derwin, newwin, or subwin Subroutine)
(5, 10, 20, 30);
WINDOW *my_window, *my_sub_window;
my_window =
newwin (derwin, newwin, or subwin Subroutine)(5, 10, 20, 30);
my_sub_window = subwin(my_window, 2, 0, 20, 30);
WINDOW *my_window, *my_sub_window
my_window = newwwin (derwin, newwin, or subwin Subroutine)
(5, 10, 20, 30);
my_sub_window = subwin(my_window, 0, 0, 22, 35);