8
* MuCurses windows instance functions
12
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
17
* @v *win pointer to window being deleted
18
* @ret rc return status code
20
int delwin ( WINDOW *win ) {
21
/* I think we should blank the region covered by the window -
22
ncurses doesn't do this, but they have a buffer, so they
23
may just be deleting from an offscreen context whereas we
24
are guaranteed to be deleting something onscreen */
26
chtype killch = (chtype)' ';
28
_wputch( win, killch, WRAP );
29
} while ( win->curs_x + win->curs_y );
33
wmove ( stdscr, 0, 0 );
39
* Create a new derived window
41
* @v parent parent window
42
* @v nlines window height
43
* @v ncols window width
44
* @v begin_y window y origin (relative to parent)
45
* @v begin_x window x origin (relative to parent)
46
* @ret ptr return pointer to child window
48
WINDOW *derwin ( WINDOW *parent, int nlines, int ncols,
49
int begin_y, int begin_x ) {
51
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
53
if ( ( (unsigned)ncols > parent->width ) ||
54
( (unsigned)nlines > parent->height ) )
56
child->ori_y = parent->ori_y + begin_y;
57
child->ori_x = parent->ori_x + begin_x;
58
child->height = nlines;
60
child->parent = parent;
61
child->scr = parent->scr;
66
* Create a duplicate of the specified window
68
* @v orig original window
69
* @ret ptr pointer to duplicate window
71
WINDOW *dupwin ( WINDOW *orig ) {
73
if ( ( copy = malloc( sizeof( WINDOW ) ) ) == NULL )
75
copy->scr = orig->scr;
76
copy->attrs = orig->attrs;
77
copy->ori_y = orig->ori_y;
78
copy->ori_x = orig->ori_x;
79
copy->curs_y = orig->curs_y;
80
copy->curs_x = orig->curs_x;
81
copy->height = orig->height;
82
copy->width = orig->width;
87
* Move window origin to specified coordinates
89
* @v *win window to move
92
* @ret rc return status code
94
int mvwin ( WINDOW *win, int y, int x ) {
95
if ( ( ( (unsigned)y + win->height ) > LINES ) ||
96
( ( (unsigned)x + win->width ) > COLS ) )
108
* @v nlines number of lines
109
* @v ncols number of columns
110
* @v begin_y column origin
111
* @v begin_x line origin
112
* @ret *win return pointer to new window
114
WINDOW *newwin ( int nlines, int ncols, int begin_y, int begin_x ) {
116
if ( ( win = malloc( sizeof(WINDOW) ) ) == NULL )
118
if ( ( (unsigned)( begin_y + nlines ) > stdscr->height ) &&
119
( (unsigned)( begin_x + ncols ) > stdscr->width ) )
121
win->ori_y = begin_y;
122
win->ori_x = begin_x;
123
win->height = nlines;
125
win->scr = stdscr->scr;
126
win->parent = stdscr;
131
* Create a new sub-window
133
* @v orig parent window
134
* @v nlines window height
135
* @v ncols window width
136
* @v begin_y window y origin (absolute)
137
* @v begin_x window x origin (absolute)
138
* @ret ptr return pointer to child window
140
WINDOW *subwin ( WINDOW *parent, int nlines, int ncols,
141
int begin_y, int begin_x ) {
143
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
145
child = newwin( nlines, ncols, begin_y, begin_x );
146
child->parent = parent;
147
child->scr = parent->scr;