summaryrefslogtreecommitdiff
path: root/lib/libcurses/curses_window.3
blob: f13ab32bd628586e9197264af4bd46a3f36d9363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
.\"	$NetBSD: curses_window.3,v 1.16 2013/10/15 22:15:17 roy Exp $
.\"
.\" Copyright (c) 2002
.\"	Brett Lymn (blymn@NetBSD.org, brett_lymn@yahoo.com.au)
.\"
.\" This code is donated to the NetBSD Foundation by the Author.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. The name of the Author may not be used to endorse or promote
.\"    products derived from this software without specific prior written
.\"    permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.Dd October 15, 2013
.Dt CURSES_WINDOW 3
.Os
.Sh NAME
.Nm curses_window ,
.Nm copywin ,
.Nm dupwin ,
.Nm delwin ,
.Nm derwin ,
.Nm mvwin ,
.Nm mvderwin ,
.Nm newwin ,
.Nm overlay ,
.Nm overwrite ,
.Nm subwin ,
.Nm wresize
.Nd curses window routines
.Sh LIBRARY
.Lb libcurses
.Sh SYNOPSIS
.In curses.h
.Ft int
.Fo copywin
.Fa "WINDOW *source"
.Fa "WINDOW *dest"
.Fa "int sminrow"
.Fa "int smincol"
.Fa "int dminrow"
.Fa "int dmincol"
.Fa "int dmaxrow"
.Fa "int dmaxcol"
.Fa "int overlay"
.Fc
.Ft WINDOW *
.Fn dupwin "WINDOW *win"
.Ft WINDOW *
.Fn derwin "WINDOW *win" "int lines" "int cols" "int y" "int x"
.Ft int
.Fn delwin "WINDOW *win"
.Ft int
.Fn mvwin "WINDOW *win" "int y" "int x"
.Ft int
.Fn mvderwin "WINDOW *win" "int y" "int x"
.Ft WINDOW *
.Fn newwin "int lines" "int cols" "int begin_y" "int begin_x"
.Ft WINDOW *
.Fn subwin "WINDOW *win" "int lines" "int cols" "int begin_y" "int begin_x"
.Ft int
.Fn overlay "WINDOW *source" "WINDOW *dest"
.Ft int
.Fn overwrite "WINDOW *source" "WINDOW *dest"
.Ft int
.Fn wresize "WINDOW *win" "int lines" "int cols"
.Sh DESCRIPTION
These functions create, modify and delete windows on the current screen.
.Pp
The contents of a window may be copied to another window by using the
.Fn copywin
function, a section of the destination window
.Fa dest
bounded by
.Fa (dminrow ,
.Fa dmincol )
and
.Fa (dmaxrow ,
.Fa dmaxcol )
will be overwritten with the contents of the window
.Fa source
starting at the coordinates
.Fa (sminrow ,
.Fa smincol ) .
If the
.Fa overlay
flag is
.Dv TRUE
then only non-blank characters from
.Fa source
will be copied to
.Fa dest ,
if
.Fa overlay
is
.Dv FALSE
then all characters from
.Fa source
will be copied to
.Fa dest .
If the bounding rectangles of either the source or the destination
windows lay outside the maximum size of the respective windows then
the size of the window copied will be adjusted to be within the bounds
of both the source and destination windows.
.Pp
The
.Fn dupwin
function creates an exact duplicate of
.Fa win
and returns a pointer to it.
.Pp
Calling
.Fn derwin
will create a subwindow of
.Fa win
in the same manner as
.Fn subwin
excepting that the starting column and row
.Fa y ,
.Fa x
are relative to the parent window origin.
.Pp
A window may deleted and all resources freed by calling the
.Fn delwin
function with the pointer to the window to be deleted in
.Fa win .
If
.Fa win
is
.Dv NULL ,
then no action occurs.
.Pp
A window can be moved to a new position by calling the
.Fn mvwin
function.
The
.Fa y
and
.Fa x
positions are the new origin of the window on the screen.
If the new position would cause the any part of the window to lie outside
the screen, it is an error and the window is not moved.
.Pp
A mapping of a region relative to the parent window may be created by
calling the
.Fn mvderwin
function, the
.Fa y
and
.Fa x
positions are relative to the origin of the parent window.
The screen offset of
.Fa win
is not updated, the characters beginning at
.Fa y ,
.Fa x
for the area the size of
.Fa win
will be displayed at the screen offset of
.Fa win .
If the given window in
.Fa win
is not a subwindow then an error will be returned.
If the new position would cause the any part of the window to lie outside
the parent window, it is an error and the mapping is not updated.
.Pp
The
.Fn newwin
function creates a new window of size
.Fa lines ,
.Fa cols
with an origin at
.Fa begin_y ,
.Fa begin_x .
If
.Fa lines
is less than or equal to zero then the number of rows
for the window is set to
.Dv LINES -
.Fa begin_x
+
.Fa lines .
Similarly if
.Fa cols
is less than or equal to zero then the number of columns
for the window is set to
.Dv COLS -
.Fa begin_y
+
.Fa cols .
.Pp
.Fn subwin
is similar to
.Fn newwin
excepting that the size of the subwindow is bounded by the parent
window
.Fa win .
The subwindow shares internal data structures with the parent window
and will be refreshed when the parent window is refreshed.
The subwindow inherits the background character and attributes of the
parent window.
.Pp
The
.Fn overlay
function copies the contents of the source window
.Fa source
to the destination window
.Fa dest ,
only the characters that are not the background character in the
source window are copied to the destination.
The windows need not be the same size, only the overlapping portion of both
windows will be copied.
The
.Fn overwrite
function performs the same functions as
.Fn overlay
excepting that characters from the source window are copied to the
destination without exception.
.Pp
.Fn wresize
resizes the specified window to the new number of lines and columns
given, all internal curses structures are resized.
Any subwindows of the specified window will also be resized if any part
of them falls outside the new parent window size.
The application must redraw the window after it has been resized.
Note that
.Dv curscr
and
.Dv stdscr
can not be resized to be larger than the size of the screen.
.Sh RETURN VALUES
Functions returning pointers will return
.Dv NULL
if an error is detected.
The functions that return an int will return one of the following
values:
.Pp
.Bl -tag -width ERR -compact
.It Er OK
The function completed successfully.
.It Er ERR
An error occurred in the function.
.El
.Sh SEE ALSO
.Xr curses_fileio 3 ,
.Xr curses_pad 3 ,
.Xr curses_screen 3
.Sh STANDARDS
The
.Nx
Curses library complies with the X/Open Curses specification, part of the
Single Unix Specification.
.Sh HISTORY
The Curses package appeared in
.Bx 4.0 .