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 ( ( child
= malloc( sizeof( WINDOW
) ) ) == NULL
)
56 if ( ( (unsigned)ncols
> parent
->width
) ||
57 ( (unsigned)nlines
> parent
->height
) )
59 child
->ori_y
= parent
->ori_y
+ begin_y
;
60 child
->ori_x
= parent
->ori_x
+ begin_x
;
61 child
->height
= nlines
;
63 child
->parent
= parent
;
64 child
->scr
= parent
->scr
;
69 * Create a duplicate of the specified window
71 * @v orig original window
72 * @ret ptr pointer to duplicate window
74 WINDOW
*dupwin ( WINDOW
*orig
) {
78 if ( ( copy
= malloc( sizeof( WINDOW
) ) ) == NULL
)
80 copy
->scr
= orig
->scr
;
81 copy
->attrs
= orig
->attrs
;
82 copy
->ori_y
= orig
->ori_y
;
83 copy
->ori_x
= orig
->ori_x
;
84 copy
->curs_y
= orig
->curs_y
;
85 copy
->curs_x
= orig
->curs_x
;
86 copy
->height
= orig
->height
;
87 copy
->width
= orig
->width
;
92 * Move window origin to specified coordinates
94 * @v *win window to move
97 * @ret rc return status code
99 int mvwin ( WINDOW
*win
, int y
, int x
) {
102 if ( ( ( (unsigned)y
+ win
->height
) > LINES
) ||
103 ( ( (unsigned)x
+ win
->width
) > COLS
) )
115 * @v nlines number of lines
116 * @v ncols number of columns
117 * @v begin_y column origin
118 * @v begin_x line origin
119 * @ret *win return pointer to new window
121 WINDOW
*newwin ( int nlines
, int ncols
, int begin_y
, int begin_x
) {
123 if ( ( win
= malloc( sizeof(WINDOW
) ) ) == NULL
)
125 if ( ( (unsigned)( begin_y
+ nlines
) > stdscr
->height
) &&
126 ( (unsigned)( begin_x
+ ncols
) > stdscr
->width
) )
128 win
->ori_y
= begin_y
;
129 win
->ori_x
= begin_x
;
130 win
->height
= nlines
;
132 win
->scr
= stdscr
->scr
;
133 win
->parent
= stdscr
;
138 * Create a new sub-window
140 * @v orig parent window
141 * @v nlines window height
142 * @v ncols window width
143 * @v begin_y window y origin (absolute)
144 * @v begin_x window x origin (absolute)
145 * @ret ptr return pointer to child window
147 WINDOW
*subwin ( WINDOW
*parent
, int nlines
, int ncols
,
148 int begin_y
, int begin_x
) {
150 if ( parent
== NULL
)
152 if ( ( child
= malloc( sizeof( WINDOW
) ) ) == NULL
)
154 child
= newwin( nlines
, ncols
, begin_y
, begin_x
);
155 child
->parent
= parent
;
156 child
->scr
= parent
->scr
;