8 * MuCurses windows instance functions
15 * @v *win pointer to window being deleted
16 * @ret rc return status code
18 int delwin ( WINDOW *win ) {
22 /* I think we should blank the region covered by the window -
23 ncurses doesn't do this, but they have a buffer, so they
24 may just be deleting from an offscreen context whereas we
25 are guaranteed to be deleting something onscreen */
27 chtype killch = (chtype)' ';
29 _wputch( win, killch, WRAP );
30 } while ( win->curs_x + win->curs_y );
34 wmove ( stdscr, 0, 0 );
40 * Create a new derived window
42 * @v parent parent window
43 * @v nlines window height
44 * @v ncols window width
45 * @v begin_y window y origin (relative to parent)
46 * @v begin_x window x origin (relative to parent)
47 * @ret ptr return pointer to child window
49 WINDOW *derwin ( WINDOW *parent, int nlines, int ncols,
50 int begin_y, int begin_x ) {
54 if ( ( (unsigned)ncols > parent->width ) ||
55 ( (unsigned)nlines > parent->height ) )
57 child = malloc( sizeof( WINDOW ) );
58 child->ori_y = parent->ori_y + begin_y;
59 child->ori_x = parent->ori_x + begin_x;
60 child->height = nlines;
62 child->parent = parent;
63 child->scr = parent->scr;
68 * Create a duplicate of the specified window
70 * @v orig original window
71 * @ret ptr pointer to duplicate window
73 WINDOW *dupwin ( WINDOW *orig ) {
77 copy = malloc( sizeof( WINDOW ) );
78 copy->scr = orig->scr;
79 copy->attrs = orig->attrs;
80 copy->ori_y = orig->ori_y;
81 copy->ori_x = orig->ori_x;
82 copy->curs_y = orig->curs_y;
83 copy->curs_x = orig->curs_x;
84 copy->height = orig->height;
85 copy->width = orig->width;
90 * Move window origin to specified coordinates
92 * @v *win window to move
95 * @ret rc return status code
97 int mvwin ( WINDOW *win, int y, int x ) {
100 if ( ( ( (unsigned)y + win->height ) > LINES ) ||
101 ( ( (unsigned)x + win->width ) > COLS ) )
113 * @v nlines number of lines
114 * @v ncols number of columns
115 * @v begin_y column origin
116 * @v begin_x line origin
117 * @ret *win return pointer to new window
119 WINDOW *newwin ( int nlines, int ncols, int begin_y, int begin_x ) {
120 WINDOW *win = malloc( sizeof(WINDOW) );
121 if ( ( (unsigned)( begin_y + nlines ) > stdscr->height ) &&
122 ( (unsigned)( begin_x + ncols ) > stdscr->width ) )
124 win->ori_y = begin_y;
125 win->ori_x = begin_x;
126 win->height = nlines;
128 win->scr = stdscr->scr;
129 win->parent = stdscr;
134 * Create a new sub-window
136 * @v orig parent window
137 * @v nlines window height
138 * @v ncols window width
139 * @v begin_y window y origin (absolute)
140 * @v begin_x window x origin (absolute)
141 * @ret ptr return pointer to child window
143 WINDOW *subwin ( WINDOW *parent, int nlines, int ncols,
144 int begin_y, int begin_x ) {
146 if ( parent == NULL )
148 child = malloc( sizeof( WINDOW ) );
149 child = newwin( nlines, ncols, begin_y, begin_x );
150 child->parent = parent;
151 child->scr = parent->scr;